[Home] [Help]
PACKAGE BODY: APPS.XLA_00222_AAD_S_000007_PKG
Source
1 PACKAGE BODY XLA_00222_AAD_S_000007_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_000007_PKG |
10 | |
11 | DESCRIPTION |
12 | Package generated From Product Accounting Definition |
13 | Name : Multi-Fund Account Receivables Accrual - Account Method|
14 | Code : MFAR_ACCRUAL_ACCOUNT |
15 | Owner : PRODUCT |
16 | Version : |
17 | AMB Context Code: DEFAULT |
18 | HISTORY |
19 | Generated at 30-03-2009 at 05:03:13 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
42 ,array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
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
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_000007_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_000007_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;
166 ,p_token_1 => 'SOURCE_NAME'
163 xla_accounting_err_pkg. build_message
164 (p_appli_s_name => 'XLA'
165 ,p_msg_name => 'XLA_AP_NO_LOOKUP_MEANING'
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_000007_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_000007_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
309 ,p_level => C_LEVEL_EXCEPTION
306 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
307 trace
308 (p_msg => 'ERROR: '||sqlerrm
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_000007_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) ;
343 l_component_type_code VARCHAR2(1) ;
344 l_component_appl_id INTEGER ;
345 l_amb_context_code VARCHAR2(30) ;
346 l_log_module VARCHAR2(240) ;
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
438 --
435 xla_exceptions_pkg.raise_message
436 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctDerRule_2');
437 END AcctDerRule_2;
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 ;
467 l_amb_context_code VARCHAR2(30) ;
468 l_log_module VARCHAR2(240) ;
469 l_output_value VARCHAR2(30) ;
470 BEGIN
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_000007_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
574 , p_source_3 IN NUMBER
571 , p_side IN VARCHAR2
572 , p_override_seg_flag IN VARCHAR2
573 --Remittance Bank Account Confirmation Account
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) ;
590 l_log_module VARCHAR2(240) ;
591 l_output_value VARCHAR2(30) ;
592 BEGIN
593 IF g_log_enabled THEN
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_000007_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
705 RETURN VARCHAR2
702 , x_value_combination_id OUT NOCOPY NUMBER
703 , x_value_segment_code OUT NOCOPY VARCHAR2
704 )
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
715 IF g_log_enabled THEN
716 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_5';
717 END IF;
718 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
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_000007_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) ;
839 END IF;
836 BEGIN
837 IF g_log_enabled THEN
838 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_6';
840 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
841
842 trace
843 (p_msg => 'BEGIN of AcctDerRule_6'
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_000007_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
965 (p_msg => 'BEGIN of AcctDerRule_7'
966 ,p_level => C_LEVEL_PROCEDURE
967 ,p_module => l_log_module);
968
969 END IF;
970
971 l_component_type := 'AMB_ADR';
975 l_amb_context_code := 'DEFAULT';
972 l_component_code := 'MFAR_RCT_REMITTANCE_NATSEG';
973 l_component_type_code := 'S';
974 l_component_appl_id := 222;
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_000007_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
1089 ,p_module => l_log_module);
1090
1091 END IF;
1092
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
1110 ,p_module => l_log_module);
1107 trace
1108 (p_msg => 'END of AcctDerRule_8'
1109 ,p_level => C_LEVEL_PROCEDURE
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_000007_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
1215 l_component_type := 'AMB_ADR';
1216 l_component_code := 'MFAR_TRX_NATURAL_SEGMENT';
1217 l_component_type_code := 'S';
1218 l_component_appl_id := 222;
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' ;
1240
1237 x_value_type_code := 'S';
1238 l_output_value := null;
1239 RETURN l_output_value;
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_000007_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 --
1340 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1341 trace
1342 (p_msg => 'END of AcctDerRule_10'
1343 ,p_level => C_LEVEL_PROCEDURE
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'
1366 , l_component_code
1363 ,p_token_1 => 'COMPONENT_NAME'
1364 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1365 l_component_type
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_000007_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;
1462 x_value_type_code := null;
1463 l_output_value := null;
1464 xla_accounting_err_pkg.build_message
1465 (p_appli_s_name => 'XLA'
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
1485 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1482 ,p_token_4 => 'PAD_OWNER'
1483 ,p_value_4 => xla_lookups_pkg.get_meaning(
1484 'XLA_OWNER_TYPE'
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_000007_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 --Remittance Bank Account Cash Account
1513 , p_source_5 IN NUMBER
1514 , x_transaction_coa_id OUT NOCOPY NUMBER
1515 , x_accounting_coa_id OUT NOCOPY NUMBER
1516 , x_value_type_code OUT NOCOPY VARCHAR2
1517 )
1518 RETURN NUMBER
1519 IS
1520 l_component_type VARCHAR2(80) ;
1521 l_component_code VARCHAR2(30) ;
1522 l_component_type_code VARCHAR2(1) ;
1523 l_component_appl_id INTEGER ;
1524 l_amb_context_code VARCHAR2(30) ;
1525 l_log_module VARCHAR2(240) ;
1526 l_output_value NUMBER ;
1527 BEGIN
1528 IF g_log_enabled THEN
1529 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_12';
1530 END IF;
1531 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1532 trace
1533 (p_msg => 'BEGIN of AcctDerRule_12'
1534 ,p_level => C_LEVEL_PROCEDURE
1535 ,p_module => l_log_module);
1536 END IF;
1537 --
1538 l_component_type := 'AMB_ADR';
1539 l_component_code := 'MFAR_RCT_DEF_CASH_CCID';
1540 l_component_type_code := 'S';
1541 l_component_appl_id := 222;
1542 l_amb_context_code := 'DEFAULT';
1543 x_transaction_coa_id := null;
1544 x_accounting_coa_id := null;
1545 --
1546
1547 --
1548 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1549 trace
1550 (p_msg => 'END of AcctDerRule_12'
1551 ,p_level => C_LEVEL_PROCEDURE
1552 ,p_module => l_log_module);
1553 END IF;
1554 x_value_type_code := 'S';
1555 l_output_value := TO_NUMBER(TO_NUMBER(p_source_5));
1556 RETURN l_output_value;
1557
1558 --
1559 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1560 trace
1561 (p_msg => 'END of AcctDerRule_12(invalid)'
1562 ,p_level => C_LEVEL_PROCEDURE
1563 ,p_module => l_log_module);
1564 END IF;
1565 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1566 x_value_type_code := null;
1567 l_output_value := null;
1568 xla_accounting_err_pkg.build_message
1569 (p_appli_s_name => 'XLA'
1570 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1571 ,p_token_1 => 'COMPONENT_NAME'
1572 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1573 l_component_type
1574 , l_component_code
1575 , l_component_type_code
1576 , l_component_appl_id
1577 , l_amb_context_code
1578 )
1579 ,p_token_2 => 'OWNER'
1580 ,p_value_2 => xla_lookups_pkg.get_meaning(
1581 'XLA_OWNER_TYPE'
1582 ,l_component_type_code
1583 )
1584 ,p_token_3 => 'PAD_NAME'
1585 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1586 ,p_token_4 => 'PAD_OWNER'
1587 ,p_value_4 => xla_lookups_pkg.get_meaning(
1588 'XLA_OWNER_TYPE'
1589 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1590 )
1591 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1592 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1593 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1594 ,p_ae_header_id => NULL
1595 );
1596 RETURN l_output_value;
1597 EXCEPTION
1598 WHEN xla_exceptions_pkg.application_exception THEN
1599 RAISE;
1600 WHEN OTHERS THEN
1601 xla_exceptions_pkg.raise_message
1602 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctDerRule_12');
1603 END AcctDerRule_12;
1604 --
1605
1609 -- AcctDerRule_13
1606 ---------------------------------------
1607 --
1608 -- PRIVATE FUNCTION
1610 --
1611 ---------------------------------------
1612 FUNCTION AcctDerRule_13 (
1613 p_application_id IN NUMBER
1614 , p_ae_header_id IN NUMBER
1615 , p_side IN VARCHAR2
1616 --Remittance Bank Account Confirmation Account
1617 , p_source_3 IN NUMBER
1618 , x_transaction_coa_id OUT NOCOPY NUMBER
1619 , x_accounting_coa_id OUT NOCOPY NUMBER
1620 , x_value_type_code OUT NOCOPY VARCHAR2
1621 )
1622 RETURN NUMBER
1623 IS
1624 l_component_type VARCHAR2(80) ;
1625 l_component_code VARCHAR2(30) ;
1626 l_component_type_code VARCHAR2(1) ;
1627 l_component_appl_id INTEGER ;
1628 l_amb_context_code VARCHAR2(30) ;
1629 l_log_module VARCHAR2(240) ;
1630 l_output_value NUMBER ;
1631 BEGIN
1632 IF g_log_enabled THEN
1633 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_13';
1634 END IF;
1635 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1636 trace
1637 (p_msg => 'BEGIN of AcctDerRule_13'
1638 ,p_level => C_LEVEL_PROCEDURE
1639 ,p_module => l_log_module);
1640 END IF;
1641 --
1642 l_component_type := 'AMB_ADR';
1643 l_component_code := 'MFAR_RCT_DEF_CONFIRMATION_CCID';
1644 l_component_type_code := 'S';
1645 l_component_appl_id := 222;
1646 l_amb_context_code := 'DEFAULT';
1647 x_transaction_coa_id := null;
1648 x_accounting_coa_id := null;
1649 --
1650
1651 --
1652 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1653 trace
1654 (p_msg => 'END of AcctDerRule_13'
1655 ,p_level => C_LEVEL_PROCEDURE
1656 ,p_module => l_log_module);
1657 END IF;
1658 x_value_type_code := 'S';
1659 l_output_value := TO_NUMBER(TO_NUMBER(p_source_3));
1660 RETURN l_output_value;
1661
1662 --
1663 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1664 trace
1665 (p_msg => 'END of AcctDerRule_13(invalid)'
1666 ,p_level => C_LEVEL_PROCEDURE
1667 ,p_module => l_log_module);
1668 END IF;
1669 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1670 x_value_type_code := null;
1671 l_output_value := null;
1672 xla_accounting_err_pkg.build_message
1673 (p_appli_s_name => 'XLA'
1674 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1675 ,p_token_1 => 'COMPONENT_NAME'
1676 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1677 l_component_type
1678 , l_component_code
1679 , l_component_type_code
1680 , l_component_appl_id
1681 , l_amb_context_code
1682 )
1683 ,p_token_2 => 'OWNER'
1684 ,p_value_2 => xla_lookups_pkg.get_meaning(
1685 'XLA_OWNER_TYPE'
1686 ,l_component_type_code
1687 )
1688 ,p_token_3 => 'PAD_NAME'
1689 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1690 ,p_token_4 => 'PAD_OWNER'
1691 ,p_value_4 => xla_lookups_pkg.get_meaning(
1692 'XLA_OWNER_TYPE'
1693 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1694 )
1695 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1696 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1697 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1698 ,p_ae_header_id => NULL
1699 );
1700 RETURN l_output_value;
1701 EXCEPTION
1702 WHEN xla_exceptions_pkg.application_exception THEN
1703 RAISE;
1704 WHEN OTHERS THEN
1705 xla_exceptions_pkg.raise_message
1706 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctDerRule_13');
1707 END AcctDerRule_13;
1708 --
1709
1710 ---------------------------------------
1711 --
1712 -- PRIVATE FUNCTION
1713 -- AcctDerRule_14
1714 --
1715 ---------------------------------------
1716 FUNCTION AcctDerRule_14 (
1717 p_application_id IN NUMBER
1718 , p_ae_header_id IN NUMBER
1719 , p_side IN VARCHAR2
1720 --Remittance Bank Account Remittance Account
1721 , p_source_6 IN NUMBER
1722 , x_transaction_coa_id OUT NOCOPY NUMBER
1723 , x_accounting_coa_id OUT NOCOPY NUMBER
1724 , x_value_type_code OUT NOCOPY VARCHAR2
1725 )
1726 RETURN NUMBER
1727 IS
1728 l_component_type VARCHAR2(80) ;
1729 l_component_code VARCHAR2(30) ;
1730 l_component_type_code VARCHAR2(1) ;
1731 l_component_appl_id INTEGER ;
1732 l_amb_context_code VARCHAR2(30) ;
1733 l_log_module VARCHAR2(240) ;
1734 l_output_value NUMBER ;
1735 BEGIN
1736 IF g_log_enabled THEN
1740 trace
1737 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_14';
1738 END IF;
1739 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1741 (p_msg => 'BEGIN of AcctDerRule_14'
1742 ,p_level => C_LEVEL_PROCEDURE
1743 ,p_module => l_log_module);
1744 END IF;
1745 --
1746 l_component_type := 'AMB_ADR';
1747 l_component_code := 'MFAR_RCT_DEF_REMITTANCE_CCID';
1748 l_component_type_code := 'S';
1749 l_component_appl_id := 222;
1750 l_amb_context_code := 'DEFAULT';
1751 x_transaction_coa_id := null;
1752 x_accounting_coa_id := null;
1753 --
1754
1755 --
1756 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1757 trace
1758 (p_msg => 'END of AcctDerRule_14'
1759 ,p_level => C_LEVEL_PROCEDURE
1760 ,p_module => l_log_module);
1761 END IF;
1762 x_value_type_code := 'S';
1763 l_output_value := TO_NUMBER(TO_NUMBER(p_source_6));
1764 RETURN l_output_value;
1765
1766 --
1767 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1768 trace
1769 (p_msg => 'END of AcctDerRule_14(invalid)'
1770 ,p_level => C_LEVEL_PROCEDURE
1771 ,p_module => l_log_module);
1772 END IF;
1773 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1774 x_value_type_code := null;
1775 l_output_value := null;
1776 xla_accounting_err_pkg.build_message
1777 (p_appli_s_name => 'XLA'
1778 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1779 ,p_token_1 => 'COMPONENT_NAME'
1780 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1781 l_component_type
1782 , l_component_code
1783 , l_component_type_code
1784 , l_component_appl_id
1785 , l_amb_context_code
1786 )
1787 ,p_token_2 => 'OWNER'
1788 ,p_value_2 => xla_lookups_pkg.get_meaning(
1789 'XLA_OWNER_TYPE'
1790 ,l_component_type_code
1791 )
1792 ,p_token_3 => 'PAD_NAME'
1793 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1794 ,p_token_4 => 'PAD_OWNER'
1795 ,p_value_4 => xla_lookups_pkg.get_meaning(
1796 'XLA_OWNER_TYPE'
1797 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1798 )
1799 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1800 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1801 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1802 ,p_ae_header_id => NULL
1803 );
1804 RETURN l_output_value;
1805 EXCEPTION
1806 WHEN xla_exceptions_pkg.application_exception THEN
1807 RAISE;
1808 WHEN OTHERS THEN
1809 xla_exceptions_pkg.raise_message
1810 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctDerRule_14');
1811 END AcctDerRule_14;
1812 --
1813
1814 ---------------------------------------
1815 --
1816 -- PRIVATE FUNCTION
1817 -- AcctDerRule_15
1818 --
1819 ---------------------------------------
1820 FUNCTION AcctDerRule_15 (
1821 p_application_id IN NUMBER
1822 , p_ae_header_id IN NUMBER
1823 , p_side IN VARCHAR2
1824 --Remittance Bank Account Unapplied Account
1825 , p_source_11 IN NUMBER
1826 , x_transaction_coa_id OUT NOCOPY NUMBER
1827 , x_accounting_coa_id OUT NOCOPY NUMBER
1828 , x_value_type_code OUT NOCOPY VARCHAR2
1829 )
1830 RETURN NUMBER
1831 IS
1832 l_component_type VARCHAR2(80) ;
1833 l_component_code VARCHAR2(30) ;
1834 l_component_type_code VARCHAR2(1) ;
1835 l_component_appl_id INTEGER ;
1836 l_amb_context_code VARCHAR2(30) ;
1837 l_log_module VARCHAR2(240) ;
1838 l_output_value NUMBER ;
1839 BEGIN
1840 IF g_log_enabled THEN
1841 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_15';
1842 END IF;
1843 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1844 trace
1845 (p_msg => 'BEGIN of AcctDerRule_15'
1846 ,p_level => C_LEVEL_PROCEDURE
1847 ,p_module => l_log_module);
1848 END IF;
1849 --
1850 l_component_type := 'AMB_ADR';
1851 l_component_code := 'RMT_BNK_UNAPP_CCID';
1852 l_component_type_code := 'S';
1853 l_component_appl_id := 222;
1854 l_amb_context_code := 'DEFAULT';
1855 x_transaction_coa_id := null;
1856 x_accounting_coa_id := null;
1857 --
1858
1859 --
1860 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1861 trace
1862 (p_msg => 'END of AcctDerRule_15'
1863 ,p_level => C_LEVEL_PROCEDURE
1864 ,p_module => l_log_module);
1865 END IF;
1866 x_value_type_code := 'S';
1867 l_output_value := TO_NUMBER(TO_NUMBER(p_source_11));
1868 RETURN l_output_value;
1869
1873 (p_msg => 'END of AcctDerRule_15(invalid)'
1870 --
1871 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1872 trace
1874 ,p_level => C_LEVEL_PROCEDURE
1875 ,p_module => l_log_module);
1876 END IF;
1877 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1878 x_value_type_code := null;
1879 l_output_value := null;
1880 xla_accounting_err_pkg.build_message
1881 (p_appli_s_name => 'XLA'
1882 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1883 ,p_token_1 => 'COMPONENT_NAME'
1884 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1885 l_component_type
1886 , l_component_code
1887 , l_component_type_code
1888 , l_component_appl_id
1889 , l_amb_context_code
1890 )
1891 ,p_token_2 => 'OWNER'
1892 ,p_value_2 => xla_lookups_pkg.get_meaning(
1893 'XLA_OWNER_TYPE'
1894 ,l_component_type_code
1895 )
1896 ,p_token_3 => 'PAD_NAME'
1897 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1898 ,p_token_4 => 'PAD_OWNER'
1899 ,p_value_4 => xla_lookups_pkg.get_meaning(
1900 'XLA_OWNER_TYPE'
1901 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1902 )
1903 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1904 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1905 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1906 ,p_ae_header_id => NULL
1907 );
1908 RETURN l_output_value;
1909 EXCEPTION
1910 WHEN xla_exceptions_pkg.application_exception THEN
1911 RAISE;
1912 WHEN OTHERS THEN
1913 xla_exceptions_pkg.raise_message
1914 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctDerRule_15');
1915 END AcctDerRule_15;
1916 --
1917
1918 ---------------------------------------
1919 --
1920 -- PRIVATE FUNCTION
1921 -- AcctDerRule_16
1922 --
1923 ---------------------------------------
1924 FUNCTION AcctDerRule_16 (
1925 p_application_id IN NUMBER
1926 , p_ae_header_id IN NUMBER
1927 , p_side IN VARCHAR2
1928 --System Gain Account
1929 , p_source_12 IN NUMBER
1930 , x_transaction_coa_id OUT NOCOPY NUMBER
1931 , x_accounting_coa_id OUT NOCOPY NUMBER
1932 , x_value_type_code OUT NOCOPY VARCHAR2
1933 )
1934 RETURN NUMBER
1935 IS
1936 l_component_type VARCHAR2(80) ;
1937 l_component_code VARCHAR2(30) ;
1938 l_component_type_code VARCHAR2(1) ;
1939 l_component_appl_id INTEGER ;
1940 l_amb_context_code VARCHAR2(30) ;
1941 l_log_module VARCHAR2(240) ;
1942 l_output_value NUMBER ;
1943 BEGIN
1944 IF g_log_enabled THEN
1945 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_16';
1946 END IF;
1947 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1948 trace
1949 (p_msg => 'BEGIN of AcctDerRule_16'
1950 ,p_level => C_LEVEL_PROCEDURE
1951 ,p_module => l_log_module);
1952 END IF;
1953 --
1954 l_component_type := 'AMB_ADR';
1955 l_component_code := 'SYS_GAIN_CCID';
1956 l_component_type_code := 'S';
1957 l_component_appl_id := 222;
1958 l_amb_context_code := 'DEFAULT';
1959 x_transaction_coa_id := null;
1960 x_accounting_coa_id := null;
1961 --
1962
1963 --
1964 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1965 trace
1966 (p_msg => 'END of AcctDerRule_16'
1967 ,p_level => C_LEVEL_PROCEDURE
1968 ,p_module => l_log_module);
1969 END IF;
1970 x_value_type_code := 'S';
1971 l_output_value := TO_NUMBER(TO_NUMBER(p_source_12));
1972 RETURN l_output_value;
1973
1974 --
1975 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1976 trace
1977 (p_msg => 'END of AcctDerRule_16(invalid)'
1978 ,p_level => C_LEVEL_PROCEDURE
1979 ,p_module => l_log_module);
1980 END IF;
1981 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1982 x_value_type_code := null;
1983 l_output_value := null;
1984 xla_accounting_err_pkg.build_message
1985 (p_appli_s_name => 'XLA'
1986 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1987 ,p_token_1 => 'COMPONENT_NAME'
1988 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1989 l_component_type
1990 , l_component_code
1991 , l_component_type_code
1992 , l_component_appl_id
1996 ,p_value_2 => xla_lookups_pkg.get_meaning(
1993 , l_amb_context_code
1994 )
1995 ,p_token_2 => 'OWNER'
1997 'XLA_OWNER_TYPE'
1998 ,l_component_type_code
1999 )
2000 ,p_token_3 => 'PAD_NAME'
2001 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2002 ,p_token_4 => 'PAD_OWNER'
2003 ,p_value_4 => xla_lookups_pkg.get_meaning(
2004 'XLA_OWNER_TYPE'
2005 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2006 )
2007 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2008 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2009 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2010 ,p_ae_header_id => NULL
2011 );
2012 RETURN l_output_value;
2013 EXCEPTION
2014 WHEN xla_exceptions_pkg.application_exception THEN
2015 RAISE;
2016 WHEN OTHERS THEN
2017 xla_exceptions_pkg.raise_message
2018 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctDerRule_16');
2019 END AcctDerRule_16;
2020 --
2021
2022 ---------------------------------------
2023 --
2024 -- PRIVATE FUNCTION
2025 -- AcctDerRule_17
2026 --
2027 ---------------------------------------
2028 FUNCTION AcctDerRule_17 (
2029 p_application_id IN NUMBER
2030 , p_ae_header_id IN NUMBER
2031 , p_side IN VARCHAR2
2032 --System Loss Account
2033 , p_source_13 IN NUMBER
2034 , x_transaction_coa_id OUT NOCOPY NUMBER
2035 , x_accounting_coa_id OUT NOCOPY NUMBER
2036 , x_value_type_code OUT NOCOPY VARCHAR2
2037 )
2038 RETURN NUMBER
2039 IS
2040 l_component_type VARCHAR2(80) ;
2041 l_component_code VARCHAR2(30) ;
2042 l_component_type_code VARCHAR2(1) ;
2043 l_component_appl_id INTEGER ;
2044 l_amb_context_code VARCHAR2(30) ;
2045 l_log_module VARCHAR2(240) ;
2046 l_output_value NUMBER ;
2047 BEGIN
2048 IF g_log_enabled THEN
2049 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_17';
2050 END IF;
2051 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2052 trace
2053 (p_msg => 'BEGIN of AcctDerRule_17'
2054 ,p_level => C_LEVEL_PROCEDURE
2055 ,p_module => l_log_module);
2056 END IF;
2057 --
2058 l_component_type := 'AMB_ADR';
2059 l_component_code := 'SYS_LOSS_CCID';
2060 l_component_type_code := 'S';
2061 l_component_appl_id := 222;
2062 l_amb_context_code := 'DEFAULT';
2063 x_transaction_coa_id := null;
2064 x_accounting_coa_id := null;
2065 --
2066
2067 --
2068 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2069 trace
2070 (p_msg => 'END of AcctDerRule_17'
2071 ,p_level => C_LEVEL_PROCEDURE
2072 ,p_module => l_log_module);
2073 END IF;
2074 x_value_type_code := 'S';
2075 l_output_value := TO_NUMBER(TO_NUMBER(p_source_13));
2076 RETURN l_output_value;
2077
2078 --
2079 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2080 trace
2081 (p_msg => 'END of AcctDerRule_17(invalid)'
2082 ,p_level => C_LEVEL_PROCEDURE
2083 ,p_module => l_log_module);
2084 END IF;
2085 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2086 x_value_type_code := null;
2087 l_output_value := null;
2088 xla_accounting_err_pkg.build_message
2089 (p_appli_s_name => 'XLA'
2090 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2091 ,p_token_1 => 'COMPONENT_NAME'
2092 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2093 l_component_type
2094 , l_component_code
2095 , l_component_type_code
2096 , l_component_appl_id
2097 , l_amb_context_code
2098 )
2099 ,p_token_2 => 'OWNER'
2100 ,p_value_2 => xla_lookups_pkg.get_meaning(
2101 'XLA_OWNER_TYPE'
2102 ,l_component_type_code
2103 )
2104 ,p_token_3 => 'PAD_NAME'
2105 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2106 ,p_token_4 => 'PAD_OWNER'
2107 ,p_value_4 => xla_lookups_pkg.get_meaning(
2108 'XLA_OWNER_TYPE'
2112 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2109 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2110 )
2111 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2113 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2114 ,p_ae_header_id => NULL
2115 );
2116 RETURN l_output_value;
2117 EXCEPTION
2118 WHEN xla_exceptions_pkg.application_exception THEN
2119 RAISE;
2120 WHEN OTHERS THEN
2121 xla_exceptions_pkg.raise_message
2122 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctDerRule_17');
2123 END AcctDerRule_17;
2124 --
2125
2126 ---------------------------------------
2127 --
2128 -- PRIVATE FUNCTION
2129 -- AcctDerRule_18
2130 --
2131 ---------------------------------------
2132 FUNCTION AcctDerRule_18 (
2133 p_application_id IN NUMBER
2134 , p_ae_header_id IN NUMBER
2135 , p_side IN VARCHAR2
2136 --Transaction Distribution GL Account
2137 , p_source_14 IN NUMBER
2138 , x_transaction_coa_id OUT NOCOPY NUMBER
2139 , x_accounting_coa_id OUT NOCOPY NUMBER
2140 , x_value_type_code OUT NOCOPY VARCHAR2
2141 )
2142 RETURN NUMBER
2143 IS
2144 l_component_type VARCHAR2(80) ;
2145 l_component_code VARCHAR2(30) ;
2146 l_component_type_code VARCHAR2(1) ;
2147 l_component_appl_id INTEGER ;
2148 l_amb_context_code VARCHAR2(30) ;
2149 l_log_module VARCHAR2(240) ;
2150 l_output_value NUMBER ;
2151 BEGIN
2152 IF g_log_enabled THEN
2153 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_18';
2154 END IF;
2155 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2156 trace
2157 (p_msg => 'BEGIN of AcctDerRule_18'
2158 ,p_level => C_LEVEL_PROCEDURE
2159 ,p_module => l_log_module);
2160 END IF;
2161 --
2162 l_component_type := 'AMB_ADR';
2163 l_component_code := 'TRX_DIST_CCID';
2164 l_component_type_code := 'S';
2165 l_component_appl_id := 222;
2166 l_amb_context_code := 'DEFAULT';
2167 x_transaction_coa_id := null;
2168 x_accounting_coa_id := null;
2169 --
2170
2171 --
2172 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2173 trace
2174 (p_msg => 'END of AcctDerRule_18'
2175 ,p_level => C_LEVEL_PROCEDURE
2176 ,p_module => l_log_module);
2177 END IF;
2178 x_value_type_code := 'S';
2179 l_output_value := TO_NUMBER(TO_NUMBER(p_source_14));
2180 RETURN l_output_value;
2181
2182 --
2183 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2184 trace
2185 (p_msg => 'END of AcctDerRule_18(invalid)'
2186 ,p_level => C_LEVEL_PROCEDURE
2187 ,p_module => l_log_module);
2188 END IF;
2189 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2190 x_value_type_code := null;
2191 l_output_value := null;
2192 xla_accounting_err_pkg.build_message
2193 (p_appli_s_name => 'XLA'
2194 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2195 ,p_token_1 => 'COMPONENT_NAME'
2196 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2197 l_component_type
2198 , l_component_code
2199 , l_component_type_code
2200 , l_component_appl_id
2201 , l_amb_context_code
2202 )
2203 ,p_token_2 => 'OWNER'
2204 ,p_value_2 => xla_lookups_pkg.get_meaning(
2205 'XLA_OWNER_TYPE'
2206 ,l_component_type_code
2207 )
2208 ,p_token_3 => 'PAD_NAME'
2209 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2210 ,p_token_4 => 'PAD_OWNER'
2211 ,p_value_4 => xla_lookups_pkg.get_meaning(
2212 'XLA_OWNER_TYPE'
2213 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2214 )
2215 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2216 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2217 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2218 ,p_ae_header_id => NULL
2219 );
2220 RETURN l_output_value;
2221 EXCEPTION
2222 WHEN xla_exceptions_pkg.application_exception THEN
2223 RAISE;
2224 WHEN OTHERS THEN
2225 xla_exceptions_pkg.raise_message
2226 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctDerRule_18');
2227 END AcctDerRule_18;
2228 --
2229
2230 ---------------------------------------
2231 --
2232 -- PRIVATE FUNCTION
2233 -- AcctLineType_19
2234 --
2235 ---------------------------------------
2236 PROCEDURE AcctLineType_19 (
2240 ,p_calculate_g_l_flag IN VARCHAR2
2237 p_application_id IN NUMBER
2238 ,p_event_id IN NUMBER
2239 ,p_calculate_acctd_flag IN VARCHAR2
2241 ,p_actual_flag IN OUT VARCHAR2
2242 ,p_balance_type_code OUT VARCHAR2
2243 ,p_gain_or_loss_ref OUT VARCHAR2
2244
2245 --Distribution GL Account
2246 , p_source_10 IN NUMBER
2247 --Distribution Source Type
2248 , p_source_15 IN VARCHAR2
2249 --Receivable Activity Type
2250 , p_source_16 IN VARCHAR2
2251 --Distribution Line Identifier
2252 , p_source_17 IN NUMBER
2253 --Distribution Type
2254 , p_source_18 IN VARCHAR2
2255 --Entered Amount
2256 , p_source_19 IN NUMBER
2257 --Currency Code
2258 , p_source_20 IN VARCHAR2
2259 --Exchange Date
2260 , p_source_21 IN DATE
2261 --Exchange Rate
2262 , p_source_22 IN NUMBER
2263 --Exchange Rate Type
2264 , p_source_23 IN VARCHAR2
2265 --Applied To Document Accounting Amount
2266 , p_source_24 IN NUMBER
2267 --Bill To Customer Account Identifier
2268 , p_source_25 IN NUMBER
2269 --Bill To Customer Site Use Identifier
2270 , p_source_26 IN NUMBER
2271 --SLA Party Type
2272 , p_source_27 IN VARCHAR2
2273 )
2274 IS
2275
2276 l_component_type VARCHAR2(80);
2277 l_component_code VARCHAR2(30);
2278 l_component_type_code VARCHAR2(1);
2279 l_component_appl_id INTEGER;
2280 l_amb_context_code VARCHAR2(30);
2281 l_entity_code VARCHAR2(30);
2282 l_event_class_code VARCHAR2(30);
2283 l_ae_header_id NUMBER;
2284 l_event_type_code VARCHAR2(30);
2285 l_line_definition_code VARCHAR2(30);
2286 l_line_definition_owner_code VARCHAR2(1);
2287 --
2288 -- adr variables
2289 l_segment VARCHAR2(30);
2290 l_ccid NUMBER;
2291 l_adr_transaction_coa_id NUMBER;
2292 l_adr_accounting_coa_id NUMBER;
2293 l_adr_flexfield_segment_code VARCHAR2(30);
2294 l_adr_flex_value_set_id NUMBER;
2295 l_adr_value_type_code VARCHAR2(30);
2296 l_adr_value_combination_id NUMBER;
2297 l_adr_value_segment_code VARCHAR2(30);
2298
2299 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
2300 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
2301 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
2302 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
2303
2304 -- 4262811 Variables ------------------------------------------------------------------------------------------
2305 l_entered_amt_idx NUMBER;
2306 l_accted_amt_idx NUMBER;
2307 l_acc_rev_flag VARCHAR2(1);
2308 l_accrual_line_num NUMBER;
2309 l_tmp_amt NUMBER;
2310 l_acc_rev_natural_side_code VARCHAR2(1);
2311
2312 l_num_entries NUMBER;
2313 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
2314 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
2315 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
2316 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
2317 l_recog_line_1 NUMBER;
2318 l_recog_line_2 NUMBER;
2319
2320 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
2321 l_bflow_applied_to_amt NUMBER; -- 5132302
2322 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
2323
2324 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
2325
2326 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
2327 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
2328
2329 ---------------------------------------------------------------------------------------------------------------
2330
2331
2332 --
2333 -- bulk performance
2334 --
2335 l_balance_type_code VARCHAR2(1);
2336 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
2337 l_log_module VARCHAR2(240);
2338
2339 --
2340 -- Upgrade strategy
2341 --
2342 l_actual_upg_option VARCHAR2(1);
2343 l_enc_upg_option VARCHAR2(1);
2344
2345 --
2346 BEGIN
2347 --
2348 IF g_log_enabled THEN
2349 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_19';
2350 END IF;
2351 --
2352 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2353
2354 trace
2355 (p_msg => 'BEGIN of AcctLineType_19'
2356 ,p_level => C_LEVEL_PROCEDURE
2357 ,p_module => l_log_module);
2358
2359 END IF;
2360 --
2361 l_component_type := 'AMB_JLT';
2362 l_component_code := 'ADJ';
2363 l_component_type_code := 'S';
2364 l_component_appl_id := 222;
2365 l_amb_context_code := 'DEFAULT';
2366 l_entity_code := 'ADJUSTMENTS';
2367 l_event_class_code := 'ADJUSTMENT';
2368 l_event_type_code := 'ADJUSTMENT_ALL';
2369 l_line_definition_owner_code := 'S';
2370 l_line_definition_code := 'MFAR_ADJ_ACCRUAL_ACCOUNT';
2371 --
2372 l_balance_type_code := 'A';
2373 l_segment := NULL;
2374 l_ccid := NULL;
2375 l_adr_transaction_coa_id := NULL;
2376 l_adr_accounting_coa_id := NULL;
2377 l_adr_flexfield_segment_code := NULL;
2378 l_adr_flex_value_set_id := NULL;
2379 l_adr_value_type_code := NULL;
2383 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
2380 l_adr_value_combination_id := NULL;
2381 l_adr_value_segment_code := NULL;
2382
2384 l_bflow_class_code := ''; -- 4219869 Business Flow
2385 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
2386 l_budgetary_control_flag := 'N';
2387
2388 l_bflow_applied_to_amt_idx := NULL; -- 5132302
2389 l_bflow_applied_to_amt := NULL; -- 5132302
2390 l_entered_amt_idx := NULL; -- 4262811
2391 l_accted_amt_idx := NULL; -- 4262811
2392 l_acc_rev_flag := NULL; -- 4262811
2393 l_accrual_line_num := NULL; -- 4262811
2394 l_tmp_amt := NULL; -- 4262811
2395 --
2396
2397 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
2398 l_balance_type_code <> 'B' THEN
2399 IF NVL(p_source_15,'
2400 ') = 'ADJ' AND
2401 NVL(p_source_16,'
2402 ') <> 'ENDORSEMENT'
2403 THEN
2404
2405 --
2406 XLA_AE_LINES_PKG.SetNewLine;
2407
2408 p_balance_type_code := l_balance_type_code;
2409 -- set the flag so later we will know whether the gain loss line needs to be created
2410
2411 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
2412 p_actual_flag :='A';
2413 END IF;
2414
2415 --
2416 -- bulk performance
2417 --
2418 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
2419 p_header_num => 0); -- 4262811
2420 --
2421 -- set accounting line options
2422 --
2423 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
2424 p_natural_side_code => 'C'
2425 , p_gain_or_loss_flag => 'N'
2426 , p_gl_transfer_mode_code => 'S'
2427 , p_acct_entry_type_code => 'A'
2428 , p_switch_side_flag => 'Y'
2429 , p_merge_duplicate_code => 'A'
2430 );
2431 --
2432 l_acc_rev_natural_side_code := 'D'; -- 4262811
2433 --
2434 --
2435 -- set accounting line type info
2436 --
2437 xla_ae_lines_pkg.SetAcctLineType
2438 (p_component_type => l_component_type
2439 ,p_event_type_code => l_event_type_code
2440 ,p_line_definition_owner_code => l_line_definition_owner_code
2441 ,p_line_definition_code => l_line_definition_code
2442 ,p_accounting_line_code => l_component_code
2443 ,p_accounting_line_type_code => l_component_type_code
2444 ,p_accounting_line_appl_id => l_component_appl_id
2445 ,p_amb_context_code => l_amb_context_code
2446 ,p_entity_code => l_entity_code
2447 ,p_event_class_code => l_event_class_code);
2448 --
2449 -- set accounting class
2450 --
2451 xla_ae_lines_pkg.SetAcctClass(
2452 p_accounting_class_code => 'ADJ'
2453 , p_ae_header_id => l_ae_header_id
2454 );
2455
2456 --
2457 -- set rounding class
2458 --
2459 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
2460 'RECEIVABLE';
2461
2462 --
2463 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
2464 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
2465 --
2466 -- bulk performance
2467 --
2468 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
2469
2470 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
2471 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
2472
2473 -- 4955764
2474 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2475 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
2476
2477 -- 4458381 Public Sector Enh
2478
2479 --
2480 -- set accounting attributes for the line type
2481 --
2482 l_entered_amt_idx := 3;
2483 l_accted_amt_idx := 8;
2484 l_bflow_applied_to_amt_idx := NULL; -- 5132302
2485 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
2486 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
2487 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
2488 l_rec_acct_attrs.array_char_value(2) := p_source_18;
2489 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
2490 l_rec_acct_attrs.array_num_value(3) := p_source_19;
2491 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
2492 l_rec_acct_attrs.array_char_value(4) := p_source_20;
2493 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
2494 l_rec_acct_attrs.array_date_value(5) := p_source_21;
2495 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
2496 l_rec_acct_attrs.array_num_value(6) := p_source_22;
2497 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
2498 l_rec_acct_attrs.array_char_value(7) := p_source_23;
2499 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
2500 l_rec_acct_attrs.array_num_value(8) := p_source_24;
2501 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
2502 l_rec_acct_attrs.array_num_value(9) := p_source_25;
2503 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
2504 l_rec_acct_attrs.array_num_value(10) := p_source_26;
2505 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
2506 l_rec_acct_attrs.array_char_value(11) := p_source_27;
2507
2511 ---------------------------------------------------------------------------------------------------------------
2508 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
2509 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
2510
2512 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
2513 ---------------------------------------------------------------------------------------------------------------
2514 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
2515
2516 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
2517 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
2518
2519 IF xla_accounting_cache_pkg.GetValueChar
2520 (p_source_code => 'LEDGER_CATEGORY_CODE'
2521 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
2522 AND l_bflow_method_code = 'PRIOR_ENTRY'
2523 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
2524 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
2525 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
2526 )
2527 THEN
2528 xla_ae_lines_pkg.BflowUpgEntry
2529 (p_business_method_code => l_bflow_method_code
2530 ,p_business_class_code => l_bflow_class_code
2531 ,p_balance_type => l_balance_type_code);
2532 ELSE
2533 NULL;
2534 -- No business flow processing for business flow method of NONE.
2535 END IF;
2536
2537 --
2538 -- call analytical criteria
2539 --
2540
2541 --
2542 -- call description
2543 --
2544 -- No description or it is inherited.
2545 --
2546 -- call ADRs
2547 -- Bug 4922099
2548 --
2549 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
2550 (NVL(l_actual_upg_option, 'N') = 'O') OR
2551 (NVL(l_enc_upg_option, 'N') = 'O')
2552 )
2553 THEN
2554 NULL;
2555 --
2556 --
2557
2558 l_ccid := AcctDerRule_11(
2559 p_application_id => p_application_id
2560 , p_ae_header_id => l_ae_header_id
2561 , p_source_10 => p_source_10
2562 , x_transaction_coa_id => l_adr_transaction_coa_id
2563 , x_accounting_coa_id => l_adr_accounting_coa_id
2564 , x_value_type_code => l_adr_value_type_code
2565 , p_side => 'NA'
2566 );
2567
2568 xla_ae_lines_pkg.set_ccid(
2569 p_code_combination_id => l_ccid
2570 , p_value_type_code => l_adr_value_type_code
2571 , p_transaction_coa_id => l_adr_transaction_coa_id
2572 , p_accounting_coa_id => l_adr_accounting_coa_id
2573 , p_adr_code => 'DIST_CCID'
2574 , p_adr_type_code => 'S'
2575 , p_component_type => l_component_type
2576 , p_component_code => l_component_code
2577 , p_component_type_code => l_component_type_code
2578 , p_component_appl_id => l_component_appl_id
2579 , p_amb_context_code => l_amb_context_code
2580 , p_side => 'NA'
2581 );
2582
2583
2584 --
2585 --
2586 END IF;
2587 --
2588 -- Bug 4922099
2589 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
2590 (NVL(l_enc_upg_option, 'N') = 'O')
2591 ) AND
2592 (l_bflow_method_code = 'PRIOR_ENTRY')
2593 )
2594 THEN
2595 IF
2596 --
2597 1 = 2
2598 --
2599 THEN
2600 xla_accounting_err_pkg.build_message
2601 (p_appli_s_name => 'XLA'
2602 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2603 ,p_token_1 => 'LINE_NUMBER'
2604 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
2605 ,p_token_2 => 'LINE_TYPE_NAME'
2606 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
2607 l_component_type
2608 ,l_component_code
2609 ,l_component_type_code
2610 ,l_component_appl_id
2611 ,l_amb_context_code
2612 ,l_entity_code
2613 ,l_event_class_code
2614 )
2615 ,p_token_3 => 'OWNER'
2616 ,p_value_3 => xla_lookups_pkg.get_meaning(
2617 p_lookup_type => 'XLA_OWNER_TYPE'
2618 ,p_lookup_code => l_component_type_code
2619 )
2620 ,p_token_4 => 'PRODUCT_NAME'
2621 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
2625 ,p_ae_header_id => NULL
2622 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
2623 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
2624 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
2626 );
2627
2628 IF (C_LEVEL_ERROR>= g_log_level) THEN
2629 trace
2630 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
2631 ,p_level => C_LEVEL_ERROR
2632 ,p_module => l_log_module);
2633 END IF;
2634 END IF;
2635 END IF;
2636 --
2637 --
2638 ------------------------------------------------------------------------------------------------
2639 -- 4219869 Business Flow
2640 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
2641 -- Prior Entry. Currently, the following code is always generated.
2642 ------------------------------------------------------------------------------------------------
2643 XLA_AE_LINES_PKG.ValidateCurrentLine;
2644
2645 ------------------------------------------------------------------------------------
2646 -- 4219869 Business Flow
2647 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
2648 ------------------------------------------------------------------------------------
2649 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2650
2651 ----------------------------------------------------------------------------------
2652 -- 4219869 Business Flow
2653 -- Update journal entry status -- Need to generate this within IF <condition>
2654 ----------------------------------------------------------------------------------
2655 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2656 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
2657 ,p_balance_type_code => l_balance_type_code
2658 );
2659
2660 -------------------------------------------------------------------------------------------
2661 -- 4262811 - Generate the Accrual Reversal lines
2662 -------------------------------------------------------------------------------------------
2663 BEGIN
2664 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
2665 (g_array_event(p_event_id).array_value_num('header_index'));
2666 IF l_acc_rev_flag IS NULL THEN
2667 l_acc_rev_flag := 'N';
2668 END IF;
2669 EXCEPTION
2670 WHEN OTHERS THEN
2671 l_acc_rev_flag := 'N';
2672 END;
2673 --
2674 IF (l_acc_rev_flag = 'Y') THEN
2675
2676 -- 4645092 ------------------------------------------------------------------------------
2677 -- To allow MPA report to determine if it should generate report process
2678 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
2679 ------------------------------------------------------------------------------------------
2680
2681 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
2682 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
2683 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
2684 -- call ADRs
2685 -- Bug 4922099
2686 --
2687 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
2688 (NVL(l_actual_upg_option, 'N') = 'O') OR
2689 (NVL(l_enc_upg_option, 'N') = 'O')
2690 )
2691 THEN
2692 NULL;
2693 --
2694 --
2695
2696 l_ccid := AcctDerRule_11(
2697 p_application_id => p_application_id
2698 , p_ae_header_id => l_ae_header_id
2699 , p_source_10 => p_source_10
2700 , x_transaction_coa_id => l_adr_transaction_coa_id
2701 , x_accounting_coa_id => l_adr_accounting_coa_id
2702 , x_value_type_code => l_adr_value_type_code
2703 , p_side => 'NA'
2704 );
2705
2706 xla_ae_lines_pkg.set_ccid(
2707 p_code_combination_id => l_ccid
2708 , p_value_type_code => l_adr_value_type_code
2709 , p_transaction_coa_id => l_adr_transaction_coa_id
2710 , p_accounting_coa_id => l_adr_accounting_coa_id
2711 , p_adr_code => 'DIST_CCID'
2712 , p_adr_type_code => 'S'
2713 , p_component_type => l_component_type
2714 , p_component_code => l_component_code
2715 , p_component_type_code => l_component_type_code
2716 , p_component_appl_id => l_component_appl_id
2717 , p_amb_context_code => l_amb_context_code
2718 , p_side => 'NA'
2719 );
2720
2721
2722 --
2723 --
2724 END IF;
2725
2726 --
2727 -- Update the line information that should be overwritten
2728 --
2729 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
2730 p_header_num => 1);
2731 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
2732
2733 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
2734
2735 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
2736 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
2737 END IF;
2738
2739 --
2740 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
2741 --
2745 ---------------------------------------------------------------------------------------------------
2742 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
2743 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
2744 ELSE
2746 -- 4262811a Switch Sign
2747 ---------------------------------------------------------------------------------------------------
2748 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
2749 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2750 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2751 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
2752 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2753 -- 5132302
2754 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
2755 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
2756
2757 END IF;
2758
2759 -- 4955764
2760 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
2761 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
2762
2763
2764 XLA_AE_LINES_PKG.ValidateCurrentLine;
2765 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
2766
2767 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
2768 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
2769 ,p_balance_type_code => l_balance_type_code);
2770
2771 END IF;
2772
2773 -----------------------------------------------------------------------------------------
2774 -- 4262811 Multiperiod Accounting
2775 -----------------------------------------------------------------------------------------
2776 -- No MPA option is assigned.
2777
2778
2779 END IF;
2780 END IF;
2781 --
2782
2783 --
2784 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2785 trace
2786 (p_msg => 'END of AcctLineType_19'
2787 ,p_level => C_LEVEL_PROCEDURE
2788 ,p_module => l_log_module);
2789 END IF;
2790 --
2791 EXCEPTION
2792 WHEN xla_exceptions_pkg.application_exception THEN
2793 RAISE;
2794 WHEN OTHERS THEN
2795 xla_exceptions_pkg.raise_message
2796 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_19');
2797 END AcctLineType_19;
2798 --
2799
2800 ---------------------------------------
2801 --
2802 -- PRIVATE FUNCTION
2803 -- AcctLineType_20
2804 --
2805 ---------------------------------------
2806 PROCEDURE AcctLineType_20 (
2807 p_application_id IN NUMBER
2808 ,p_event_id IN NUMBER
2809 ,p_calculate_acctd_flag IN VARCHAR2
2810 ,p_calculate_g_l_flag IN VARCHAR2
2811 ,p_actual_flag IN OUT VARCHAR2
2812 ,p_balance_type_code OUT VARCHAR2
2813 ,p_gain_or_loss_ref OUT VARCHAR2
2814
2815 --Distribution GL Account
2816 , p_source_10 IN NUMBER
2817 --Distribution Source Type
2818 , p_source_15 IN VARCHAR2
2819 --Receivable Activity Type
2820 , p_source_16 IN VARCHAR2
2821 --Distribution Line Identifier
2822 , p_source_17 IN NUMBER
2823 --Distribution Type
2824 , p_source_18 IN VARCHAR2
2825 --Entered Amount
2826 , p_source_19 IN NUMBER
2827 --Currency Code
2828 , p_source_20 IN VARCHAR2
2829 --Exchange Date
2830 , p_source_21 IN DATE
2831 --Exchange Rate
2832 , p_source_22 IN NUMBER
2833 --Exchange Rate Type
2834 , p_source_23 IN VARCHAR2
2835 --Applied To Document Accounting Amount
2836 , p_source_24 IN NUMBER
2837 --Bill To Customer Account Identifier
2838 , p_source_25 IN NUMBER
2839 --Bill To Customer Site Use Identifier
2840 , p_source_26 IN NUMBER
2841 --SLA Party Type
2842 , p_source_27 IN VARCHAR2
2843 )
2844 IS
2845
2846 l_component_type VARCHAR2(80);
2847 l_component_code VARCHAR2(30);
2848 l_component_type_code VARCHAR2(1);
2849 l_component_appl_id INTEGER;
2850 l_amb_context_code VARCHAR2(30);
2851 l_entity_code VARCHAR2(30);
2852 l_event_class_code VARCHAR2(30);
2853 l_ae_header_id NUMBER;
2854 l_event_type_code VARCHAR2(30);
2855 l_line_definition_code VARCHAR2(30);
2856 l_line_definition_owner_code VARCHAR2(1);
2857 --
2858 -- adr variables
2859 l_segment VARCHAR2(30);
2860 l_ccid NUMBER;
2861 l_adr_transaction_coa_id NUMBER;
2862 l_adr_accounting_coa_id NUMBER;
2863 l_adr_flexfield_segment_code VARCHAR2(30);
2864 l_adr_flex_value_set_id NUMBER;
2865 l_adr_value_type_code VARCHAR2(30);
2866 l_adr_value_combination_id NUMBER;
2867 l_adr_value_segment_code VARCHAR2(30);
2868
2869 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
2870 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
2871 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
2872 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
2873
2874 -- 4262811 Variables ------------------------------------------------------------------------------------------
2875 l_entered_amt_idx NUMBER;
2879 l_tmp_amt NUMBER;
2876 l_accted_amt_idx NUMBER;
2877 l_acc_rev_flag VARCHAR2(1);
2878 l_accrual_line_num NUMBER;
2880 l_acc_rev_natural_side_code VARCHAR2(1);
2881
2882 l_num_entries NUMBER;
2883 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
2884 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
2885 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
2886 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
2887 l_recog_line_1 NUMBER;
2888 l_recog_line_2 NUMBER;
2889
2890 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
2891 l_bflow_applied_to_amt NUMBER; -- 5132302
2892 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
2893
2894 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
2895
2896 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
2897 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
2898
2899 ---------------------------------------------------------------------------------------------------------------
2900
2901
2902 --
2903 -- bulk performance
2904 --
2905 l_balance_type_code VARCHAR2(1);
2906 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
2907 l_log_module VARCHAR2(240);
2908
2909 --
2910 -- Upgrade strategy
2911 --
2912 l_actual_upg_option VARCHAR2(1);
2913 l_enc_upg_option VARCHAR2(1);
2914
2915 --
2916 BEGIN
2917 --
2918 IF g_log_enabled THEN
2919 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_20';
2920 END IF;
2921 --
2922 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2923
2924 trace
2925 (p_msg => 'BEGIN of AcctLineType_20'
2926 ,p_level => C_LEVEL_PROCEDURE
2927 ,p_module => l_log_module);
2928
2929 END IF;
2930 --
2931 l_component_type := 'AMB_JLT';
2932 l_component_code := 'ADJ_BR_ENDORSE';
2933 l_component_type_code := 'S';
2934 l_component_appl_id := 222;
2935 l_amb_context_code := 'DEFAULT';
2936 l_entity_code := 'ADJUSTMENTS';
2937 l_event_class_code := 'ADJUSTMENT';
2938 l_event_type_code := 'ADJUSTMENT_ALL';
2939 l_line_definition_owner_code := 'S';
2940 l_line_definition_code := 'MFAR_ADJ_ACCRUAL_ACCOUNT';
2941 --
2942 l_balance_type_code := 'A';
2943 l_segment := NULL;
2944 l_ccid := NULL;
2945 l_adr_transaction_coa_id := NULL;
2946 l_adr_accounting_coa_id := NULL;
2947 l_adr_flexfield_segment_code := NULL;
2948 l_adr_flex_value_set_id := NULL;
2949 l_adr_value_type_code := NULL;
2950 l_adr_value_combination_id := NULL;
2951 l_adr_value_segment_code := NULL;
2952
2953 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
2954 l_bflow_class_code := ''; -- 4219869 Business Flow
2955 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
2956 l_budgetary_control_flag := 'N';
2957
2958 l_bflow_applied_to_amt_idx := NULL; -- 5132302
2959 l_bflow_applied_to_amt := NULL; -- 5132302
2960 l_entered_amt_idx := NULL; -- 4262811
2961 l_accted_amt_idx := NULL; -- 4262811
2962 l_acc_rev_flag := NULL; -- 4262811
2963 l_accrual_line_num := NULL; -- 4262811
2964 l_tmp_amt := NULL; -- 4262811
2965 --
2966
2967 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
2968 l_balance_type_code <> 'B' THEN
2969 IF NVL(p_source_15,'
2970 ') = 'ADJ' AND
2971 NVL(p_source_16,'
2972 ') = 'ENDORSEMENT'
2973 THEN
2974
2975 --
2976 XLA_AE_LINES_PKG.SetNewLine;
2977
2978 p_balance_type_code := l_balance_type_code;
2979 -- set the flag so later we will know whether the gain loss line needs to be created
2980
2981 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
2982 p_actual_flag :='A';
2983 END IF;
2984
2985 --
2986 -- bulk performance
2987 --
2988 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
2989 p_header_num => 0); -- 4262811
2990 --
2991 -- set accounting line options
2992 --
2993 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
2994 p_natural_side_code => 'C'
2995 , p_gain_or_loss_flag => 'N'
2996 , p_gl_transfer_mode_code => 'S'
2997 , p_acct_entry_type_code => 'A'
2998 , p_switch_side_flag => 'Y'
2999 , p_merge_duplicate_code => 'A'
3000 );
3001 --
3002 l_acc_rev_natural_side_code := 'D'; -- 4262811
3003 --
3004 --
3005 -- set accounting line type info
3006 --
3007 xla_ae_lines_pkg.SetAcctLineType
3008 (p_component_type => l_component_type
3009 ,p_event_type_code => l_event_type_code
3010 ,p_line_definition_owner_code => l_line_definition_owner_code
3011 ,p_line_definition_code => l_line_definition_code
3012 ,p_accounting_line_code => l_component_code
3013 ,p_accounting_line_type_code => l_component_type_code
3014 ,p_accounting_line_appl_id => l_component_appl_id
3015 ,p_amb_context_code => l_amb_context_code
3019 -- set accounting class
3016 ,p_entity_code => l_entity_code
3017 ,p_event_class_code => l_event_class_code);
3018 --
3020 --
3021 xla_ae_lines_pkg.SetAcctClass(
3022 p_accounting_class_code => 'ENDORSEMENT'
3023 , p_ae_header_id => l_ae_header_id
3024 );
3025
3026 --
3027 -- set rounding class
3028 --
3029 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
3030 'RECEIVABLE';
3031
3032 --
3033 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
3034 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
3035 --
3036 -- bulk performance
3037 --
3038 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
3039
3040 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
3041 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
3042
3043 -- 4955764
3044 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
3045 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
3046
3047 -- 4458381 Public Sector Enh
3048
3049 --
3050 -- set accounting attributes for the line type
3051 --
3052 l_entered_amt_idx := 3;
3053 l_accted_amt_idx := 8;
3054 l_bflow_applied_to_amt_idx := NULL; -- 5132302
3055 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
3056 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
3057 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
3058 l_rec_acct_attrs.array_char_value(2) := p_source_18;
3059 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
3060 l_rec_acct_attrs.array_num_value(3) := p_source_19;
3061 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
3062 l_rec_acct_attrs.array_char_value(4) := p_source_20;
3063 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
3064 l_rec_acct_attrs.array_date_value(5) := p_source_21;
3065 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
3066 l_rec_acct_attrs.array_num_value(6) := p_source_22;
3067 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
3068 l_rec_acct_attrs.array_char_value(7) := p_source_23;
3069 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
3070 l_rec_acct_attrs.array_num_value(8) := p_source_24;
3071 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
3072 l_rec_acct_attrs.array_num_value(9) := p_source_25;
3073 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
3074 l_rec_acct_attrs.array_num_value(10) := p_source_26;
3075 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
3076 l_rec_acct_attrs.array_char_value(11) := p_source_27;
3077
3078 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
3079 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
3080
3081 ---------------------------------------------------------------------------------------------------------------
3082 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
3083 ---------------------------------------------------------------------------------------------------------------
3084 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
3085
3086 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
3087 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
3088
3089 IF xla_accounting_cache_pkg.GetValueChar
3090 (p_source_code => 'LEDGER_CATEGORY_CODE'
3091 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
3092 AND l_bflow_method_code = 'PRIOR_ENTRY'
3093 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
3094 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
3095 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
3096 )
3097 THEN
3098 xla_ae_lines_pkg.BflowUpgEntry
3099 (p_business_method_code => l_bflow_method_code
3100 ,p_business_class_code => l_bflow_class_code
3101 ,p_balance_type => l_balance_type_code);
3102 ELSE
3103 NULL;
3104 -- No business flow processing for business flow method of NONE.
3105 END IF;
3106
3107 --
3108 -- call analytical criteria
3109 --
3110
3111 --
3112 -- call description
3113 --
3114 -- No description or it is inherited.
3115 --
3116 -- call ADRs
3117 -- Bug 4922099
3118 --
3119 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
3120 (NVL(l_actual_upg_option, 'N') = 'O') OR
3121 (NVL(l_enc_upg_option, 'N') = 'O')
3122 )
3123 THEN
3124 NULL;
3125 --
3126 --
3127
3128 l_ccid := AcctDerRule_11(
3129 p_application_id => p_application_id
3130 , p_ae_header_id => l_ae_header_id
3131 , p_source_10 => p_source_10
3132 , x_transaction_coa_id => l_adr_transaction_coa_id
3133 , x_accounting_coa_id => l_adr_accounting_coa_id
3134 , x_value_type_code => l_adr_value_type_code
3135 , p_side => 'NA'
3136 );
3137
3138 xla_ae_lines_pkg.set_ccid(
3139 p_code_combination_id => l_ccid
3143 , p_adr_code => 'DIST_CCID'
3140 , p_value_type_code => l_adr_value_type_code
3141 , p_transaction_coa_id => l_adr_transaction_coa_id
3142 , p_accounting_coa_id => l_adr_accounting_coa_id
3144 , p_adr_type_code => 'S'
3145 , p_component_type => l_component_type
3146 , p_component_code => l_component_code
3147 , p_component_type_code => l_component_type_code
3148 , p_component_appl_id => l_component_appl_id
3149 , p_amb_context_code => l_amb_context_code
3150 , p_side => 'NA'
3151 );
3152
3153
3154 --
3155 --
3156 END IF;
3157 --
3158 -- Bug 4922099
3159 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
3160 (NVL(l_enc_upg_option, 'N') = 'O')
3161 ) AND
3162 (l_bflow_method_code = 'PRIOR_ENTRY')
3163 )
3164 THEN
3165 IF
3166 --
3167 1 = 2
3168 --
3169 THEN
3170 xla_accounting_err_pkg.build_message
3171 (p_appli_s_name => 'XLA'
3172 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
3173 ,p_token_1 => 'LINE_NUMBER'
3174 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
3175 ,p_token_2 => 'LINE_TYPE_NAME'
3176 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
3177 l_component_type
3178 ,l_component_code
3179 ,l_component_type_code
3180 ,l_component_appl_id
3181 ,l_amb_context_code
3182 ,l_entity_code
3183 ,l_event_class_code
3184 )
3185 ,p_token_3 => 'OWNER'
3186 ,p_value_3 => xla_lookups_pkg.get_meaning(
3187 p_lookup_type => 'XLA_OWNER_TYPE'
3188 ,p_lookup_code => l_component_type_code
3189 )
3190 ,p_token_4 => 'PRODUCT_NAME'
3191 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
3192 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
3193 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
3194 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
3195 ,p_ae_header_id => NULL
3196 );
3197
3198 IF (C_LEVEL_ERROR>= g_log_level) THEN
3199 trace
3200 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
3201 ,p_level => C_LEVEL_ERROR
3202 ,p_module => l_log_module);
3203 END IF;
3204 END IF;
3205 END IF;
3206 --
3207 --
3208 ------------------------------------------------------------------------------------------------
3209 -- 4219869 Business Flow
3210 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
3211 -- Prior Entry. Currently, the following code is always generated.
3212 ------------------------------------------------------------------------------------------------
3213 XLA_AE_LINES_PKG.ValidateCurrentLine;
3214
3215 ------------------------------------------------------------------------------------
3216 -- 4219869 Business Flow
3217 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
3218 ------------------------------------------------------------------------------------
3219 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
3220
3221 ----------------------------------------------------------------------------------
3222 -- 4219869 Business Flow
3223 -- Update journal entry status -- Need to generate this within IF <condition>
3224 ----------------------------------------------------------------------------------
3225 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
3226 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
3227 ,p_balance_type_code => l_balance_type_code
3228 );
3229
3230 -------------------------------------------------------------------------------------------
3231 -- 4262811 - Generate the Accrual Reversal lines
3232 -------------------------------------------------------------------------------------------
3233 BEGIN
3234 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
3235 (g_array_event(p_event_id).array_value_num('header_index'));
3236 IF l_acc_rev_flag IS NULL THEN
3237 l_acc_rev_flag := 'N';
3238 END IF;
3239 EXCEPTION
3240 WHEN OTHERS THEN
3241 l_acc_rev_flag := 'N';
3242 END;
3243 --
3244 IF (l_acc_rev_flag = 'Y') THEN
3248 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
3245
3246 -- 4645092 ------------------------------------------------------------------------------
3247 -- To allow MPA report to determine if it should generate report process
3249 ------------------------------------------------------------------------------------------
3250
3251 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
3252 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
3253 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
3254 -- call ADRs
3255 -- Bug 4922099
3256 --
3257 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
3258 (NVL(l_actual_upg_option, 'N') = 'O') OR
3259 (NVL(l_enc_upg_option, 'N') = 'O')
3260 )
3261 THEN
3262 NULL;
3263 --
3264 --
3265
3266 l_ccid := AcctDerRule_11(
3267 p_application_id => p_application_id
3268 , p_ae_header_id => l_ae_header_id
3269 , p_source_10 => p_source_10
3270 , x_transaction_coa_id => l_adr_transaction_coa_id
3271 , x_accounting_coa_id => l_adr_accounting_coa_id
3272 , x_value_type_code => l_adr_value_type_code
3273 , p_side => 'NA'
3274 );
3275
3276 xla_ae_lines_pkg.set_ccid(
3277 p_code_combination_id => l_ccid
3278 , p_value_type_code => l_adr_value_type_code
3279 , p_transaction_coa_id => l_adr_transaction_coa_id
3280 , p_accounting_coa_id => l_adr_accounting_coa_id
3281 , p_adr_code => 'DIST_CCID'
3282 , p_adr_type_code => 'S'
3283 , p_component_type => l_component_type
3284 , p_component_code => l_component_code
3285 , p_component_type_code => l_component_type_code
3286 , p_component_appl_id => l_component_appl_id
3287 , p_amb_context_code => l_amb_context_code
3288 , p_side => 'NA'
3289 );
3290
3291
3292 --
3293 --
3294 END IF;
3295
3296 --
3297 -- Update the line information that should be overwritten
3298 --
3299 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
3300 p_header_num => 1);
3301 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
3302
3303 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
3304
3305 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
3306 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
3307 END IF;
3308
3309 --
3310 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
3311 --
3312 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
3313 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
3314 ELSE
3315 ---------------------------------------------------------------------------------------------------
3316 -- 4262811a Switch Sign
3317 ---------------------------------------------------------------------------------------------------
3318 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
3319 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
3320 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3321 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
3322 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3323 -- 5132302
3324 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
3325 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3326
3327 END IF;
3328
3329 -- 4955764
3330 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
3331 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
3332
3333
3334 XLA_AE_LINES_PKG.ValidateCurrentLine;
3335 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
3336
3337 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
3338 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
3339 ,p_balance_type_code => l_balance_type_code);
3340
3341 END IF;
3342
3343 -----------------------------------------------------------------------------------------
3344 -- 4262811 Multiperiod Accounting
3345 -----------------------------------------------------------------------------------------
3346 -- No MPA option is assigned.
3347
3348
3349 END IF;
3350 END IF;
3351 --
3352
3353 --
3354 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3355 trace
3356 (p_msg => 'END of AcctLineType_20'
3357 ,p_level => C_LEVEL_PROCEDURE
3358 ,p_module => l_log_module);
3359 END IF;
3360 --
3361 EXCEPTION
3362 WHEN xla_exceptions_pkg.application_exception THEN
3363 RAISE;
3364 WHEN OTHERS THEN
3365 xla_exceptions_pkg.raise_message
3366 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_20');
3367 END AcctLineType_20;
3368 --
3369
3370 ---------------------------------------
3374 --
3371 --
3372 -- PRIVATE FUNCTION
3373 -- AcctLineType_21
3375 ---------------------------------------
3376 PROCEDURE AcctLineType_21 (
3377 p_application_id IN NUMBER
3378 ,p_event_id IN NUMBER
3379 ,p_calculate_acctd_flag IN VARCHAR2
3380 ,p_calculate_g_l_flag IN VARCHAR2
3381 ,p_actual_flag IN OUT VARCHAR2
3382 ,p_balance_type_code OUT VARCHAR2
3383 ,p_gain_or_loss_ref OUT VARCHAR2
3384
3385 --Distribution GL Account
3386 , p_source_10 IN NUMBER
3387 --Distribution Source Type
3388 , p_source_15 IN VARCHAR2
3389 --Distribution Line Identifier
3390 , p_source_17 IN NUMBER
3391 --Distribution Type
3392 , p_source_18 IN VARCHAR2
3393 --Entered Amount
3394 , p_source_19 IN NUMBER
3395 --Currency Code
3396 , p_source_20 IN VARCHAR2
3397 --Exchange Date
3398 , p_source_21 IN DATE
3399 --Exchange Rate
3400 , p_source_22 IN NUMBER
3401 --Exchange Rate Type
3402 , p_source_23 IN VARCHAR2
3403 --Applied To Document Accounting Amount
3404 , p_source_24 IN NUMBER
3405 --Bill To Customer Account Identifier
3406 , p_source_25 IN NUMBER
3407 --Bill To Customer Site Use Identifier
3408 , p_source_26 IN NUMBER
3409 --SLA Party Type
3410 , p_source_27 IN VARCHAR2
3411 )
3412 IS
3413
3414 l_component_type VARCHAR2(80);
3415 l_component_code VARCHAR2(30);
3416 l_component_type_code VARCHAR2(1);
3417 l_component_appl_id INTEGER;
3418 l_amb_context_code VARCHAR2(30);
3419 l_entity_code VARCHAR2(30);
3420 l_event_class_code VARCHAR2(30);
3421 l_ae_header_id NUMBER;
3422 l_event_type_code VARCHAR2(30);
3423 l_line_definition_code VARCHAR2(30);
3424 l_line_definition_owner_code VARCHAR2(1);
3425 --
3426 -- adr variables
3427 l_segment VARCHAR2(30);
3428 l_ccid NUMBER;
3429 l_adr_transaction_coa_id NUMBER;
3430 l_adr_accounting_coa_id NUMBER;
3431 l_adr_flexfield_segment_code VARCHAR2(30);
3432 l_adr_flex_value_set_id NUMBER;
3433 l_adr_value_type_code VARCHAR2(30);
3434 l_adr_value_combination_id NUMBER;
3435 l_adr_value_segment_code VARCHAR2(30);
3436
3437 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
3438 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
3439 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
3440 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
3441
3442 -- 4262811 Variables ------------------------------------------------------------------------------------------
3443 l_entered_amt_idx NUMBER;
3444 l_accted_amt_idx NUMBER;
3445 l_acc_rev_flag VARCHAR2(1);
3446 l_accrual_line_num NUMBER;
3447 l_tmp_amt NUMBER;
3448 l_acc_rev_natural_side_code VARCHAR2(1);
3449
3450 l_num_entries NUMBER;
3451 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
3452 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
3453 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
3454 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
3455 l_recog_line_1 NUMBER;
3456 l_recog_line_2 NUMBER;
3457
3458 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
3459 l_bflow_applied_to_amt NUMBER; -- 5132302
3460 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
3461
3462 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
3463
3464 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
3465 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
3466
3467 ---------------------------------------------------------------------------------------------------------------
3468
3469
3470 --
3471 -- bulk performance
3472 --
3473 l_balance_type_code VARCHAR2(1);
3474 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
3475 l_log_module VARCHAR2(240);
3476
3477 --
3478 -- Upgrade strategy
3479 --
3480 l_actual_upg_option VARCHAR2(1);
3481 l_enc_upg_option VARCHAR2(1);
3482
3483 --
3484 BEGIN
3485 --
3486 IF g_log_enabled THEN
3487 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_21';
3488 END IF;
3489 --
3490 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3491
3492 trace
3493 (p_msg => 'BEGIN of AcctLineType_21'
3494 ,p_level => C_LEVEL_PROCEDURE
3495 ,p_module => l_log_module);
3496
3497 END IF;
3498 --
3499 l_component_type := 'AMB_JLT';
3500 l_component_code := 'ADJ_CHRG';
3501 l_component_type_code := 'S';
3502 l_component_appl_id := 222;
3503 l_amb_context_code := 'DEFAULT';
3504 l_entity_code := 'ADJUSTMENTS';
3505 l_event_class_code := 'ADJUSTMENT';
3506 l_event_type_code := 'ADJUSTMENT_ALL';
3507 l_line_definition_owner_code := 'S';
3508 l_line_definition_code := 'MFAR_ADJ_ACCRUAL_ACCOUNT';
3509 --
3510 l_balance_type_code := 'A';
3511 l_segment := NULL;
3512 l_ccid := NULL;
3513 l_adr_transaction_coa_id := NULL;
3514 l_adr_accounting_coa_id := NULL;
3518 l_adr_value_combination_id := NULL;
3515 l_adr_flexfield_segment_code := NULL;
3516 l_adr_flex_value_set_id := NULL;
3517 l_adr_value_type_code := NULL;
3519 l_adr_value_segment_code := NULL;
3520
3521 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
3522 l_bflow_class_code := ''; -- 4219869 Business Flow
3523 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
3524 l_budgetary_control_flag := 'N';
3525
3526 l_bflow_applied_to_amt_idx := NULL; -- 5132302
3527 l_bflow_applied_to_amt := NULL; -- 5132302
3528 l_entered_amt_idx := NULL; -- 4262811
3529 l_accted_amt_idx := NULL; -- 4262811
3530 l_acc_rev_flag := NULL; -- 4262811
3531 l_accrual_line_num := NULL; -- 4262811
3532 l_tmp_amt := NULL; -- 4262811
3533 --
3534
3535 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
3536 l_balance_type_code <> 'B' THEN
3537 IF NVL(p_source_15,'
3538 ') = 'FINCHRG' OR
3539 NVL(p_source_15,'
3540 ') = 'FINCHRG_NON_REC_TAX'
3541 THEN
3542
3543 --
3544 XLA_AE_LINES_PKG.SetNewLine;
3545
3546 p_balance_type_code := l_balance_type_code;
3547 -- set the flag so later we will know whether the gain loss line needs to be created
3548
3549 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
3550 p_actual_flag :='A';
3551 END IF;
3552
3553 --
3554 -- bulk performance
3555 --
3556 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
3557 p_header_num => 0); -- 4262811
3558 --
3559 -- set accounting line options
3560 --
3561 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
3562 p_natural_side_code => 'C'
3563 , p_gain_or_loss_flag => 'N'
3564 , p_gl_transfer_mode_code => 'S'
3565 , p_acct_entry_type_code => 'A'
3566 , p_switch_side_flag => 'Y'
3567 , p_merge_duplicate_code => 'A'
3568 );
3569 --
3570 l_acc_rev_natural_side_code := 'D'; -- 4262811
3571 --
3572 --
3573 -- set accounting line type info
3574 --
3575 xla_ae_lines_pkg.SetAcctLineType
3576 (p_component_type => l_component_type
3577 ,p_event_type_code => l_event_type_code
3578 ,p_line_definition_owner_code => l_line_definition_owner_code
3579 ,p_line_definition_code => l_line_definition_code
3580 ,p_accounting_line_code => l_component_code
3581 ,p_accounting_line_type_code => l_component_type_code
3582 ,p_accounting_line_appl_id => l_component_appl_id
3583 ,p_amb_context_code => l_amb_context_code
3584 ,p_entity_code => l_entity_code
3585 ,p_event_class_code => l_event_class_code);
3586 --
3587 -- set accounting class
3588 --
3589 xla_ae_lines_pkg.SetAcctClass(
3590 p_accounting_class_code => 'CHARGES'
3591 , p_ae_header_id => l_ae_header_id
3592 );
3593
3594 --
3595 -- set rounding class
3596 --
3597 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
3598 'RECEIVABLE';
3599
3600 --
3601 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
3602 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
3603 --
3604 -- bulk performance
3605 --
3606 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
3607
3608 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
3609 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
3610
3611 -- 4955764
3612 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
3613 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
3614
3615 -- 4458381 Public Sector Enh
3616
3617 --
3618 -- set accounting attributes for the line type
3619 --
3620 l_entered_amt_idx := 3;
3621 l_accted_amt_idx := 8;
3622 l_bflow_applied_to_amt_idx := NULL; -- 5132302
3623 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
3624 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
3625 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
3626 l_rec_acct_attrs.array_char_value(2) := p_source_18;
3627 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
3628 l_rec_acct_attrs.array_num_value(3) := p_source_19;
3629 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
3630 l_rec_acct_attrs.array_char_value(4) := p_source_20;
3631 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
3632 l_rec_acct_attrs.array_date_value(5) := p_source_21;
3633 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
3634 l_rec_acct_attrs.array_num_value(6) := p_source_22;
3635 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
3636 l_rec_acct_attrs.array_char_value(7) := p_source_23;
3637 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
3638 l_rec_acct_attrs.array_num_value(8) := p_source_24;
3639 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
3640 l_rec_acct_attrs.array_num_value(9) := p_source_25;
3641 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
3642 l_rec_acct_attrs.array_num_value(10) := p_source_26;
3646 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
3643 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
3644 l_rec_acct_attrs.array_char_value(11) := p_source_27;
3645
3647 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
3648
3649 ---------------------------------------------------------------------------------------------------------------
3650 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
3651 ---------------------------------------------------------------------------------------------------------------
3652 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
3653
3654 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
3655 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
3656
3657 IF xla_accounting_cache_pkg.GetValueChar
3658 (p_source_code => 'LEDGER_CATEGORY_CODE'
3659 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
3660 AND l_bflow_method_code = 'PRIOR_ENTRY'
3661 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
3662 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
3663 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
3664 )
3665 THEN
3666 xla_ae_lines_pkg.BflowUpgEntry
3667 (p_business_method_code => l_bflow_method_code
3668 ,p_business_class_code => l_bflow_class_code
3669 ,p_balance_type => l_balance_type_code);
3670 ELSE
3671 NULL;
3672 -- No business flow processing for business flow method of NONE.
3673 END IF;
3674
3675 --
3676 -- call analytical criteria
3677 --
3678
3679 --
3680 -- call description
3681 --
3682 -- No description or it is inherited.
3683 --
3684 -- call ADRs
3685 -- Bug 4922099
3686 --
3687 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
3688 (NVL(l_actual_upg_option, 'N') = 'O') OR
3689 (NVL(l_enc_upg_option, 'N') = 'O')
3690 )
3691 THEN
3692 NULL;
3693 --
3694 --
3695
3696 l_ccid := AcctDerRule_11(
3697 p_application_id => p_application_id
3698 , p_ae_header_id => l_ae_header_id
3699 , p_source_10 => p_source_10
3700 , x_transaction_coa_id => l_adr_transaction_coa_id
3701 , x_accounting_coa_id => l_adr_accounting_coa_id
3702 , x_value_type_code => l_adr_value_type_code
3703 , p_side => 'NA'
3704 );
3705
3706 xla_ae_lines_pkg.set_ccid(
3707 p_code_combination_id => l_ccid
3708 , p_value_type_code => l_adr_value_type_code
3709 , p_transaction_coa_id => l_adr_transaction_coa_id
3710 , p_accounting_coa_id => l_adr_accounting_coa_id
3711 , p_adr_code => 'DIST_CCID'
3712 , p_adr_type_code => 'S'
3713 , p_component_type => l_component_type
3714 , p_component_code => l_component_code
3715 , p_component_type_code => l_component_type_code
3716 , p_component_appl_id => l_component_appl_id
3717 , p_amb_context_code => l_amb_context_code
3718 , p_side => 'NA'
3719 );
3720
3721
3722 --
3723 --
3724 END IF;
3725 --
3726 -- Bug 4922099
3727 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
3728 (NVL(l_enc_upg_option, 'N') = 'O')
3729 ) AND
3730 (l_bflow_method_code = 'PRIOR_ENTRY')
3731 )
3732 THEN
3733 IF
3734 --
3735 1 = 2
3736 --
3737 THEN
3738 xla_accounting_err_pkg.build_message
3739 (p_appli_s_name => 'XLA'
3740 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
3741 ,p_token_1 => 'LINE_NUMBER'
3742 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
3743 ,p_token_2 => 'LINE_TYPE_NAME'
3744 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
3745 l_component_type
3746 ,l_component_code
3747 ,l_component_type_code
3748 ,l_component_appl_id
3749 ,l_amb_context_code
3753 ,p_token_3 => 'OWNER'
3750 ,l_entity_code
3751 ,l_event_class_code
3752 )
3754 ,p_value_3 => xla_lookups_pkg.get_meaning(
3755 p_lookup_type => 'XLA_OWNER_TYPE'
3756 ,p_lookup_code => l_component_type_code
3757 )
3758 ,p_token_4 => 'PRODUCT_NAME'
3759 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
3760 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
3761 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
3762 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
3763 ,p_ae_header_id => NULL
3764 );
3765
3766 IF (C_LEVEL_ERROR>= g_log_level) THEN
3767 trace
3768 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
3769 ,p_level => C_LEVEL_ERROR
3770 ,p_module => l_log_module);
3771 END IF;
3772 END IF;
3773 END IF;
3774 --
3775 --
3776 ------------------------------------------------------------------------------------------------
3777 -- 4219869 Business Flow
3778 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
3779 -- Prior Entry. Currently, the following code is always generated.
3780 ------------------------------------------------------------------------------------------------
3781 XLA_AE_LINES_PKG.ValidateCurrentLine;
3782
3783 ------------------------------------------------------------------------------------
3784 -- 4219869 Business Flow
3785 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
3786 ------------------------------------------------------------------------------------
3787 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
3788
3789 ----------------------------------------------------------------------------------
3790 -- 4219869 Business Flow
3791 -- Update journal entry status -- Need to generate this within IF <condition>
3792 ----------------------------------------------------------------------------------
3793 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
3794 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
3795 ,p_balance_type_code => l_balance_type_code
3796 );
3797
3798 -------------------------------------------------------------------------------------------
3799 -- 4262811 - Generate the Accrual Reversal lines
3800 -------------------------------------------------------------------------------------------
3801 BEGIN
3802 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
3803 (g_array_event(p_event_id).array_value_num('header_index'));
3804 IF l_acc_rev_flag IS NULL THEN
3805 l_acc_rev_flag := 'N';
3806 END IF;
3807 EXCEPTION
3808 WHEN OTHERS THEN
3809 l_acc_rev_flag := 'N';
3810 END;
3811 --
3812 IF (l_acc_rev_flag = 'Y') THEN
3813
3814 -- 4645092 ------------------------------------------------------------------------------
3815 -- To allow MPA report to determine if it should generate report process
3816 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
3817 ------------------------------------------------------------------------------------------
3818
3819 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
3820 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
3821 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
3822 -- call ADRs
3823 -- Bug 4922099
3824 --
3825 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
3826 (NVL(l_actual_upg_option, 'N') = 'O') OR
3827 (NVL(l_enc_upg_option, 'N') = 'O')
3828 )
3829 THEN
3830 NULL;
3831 --
3832 --
3833
3834 l_ccid := AcctDerRule_11(
3835 p_application_id => p_application_id
3836 , p_ae_header_id => l_ae_header_id
3837 , p_source_10 => p_source_10
3838 , x_transaction_coa_id => l_adr_transaction_coa_id
3839 , x_accounting_coa_id => l_adr_accounting_coa_id
3840 , x_value_type_code => l_adr_value_type_code
3841 , p_side => 'NA'
3842 );
3843
3844 xla_ae_lines_pkg.set_ccid(
3845 p_code_combination_id => l_ccid
3846 , p_value_type_code => l_adr_value_type_code
3847 , p_transaction_coa_id => l_adr_transaction_coa_id
3848 , p_accounting_coa_id => l_adr_accounting_coa_id
3849 , p_adr_code => 'DIST_CCID'
3850 , p_adr_type_code => 'S'
3851 , p_component_type => l_component_type
3852 , p_component_code => l_component_code
3853 , p_component_type_code => l_component_type_code
3857 );
3854 , p_component_appl_id => l_component_appl_id
3855 , p_amb_context_code => l_amb_context_code
3856 , p_side => 'NA'
3858
3859
3860 --
3861 --
3862 END IF;
3863
3864 --
3865 -- Update the line information that should be overwritten
3866 --
3867 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
3868 p_header_num => 1);
3869 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
3870
3871 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
3872
3873 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
3874 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
3875 END IF;
3876
3877 --
3878 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
3879 --
3883 ---------------------------------------------------------------------------------------------------
3880 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
3881 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
3882 ELSE
3884 -- 4262811a Switch Sign
3885 ---------------------------------------------------------------------------------------------------
3886 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
3887 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
3888 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3889 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
3890 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3891 -- 5132302
3892 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
3893 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
3894
3895 END IF;
3896
3897 -- 4955764
3898 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
3899 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
3900
3901
3902 XLA_AE_LINES_PKG.ValidateCurrentLine;
3903 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
3904
3905 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
3906 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
3907 ,p_balance_type_code => l_balance_type_code);
3908
3909 END IF;
3910
3911 -----------------------------------------------------------------------------------------
3912 -- 4262811 Multiperiod Accounting
3913 -----------------------------------------------------------------------------------------
3914 -- No MPA option is assigned.
3915
3916
3917 END IF;
3918 END IF;
3919 --
3920
3921 --
3922 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3923 trace
3924 (p_msg => 'END of AcctLineType_21'
3925 ,p_level => C_LEVEL_PROCEDURE
3926 ,p_module => l_log_module);
3927 END IF;
3928 --
3929 EXCEPTION
3930 WHEN xla_exceptions_pkg.application_exception THEN
3931 RAISE;
3932 WHEN OTHERS THEN
3933 xla_exceptions_pkg.raise_message
3934 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_21');
3935 END AcctLineType_21;
3936 --
3937
3938 ---------------------------------------
3939 --
3940 -- PRIVATE FUNCTION
3941 -- AcctLineType_22
3942 --
3943 ---------------------------------------
3944 PROCEDURE AcctLineType_22 (
3945 p_application_id IN NUMBER
3946 ,p_event_id IN NUMBER
3947 ,p_calculate_acctd_flag IN VARCHAR2
3948 ,p_calculate_g_l_flag IN VARCHAR2
3949 ,p_actual_flag IN OUT VARCHAR2
3950 ,p_balance_type_code OUT VARCHAR2
3951 ,p_gain_or_loss_ref OUT VARCHAR2
3952
3953 --Distribution GL Account
3954 , p_source_10 IN NUMBER
3955 --Distribution Source Type
3956 , p_source_15 IN VARCHAR2
3957 --Distribution Line Identifier
3958 , p_source_17 IN NUMBER
3959 --Distribution Type
3960 , p_source_18 IN VARCHAR2
3961 --Entered Amount
3962 , p_source_19 IN NUMBER
3963 --Currency Code
3964 , p_source_20 IN VARCHAR2
3965 --Exchange Date
3966 , p_source_21 IN DATE
3967 --Exchange Rate
3971 --Applied To Document Accounting Amount
3968 , p_source_22 IN NUMBER
3969 --Exchange Rate Type
3970 , p_source_23 IN VARCHAR2
3972 , p_source_24 IN NUMBER
3973 --Bill To Customer Account Identifier
3974 , p_source_25 IN NUMBER
3975 --Bill To Customer Site Use Identifier
3976 , p_source_26 IN NUMBER
3977 --SLA Party Type
3978 , p_source_27 IN VARCHAR2
3979 )
3980 IS
3981
3982 l_component_type VARCHAR2(80);
3983 l_component_code VARCHAR2(30);
3984 l_component_type_code VARCHAR2(1);
3985 l_component_appl_id INTEGER;
3986 l_amb_context_code VARCHAR2(30);
3987 l_entity_code VARCHAR2(30);
3988 l_event_class_code VARCHAR2(30);
3989 l_ae_header_id NUMBER;
3990 l_event_type_code VARCHAR2(30);
3991 l_line_definition_code VARCHAR2(30);
3992 l_line_definition_owner_code VARCHAR2(1);
3993 --
3994 -- adr variables
3995 l_segment VARCHAR2(30);
3996 l_ccid NUMBER;
3997 l_adr_transaction_coa_id NUMBER;
3998 l_adr_accounting_coa_id NUMBER;
3999 l_adr_flexfield_segment_code VARCHAR2(30);
4000 l_adr_flex_value_set_id NUMBER;
4001 l_adr_value_type_code VARCHAR2(30);
4002 l_adr_value_combination_id NUMBER;
4003 l_adr_value_segment_code VARCHAR2(30);
4004
4005 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
4006 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
4007 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
4008 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
4009
4010 -- 4262811 Variables ------------------------------------------------------------------------------------------
4011 l_entered_amt_idx NUMBER;
4012 l_accted_amt_idx NUMBER;
4013 l_acc_rev_flag VARCHAR2(1);
4014 l_accrual_line_num NUMBER;
4015 l_tmp_amt NUMBER;
4016 l_acc_rev_natural_side_code VARCHAR2(1);
4017
4018 l_num_entries NUMBER;
4019 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
4020 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
4021 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
4022 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
4023 l_recog_line_1 NUMBER;
4024 l_recog_line_2 NUMBER;
4025
4026 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
4027 l_bflow_applied_to_amt NUMBER; -- 5132302
4028 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
4029
4030 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
4031
4035 ---------------------------------------------------------------------------------------------------------------
4032 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
4033 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
4034
4036
4037
4038 --
4039 -- bulk performance
4040 --
4041 l_balance_type_code VARCHAR2(1);
4042 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
4043 l_log_module VARCHAR2(240);
4044
4045 --
4049 l_enc_upg_option VARCHAR2(1);
4046 -- Upgrade strategy
4047 --
4048 l_actual_upg_option VARCHAR2(1);
4050
4051 --
4052 BEGIN
4053 --
4054 IF g_log_enabled THEN
4055 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_22';
4056 END IF;
4057 --
4058 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4059
4060 trace
4061 (p_msg => 'BEGIN of AcctLineType_22'
4062 ,p_level => C_LEVEL_PROCEDURE
4063 ,p_module => l_log_module);
4064
4065 END IF;
4066 --
4067 l_component_type := 'AMB_JLT';
4068 l_component_code := 'ADJ_TAX';
4069 l_component_type_code := 'S';
4070 l_component_appl_id := 222;
4071 l_amb_context_code := 'DEFAULT';
4072 l_entity_code := 'ADJUSTMENTS';
4073 l_event_class_code := 'ADJUSTMENT';
4074 l_event_type_code := 'ADJUSTMENT_ALL';
4075 l_line_definition_owner_code := 'S';
4076 l_line_definition_code := 'MFAR_ADJ_ACCRUAL_ACCOUNT';
4077 --
4078 l_balance_type_code := 'A';
4079 l_segment := NULL;
4080 l_ccid := NULL;
4081 l_adr_transaction_coa_id := NULL;
4082 l_adr_accounting_coa_id := NULL;
4083 l_adr_flexfield_segment_code := NULL;
4084 l_adr_flex_value_set_id := NULL;
4085 l_adr_value_type_code := NULL;
4086 l_adr_value_combination_id := NULL;
4087 l_adr_value_segment_code := NULL;
4088
4089 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
4090 l_bflow_class_code := ''; -- 4219869 Business Flow
4091 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
4092 l_budgetary_control_flag := 'N';
4093
4094 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4095 l_bflow_applied_to_amt := NULL; -- 5132302
4096 l_entered_amt_idx := NULL; -- 4262811
4097 l_accted_amt_idx := NULL; -- 4262811
4098 l_acc_rev_flag := NULL; -- 4262811
4099 l_accrual_line_num := NULL; -- 4262811
4100 l_tmp_amt := NULL; -- 4262811
4101 --
4102
4103 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
4104 l_balance_type_code <> 'B' THEN
4105 IF NVL(p_source_15,'
4106 ') = 'TAX'
4107 THEN
4108
4109 --
4110 XLA_AE_LINES_PKG.SetNewLine;
4111
4112 p_balance_type_code := l_balance_type_code;
4113 -- set the flag so later we will know whether the gain loss line needs to be created
4114
4115 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
4116 p_actual_flag :='A';
4117 END IF;
4118
4119 --
4120 -- bulk performance
4121 --
4122 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
4123 p_header_num => 0); -- 4262811
4124 --
4125 -- set accounting line options
4126 --
4127 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
4128 p_natural_side_code => 'C'
4129 , p_gain_or_loss_flag => 'N'
4130 , p_gl_transfer_mode_code => 'S'
4131 , p_acct_entry_type_code => 'A'
4132 , p_switch_side_flag => 'Y'
4133 , p_merge_duplicate_code => 'A'
4134 );
4135 --
4136 l_acc_rev_natural_side_code := 'D'; -- 4262811
4137 --
4138 --
4139 -- set accounting line type info
4140 --
4141 xla_ae_lines_pkg.SetAcctLineType
4142 (p_component_type => l_component_type
4143 ,p_event_type_code => l_event_type_code
4144 ,p_line_definition_owner_code => l_line_definition_owner_code
4145 ,p_line_definition_code => l_line_definition_code
4146 ,p_accounting_line_code => l_component_code
4147 ,p_accounting_line_type_code => l_component_type_code
4148 ,p_accounting_line_appl_id => l_component_appl_id
4149 ,p_amb_context_code => l_amb_context_code
4150 ,p_entity_code => l_entity_code
4151 ,p_event_class_code => l_event_class_code);
4152 --
4153 -- set accounting class
4154 --
4155 xla_ae_lines_pkg.SetAcctClass(
4156 p_accounting_class_code => 'TAX'
4157 , p_ae_header_id => l_ae_header_id
4158 );
4159
4160 --
4161 -- set rounding class
4162 --
4163 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
4164 'RECEIVABLE';
4165
4166 --
4167 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
4168 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
4169 --
4170 -- bulk performance
4171 --
4172 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
4173
4174 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
4175 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
4176
4177 -- 4955764
4178 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4179 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
4180
4181 -- 4458381 Public Sector Enh
4182
4183 --
4184 -- set accounting attributes for the line type
4185 --
4189 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
4186 l_entered_amt_idx := 3;
4187 l_accted_amt_idx := 8;
4188 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4190 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
4191 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
4192 l_rec_acct_attrs.array_char_value(2) := p_source_18;
4193 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
4194 l_rec_acct_attrs.array_num_value(3) := p_source_19;
4198 l_rec_acct_attrs.array_date_value(5) := p_source_21;
4195 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
4196 l_rec_acct_attrs.array_char_value(4) := p_source_20;
4197 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
4199 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
4200 l_rec_acct_attrs.array_num_value(6) := p_source_22;
4201 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
4202 l_rec_acct_attrs.array_char_value(7) := p_source_23;
4203 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
4204 l_rec_acct_attrs.array_num_value(8) := p_source_24;
4205 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
4206 l_rec_acct_attrs.array_num_value(9) := p_source_25;
4207 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
4208 l_rec_acct_attrs.array_num_value(10) := p_source_26;
4209 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
4210 l_rec_acct_attrs.array_char_value(11) := p_source_27;
4211
4212 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
4213 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
4214
4215 ---------------------------------------------------------------------------------------------------------------
4216 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
4217 ---------------------------------------------------------------------------------------------------------------
4218 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
4219
4220 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4221 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4222
4223 IF xla_accounting_cache_pkg.GetValueChar
4224 (p_source_code => 'LEDGER_CATEGORY_CODE'
4225 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
4226 AND l_bflow_method_code = 'PRIOR_ENTRY'
4227 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
4228 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
4229 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
4230 )
4231 THEN
4232 xla_ae_lines_pkg.BflowUpgEntry
4233 (p_business_method_code => l_bflow_method_code
4234 ,p_business_class_code => l_bflow_class_code
4235 ,p_balance_type => l_balance_type_code);
4236 ELSE
4237 NULL;
4238 -- No business flow processing for business flow method of NONE.
4239 END IF;
4240
4241 --
4242 -- call analytical criteria
4243 --
4244
4245 --
4246 -- call description
4247 --
4248 -- No description or it is inherited.
4249 --
4250 -- call ADRs
4251 -- Bug 4922099
4252 --
4253 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4254 (NVL(l_actual_upg_option, 'N') = 'O') OR
4255 (NVL(l_enc_upg_option, 'N') = 'O')
4256 )
4257 THEN
4258 NULL;
4259 --
4260 --
4261
4262 l_ccid := AcctDerRule_11(
4263 p_application_id => p_application_id
4264 , p_ae_header_id => l_ae_header_id
4265 , p_source_10 => p_source_10
4266 , x_transaction_coa_id => l_adr_transaction_coa_id
4267 , x_accounting_coa_id => l_adr_accounting_coa_id
4268 , x_value_type_code => l_adr_value_type_code
4269 , p_side => 'NA'
4270 );
4271
4272 xla_ae_lines_pkg.set_ccid(
4273 p_code_combination_id => l_ccid
4274 , p_value_type_code => l_adr_value_type_code
4275 , p_transaction_coa_id => l_adr_transaction_coa_id
4276 , p_accounting_coa_id => l_adr_accounting_coa_id
4277 , p_adr_code => 'DIST_CCID'
4278 , p_adr_type_code => 'S'
4279 , p_component_type => l_component_type
4280 , p_component_code => l_component_code
4281 , p_component_type_code => l_component_type_code
4282 , p_component_appl_id => l_component_appl_id
4286
4283 , p_amb_context_code => l_amb_context_code
4284 , p_side => 'NA'
4285 );
4287
4288 --
4289 --
4290 END IF;
4291 --
4292 -- Bug 4922099
4293 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
4294 (NVL(l_enc_upg_option, 'N') = 'O')
4295 ) AND
4296 (l_bflow_method_code = 'PRIOR_ENTRY')
4297 )
4298 THEN
4299 IF
4300 --
4301 1 = 2
4302 --
4303 THEN
4304 xla_accounting_err_pkg.build_message
4305 (p_appli_s_name => 'XLA'
4306 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4307 ,p_token_1 => 'LINE_NUMBER'
4308 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
4309 ,p_token_2 => 'LINE_TYPE_NAME'
4310 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
4311 l_component_type
4312 ,l_component_code
4313 ,l_component_type_code
4314 ,l_component_appl_id
4315 ,l_amb_context_code
4316 ,l_entity_code
4317 ,l_event_class_code
4318 )
4319 ,p_token_3 => 'OWNER'
4320 ,p_value_3 => xla_lookups_pkg.get_meaning(
4321 p_lookup_type => 'XLA_OWNER_TYPE'
4322 ,p_lookup_code => l_component_type_code
4323 )
4324 ,p_token_4 => 'PRODUCT_NAME'
4325 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
4329 ,p_ae_header_id => NULL
4326 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
4327 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
4328 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
4330 );
4331
4332 IF (C_LEVEL_ERROR>= g_log_level) THEN
4333 trace
4334 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4335 ,p_level => C_LEVEL_ERROR
4336 ,p_module => l_log_module);
4337 END IF;
4338 END IF;
4339 END IF;
4340 --
4341 --
4342 ------------------------------------------------------------------------------------------------
4343 -- 4219869 Business Flow
4344 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
4345 -- Prior Entry. Currently, the following code is always generated.
4346 ------------------------------------------------------------------------------------------------
4347 XLA_AE_LINES_PKG.ValidateCurrentLine;
4348
4349 ------------------------------------------------------------------------------------
4350 -- 4219869 Business Flow
4351 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
4352 ------------------------------------------------------------------------------------
4353 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
4354
4355 ----------------------------------------------------------------------------------
4356 -- 4219869 Business Flow
4357 -- Update journal entry status -- Need to generate this within IF <condition>
4358 ----------------------------------------------------------------------------------
4359 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4360 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
4361 ,p_balance_type_code => l_balance_type_code
4362 );
4363
4364 -------------------------------------------------------------------------------------------
4365 -- 4262811 - Generate the Accrual Reversal lines
4366 -------------------------------------------------------------------------------------------
4367 BEGIN
4368 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
4369 (g_array_event(p_event_id).array_value_num('header_index'));
4370 IF l_acc_rev_flag IS NULL THEN
4371 l_acc_rev_flag := 'N';
4372 END IF;
4373 EXCEPTION
4374 WHEN OTHERS THEN
4375 l_acc_rev_flag := 'N';
4376 END;
4377 --
4378 IF (l_acc_rev_flag = 'Y') THEN
4379
4380 -- 4645092 ------------------------------------------------------------------------------
4381 -- To allow MPA report to determine if it should generate report process
4382 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
4383 ------------------------------------------------------------------------------------------
4384
4385 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
4386 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
4387 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
4388 -- call ADRs
4389 -- Bug 4922099
4390 --
4391 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4392 (NVL(l_actual_upg_option, 'N') = 'O') OR
4393 (NVL(l_enc_upg_option, 'N') = 'O')
4394 )
4395 THEN
4396 NULL;
4397 --
4398 --
4399
4400 l_ccid := AcctDerRule_11(
4401 p_application_id => p_application_id
4402 , p_ae_header_id => l_ae_header_id
4403 , p_source_10 => p_source_10
4404 , x_transaction_coa_id => l_adr_transaction_coa_id
4405 , x_accounting_coa_id => l_adr_accounting_coa_id
4406 , x_value_type_code => l_adr_value_type_code
4407 , p_side => 'NA'
4408 );
4409
4410 xla_ae_lines_pkg.set_ccid(
4411 p_code_combination_id => l_ccid
4412 , p_value_type_code => l_adr_value_type_code
4413 , p_transaction_coa_id => l_adr_transaction_coa_id
4414 , p_accounting_coa_id => l_adr_accounting_coa_id
4415 , p_adr_code => 'DIST_CCID'
4416 , p_adr_type_code => 'S'
4417 , p_component_type => l_component_type
4418 , p_component_code => l_component_code
4419 , p_component_type_code => l_component_type_code
4420 , p_component_appl_id => l_component_appl_id
4421 , p_amb_context_code => l_amb_context_code
4422 , p_side => 'NA'
4423 );
4424
4425
4426 --
4427 --
4428 END IF;
4429
4430 --
4431 -- Update the line information that should be overwritten
4432 --
4433 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
4434 p_header_num => 1);
4435 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
4436
4440 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
4437 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
4438
4439 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
4441 END IF;
4442
4443 --
4444 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
4445 --
4446 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
4447 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
4448 ELSE
4449 ---------------------------------------------------------------------------------------------------
4450 -- 4262811a Switch Sign
4451 ---------------------------------------------------------------------------------------------------
4452 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
4453 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
4454 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4455 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
4456 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4457 -- 5132302
4458 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
4459 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4460
4461 END IF;
4462
4463 -- 4955764
4464 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4465 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
4466
4467
4468 XLA_AE_LINES_PKG.ValidateCurrentLine;
4469 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
4470
4471 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4472 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
4473 ,p_balance_type_code => l_balance_type_code);
4474
4475 END IF;
4476
4477 -----------------------------------------------------------------------------------------
4478 -- 4262811 Multiperiod Accounting
4479 -----------------------------------------------------------------------------------------
4480 -- No MPA option is assigned.
4481
4482
4483 END IF;
4484 END IF;
4485 --
4486
4487 --
4488 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4489 trace
4490 (p_msg => 'END of AcctLineType_22'
4491 ,p_level => C_LEVEL_PROCEDURE
4492 ,p_module => l_log_module);
4493 END IF;
4494 --
4495 EXCEPTION
4496 WHEN xla_exceptions_pkg.application_exception THEN
4497 RAISE;
4498 WHEN OTHERS THEN
4499 xla_exceptions_pkg.raise_message
4500 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_22');
4501 END AcctLineType_22;
4502 --
4503
4504 ---------------------------------------
4505 --
4506 -- PRIVATE FUNCTION
4507 -- AcctLineType_23
4508 --
4509 ---------------------------------------
4510 PROCEDURE AcctLineType_23 (
4511 p_application_id IN NUMBER
4512 ,p_event_id IN NUMBER
4513 ,p_calculate_acctd_flag IN VARCHAR2
4514 ,p_calculate_g_l_flag IN VARCHAR2
4515 ,p_actual_flag IN OUT VARCHAR2
4516 ,p_balance_type_code OUT VARCHAR2
4517 ,p_gain_or_loss_ref OUT VARCHAR2
4518
4519 --Transaction Distribution GL Account
4520 , p_source_14 IN NUMBER
4521 --Bill To Customer Account Identifier
4522 , p_source_25 IN NUMBER
4523 --Bill To Customer Site Use Identifier
4524 , p_source_26 IN NUMBER
4525 --SLA Party Type
4526 , p_source_27 IN VARCHAR2
4527 --Transaction Distribution Account Class
4528 , p_source_28 IN VARCHAR2
4529 --Transaction Distribution Identifier
4530 , p_source_29 IN NUMBER
4531 --Transaction Distribution Type
4532 , p_source_30 IN VARCHAR2
4533 --Transaction Distribution Entered Amount
4534 , p_source_31 IN NUMBER
4535 --Transaction Currency Code
4536 , p_source_32 IN VARCHAR2
4537 --Transaction Exchange Date
4538 , p_source_33 IN DATE
4539 --Transaction Exchange Rate
4540 , p_source_34 IN NUMBER
4541 --Transaction Exchange Rate Type
4542 , p_source_35 IN VARCHAR2
4543 --Transaction Accounting Amount
4544 , p_source_36 IN NUMBER
4545 )
4546 IS
4547
4548 l_component_type VARCHAR2(80);
4549 l_component_code VARCHAR2(30);
4550 l_component_type_code VARCHAR2(1);
4551 l_component_appl_id INTEGER;
4552 l_amb_context_code VARCHAR2(30);
4553 l_entity_code VARCHAR2(30);
4554 l_event_class_code VARCHAR2(30);
4555 l_ae_header_id NUMBER;
4556 l_event_type_code VARCHAR2(30);
4557 l_line_definition_code VARCHAR2(30);
4558 l_line_definition_owner_code VARCHAR2(1);
4559 --
4560 -- adr variables
4561 l_segment VARCHAR2(30);
4562 l_ccid NUMBER;
4563 l_adr_transaction_coa_id NUMBER;
4564 l_adr_accounting_coa_id NUMBER;
4565 l_adr_flexfield_segment_code VARCHAR2(30);
4566 l_adr_flex_value_set_id NUMBER;
4567 l_adr_value_type_code VARCHAR2(30);
4568 l_adr_value_combination_id NUMBER;
4569 l_adr_value_segment_code VARCHAR2(30);
4570
4571 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
4572 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
4573 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
4574 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
4575
4576 -- 4262811 Variables ------------------------------------------------------------------------------------------
4577 l_entered_amt_idx NUMBER;
4578 l_accted_amt_idx NUMBER;
4579 l_acc_rev_flag VARCHAR2(1);
4580 l_accrual_line_num NUMBER;
4581 l_tmp_amt NUMBER;
4582 l_acc_rev_natural_side_code VARCHAR2(1);
4583
4584 l_num_entries NUMBER;
4585 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
4586 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
4587 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
4588 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
4589 l_recog_line_1 NUMBER;
4590 l_recog_line_2 NUMBER;
4591
4592 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
4593 l_bflow_applied_to_amt NUMBER; -- 5132302
4594 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
4595
4596 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
4597
4598 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
4599 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
4600
4601 ---------------------------------------------------------------------------------------------------------------
4602
4603
4604 --
4605 -- bulk performance
4606 --
4607 l_balance_type_code VARCHAR2(1);
4608 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
4609 l_log_module VARCHAR2(240);
4610
4611 --
4612 -- Upgrade strategy
4613 --
4614 l_actual_upg_option VARCHAR2(1);
4615 l_enc_upg_option VARCHAR2(1);
4616
4617 --
4618 BEGIN
4619 --
4620 IF g_log_enabled THEN
4621 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_23';
4622 END IF;
4623 --
4624 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4625
4629 ,p_module => l_log_module);
4626 trace
4627 (p_msg => 'BEGIN of AcctLineType_23'
4628 ,p_level => C_LEVEL_PROCEDURE
4630
4631 END IF;
4632 --
4633 l_component_type := 'AMB_JLT';
4634 l_component_code := 'CB_DEFAULT_REC';
4635 l_component_type_code := 'S';
4636 l_component_appl_id := 222;
4637 l_amb_context_code := 'DEFAULT';
4638 l_entity_code := 'TRANSACTIONS';
4639 l_event_class_code := 'CHARGEBACK';
4640 l_event_type_code := 'CHARGEBACK_ALL';
4641 l_line_definition_owner_code := 'S';
4642 l_line_definition_code := 'AR_CB_DEFAULT_ACCRUAL';
4643 --
4644 l_balance_type_code := 'A';
4645 l_segment := NULL;
4649 l_adr_flexfield_segment_code := NULL;
4646 l_ccid := NULL;
4647 l_adr_transaction_coa_id := NULL;
4648 l_adr_accounting_coa_id := NULL;
4650 l_adr_flex_value_set_id := NULL;
4651 l_adr_value_type_code := NULL;
4652 l_adr_value_combination_id := NULL;
4653 l_adr_value_segment_code := NULL;
4654
4655 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
4656 l_bflow_class_code := ''; -- 4219869 Business Flow
4657 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
4658 l_budgetary_control_flag := 'N';
4659
4660 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4661 l_bflow_applied_to_amt := NULL; -- 5132302
4662 l_entered_amt_idx := NULL; -- 4262811
4663 l_accted_amt_idx := NULL; -- 4262811
4664 l_acc_rev_flag := NULL; -- 4262811
4665 l_accrual_line_num := NULL; -- 4262811
4666 l_tmp_amt := NULL; -- 4262811
4667 --
4668
4669 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
4670 l_balance_type_code <> 'B' THEN
4671 IF NVL(p_source_28,'
4672 ') = 'REC'
4673 THEN
4674
4675 --
4676 XLA_AE_LINES_PKG.SetNewLine;
4677
4678 p_balance_type_code := l_balance_type_code;
4679 -- set the flag so later we will know whether the gain loss line needs to be created
4680
4681 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
4682 p_actual_flag :='A';
4683 END IF;
4684
4685 --
4686 -- bulk performance
4687 --
4688 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
4689 p_header_num => 0); -- 4262811
4690 --
4691 -- set accounting line options
4692 --
4693 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
4694 p_natural_side_code => 'D'
4695 , p_gain_or_loss_flag => 'N'
4696 , p_gl_transfer_mode_code => 'S'
4697 , p_acct_entry_type_code => 'A'
4698 , p_switch_side_flag => 'Y'
4699 , p_merge_duplicate_code => 'A'
4700 );
4701 --
4702 l_acc_rev_natural_side_code := 'C'; -- 4262811
4703 --
4704 --
4705 -- set accounting line type info
4706 --
4707 xla_ae_lines_pkg.SetAcctLineType
4708 (p_component_type => l_component_type
4709 ,p_event_type_code => l_event_type_code
4710 ,p_line_definition_owner_code => l_line_definition_owner_code
4711 ,p_line_definition_code => l_line_definition_code
4712 ,p_accounting_line_code => l_component_code
4713 ,p_accounting_line_type_code => l_component_type_code
4714 ,p_accounting_line_appl_id => l_component_appl_id
4715 ,p_amb_context_code => l_amb_context_code
4716 ,p_entity_code => l_entity_code
4717 ,p_event_class_code => l_event_class_code);
4718 --
4719 -- set accounting class
4720 --
4721 xla_ae_lines_pkg.SetAcctClass(
4722 p_accounting_class_code => 'RECEIVABLE'
4723 , p_ae_header_id => l_ae_header_id
4724 );
4725
4726 --
4727 -- set rounding class
4728 --
4729 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
4730 'RECEIVABLE';
4731
4732 --
4733 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
4734 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
4735 --
4736 -- bulk performance
4737 --
4738 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
4739
4740 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
4741 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
4742
4743 -- 4955764
4744 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4745 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
4746
4747 -- 4458381 Public Sector Enh
4748
4749 --
4750 -- set accounting attributes for the line type
4751 --
4752 l_entered_amt_idx := 3;
4753 l_accted_amt_idx := 8;
4754 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4755 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
4756 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
4757 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
4758 l_rec_acct_attrs.array_char_value(2) := p_source_30;
4759 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
4760 l_rec_acct_attrs.array_num_value(3) := p_source_31;
4761 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
4762 l_rec_acct_attrs.array_char_value(4) := p_source_32;
4763 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
4764 l_rec_acct_attrs.array_date_value(5) := p_source_33;
4765 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
4766 l_rec_acct_attrs.array_num_value(6) := p_source_34;
4767 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
4768 l_rec_acct_attrs.array_char_value(7) := p_source_35;
4769 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
4773 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
4770 l_rec_acct_attrs.array_num_value(8) := p_source_36;
4771 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
4772 l_rec_acct_attrs.array_num_value(9) := p_source_25;
4774 l_rec_acct_attrs.array_num_value(10) := p_source_26;
4775 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
4779 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
4776 l_rec_acct_attrs.array_char_value(11) := p_source_27;
4777
4778 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
4780
4781 ---------------------------------------------------------------------------------------------------------------
4782 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
4783 ---------------------------------------------------------------------------------------------------------------
4784 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
4785
4786 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4787 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4788
4789 IF xla_accounting_cache_pkg.GetValueChar
4790 (p_source_code => 'LEDGER_CATEGORY_CODE'
4791 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
4792 AND l_bflow_method_code = 'PRIOR_ENTRY'
4793 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
4794 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
4795 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
4796 )
4797 THEN
4798 xla_ae_lines_pkg.BflowUpgEntry
4799 (p_business_method_code => l_bflow_method_code
4800 ,p_business_class_code => l_bflow_class_code
4801 ,p_balance_type => l_balance_type_code);
4802 ELSE
4803 NULL;
4804 -- No business flow processing for business flow method of NONE.
4805 END IF;
4806
4807 --
4808 -- call analytical criteria
4809 --
4810
4811 --
4812 -- call description
4813 --
4814 -- No description or it is inherited.
4815 --
4816 -- call ADRs
4817 -- Bug 4922099
4818 --
4819 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4820 (NVL(l_actual_upg_option, 'N') = 'O') OR
4821 (NVL(l_enc_upg_option, 'N') = 'O')
4822 )
4823 THEN
4824 NULL;
4825 --
4826 --
4827
4828 l_ccid := AcctDerRule_18(
4829 p_application_id => p_application_id
4830 , p_ae_header_id => l_ae_header_id
4831 , p_source_14 => p_source_14
4832 , x_transaction_coa_id => l_adr_transaction_coa_id
4833 , x_accounting_coa_id => l_adr_accounting_coa_id
4834 , x_value_type_code => l_adr_value_type_code
4835 , p_side => 'NA'
4836 );
4837
4838 xla_ae_lines_pkg.set_ccid(
4839 p_code_combination_id => l_ccid
4840 , p_value_type_code => l_adr_value_type_code
4841 , p_transaction_coa_id => l_adr_transaction_coa_id
4842 , p_accounting_coa_id => l_adr_accounting_coa_id
4843 , p_adr_code => 'TRX_DIST_CCID'
4844 , p_adr_type_code => 'S'
4845 , p_component_type => l_component_type
4846 , p_component_code => l_component_code
4847 , p_component_type_code => l_component_type_code
4848 , p_component_appl_id => l_component_appl_id
4849 , p_amb_context_code => l_amb_context_code
4850 , p_side => 'NA'
4851 );
4852
4853
4854 --
4855 --
4856 END IF;
4857 --
4858 -- Bug 4922099
4859 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
4860 (NVL(l_enc_upg_option, 'N') = 'O')
4861 ) AND
4862 (l_bflow_method_code = 'PRIOR_ENTRY')
4863 )
4864 THEN
4865 IF
4866 --
4867 1 = 2
4868 --
4869 THEN
4870 xla_accounting_err_pkg.build_message
4871 (p_appli_s_name => 'XLA'
4872 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4873 ,p_token_1 => 'LINE_NUMBER'
4874 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
4875 ,p_token_2 => 'LINE_TYPE_NAME'
4876 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
4877 l_component_type
4878 ,l_component_code
4879 ,l_component_type_code
4880 ,l_component_appl_id
4881 ,l_amb_context_code
4882 ,l_entity_code
4883 ,l_event_class_code
4884 )
4885 ,p_token_3 => 'OWNER'
4886 ,p_value_3 => xla_lookups_pkg.get_meaning(
4887 p_lookup_type => 'XLA_OWNER_TYPE'
4888 ,p_lookup_code => l_component_type_code
4889 )
4890 ,p_token_4 => 'PRODUCT_NAME'
4891 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
4892 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
4893 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
4894 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
4895 ,p_ae_header_id => NULL
4896 );
4897
4898 IF (C_LEVEL_ERROR>= g_log_level) THEN
4899 trace
4900 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4901 ,p_level => C_LEVEL_ERROR
4902 ,p_module => l_log_module);
4903 END IF;
4904 END IF;
4905 END IF;
4906 --
4907 --
4908 ------------------------------------------------------------------------------------------------
4909 -- 4219869 Business Flow
4910 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
4911 -- Prior Entry. Currently, the following code is always generated.
4912 ------------------------------------------------------------------------------------------------
4913 XLA_AE_LINES_PKG.ValidateCurrentLine;
4914
4915 ------------------------------------------------------------------------------------
4916 -- 4219869 Business Flow
4917 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
4918 ------------------------------------------------------------------------------------
4919 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
4920
4921 ----------------------------------------------------------------------------------
4922 -- 4219869 Business Flow
4923 -- Update journal entry status -- Need to generate this within IF <condition>
4924 ----------------------------------------------------------------------------------
4925 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4926 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
4927 ,p_balance_type_code => l_balance_type_code
4928 );
4929
4930 -------------------------------------------------------------------------------------------
4931 -- 4262811 - Generate the Accrual Reversal lines
4932 -------------------------------------------------------------------------------------------
4933 BEGIN
4934 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
4935 (g_array_event(p_event_id).array_value_num('header_index'));
4936 IF l_acc_rev_flag IS NULL THEN
4937 l_acc_rev_flag := 'N';
4938 END IF;
4939 EXCEPTION
4940 WHEN OTHERS THEN
4941 l_acc_rev_flag := 'N';
4942 END;
4943 --
4944 IF (l_acc_rev_flag = 'Y') THEN
4945
4949 ------------------------------------------------------------------------------------------
4946 -- 4645092 ------------------------------------------------------------------------------
4947 -- To allow MPA report to determine if it should generate report process
4948 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
4950
4951 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
4952 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
4953 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
4954 -- call ADRs
4955 -- Bug 4922099
4956 --
4957 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4958 (NVL(l_actual_upg_option, 'N') = 'O') OR
4959 (NVL(l_enc_upg_option, 'N') = 'O')
4960 )
4961 THEN
4962 NULL;
4963 --
4964 --
4965
4966 l_ccid := AcctDerRule_18(
4967 p_application_id => p_application_id
4968 , p_ae_header_id => l_ae_header_id
4969 , p_source_14 => p_source_14
4970 , x_transaction_coa_id => l_adr_transaction_coa_id
4971 , x_accounting_coa_id => l_adr_accounting_coa_id
4972 , x_value_type_code => l_adr_value_type_code
4973 , p_side => 'NA'
4974 );
4975
4976 xla_ae_lines_pkg.set_ccid(
4977 p_code_combination_id => l_ccid
4978 , p_value_type_code => l_adr_value_type_code
4979 , p_transaction_coa_id => l_adr_transaction_coa_id
4980 , p_accounting_coa_id => l_adr_accounting_coa_id
4981 , p_adr_code => 'TRX_DIST_CCID'
4982 , p_adr_type_code => 'S'
4983 , p_component_type => l_component_type
4984 , p_component_code => l_component_code
4985 , p_component_type_code => l_component_type_code
4986 , p_component_appl_id => l_component_appl_id
4987 , p_amb_context_code => l_amb_context_code
4988 , p_side => 'NA'
4989 );
4990
4991
4992 --
4993 --
4994 END IF;
4995
4996 --
4997 -- Update the line information that should be overwritten
4998 --
4999 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
5000 p_header_num => 1);
5001 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
5002
5003 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
5004
5005 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
5006 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
5007 END IF;
5008
5009 --
5010 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
5011 --
5012 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
5013 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
5014 ELSE
5015 ---------------------------------------------------------------------------------------------------
5016 -- 4262811a Switch Sign
5017 ---------------------------------------------------------------------------------------------------
5018 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
5019 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5020 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5021 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5022 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5023 -- 5132302
5024 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
5025 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5026
5027 END IF;
5028
5029 -- 4955764
5030 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5031 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
5032
5033
5034 XLA_AE_LINES_PKG.ValidateCurrentLine;
5035 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5036
5037 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5038 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
5039 ,p_balance_type_code => l_balance_type_code);
5040
5041 END IF;
5042
5043 -----------------------------------------------------------------------------------------
5044 -- 4262811 Multiperiod Accounting
5045 -----------------------------------------------------------------------------------------
5046 -- No MPA option is assigned.
5047
5048
5049 END IF;
5050 END IF;
5051 --
5052
5053 --
5054 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5055 trace
5056 (p_msg => 'END of AcctLineType_23'
5057 ,p_level => C_LEVEL_PROCEDURE
5058 ,p_module => l_log_module);
5059 END IF;
5060 --
5061 EXCEPTION
5062 WHEN xla_exceptions_pkg.application_exception THEN
5063 RAISE;
5064 WHEN OTHERS THEN
5065 xla_exceptions_pkg.raise_message
5066 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_23');
5067 END AcctLineType_23;
5068 --
5069
5070 ---------------------------------------
5071 --
5072 -- PRIVATE FUNCTION
5076 PROCEDURE AcctLineType_24 (
5073 -- AcctLineType_24
5074 --
5075 ---------------------------------------
5077 p_application_id IN NUMBER
5078 ,p_event_id IN NUMBER
5079 ,p_calculate_acctd_flag IN VARCHAR2
5080 ,p_calculate_g_l_flag IN VARCHAR2
5081 ,p_actual_flag IN OUT VARCHAR2
5082 ,p_balance_type_code OUT VARCHAR2
5083 ,p_gain_or_loss_ref OUT VARCHAR2
5084
5085 --Transaction Distribution GL Account
5086 , p_source_14 IN NUMBER
5087 --Bill To Customer Account Identifier
5088 , p_source_25 IN NUMBER
5089 --Bill To Customer Site Use Identifier
5090 , p_source_26 IN NUMBER
5091 --SLA Party Type
5092 , p_source_27 IN VARCHAR2
5093 --Transaction Distribution Account Class
5094 , p_source_28 IN VARCHAR2
5095 --Transaction Distribution Identifier
5096 , p_source_29 IN NUMBER
5097 --Transaction Distribution Type
5098 , p_source_30 IN VARCHAR2
5099 --Transaction Distribution Entered Amount
5100 , p_source_31 IN NUMBER
5101 --Transaction Currency Code
5102 , p_source_32 IN VARCHAR2
5103 --Transaction Exchange Date
5104 , p_source_33 IN DATE
5105 --Transaction Exchange Rate
5106 , p_source_34 IN NUMBER
5107 --Transaction Exchange Rate Type
5108 , p_source_35 IN VARCHAR2
5109 --Transaction Accounting Amount
5110 , p_source_36 IN NUMBER
5111 )
5112 IS
5113
5114 l_component_type VARCHAR2(80);
5115 l_component_code VARCHAR2(30);
5116 l_component_type_code VARCHAR2(1);
5117 l_component_appl_id INTEGER;
5118 l_amb_context_code VARCHAR2(30);
5119 l_entity_code VARCHAR2(30);
5120 l_event_class_code VARCHAR2(30);
5121 l_ae_header_id NUMBER;
5122 l_event_type_code VARCHAR2(30);
5123 l_line_definition_code VARCHAR2(30);
5124 l_line_definition_owner_code VARCHAR2(1);
5125 --
5126 -- adr variables
5127 l_segment VARCHAR2(30);
5128 l_ccid NUMBER;
5129 l_adr_transaction_coa_id NUMBER;
5130 l_adr_accounting_coa_id NUMBER;
5131 l_adr_flexfield_segment_code VARCHAR2(30);
5132 l_adr_flex_value_set_id NUMBER;
5133 l_adr_value_type_code VARCHAR2(30);
5134 l_adr_value_combination_id NUMBER;
5135 l_adr_value_segment_code VARCHAR2(30);
5136
5137 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
5138 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
5139 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
5140 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
5141
5142 -- 4262811 Variables ------------------------------------------------------------------------------------------
5143 l_entered_amt_idx NUMBER;
5144 l_accted_amt_idx NUMBER;
5145 l_acc_rev_flag VARCHAR2(1);
5146 l_accrual_line_num NUMBER;
5147 l_tmp_amt NUMBER;
5148 l_acc_rev_natural_side_code VARCHAR2(1);
5149
5150 l_num_entries NUMBER;
5151 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
5152 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
5153 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
5154 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
5155 l_recog_line_1 NUMBER;
5156 l_recog_line_2 NUMBER;
5157
5158 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
5159 l_bflow_applied_to_amt NUMBER; -- 5132302
5160 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
5161
5162 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
5163
5164 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
5165 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
5166
5167 ---------------------------------------------------------------------------------------------------------------
5168
5169
5170 --
5171 -- bulk performance
5172 --
5173 l_balance_type_code VARCHAR2(1);
5174 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
5175 l_log_module VARCHAR2(240);
5176
5177 --
5178 -- Upgrade strategy
5179 --
5180 l_actual_upg_option VARCHAR2(1);
5181 l_enc_upg_option VARCHAR2(1);
5182
5183 --
5184 BEGIN
5185 --
5186 IF g_log_enabled THEN
5187 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_24';
5188 END IF;
5189 --
5190 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5191
5192 trace
5193 (p_msg => 'BEGIN of AcctLineType_24'
5194 ,p_level => C_LEVEL_PROCEDURE
5195 ,p_module => l_log_module);
5196
5197 END IF;
5198 --
5199 l_component_type := 'AMB_JLT';
5200 l_component_code := 'CB_REV';
5201 l_component_type_code := 'S';
5202 l_component_appl_id := 222;
5203 l_amb_context_code := 'DEFAULT';
5204 l_entity_code := 'TRANSACTIONS';
5205 l_event_class_code := 'CHARGEBACK';
5206 l_event_type_code := 'CHARGEBACK_ALL';
5207 l_line_definition_owner_code := 'S';
5208 l_line_definition_code := 'AR_CB_DEFAULT_ACCRUAL';
5209 --
5210 l_balance_type_code := 'A';
5211 l_segment := NULL;
5212 l_ccid := NULL;
5213 l_adr_transaction_coa_id := NULL;
5217 l_adr_value_type_code := NULL;
5214 l_adr_accounting_coa_id := NULL;
5215 l_adr_flexfield_segment_code := NULL;
5216 l_adr_flex_value_set_id := NULL;
5218 l_adr_value_combination_id := NULL;
5219 l_adr_value_segment_code := NULL;
5220
5221 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
5222 l_bflow_class_code := ''; -- 4219869 Business Flow
5223 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
5224 l_budgetary_control_flag := 'N';
5225
5226 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5227 l_bflow_applied_to_amt := NULL; -- 5132302
5228 l_entered_amt_idx := NULL; -- 4262811
5229 l_accted_amt_idx := NULL; -- 4262811
5230 l_acc_rev_flag := NULL; -- 4262811
5231 l_accrual_line_num := NULL; -- 4262811
5232 l_tmp_amt := NULL; -- 4262811
5233 --
5234
5235 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
5236 l_balance_type_code <> 'B' THEN
5237 IF NVL(p_source_28,'
5238 ') = 'REV'
5239 THEN
5240
5241 --
5242 XLA_AE_LINES_PKG.SetNewLine;
5243
5244 p_balance_type_code := l_balance_type_code;
5245 -- set the flag so later we will know whether the gain loss line needs to be created
5246
5247 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
5248 p_actual_flag :='A';
5249 END IF;
5250
5251 --
5252 -- bulk performance
5253 --
5254 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
5255 p_header_num => 0); -- 4262811
5256 --
5257 -- set accounting line options
5258 --
5259 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
5260 p_natural_side_code => 'C'
5261 , p_gain_or_loss_flag => 'N'
5262 , p_gl_transfer_mode_code => 'S'
5263 , p_acct_entry_type_code => 'A'
5264 , p_switch_side_flag => 'Y'
5265 , p_merge_duplicate_code => 'A'
5266 );
5267 --
5268 l_acc_rev_natural_side_code := 'D'; -- 4262811
5269 --
5270 --
5271 -- set accounting line type info
5272 --
5273 xla_ae_lines_pkg.SetAcctLineType
5274 (p_component_type => l_component_type
5275 ,p_event_type_code => l_event_type_code
5276 ,p_line_definition_owner_code => l_line_definition_owner_code
5277 ,p_line_definition_code => l_line_definition_code
5278 ,p_accounting_line_code => l_component_code
5279 ,p_accounting_line_type_code => l_component_type_code
5280 ,p_accounting_line_appl_id => l_component_appl_id
5281 ,p_amb_context_code => l_amb_context_code
5282 ,p_entity_code => l_entity_code
5283 ,p_event_class_code => l_event_class_code);
5284 --
5285 -- set accounting class
5286 --
5287 xla_ae_lines_pkg.SetAcctClass(
5288 p_accounting_class_code => 'REVENUE'
5289 , p_ae_header_id => l_ae_header_id
5290 );
5291
5292 --
5293 -- set rounding class
5294 --
5295 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
5296 'RECEIVABLE';
5297
5298 --
5299 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
5300 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
5301 --
5302 -- bulk performance
5303 --
5304 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
5305
5306 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
5307 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
5308
5309 -- 4955764
5310 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5311 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
5312
5313 -- 4458381 Public Sector Enh
5314
5315 --
5316 -- set accounting attributes for the line type
5317 --
5318 l_entered_amt_idx := 3;
5319 l_accted_amt_idx := 8;
5323 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
5320 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5321 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
5322 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
5324 l_rec_acct_attrs.array_char_value(2) := p_source_30;
5325 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
5326 l_rec_acct_attrs.array_num_value(3) := p_source_31;
5327 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
5328 l_rec_acct_attrs.array_char_value(4) := p_source_32;
5329 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
5330 l_rec_acct_attrs.array_date_value(5) := p_source_33;
5331 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
5332 l_rec_acct_attrs.array_num_value(6) := p_source_34;
5333 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
5334 l_rec_acct_attrs.array_char_value(7) := p_source_35;
5335 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
5336 l_rec_acct_attrs.array_num_value(8) := p_source_36;
5337 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
5338 l_rec_acct_attrs.array_num_value(9) := p_source_25;
5339 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
5340 l_rec_acct_attrs.array_num_value(10) := p_source_26;
5341 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
5342 l_rec_acct_attrs.array_char_value(11) := p_source_27;
5343
5344 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
5345 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
5346
5347 ---------------------------------------------------------------------------------------------------------------
5348 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
5349 ---------------------------------------------------------------------------------------------------------------
5350 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
5351
5352 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5353 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5354
5358 AND l_bflow_method_code = 'PRIOR_ENTRY'
5355 IF xla_accounting_cache_pkg.GetValueChar
5356 (p_source_code => 'LEDGER_CATEGORY_CODE'
5357 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
5359 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
5360 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
5361 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
5362 )
5363 THEN
5364 xla_ae_lines_pkg.BflowUpgEntry
5365 (p_business_method_code => l_bflow_method_code
5366 ,p_business_class_code => l_bflow_class_code
5367 ,p_balance_type => l_balance_type_code);
5368 ELSE
5369 NULL;
5370 -- No business flow processing for business flow method of NONE.
5371 END IF;
5372
5373 --
5374 -- call analytical criteria
5375 --
5376
5377 --
5378 -- call description
5379 --
5380 -- No description or it is inherited.
5381 --
5382 -- call ADRs
5383 -- Bug 4922099
5384 --
5385 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5386 (NVL(l_actual_upg_option, 'N') = 'O') OR
5387 (NVL(l_enc_upg_option, 'N') = 'O')
5388 )
5389 THEN
5390 NULL;
5391 --
5392 --
5393
5394 l_ccid := AcctDerRule_18(
5395 p_application_id => p_application_id
5396 , p_ae_header_id => l_ae_header_id
5397 , p_source_14 => p_source_14
5398 , x_transaction_coa_id => l_adr_transaction_coa_id
5399 , x_accounting_coa_id => l_adr_accounting_coa_id
5400 , x_value_type_code => l_adr_value_type_code
5401 , p_side => 'NA'
5402 );
5403
5404 xla_ae_lines_pkg.set_ccid(
5405 p_code_combination_id => l_ccid
5406 , p_value_type_code => l_adr_value_type_code
5407 , p_transaction_coa_id => l_adr_transaction_coa_id
5408 , p_accounting_coa_id => l_adr_accounting_coa_id
5409 , p_adr_code => 'TRX_DIST_CCID'
5410 , p_adr_type_code => 'S'
5411 , p_component_type => l_component_type
5412 , p_component_code => l_component_code
5413 , p_component_type_code => l_component_type_code
5414 , p_component_appl_id => l_component_appl_id
5415 , p_amb_context_code => l_amb_context_code
5416 , p_side => 'NA'
5417 );
5421 --
5418
5419
5420 --
5422 END IF;
5423 --
5424 -- Bug 4922099
5425 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
5426 (NVL(l_enc_upg_option, 'N') = 'O')
5427 ) AND
5428 (l_bflow_method_code = 'PRIOR_ENTRY')
5429 )
5430 THEN
5431 IF
5432 --
5433 1 = 2
5434 --
5435 THEN
5436 xla_accounting_err_pkg.build_message
5437 (p_appli_s_name => 'XLA'
5438 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5439 ,p_token_1 => 'LINE_NUMBER'
5440 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
5441 ,p_token_2 => 'LINE_TYPE_NAME'
5442 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
5443 l_component_type
5444 ,l_component_code
5445 ,l_component_type_code
5446 ,l_component_appl_id
5447 ,l_amb_context_code
5448 ,l_entity_code
5449 ,l_event_class_code
5450 )
5451 ,p_token_3 => 'OWNER'
5452 ,p_value_3 => xla_lookups_pkg.get_meaning(
5453 p_lookup_type => 'XLA_OWNER_TYPE'
5454 ,p_lookup_code => l_component_type_code
5455 )
5456 ,p_token_4 => 'PRODUCT_NAME'
5457 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
5458 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
5459 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
5460 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
5461 ,p_ae_header_id => NULL
5462 );
5463
5464 IF (C_LEVEL_ERROR>= g_log_level) THEN
5465 trace
5466 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5467 ,p_level => C_LEVEL_ERROR
5468 ,p_module => l_log_module);
5469 END IF;
5470 END IF;
5471 END IF;
5472 --
5473 --
5474 ------------------------------------------------------------------------------------------------
5475 -- 4219869 Business Flow
5476 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
5477 -- Prior Entry. Currently, the following code is always generated.
5478 ------------------------------------------------------------------------------------------------
5479 XLA_AE_LINES_PKG.ValidateCurrentLine;
5480
5481 ------------------------------------------------------------------------------------
5482 -- 4219869 Business Flow
5483 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
5484 ------------------------------------------------------------------------------------
5485 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5486
5487 ----------------------------------------------------------------------------------
5488 -- 4219869 Business Flow
5489 -- Update journal entry status -- Need to generate this within IF <condition>
5493 ,p_balance_type_code => l_balance_type_code
5490 ----------------------------------------------------------------------------------
5491 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5492 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
5494 );
5495
5496 -------------------------------------------------------------------------------------------
5497 -- 4262811 - Generate the Accrual Reversal lines
5498 -------------------------------------------------------------------------------------------
5499 BEGIN
5503 l_acc_rev_flag := 'N';
5500 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
5501 (g_array_event(p_event_id).array_value_num('header_index'));
5502 IF l_acc_rev_flag IS NULL THEN
5504 END IF;
5505 EXCEPTION
5506 WHEN OTHERS THEN
5507 l_acc_rev_flag := 'N';
5508 END;
5509 --
5510 IF (l_acc_rev_flag = 'Y') THEN
5511
5512 -- 4645092 ------------------------------------------------------------------------------
5513 -- To allow MPA report to determine if it should generate report process
5514 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
5515 ------------------------------------------------------------------------------------------
5516
5517 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
5518 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
5519 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
5520 -- call ADRs
5521 -- Bug 4922099
5522 --
5523 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5524 (NVL(l_actual_upg_option, 'N') = 'O') OR
5525 (NVL(l_enc_upg_option, 'N') = 'O')
5526 )
5527 THEN
5528 NULL;
5529 --
5530 --
5531
5532 l_ccid := AcctDerRule_18(
5533 p_application_id => p_application_id
5534 , p_ae_header_id => l_ae_header_id
5535 , p_source_14 => p_source_14
5536 , x_transaction_coa_id => l_adr_transaction_coa_id
5537 , x_accounting_coa_id => l_adr_accounting_coa_id
5538 , x_value_type_code => l_adr_value_type_code
5539 , p_side => 'NA'
5540 );
5541
5542 xla_ae_lines_pkg.set_ccid(
5543 p_code_combination_id => l_ccid
5544 , p_value_type_code => l_adr_value_type_code
5545 , p_transaction_coa_id => l_adr_transaction_coa_id
5546 , p_accounting_coa_id => l_adr_accounting_coa_id
5547 , p_adr_code => 'TRX_DIST_CCID'
5548 , p_adr_type_code => 'S'
5549 , p_component_type => l_component_type
5550 , p_component_code => l_component_code
5551 , p_component_type_code => l_component_type_code
5552 , p_component_appl_id => l_component_appl_id
5553 , p_amb_context_code => l_amb_context_code
5554 , p_side => 'NA'
5555 );
5556
5557
5558 --
5559 --
5560 END IF;
5561
5562 --
5563 -- Update the line information that should be overwritten
5564 --
5565 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
5566 p_header_num => 1);
5567 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
5568
5569 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
5570
5571 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
5572 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
5573 END IF;
5574
5575 --
5576 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
5577 --
5578 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
5579 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
5580 ELSE
5581 ---------------------------------------------------------------------------------------------------
5582 -- 4262811a Switch Sign
5583 ---------------------------------------------------------------------------------------------------
5584 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
5585 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5586 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5587 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5588 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5589 -- 5132302
5590 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
5591 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5592
5593 END IF;
5594
5595 -- 4955764
5596 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5597 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
5598
5599
5600 XLA_AE_LINES_PKG.ValidateCurrentLine;
5601 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5602
5603 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5604 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
5605 ,p_balance_type_code => l_balance_type_code);
5606
5607 END IF;
5608
5609 -----------------------------------------------------------------------------------------
5610 -- 4262811 Multiperiod Accounting
5611 -----------------------------------------------------------------------------------------
5612 -- No MPA option is assigned.
5613
5614
5615 END IF;
5616 END IF;
5617 --
5618
5619 --
5620 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5621 trace
5622 (p_msg => 'END of AcctLineType_24'
5623 ,p_level => C_LEVEL_PROCEDURE
5627 EXCEPTION
5624 ,p_module => l_log_module);
5625 END IF;
5626 --
5628 WHEN xla_exceptions_pkg.application_exception THEN
5629 RAISE;
5630 WHEN OTHERS THEN
5631 xla_exceptions_pkg.raise_message
5632 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_24');
5633 END AcctLineType_24;
5634 --
5635
5636 ---------------------------------------
5640 --
5637 --
5638 -- PRIVATE FUNCTION
5639 -- AcctLineType_25
5641 ---------------------------------------
5642 PROCEDURE AcctLineType_25 (
5643 p_application_id IN NUMBER
5644 ,p_event_id IN NUMBER
5645 ,p_calculate_acctd_flag IN VARCHAR2
5646 ,p_calculate_g_l_flag IN VARCHAR2
5647 ,p_actual_flag IN OUT VARCHAR2
5648 ,p_balance_type_code OUT VARCHAR2
5649 ,p_gain_or_loss_ref OUT VARCHAR2
5650
5651 --Distribution GL Account
5652 , p_source_10 IN NUMBER
5653 --Distribution Source Type
5654 , p_source_15 IN VARCHAR2
5655 --Entered Amount
5656 , p_source_19 IN NUMBER
5657 --SLA Party Type
5658 , p_source_27 IN VARCHAR2
5659 --Credit Memo Distribution Identifier
5660 , p_source_37 IN NUMBER
5661 --Credit memo distributions type
5662 , p_source_38 IN VARCHAR2
5663 --Credit Memo Currency Code
5664 , p_source_39 IN VARCHAR2
5665 --Credit Memo Exchange Date
5666 , p_source_40 IN DATE
5667 --Credit Memo Exchange Rate
5668 , p_source_41 IN NUMBER
5669 --Credit Memo Exchange Rate Type
5670 , p_source_42 IN VARCHAR2
5671 --Gain Loss Reference
5672 , p_source_43 IN VARCHAR2
5673 --Credit Memo Accounting Amount
5674 , p_source_44 IN NUMBER
5675 --Credit Memo Bill To Customer Account Identifier
5676 , p_source_45 IN NUMBER
5677 --Credit Memo Bill To Customer Site Use Identifier
5678 , p_source_46 IN NUMBER
5679 --Credit Memo Tax Line Identifier
5680 , p_source_47 IN NUMBER
5681 )
5682 IS
5683
5684 l_component_type VARCHAR2(80);
5685 l_component_code VARCHAR2(30);
5686 l_component_type_code VARCHAR2(1);
5687 l_component_appl_id INTEGER;
5688 l_amb_context_code VARCHAR2(30);
5689 l_entity_code VARCHAR2(30);
5690 l_event_class_code VARCHAR2(30);
5691 l_ae_header_id NUMBER;
5692 l_event_type_code VARCHAR2(30);
5693 l_line_definition_code VARCHAR2(30);
5694 l_line_definition_owner_code VARCHAR2(1);
5695 --
5696 -- adr variables
5697 l_segment VARCHAR2(30);
5698 l_ccid NUMBER;
5699 l_adr_transaction_coa_id NUMBER;
5700 l_adr_accounting_coa_id NUMBER;
5701 l_adr_flexfield_segment_code VARCHAR2(30);
5702 l_adr_flex_value_set_id NUMBER;
5703 l_adr_value_type_code VARCHAR2(30);
5704 l_adr_value_combination_id NUMBER;
5705 l_adr_value_segment_code VARCHAR2(30);
5706
5707 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
5708 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
5709 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
5710 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
5711
5712 -- 4262811 Variables ------------------------------------------------------------------------------------------
5713 l_entered_amt_idx NUMBER;
5714 l_accted_amt_idx NUMBER;
5715 l_acc_rev_flag VARCHAR2(1);
5716 l_accrual_line_num NUMBER;
5717 l_tmp_amt NUMBER;
5718 l_acc_rev_natural_side_code VARCHAR2(1);
5719
5720 l_num_entries NUMBER;
5721 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
5722 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
5723 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
5724 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
5725 l_recog_line_1 NUMBER;
5726 l_recog_line_2 NUMBER;
5727
5728 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
5729 l_bflow_applied_to_amt NUMBER; -- 5132302
5730 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
5731
5732 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
5733
5734 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
5735 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
5736
5740 --
5737 ---------------------------------------------------------------------------------------------------------------
5738
5739
5741 -- bulk performance
5742 --
5743 l_balance_type_code VARCHAR2(1);
5744 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
5745 l_log_module VARCHAR2(240);
5746
5747 --
5748 -- Upgrade strategy
5749 --
5750 l_actual_upg_option VARCHAR2(1);
5751 l_enc_upg_option VARCHAR2(1);
5752
5753 --
5754 BEGIN
5755 --
5756 IF g_log_enabled THEN
5757 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_25';
5758 END IF;
5759 --
5760 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5761
5762 trace
5763 (p_msg => 'BEGIN of AcctLineType_25'
5764 ,p_level => C_LEVEL_PROCEDURE
5765 ,p_module => l_log_module);
5766
5767 END IF;
5768 --
5769 l_component_type := 'AMB_JLT';
5770 l_component_code := 'CM_APP_DEFAULT_REC';
5771 l_component_type_code := 'S';
5772 l_component_appl_id := 222;
5773 l_amb_context_code := 'DEFAULT';
5774 l_entity_code := 'TRANSACTIONS';
5775 l_event_class_code := 'CREDIT_MEMO';
5776 l_event_type_code := 'CREDIT_MEMO_ALL';
5777 l_line_definition_owner_code := 'S';
5778 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
5779 --
5780 l_balance_type_code := 'A';
5781 l_segment := NULL;
5782 l_ccid := NULL;
5783 l_adr_transaction_coa_id := NULL;
5784 l_adr_accounting_coa_id := NULL;
5785 l_adr_flexfield_segment_code := NULL;
5786 l_adr_flex_value_set_id := NULL;
5787 l_adr_value_type_code := NULL;
5788 l_adr_value_combination_id := NULL;
5789 l_adr_value_segment_code := NULL;
5790
5791 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
5792 l_bflow_class_code := ''; -- 4219869 Business Flow
5793 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
5794 l_budgetary_control_flag := 'N';
5795
5796 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5797 l_bflow_applied_to_amt := NULL; -- 5132302
5798 l_entered_amt_idx := NULL; -- 4262811
5799 l_accted_amt_idx := NULL; -- 4262811
5803 --
5800 l_acc_rev_flag := NULL; -- 4262811
5801 l_accrual_line_num := NULL; -- 4262811
5802 l_tmp_amt := NULL; -- 4262811
5804
5805 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
5806 l_balance_type_code <> 'B' THEN
5807 IF NVL(p_source_15,'
5808 ') = 'REC'
5809 THEN
5810
5811 --
5812 XLA_AE_LINES_PKG.SetNewLine;
5813
5814 p_balance_type_code := l_balance_type_code;
5815 -- set the flag so later we will know whether the gain loss line needs to be created
5816
5817 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
5818 p_actual_flag :='A';
5819 END IF;
5820
5821 --
5822 -- bulk performance
5823 --
5824 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
5825 p_header_num => 0); -- 4262811
5826 --
5827 -- set accounting line options
5828 --
5829 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
5830 p_natural_side_code => 'C'
5831 , p_gain_or_loss_flag => 'N'
5832 , p_gl_transfer_mode_code => 'S'
5833 , p_acct_entry_type_code => 'A'
5834 , p_switch_side_flag => 'Y'
5835 , p_merge_duplicate_code => 'A'
5836 );
5837 --
5838 l_acc_rev_natural_side_code := 'D'; -- 4262811
5839 --
5840 --
5841 -- set accounting line type info
5842 --
5843 xla_ae_lines_pkg.SetAcctLineType
5844 (p_component_type => l_component_type
5845 ,p_event_type_code => l_event_type_code
5846 ,p_line_definition_owner_code => l_line_definition_owner_code
5847 ,p_line_definition_code => l_line_definition_code
5848 ,p_accounting_line_code => l_component_code
5849 ,p_accounting_line_type_code => l_component_type_code
5850 ,p_accounting_line_appl_id => l_component_appl_id
5851 ,p_amb_context_code => l_amb_context_code
5852 ,p_entity_code => l_entity_code
5853 ,p_event_class_code => l_event_class_code);
5854 --
5855 -- set accounting class
5856 --
5857 xla_ae_lines_pkg.SetAcctClass(
5858 p_accounting_class_code => 'RECEIVABLE'
5859 , p_ae_header_id => l_ae_header_id
5860 );
5861
5862 --
5863 -- set rounding class
5864 --
5865 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
5866 'RECEIVABLE';
5867
5868 --
5869 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
5870 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
5871 --
5872 -- bulk performance
5873 --
5874 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
5875
5876 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
5877 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
5878
5879 -- 4955764
5880 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5881 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
5882
5883 -- 4458381 Public Sector Enh
5884
5885 --
5886 -- set accounting attributes for the line type
5887 --
5888 l_entered_amt_idx := 3;
5889 l_accted_amt_idx := 9;
5890 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5891 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
5892 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_37);
5893 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
5894 l_rec_acct_attrs.array_char_value(2) := p_source_38;
5895 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
5896 l_rec_acct_attrs.array_num_value(3) := p_source_19;
5897 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
5898 l_rec_acct_attrs.array_char_value(4) := p_source_39;
5899 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
5900 l_rec_acct_attrs.array_date_value(5) := p_source_40;
5901 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
5902 l_rec_acct_attrs.array_num_value(6) := p_source_41;
5903 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
5904 l_rec_acct_attrs.array_char_value(7) := p_source_42;
5905 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
5906 l_rec_acct_attrs.array_char_value(8) := p_source_43;
5907 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
5911 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
5908 l_rec_acct_attrs.array_num_value(9) := p_source_44;
5909 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
5910 l_rec_acct_attrs.array_num_value(10) := p_source_45;
5912 l_rec_acct_attrs.array_num_value(11) := p_source_46;
5913 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
5914 l_rec_acct_attrs.array_char_value(12) := p_source_27;
5915 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
5916 l_rec_acct_attrs.array_num_value(13) := p_source_47;
5917
5918 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
5919 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
5920
5921 ---------------------------------------------------------------------------------------------------------------
5922 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
5923 ---------------------------------------------------------------------------------------------------------------
5924 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
5925
5926 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5927 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5928
5929 IF xla_accounting_cache_pkg.GetValueChar
5930 (p_source_code => 'LEDGER_CATEGORY_CODE'
5931 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
5932 AND l_bflow_method_code = 'PRIOR_ENTRY'
5933 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
5934 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
5935 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
5936 )
5937 THEN
5938 xla_ae_lines_pkg.BflowUpgEntry
5942 ELSE
5939 (p_business_method_code => l_bflow_method_code
5940 ,p_business_class_code => l_bflow_class_code
5941 ,p_balance_type => l_balance_type_code);
5943 NULL;
5944 -- No business flow processing for business flow method of NONE.
5945 END IF;
5946
5947 --
5948 -- call analytical criteria
5949 --
5950
5951 --
5952 -- call description
5953 --
5954 -- No description or it is inherited.
5955 --
5956 -- call ADRs
5957 -- Bug 4922099
5958 --
5959 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5960 (NVL(l_actual_upg_option, 'N') = 'O') OR
5961 (NVL(l_enc_upg_option, 'N') = 'O')
5962 )
5963 THEN
5964 NULL;
5965 --
5966 --
5967
5968 l_ccid := AcctDerRule_11(
5969 p_application_id => p_application_id
5970 , p_ae_header_id => l_ae_header_id
5971 , p_source_10 => p_source_10
5972 , x_transaction_coa_id => l_adr_transaction_coa_id
5973 , x_accounting_coa_id => l_adr_accounting_coa_id
5974 , x_value_type_code => l_adr_value_type_code
5975 , p_side => 'NA'
5976 );
5977
5978 xla_ae_lines_pkg.set_ccid(
5979 p_code_combination_id => l_ccid
5980 , p_value_type_code => l_adr_value_type_code
5981 , p_transaction_coa_id => l_adr_transaction_coa_id
5982 , p_accounting_coa_id => l_adr_accounting_coa_id
5983 , p_adr_code => 'DIST_CCID'
5984 , p_adr_type_code => 'S'
5985 , p_component_type => l_component_type
5986 , p_component_code => l_component_code
5987 , p_component_type_code => l_component_type_code
5988 , p_component_appl_id => l_component_appl_id
5989 , p_amb_context_code => l_amb_context_code
5990 , p_side => 'NA'
5991 );
5992
5993
5994 --
5995 --
5996 END IF;
5997 --
5998 -- Bug 4922099
5999 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
6000 (NVL(l_enc_upg_option, 'N') = 'O')
6001 ) AND
6002 (l_bflow_method_code = 'PRIOR_ENTRY')
6003 )
6004 THEN
6005 IF
6006 --
6007 1 = 2
6008 --
6009 THEN
6010 xla_accounting_err_pkg.build_message
6011 (p_appli_s_name => 'XLA'
6012 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6016 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
6013 ,p_token_1 => 'LINE_NUMBER'
6014 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
6015 ,p_token_2 => 'LINE_TYPE_NAME'
6017 l_component_type
6018 ,l_component_code
6019 ,l_component_type_code
6020 ,l_component_appl_id
6021 ,l_amb_context_code
6022 ,l_entity_code
6023 ,l_event_class_code
6024 )
6025 ,p_token_3 => 'OWNER'
6026 ,p_value_3 => xla_lookups_pkg.get_meaning(
6027 p_lookup_type => 'XLA_OWNER_TYPE'
6028 ,p_lookup_code => l_component_type_code
6029 )
6030 ,p_token_4 => 'PRODUCT_NAME'
6031 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
6032 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
6033 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
6034 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
6035 ,p_ae_header_id => NULL
6036 );
6037
6038 IF (C_LEVEL_ERROR>= g_log_level) THEN
6039 trace
6040 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6041 ,p_level => C_LEVEL_ERROR
6042 ,p_module => l_log_module);
6043 END IF;
6044 END IF;
6045 END IF;
6046 --
6047 --
6048 ------------------------------------------------------------------------------------------------
6049 -- 4219869 Business Flow
6050 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
6051 -- Prior Entry. Currently, the following code is always generated.
6052 ------------------------------------------------------------------------------------------------
6053 XLA_AE_LINES_PKG.ValidateCurrentLine;
6054
6055 ------------------------------------------------------------------------------------
6056 -- 4219869 Business Flow
6057 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
6058 ------------------------------------------------------------------------------------
6059 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6060
6061 ----------------------------------------------------------------------------------
6062 -- 4219869 Business Flow
6063 -- Update journal entry status -- Need to generate this within IF <condition>
6064 ----------------------------------------------------------------------------------
6065 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6066 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
6067 ,p_balance_type_code => l_balance_type_code
6068 );
6069
6070 -------------------------------------------------------------------------------------------
6071 -- 4262811 - Generate the Accrual Reversal lines
6072 -------------------------------------------------------------------------------------------
6073 BEGIN
6077 l_acc_rev_flag := 'N';
6074 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
6075 (g_array_event(p_event_id).array_value_num('header_index'));
6076 IF l_acc_rev_flag IS NULL THEN
6078 END IF;
6079 EXCEPTION
6080 WHEN OTHERS THEN
6081 l_acc_rev_flag := 'N';
6082 END;
6083 --
6087 -- To allow MPA report to determine if it should generate report process
6084 IF (l_acc_rev_flag = 'Y') THEN
6085
6086 -- 4645092 ------------------------------------------------------------------------------
6088 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
6089 ------------------------------------------------------------------------------------------
6090
6091 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
6092 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
6093 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
6094 -- call ADRs
6095 -- Bug 4922099
6096 --
6097 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6098 (NVL(l_actual_upg_option, 'N') = 'O') OR
6099 (NVL(l_enc_upg_option, 'N') = 'O')
6100 )
6101 THEN
6102 NULL;
6103 --
6104 --
6105
6106 l_ccid := AcctDerRule_11(
6107 p_application_id => p_application_id
6108 , p_ae_header_id => l_ae_header_id
6109 , p_source_10 => p_source_10
6110 , x_transaction_coa_id => l_adr_transaction_coa_id
6111 , x_accounting_coa_id => l_adr_accounting_coa_id
6112 , x_value_type_code => l_adr_value_type_code
6113 , p_side => 'NA'
6114 );
6115
6116 xla_ae_lines_pkg.set_ccid(
6117 p_code_combination_id => l_ccid
6118 , p_value_type_code => l_adr_value_type_code
6119 , p_transaction_coa_id => l_adr_transaction_coa_id
6120 , p_accounting_coa_id => l_adr_accounting_coa_id
6121 , p_adr_code => 'DIST_CCID'
6122 , p_adr_type_code => 'S'
6123 , p_component_type => l_component_type
6124 , p_component_code => l_component_code
6125 , p_component_type_code => l_component_type_code
6126 , p_component_appl_id => l_component_appl_id
6127 , p_amb_context_code => l_amb_context_code
6128 , p_side => 'NA'
6129 );
6130
6131
6132 --
6133 --
6134 END IF;
6135
6136 --
6137 -- Update the line information that should be overwritten
6138 --
6139 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
6140 p_header_num => 1);
6141 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
6142
6143 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
6144
6145 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
6146 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
6147 END IF;
6148
6149 --
6150 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
6151 --
6152 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
6153 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
6154 ELSE
6155 ---------------------------------------------------------------------------------------------------
6156 -- 4262811a Switch Sign
6157 ---------------------------------------------------------------------------------------------------
6158 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
6159 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6160 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6161 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6162 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6163 -- 5132302
6164 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
6165 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6166
6167 END IF;
6168
6169 -- 4955764
6170 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6171 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
6172
6173
6174 XLA_AE_LINES_PKG.ValidateCurrentLine;
6175 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6176
6177 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6178 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
6179 ,p_balance_type_code => l_balance_type_code);
6180
6181 END IF;
6182
6183 -----------------------------------------------------------------------------------------
6184 -- 4262811 Multiperiod Accounting
6185 -----------------------------------------------------------------------------------------
6186 -- No MPA option is assigned.
6187
6188
6189 END IF;
6190 END IF;
6191 --
6192
6193 --
6194 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6195 trace
6196 (p_msg => 'END of AcctLineType_25'
6197 ,p_level => C_LEVEL_PROCEDURE
6198 ,p_module => l_log_module);
6199 END IF;
6200 --
6201 EXCEPTION
6202 WHEN xla_exceptions_pkg.application_exception THEN
6203 RAISE;
6204 WHEN OTHERS THEN
6205 xla_exceptions_pkg.raise_message
6206 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_25');
6207 END AcctLineType_25;
6208 --
6209
6213 -- AcctLineType_26
6210 ---------------------------------------
6211 --
6212 -- PRIVATE FUNCTION
6214 --
6215 ---------------------------------------
6216 PROCEDURE AcctLineType_26 (
6217 p_application_id IN NUMBER
6218 ,p_event_id IN NUMBER
6219 ,p_calculate_acctd_flag IN VARCHAR2
6220 ,p_calculate_g_l_flag IN VARCHAR2
6221 ,p_actual_flag IN OUT VARCHAR2
6222 ,p_balance_type_code OUT VARCHAR2
6223 ,p_gain_or_loss_ref OUT VARCHAR2
6224
6225 --Distribution GL Account
6226 , p_source_10 IN NUMBER
6227 --Distribution Source Type
6228 , p_source_15 IN VARCHAR2
6229 --Receivable Activity Type
6230 , p_source_16 IN VARCHAR2
6231 --Entered Amount
6232 , p_source_19 IN NUMBER
6233 --SLA Party Type
6234 , p_source_27 IN VARCHAR2
6235 --Credit Memo Distribution Identifier
6236 , p_source_37 IN NUMBER
6237 --Credit memo distributions type
6238 , p_source_38 IN VARCHAR2
6239 --Credit Memo Currency Code
6240 , p_source_39 IN VARCHAR2
6241 --Credit Memo Exchange Date
6242 , p_source_40 IN DATE
6243 --Credit Memo Exchange Rate
6244 , p_source_41 IN NUMBER
6245 --Credit Memo Exchange Rate Type
6246 , p_source_42 IN VARCHAR2
6247 --Gain Loss Reference
6248 , p_source_43 IN VARCHAR2
6249 --Credit Memo Accounting Amount
6250 , p_source_44 IN NUMBER
6251 --Credit Memo Bill To Customer Account Identifier
6252 , p_source_45 IN NUMBER
6253 --Credit Memo Bill To Customer Site Use Identifier
6254 , p_source_46 IN NUMBER
6258 IS
6255 --Credit Memo Tax Line Identifier
6256 , p_source_47 IN NUMBER
6257 )
6259
6260 l_component_type VARCHAR2(80);
6261 l_component_code VARCHAR2(30);
6262 l_component_type_code VARCHAR2(1);
6263 l_component_appl_id INTEGER;
6264 l_amb_context_code VARCHAR2(30);
6265 l_entity_code VARCHAR2(30);
6266 l_event_class_code VARCHAR2(30);
6267 l_ae_header_id NUMBER;
6268 l_event_type_code VARCHAR2(30);
6269 l_line_definition_code VARCHAR2(30);
6270 l_line_definition_owner_code VARCHAR2(1);
6271 --
6272 -- adr variables
6273 l_segment VARCHAR2(30);
6274 l_ccid NUMBER;
6275 l_adr_transaction_coa_id NUMBER;
6276 l_adr_accounting_coa_id NUMBER;
6277 l_adr_flexfield_segment_code VARCHAR2(30);
6278 l_adr_flex_value_set_id NUMBER;
6279 l_adr_value_type_code VARCHAR2(30);
6280 l_adr_value_combination_id NUMBER;
6281 l_adr_value_segment_code VARCHAR2(30);
6282
6283 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
6284 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
6285 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
6286 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
6287
6288 -- 4262811 Variables ------------------------------------------------------------------------------------------
6289 l_entered_amt_idx NUMBER;
6290 l_accted_amt_idx NUMBER;
6291 l_acc_rev_flag VARCHAR2(1);
6292 l_accrual_line_num NUMBER;
6293 l_tmp_amt NUMBER;
6294 l_acc_rev_natural_side_code VARCHAR2(1);
6295
6296 l_num_entries NUMBER;
6297 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
6298 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
6299 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
6300 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
6301 l_recog_line_1 NUMBER;
6302 l_recog_line_2 NUMBER;
6303
6304 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
6305 l_bflow_applied_to_amt NUMBER; -- 5132302
6306 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
6307
6308 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
6309
6310 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
6311 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
6312
6313 ---------------------------------------------------------------------------------------------------------------
6314
6315
6316 --
6317 -- bulk performance
6318 --
6319 l_balance_type_code VARCHAR2(1);
6320 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
6321 l_log_module VARCHAR2(240);
6322
6323 --
6324 -- Upgrade strategy
6325 --
6326 l_actual_upg_option VARCHAR2(1);
6327 l_enc_upg_option VARCHAR2(1);
6328
6329 --
6330 BEGIN
6331 --
6332 IF g_log_enabled THEN
6333 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_26';
6334 END IF;
6335 --
6336 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6337
6338 trace
6339 (p_msg => 'BEGIN of AcctLineType_26'
6340 ,p_level => C_LEVEL_PROCEDURE
6341 ,p_module => l_log_module);
6342
6343 END IF;
6344 --
6345 l_component_type := 'AMB_JLT';
6346 l_component_code := 'CM_APP_REFUND';
6347 l_component_type_code := 'S';
6348 l_component_appl_id := 222;
6349 l_amb_context_code := 'DEFAULT';
6350 l_entity_code := 'TRANSACTIONS';
6351 l_event_class_code := 'CREDIT_MEMO';
6352 l_event_type_code := 'CREDIT_MEMO_ALL';
6353 l_line_definition_owner_code := 'S';
6354 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
6355 --
6356 l_balance_type_code := 'A';
6357 l_segment := NULL;
6358 l_ccid := NULL;
6359 l_adr_transaction_coa_id := NULL;
6360 l_adr_accounting_coa_id := NULL;
6361 l_adr_flexfield_segment_code := NULL;
6362 l_adr_flex_value_set_id := NULL;
6363 l_adr_value_type_code := NULL;
6364 l_adr_value_combination_id := NULL;
6365 l_adr_value_segment_code := NULL;
6366
6367 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
6368 l_bflow_class_code := ''; -- 4219869 Business Flow
6369 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
6370 l_budgetary_control_flag := 'N';
6371
6372 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6373 l_bflow_applied_to_amt := NULL; -- 5132302
6374 l_entered_amt_idx := NULL; -- 4262811
6375 l_accted_amt_idx := NULL; -- 4262811
6376 l_acc_rev_flag := NULL; -- 4262811
6377 l_accrual_line_num := NULL; -- 4262811
6378 l_tmp_amt := NULL; -- 4262811
6379 --
6380
6381 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
6382 l_balance_type_code <> 'B' THEN
6383 IF (NVL(p_source_15,'
6384 ') = 'ACTIVITY' AND
6385 NVL(p_source_16,'
6386 ') = 'REFUND') OR
6387 (NVL(p_source_15,'
6391 THEN
6388 ') = 'ACTIVITY' AND
6389 NVL(p_source_16,'
6390 ') = 'CM_REFUND')
6392
6393 --
6394 XLA_AE_LINES_PKG.SetNewLine;
6395
6396 p_balance_type_code := l_balance_type_code;
6397 -- set the flag so later we will know whether the gain loss line needs to be created
6398
6399 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
6400 p_actual_flag :='A';
6401 END IF;
6402
6403 --
6404 -- bulk performance
6405 --
6406 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
6407 p_header_num => 0); -- 4262811
6408 --
6409 -- set accounting line options
6410 --
6411 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
6412 p_natural_side_code => 'C'
6413 , p_gain_or_loss_flag => 'N'
6414 , p_gl_transfer_mode_code => 'S'
6415 , p_acct_entry_type_code => 'A'
6416 , p_switch_side_flag => 'Y'
6417 , p_merge_duplicate_code => 'A'
6418 );
6419 --
6420 l_acc_rev_natural_side_code := 'D'; -- 4262811
6421 --
6422 --
6423 -- set accounting line type info
6424 --
6425 xla_ae_lines_pkg.SetAcctLineType
6426 (p_component_type => l_component_type
6427 ,p_event_type_code => l_event_type_code
6428 ,p_line_definition_owner_code => l_line_definition_owner_code
6429 ,p_line_definition_code => l_line_definition_code
6430 ,p_accounting_line_code => l_component_code
6431 ,p_accounting_line_type_code => l_component_type_code
6432 ,p_accounting_line_appl_id => l_component_appl_id
6433 ,p_amb_context_code => l_amb_context_code
6434 ,p_entity_code => l_entity_code
6435 ,p_event_class_code => l_event_class_code);
6436 --
6437 -- set accounting class
6438 --
6439 xla_ae_lines_pkg.SetAcctClass(
6440 p_accounting_class_code => 'REFUND'
6441 , p_ae_header_id => l_ae_header_id
6442 );
6443
6444 --
6445 -- set rounding class
6446 --
6447 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
6448 'REFUND';
6449
6450 --
6451 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
6452 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
6453 --
6454 -- bulk performance
6455 --
6456 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
6457
6458 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
6459 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
6460
6461 -- 4955764
6462 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6463 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
6464
6465 -- 4458381 Public Sector Enh
6466
6467 --
6468 -- set accounting attributes for the line type
6469 --
6470 l_entered_amt_idx := 3;
6471 l_accted_amt_idx := 9;
6472 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6473 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
6474 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_37);
6475 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
6476 l_rec_acct_attrs.array_char_value(2) := p_source_38;
6477 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
6478 l_rec_acct_attrs.array_num_value(3) := p_source_19;
6479 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
6480 l_rec_acct_attrs.array_char_value(4) := p_source_39;
6481 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
6482 l_rec_acct_attrs.array_date_value(5) := p_source_40;
6483 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
6484 l_rec_acct_attrs.array_num_value(6) := p_source_41;
6485 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
6486 l_rec_acct_attrs.array_char_value(7) := p_source_42;
6487 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
6488 l_rec_acct_attrs.array_char_value(8) := p_source_43;
6489 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
6490 l_rec_acct_attrs.array_num_value(9) := p_source_44;
6491 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
6492 l_rec_acct_attrs.array_num_value(10) := p_source_45;
6493 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
6494 l_rec_acct_attrs.array_num_value(11) := p_source_46;
6495 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
6496 l_rec_acct_attrs.array_char_value(12) := p_source_27;
6497 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
6498 l_rec_acct_attrs.array_num_value(13) := p_source_47;
6499
6500 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
6501 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
6502
6503 ---------------------------------------------------------------------------------------------------------------
6504 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
6505 ---------------------------------------------------------------------------------------------------------------
6506 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
6507
6508 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6512 (p_source_code => 'LEDGER_CATEGORY_CODE'
6509 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6510
6511 IF xla_accounting_cache_pkg.GetValueChar
6513 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
6514 AND l_bflow_method_code = 'PRIOR_ENTRY'
6515 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
6516 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
6517 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
6518 )
6519 THEN
6520 xla_ae_lines_pkg.BflowUpgEntry
6521 (p_business_method_code => l_bflow_method_code
6522 ,p_business_class_code => l_bflow_class_code
6523 ,p_balance_type => l_balance_type_code);
6524 ELSE
6525 NULL;
6526 -- No business flow processing for business flow method of NONE.
6527 END IF;
6528
6529 --
6530 -- call analytical criteria
6531 --
6532
6533 --
6534 -- call description
6535 --
6536 -- No description or it is inherited.
6537 --
6538 -- call ADRs
6539 -- Bug 4922099
6540 --
6541 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6542 (NVL(l_actual_upg_option, 'N') = 'O') OR
6543 (NVL(l_enc_upg_option, 'N') = 'O')
6544 )
6545 THEN
6546 NULL;
6547 --
6548 --
6549
6550 l_ccid := AcctDerRule_11(
6551 p_application_id => p_application_id
6552 , p_ae_header_id => l_ae_header_id
6553 , p_source_10 => p_source_10
6554 , x_transaction_coa_id => l_adr_transaction_coa_id
6555 , x_accounting_coa_id => l_adr_accounting_coa_id
6556 , x_value_type_code => l_adr_value_type_code
6557 , p_side => 'NA'
6558 );
6559
6560 xla_ae_lines_pkg.set_ccid(
6561 p_code_combination_id => l_ccid
6562 , p_value_type_code => l_adr_value_type_code
6563 , p_transaction_coa_id => l_adr_transaction_coa_id
6564 , p_accounting_coa_id => l_adr_accounting_coa_id
6565 , p_adr_code => 'DIST_CCID'
6566 , p_adr_type_code => 'S'
6567 , p_component_type => l_component_type
6568 , p_component_code => l_component_code
6569 , p_component_type_code => l_component_type_code
6570 , p_component_appl_id => l_component_appl_id
6571 , p_amb_context_code => l_amb_context_code
6572 , p_side => 'NA'
6573 );
6574
6575
6576 --
6577 --
6578 END IF;
6579 --
6580 -- Bug 4922099
6581 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
6582 (NVL(l_enc_upg_option, 'N') = 'O')
6583 ) AND
6584 (l_bflow_method_code = 'PRIOR_ENTRY')
6585 )
6586 THEN
6587 IF
6588 --
6589 1 = 2
6590 --
6591 THEN
6592 xla_accounting_err_pkg.build_message
6593 (p_appli_s_name => 'XLA'
6594 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6595 ,p_token_1 => 'LINE_NUMBER'
6596 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
6597 ,p_token_2 => 'LINE_TYPE_NAME'
6598 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
6599 l_component_type
6600 ,l_component_code
6601 ,l_component_type_code
6602 ,l_component_appl_id
6603 ,l_amb_context_code
6604 ,l_entity_code
6605 ,l_event_class_code
6606 )
6607 ,p_token_3 => 'OWNER'
6608 ,p_value_3 => xla_lookups_pkg.get_meaning(
6609 p_lookup_type => 'XLA_OWNER_TYPE'
6610 ,p_lookup_code => l_component_type_code
6611 )
6612 ,p_token_4 => 'PRODUCT_NAME'
6613 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
6614 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
6615 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
6616 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
6617 ,p_ae_header_id => NULL
6618 );
6619
6620 IF (C_LEVEL_ERROR>= g_log_level) THEN
6621 trace
6622 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6623 ,p_level => C_LEVEL_ERROR
6624 ,p_module => l_log_module);
6625 END IF;
6626 END IF;
6630 ------------------------------------------------------------------------------------------------
6627 END IF;
6628 --
6629 --
6631 -- 4219869 Business Flow
6632 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
6633 -- Prior Entry. Currently, the following code is always generated.
6634 ------------------------------------------------------------------------------------------------
6635 XLA_AE_LINES_PKG.ValidateCurrentLine;
6636
6637 ------------------------------------------------------------------------------------
6638 -- 4219869 Business Flow
6639 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
6640 ------------------------------------------------------------------------------------
6641 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6642
6643 ----------------------------------------------------------------------------------
6644 -- 4219869 Business Flow
6645 -- Update journal entry status -- Need to generate this within IF <condition>
6646 ----------------------------------------------------------------------------------
6647 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6648 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
6649 ,p_balance_type_code => l_balance_type_code
6650 );
6651
6652 -------------------------------------------------------------------------------------------
6653 -- 4262811 - Generate the Accrual Reversal lines
6654 -------------------------------------------------------------------------------------------
6655 BEGIN
6656 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
6657 (g_array_event(p_event_id).array_value_num('header_index'));
6658 IF l_acc_rev_flag IS NULL THEN
6659 l_acc_rev_flag := 'N';
6660 END IF;
6661 EXCEPTION
6662 WHEN OTHERS THEN
6663 l_acc_rev_flag := 'N';
6664 END;
6665 --
6666 IF (l_acc_rev_flag = 'Y') THEN
6667
6668 -- 4645092 ------------------------------------------------------------------------------
6669 -- To allow MPA report to determine if it should generate report process
6670 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
6671 ------------------------------------------------------------------------------------------
6672
6673 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
6674 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
6675 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
6676 -- call ADRs
6677 -- Bug 4922099
6678 --
6679 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6680 (NVL(l_actual_upg_option, 'N') = 'O') OR
6681 (NVL(l_enc_upg_option, 'N') = 'O')
6682 )
6683 THEN
6684 NULL;
6685 --
6686 --
6687
6688 l_ccid := AcctDerRule_11(
6689 p_application_id => p_application_id
6690 , p_ae_header_id => l_ae_header_id
6691 , p_source_10 => p_source_10
6692 , x_transaction_coa_id => l_adr_transaction_coa_id
6693 , x_accounting_coa_id => l_adr_accounting_coa_id
6694 , x_value_type_code => l_adr_value_type_code
6695 , p_side => 'NA'
6696 );
6697
6698 xla_ae_lines_pkg.set_ccid(
6699 p_code_combination_id => l_ccid
6700 , p_value_type_code => l_adr_value_type_code
6701 , p_transaction_coa_id => l_adr_transaction_coa_id
6702 , p_accounting_coa_id => l_adr_accounting_coa_id
6703 , p_adr_code => 'DIST_CCID'
6704 , p_adr_type_code => 'S'
6705 , p_component_type => l_component_type
6706 , p_component_code => l_component_code
6707 , p_component_type_code => l_component_type_code
6708 , p_component_appl_id => l_component_appl_id
6709 , p_amb_context_code => l_amb_context_code
6710 , p_side => 'NA'
6711 );
6712
6713
6714 --
6715 --
6716 END IF;
6717
6718 --
6719 -- Update the line information that should be overwritten
6720 --
6721 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
6722 p_header_num => 1);
6723 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
6724
6725 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
6726
6727 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
6728 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
6729 END IF;
6730
6731 --
6732 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
6733 --
6734 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
6735 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
6736 ELSE
6737 ---------------------------------------------------------------------------------------------------
6738 -- 4262811a Switch Sign
6739 ---------------------------------------------------------------------------------------------------
6740 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
6741 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6742 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6746 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
6743 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6744 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6745 -- 5132302
6747 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6748
6749 END IF;
6750
6751 -- 4955764
6752 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6753 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
6754
6755
6756 XLA_AE_LINES_PKG.ValidateCurrentLine;
6757 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6758
6759 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6760 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
6761 ,p_balance_type_code => l_balance_type_code);
6762
6763 END IF;
6764
6765 -----------------------------------------------------------------------------------------
6766 -- 4262811 Multiperiod Accounting
6767 -----------------------------------------------------------------------------------------
6768 -- No MPA option is assigned.
6769
6770
6771 END IF;
6772 END IF;
6773 --
6774
6775 --
6776 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6777 trace
6778 (p_msg => 'END of AcctLineType_26'
6779 ,p_level => C_LEVEL_PROCEDURE
6780 ,p_module => l_log_module);
6781 END IF;
6782 --
6783 EXCEPTION
6784 WHEN xla_exceptions_pkg.application_exception THEN
6785 RAISE;
6786 WHEN OTHERS THEN
6787 xla_exceptions_pkg.raise_message
6788 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_26');
6789 END AcctLineType_26;
6790 --
6791
6792 ---------------------------------------
6793 --
6794 -- PRIVATE FUNCTION
6795 -- AcctLineType_27
6796 --
6797 ---------------------------------------
6798 PROCEDURE AcctLineType_27 (
6799 p_application_id IN NUMBER
6800 ,p_event_id IN NUMBER
6801 ,p_calculate_acctd_flag IN VARCHAR2
6802 ,p_calculate_g_l_flag IN VARCHAR2
6803 ,p_actual_flag IN OUT VARCHAR2
6804 ,p_balance_type_code OUT VARCHAR2
6805 ,p_gain_or_loss_ref OUT VARCHAR2
6806
6807 --Credit Memo Distribution GL Account
6808 , p_source_9 IN NUMBER
6809 --SLA Party Type
6810 , p_source_27 IN VARCHAR2
6811 --Credit Memo Distribution Identifier
6812 , p_source_37 IN NUMBER
6813 --Credit memo distributions type
6814 , p_source_38 IN VARCHAR2
6815 --Credit Memo Currency Code
6816 , p_source_39 IN VARCHAR2
6817 --Credit Memo Exchange Date
6818 , p_source_40 IN DATE
6819 --Credit Memo Exchange Rate
6820 , p_source_41 IN NUMBER
6821 --Credit Memo Exchange Rate Type
6822 , p_source_42 IN VARCHAR2
6823 --Gain Loss Reference
6824 , p_source_43 IN VARCHAR2
6825 --Credit Memo Accounting Amount
6826 , p_source_44 IN NUMBER
6827 --Credit Memo Bill To Customer Account Identifier
6828 , p_source_45 IN NUMBER
6829 --Credit Memo Bill To Customer Site Use Identifier
6830 , p_source_46 IN NUMBER
6831 --Credit Memo Tax Line Identifier
6832 , p_source_47 IN NUMBER
6833 --Credit Memo Distribution Account Class
6834 , p_source_48 IN VARCHAR2
6835 --Credit Memo Distribution Entered Amount
6836 , p_source_49 IN NUMBER
6837 )
6838 IS
6839
6840 l_component_type VARCHAR2(80);
6841 l_component_code VARCHAR2(30);
6842 l_component_type_code VARCHAR2(1);
6843 l_component_appl_id INTEGER;
6844 l_amb_context_code VARCHAR2(30);
6845 l_entity_code VARCHAR2(30);
6846 l_event_class_code VARCHAR2(30);
6847 l_ae_header_id NUMBER;
6848 l_event_type_code VARCHAR2(30);
6849 l_line_definition_code VARCHAR2(30);
6850 l_line_definition_owner_code VARCHAR2(1);
6851 --
6852 -- adr variables
6853 l_segment VARCHAR2(30);
6854 l_ccid NUMBER;
6855 l_adr_transaction_coa_id NUMBER;
6856 l_adr_accounting_coa_id NUMBER;
6857 l_adr_flexfield_segment_code VARCHAR2(30);
6858 l_adr_flex_value_set_id NUMBER;
6859 l_adr_value_type_code VARCHAR2(30);
6860 l_adr_value_combination_id NUMBER;
6861 l_adr_value_segment_code VARCHAR2(30);
6862
6863 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
6864 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
6865 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
6866 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
6867
6868 -- 4262811 Variables ------------------------------------------------------------------------------------------
6869 l_entered_amt_idx NUMBER;
6870 l_accted_amt_idx NUMBER;
6871 l_acc_rev_flag VARCHAR2(1);
6872 l_accrual_line_num NUMBER;
6873 l_tmp_amt NUMBER;
6874 l_acc_rev_natural_side_code VARCHAR2(1);
6875
6876 l_num_entries NUMBER;
6877 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
6881 l_recog_line_1 NUMBER;
6878 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
6879 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
6880 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
6882 l_recog_line_2 NUMBER;
6883
6884 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
6885 l_bflow_applied_to_amt NUMBER; -- 5132302
6886 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
6887
6888 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
6889
6890 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
6891 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
6892
6893 ---------------------------------------------------------------------------------------------------------------
6894
6895
6896 --
6897 -- bulk performance
6898 --
6899 l_balance_type_code VARCHAR2(1);
6900 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
6901 l_log_module VARCHAR2(240);
6902
6903 --
6904 -- Upgrade strategy
6905 --
6906 l_actual_upg_option VARCHAR2(1);
6907 l_enc_upg_option VARCHAR2(1);
6908
6909 --
6910 BEGIN
6911 --
6912 IF g_log_enabled THEN
6913 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_27';
6914 END IF;
6915 --
6916 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6917
6918 trace
6919 (p_msg => 'BEGIN of AcctLineType_27'
6920 ,p_level => C_LEVEL_PROCEDURE
6921 ,p_module => l_log_module);
6922
6923 END IF;
6924 --
6925 l_component_type := 'AMB_JLT';
6926 l_component_code := 'CM_CHARGES';
6927 l_component_type_code := 'S';
6928 l_component_appl_id := 222;
6929 l_amb_context_code := 'DEFAULT';
6930 l_entity_code := 'TRANSACTIONS';
6931 l_event_class_code := 'CREDIT_MEMO';
6932 l_event_type_code := 'CREDIT_MEMO_ALL';
6933 l_line_definition_owner_code := 'S';
6934 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
6935 --
6936 l_balance_type_code := 'A';
6937 l_segment := NULL;
6938 l_ccid := NULL;
6939 l_adr_transaction_coa_id := NULL;
6940 l_adr_accounting_coa_id := NULL;
6941 l_adr_flexfield_segment_code := NULL;
6942 l_adr_flex_value_set_id := NULL;
6943 l_adr_value_type_code := NULL;
6944 l_adr_value_combination_id := NULL;
6945 l_adr_value_segment_code := NULL;
6946
6947 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
6948 l_bflow_class_code := ''; -- 4219869 Business Flow
6949 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
6950 l_budgetary_control_flag := 'N';
6951
6952 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6953 l_bflow_applied_to_amt := NULL; -- 5132302
6954 l_entered_amt_idx := NULL; -- 4262811
6955 l_accted_amt_idx := NULL; -- 4262811
6956 l_acc_rev_flag := NULL; -- 4262811
6957 l_accrual_line_num := NULL; -- 4262811
6958 l_tmp_amt := NULL; -- 4262811
6959 --
6960
6961 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
6962 l_balance_type_code <> 'B' THEN
6963 IF NVL(p_source_48,'
6964 ') = 'CHARGES'
6965 THEN
6966
6967 --
6968 XLA_AE_LINES_PKG.SetNewLine;
6969
6970 p_balance_type_code := l_balance_type_code;
6971 -- set the flag so later we will know whether the gain loss line needs to be created
6972
6973 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
6974 p_actual_flag :='A';
6975 END IF;
6976
6977 --
6978 -- bulk performance
6979 --
6980 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
6981 p_header_num => 0); -- 4262811
6982 --
6983 -- set accounting line options
6984 --
6985 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
6986 p_natural_side_code => 'C'
6987 , p_gain_or_loss_flag => 'N'
6988 , p_gl_transfer_mode_code => 'S'
6989 , p_acct_entry_type_code => 'A'
6990 , p_switch_side_flag => 'Y'
6991 , p_merge_duplicate_code => 'A'
6992 );
6993 --
6994 l_acc_rev_natural_side_code := 'D'; -- 4262811
6995 --
6996 --
6997 -- set accounting line type info
6998 --
6999 xla_ae_lines_pkg.SetAcctLineType
7000 (p_component_type => l_component_type
7001 ,p_event_type_code => l_event_type_code
7002 ,p_line_definition_owner_code => l_line_definition_owner_code
7003 ,p_line_definition_code => l_line_definition_code
7004 ,p_accounting_line_code => l_component_code
7005 ,p_accounting_line_type_code => l_component_type_code
7006 ,p_accounting_line_appl_id => l_component_appl_id
7007 ,p_amb_context_code => l_amb_context_code
7008 ,p_entity_code => l_entity_code
7009 ,p_event_class_code => l_event_class_code);
7010 --
7011 -- set accounting class
7012 --
7013 xla_ae_lines_pkg.SetAcctClass(
7017
7014 p_accounting_class_code => 'CHARGES'
7015 , p_ae_header_id => l_ae_header_id
7016 );
7018 --
7019 -- set rounding class
7020 --
7021 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
7022 'RECEIVABLE';
7023
7024 --
7025 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
7026 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
7027 --
7028 -- bulk performance
7029 --
7030 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
7031
7032 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
7033 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
7034
7035 -- 4955764
7036 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7037 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
7038
7039 -- 4458381 Public Sector Enh
7040
7041 --
7042 -- set accounting attributes for the line type
7043 --
7044 l_entered_amt_idx := 3;
7045 l_accted_amt_idx := 9;
7046 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7047 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
7048 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_37);
7049 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
7050 l_rec_acct_attrs.array_char_value(2) := p_source_38;
7051 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
7052 l_rec_acct_attrs.array_num_value(3) := p_source_49;
7053 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
7054 l_rec_acct_attrs.array_char_value(4) := p_source_39;
7055 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
7056 l_rec_acct_attrs.array_date_value(5) := p_source_40;
7057 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
7058 l_rec_acct_attrs.array_num_value(6) := p_source_41;
7059 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
7060 l_rec_acct_attrs.array_char_value(7) := p_source_42;
7061 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
7062 l_rec_acct_attrs.array_char_value(8) := p_source_43;
7063 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
7064 l_rec_acct_attrs.array_num_value(9) := p_source_44;
7065 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
7066 l_rec_acct_attrs.array_num_value(10) := p_source_45;
7067 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
7068 l_rec_acct_attrs.array_num_value(11) := p_source_46;
7069 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
7070 l_rec_acct_attrs.array_char_value(12) := p_source_27;
7071 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
7072 l_rec_acct_attrs.array_num_value(13) := p_source_47;
7073
7074 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
7075 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
7076
7077 ---------------------------------------------------------------------------------------------------------------
7078 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
7079 ---------------------------------------------------------------------------------------------------------------
7080 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
7081
7082 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7083 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7084
7085 IF xla_accounting_cache_pkg.GetValueChar
7086 (p_source_code => 'LEDGER_CATEGORY_CODE'
7087 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
7088 AND l_bflow_method_code = 'PRIOR_ENTRY'
7089 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
7090 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
7091 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
7092 )
7093 THEN
7094 xla_ae_lines_pkg.BflowUpgEntry
7095 (p_business_method_code => l_bflow_method_code
7096 ,p_business_class_code => l_bflow_class_code
7097 ,p_balance_type => l_balance_type_code);
7098 ELSE
7099 NULL;
7100 -- No business flow processing for business flow method of NONE.
7101 END IF;
7102
7103 --
7104 -- call analytical criteria
7105 --
7106
7107 --
7108 -- call description
7109 --
7110 -- No description or it is inherited.
7111 --
7112 -- call ADRs
7113 -- Bug 4922099
7114 --
7115 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7116 (NVL(l_actual_upg_option, 'N') = 'O') OR
7117 (NVL(l_enc_upg_option, 'N') = 'O')
7118 )
7119 THEN
7120 NULL;
7121 --
7122 --
7123
7124 l_ccid := AcctDerRule_10(
7125 p_application_id => p_application_id
7126 , p_ae_header_id => l_ae_header_id
7127 , p_source_9 => p_source_9
7128 , x_transaction_coa_id => l_adr_transaction_coa_id
7129 , x_accounting_coa_id => l_adr_accounting_coa_id
7133
7130 , x_value_type_code => l_adr_value_type_code
7131 , p_side => 'NA'
7132 );
7134 xla_ae_lines_pkg.set_ccid(
7135 p_code_combination_id => l_ccid
7136 , p_value_type_code => l_adr_value_type_code
7137 , p_transaction_coa_id => l_adr_transaction_coa_id
7138 , p_accounting_coa_id => l_adr_accounting_coa_id
7139 , p_adr_code => 'CM_DIST_CCID'
7140 , p_adr_type_code => 'S'
7141 , p_component_type => l_component_type
7142 , p_component_code => l_component_code
7143 , p_component_type_code => l_component_type_code
7144 , p_component_appl_id => l_component_appl_id
7145 , p_amb_context_code => l_amb_context_code
7146 , p_side => 'NA'
7147 );
7148
7149
7150 --
7151 --
7152 END IF;
7153 --
7154 -- Bug 4922099
7155 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
7156 (NVL(l_enc_upg_option, 'N') = 'O')
7157 ) AND
7158 (l_bflow_method_code = 'PRIOR_ENTRY')
7159 )
7160 THEN
7161 IF
7162 --
7163 1 = 2
7164 --
7165 THEN
7166 xla_accounting_err_pkg.build_message
7167 (p_appli_s_name => 'XLA'
7168 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7169 ,p_token_1 => 'LINE_NUMBER'
7170 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
7171 ,p_token_2 => 'LINE_TYPE_NAME'
7172 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
7173 l_component_type
7174 ,l_component_code
7175 ,l_component_type_code
7176 ,l_component_appl_id
7177 ,l_amb_context_code
7178 ,l_entity_code
7179 ,l_event_class_code
7180 )
7181 ,p_token_3 => 'OWNER'
7182 ,p_value_3 => xla_lookups_pkg.get_meaning(
7183 p_lookup_type => 'XLA_OWNER_TYPE'
7184 ,p_lookup_code => l_component_type_code
7185 )
7186 ,p_token_4 => 'PRODUCT_NAME'
7187 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
7188 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
7189 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
7190 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
7191 ,p_ae_header_id => NULL
7192 );
7193
7194 IF (C_LEVEL_ERROR>= g_log_level) THEN
7195 trace
7196 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7197 ,p_level => C_LEVEL_ERROR
7198 ,p_module => l_log_module);
7199 END IF;
7200 END IF;
7201 END IF;
7202 --
7203 --
7204 ------------------------------------------------------------------------------------------------
7205 -- 4219869 Business Flow
7206 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
7207 -- Prior Entry. Currently, the following code is always generated.
7208 ------------------------------------------------------------------------------------------------
7209 XLA_AE_LINES_PKG.ValidateCurrentLine;
7210
7211 ------------------------------------------------------------------------------------
7212 -- 4219869 Business Flow
7213 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
7214 ------------------------------------------------------------------------------------
7215 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7216
7217 ----------------------------------------------------------------------------------
7218 -- 4219869 Business Flow
7219 -- Update journal entry status -- Need to generate this within IF <condition>
7220 ----------------------------------------------------------------------------------
7221 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7222 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
7223 ,p_balance_type_code => l_balance_type_code
7224 );
7225
7226 -------------------------------------------------------------------------------------------
7227 -- 4262811 - Generate the Accrual Reversal lines
7228 -------------------------------------------------------------------------------------------
7229 BEGIN
7230 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
7234 END IF;
7231 (g_array_event(p_event_id).array_value_num('header_index'));
7232 IF l_acc_rev_flag IS NULL THEN
7233 l_acc_rev_flag := 'N';
7235 EXCEPTION
7236 WHEN OTHERS THEN
7237 l_acc_rev_flag := 'N';
7238 END;
7239 --
7240 IF (l_acc_rev_flag = 'Y') THEN
7241
7242 -- 4645092 ------------------------------------------------------------------------------
7243 -- To allow MPA report to determine if it should generate report process
7244 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
7245 ------------------------------------------------------------------------------------------
7246
7247 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
7248 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
7249 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
7250 -- call ADRs
7251 -- Bug 4922099
7252 --
7253 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7254 (NVL(l_actual_upg_option, 'N') = 'O') OR
7255 (NVL(l_enc_upg_option, 'N') = 'O')
7256 )
7257 THEN
7258 NULL;
7259 --
7260 --
7261
7262 l_ccid := AcctDerRule_10(
7263 p_application_id => p_application_id
7264 , p_ae_header_id => l_ae_header_id
7265 , p_source_9 => p_source_9
7266 , x_transaction_coa_id => l_adr_transaction_coa_id
7267 , x_accounting_coa_id => l_adr_accounting_coa_id
7268 , x_value_type_code => l_adr_value_type_code
7269 , p_side => 'NA'
7270 );
7271
7272 xla_ae_lines_pkg.set_ccid(
7273 p_code_combination_id => l_ccid
7274 , p_value_type_code => l_adr_value_type_code
7275 , p_transaction_coa_id => l_adr_transaction_coa_id
7276 , p_accounting_coa_id => l_adr_accounting_coa_id
7277 , p_adr_code => 'CM_DIST_CCID'
7278 , p_adr_type_code => 'S'
7279 , p_component_type => l_component_type
7280 , p_component_code => l_component_code
7281 , p_component_type_code => l_component_type_code
7282 , p_component_appl_id => l_component_appl_id
7283 , p_amb_context_code => l_amb_context_code
7284 , p_side => 'NA'
7285 );
7286
7287
7288 --
7289 --
7290 END IF;
7291
7292 --
7293 -- Update the line information that should be overwritten
7294 --
7295 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
7296 p_header_num => 1);
7297 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
7298
7299 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
7300
7301 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
7302 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
7303 END IF;
7304
7305 --
7306 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
7307 --
7308 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
7309 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
7310 ELSE
7311 ---------------------------------------------------------------------------------------------------
7312 -- 4262811a Switch Sign
7313 ---------------------------------------------------------------------------------------------------
7314 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
7315 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7316 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7317 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7318 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7319 -- 5132302
7320 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
7321 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7322
7323 END IF;
7324
7325 -- 4955764
7326 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7327 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
7328
7329
7330 XLA_AE_LINES_PKG.ValidateCurrentLine;
7331 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7332
7333 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7334 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
7335 ,p_balance_type_code => l_balance_type_code);
7336
7337 END IF;
7338
7339 -----------------------------------------------------------------------------------------
7340 -- 4262811 Multiperiod Accounting
7341 -----------------------------------------------------------------------------------------
7342 -- No MPA option is assigned.
7343
7344
7345 END IF;
7346 END IF;
7347 --
7348
7349 --
7350 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7351 trace
7352 (p_msg => 'END of AcctLineType_27'
7353 ,p_level => C_LEVEL_PROCEDURE
7357 EXCEPTION
7354 ,p_module => l_log_module);
7355 END IF;
7356 --
7358 WHEN xla_exceptions_pkg.application_exception THEN
7359 RAISE;
7360 WHEN OTHERS THEN
7361 xla_exceptions_pkg.raise_message
7362 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_27');
7363 END AcctLineType_27;
7364 --
7365
7366 ---------------------------------------
7367 --
7368 -- PRIVATE FUNCTION
7369 -- AcctLineType_28
7370 --
7371 ---------------------------------------
7372 PROCEDURE AcctLineType_28 (
7373 p_application_id IN NUMBER
7374 ,p_event_id IN NUMBER
7375 ,p_calculate_acctd_flag IN VARCHAR2
7376 ,p_calculate_g_l_flag IN VARCHAR2
7377 ,p_actual_flag IN OUT VARCHAR2
7378 ,p_balance_type_code OUT VARCHAR2
7379 ,p_gain_or_loss_ref OUT VARCHAR2
7380
7381 --Credit Memo Distribution GL Account
7382 , p_source_9 IN NUMBER
7383 --SLA Party Type
7384 , p_source_27 IN VARCHAR2
7385 --Credit Memo Distribution Identifier
7386 , p_source_37 IN NUMBER
7387 --Credit memo distributions type
7388 , p_source_38 IN VARCHAR2
7389 --Credit Memo Currency Code
7390 , p_source_39 IN VARCHAR2
7391 --Credit Memo Exchange Date
7392 , p_source_40 IN DATE
7393 --Credit Memo Exchange Rate
7394 , p_source_41 IN NUMBER
7395 --Credit Memo Exchange Rate Type
7396 , p_source_42 IN VARCHAR2
7397 --Gain Loss Reference
7398 , p_source_43 IN VARCHAR2
7399 --Credit Memo Accounting Amount
7400 , p_source_44 IN NUMBER
7401 --Credit Memo Bill To Customer Account Identifier
7402 , p_source_45 IN NUMBER
7403 --Credit Memo Bill To Customer Site Use Identifier
7404 , p_source_46 IN NUMBER
7405 --Credit Memo Tax Line Identifier
7406 , p_source_47 IN NUMBER
7407 --Credit Memo Distribution Account Class
7408 , p_source_48 IN VARCHAR2
7409 --Credit Memo Distribution Entered Amount
7410 , p_source_49 IN NUMBER
7411 )
7412 IS
7413
7414 l_component_type VARCHAR2(80);
7415 l_component_code VARCHAR2(30);
7416 l_component_type_code VARCHAR2(1);
7417 l_component_appl_id INTEGER;
7418 l_amb_context_code VARCHAR2(30);
7419 l_entity_code VARCHAR2(30);
7420 l_event_class_code VARCHAR2(30);
7421 l_ae_header_id NUMBER;
7422 l_event_type_code VARCHAR2(30);
7423 l_line_definition_code VARCHAR2(30);
7424 l_line_definition_owner_code VARCHAR2(1);
7425 --
7426 -- adr variables
7427 l_segment VARCHAR2(30);
7428 l_ccid NUMBER;
7429 l_adr_transaction_coa_id NUMBER;
7430 l_adr_accounting_coa_id NUMBER;
7431 l_adr_flexfield_segment_code VARCHAR2(30);
7432 l_adr_flex_value_set_id NUMBER;
7433 l_adr_value_type_code VARCHAR2(30);
7434 l_adr_value_combination_id NUMBER;
7435 l_adr_value_segment_code VARCHAR2(30);
7436
7437 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
7438 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
7439 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
7440 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
7441
7442 -- 4262811 Variables ------------------------------------------------------------------------------------------
7443 l_entered_amt_idx NUMBER;
7444 l_accted_amt_idx NUMBER;
7445 l_acc_rev_flag VARCHAR2(1);
7446 l_accrual_line_num NUMBER;
7447 l_tmp_amt NUMBER;
7448 l_acc_rev_natural_side_code VARCHAR2(1);
7449
7450 l_num_entries NUMBER;
7451 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
7452 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
7453 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
7454 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
7455 l_recog_line_1 NUMBER;
7456 l_recog_line_2 NUMBER;
7457
7458 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
7459 l_bflow_applied_to_amt NUMBER; -- 5132302
7460 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
7461
7462 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
7463
7464 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
7465 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
7466
7467 ---------------------------------------------------------------------------------------------------------------
7468
7469
7470 --
7471 -- bulk performance
7472 --
7473 l_balance_type_code VARCHAR2(1);
7474 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
7475 l_log_module VARCHAR2(240);
7476
7477 --
7478 -- Upgrade strategy
7479 --
7480 l_actual_upg_option VARCHAR2(1);
7481 l_enc_upg_option VARCHAR2(1);
7482
7483 --
7484 BEGIN
7485 --
7486 IF g_log_enabled THEN
7487 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_28';
7488 END IF;
7489 --
7490 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7491
7492 trace
7493 (p_msg => 'BEGIN of AcctLineType_28'
7494 ,p_level => C_LEVEL_PROCEDURE
7498 --
7495 ,p_module => l_log_module);
7496
7497 END IF;
7499 l_component_type := 'AMB_JLT';
7500 l_component_code := 'CM_DEFAULT_FREIGHT';
7501 l_component_type_code := 'S';
7502 l_component_appl_id := 222;
7503 l_amb_context_code := 'DEFAULT';
7504 l_entity_code := 'TRANSACTIONS';
7505 l_event_class_code := 'CREDIT_MEMO';
7506 l_event_type_code := 'CREDIT_MEMO_ALL';
7507 l_line_definition_owner_code := 'S';
7508 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
7509 --
7510 l_balance_type_code := 'A';
7511 l_segment := NULL;
7512 l_ccid := NULL;
7513 l_adr_transaction_coa_id := NULL;
7514 l_adr_accounting_coa_id := NULL;
7515 l_adr_flexfield_segment_code := NULL;
7516 l_adr_flex_value_set_id := NULL;
7517 l_adr_value_type_code := NULL;
7518 l_adr_value_combination_id := NULL;
7519 l_adr_value_segment_code := NULL;
7520
7521 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
7522 l_bflow_class_code := ''; -- 4219869 Business Flow
7523 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
7524 l_budgetary_control_flag := 'N';
7525
7526 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7527 l_bflow_applied_to_amt := NULL; -- 5132302
7528 l_entered_amt_idx := NULL; -- 4262811
7529 l_accted_amt_idx := NULL; -- 4262811
7530 l_acc_rev_flag := NULL; -- 4262811
7531 l_accrual_line_num := NULL; -- 4262811
7532 l_tmp_amt := NULL; -- 4262811
7533 --
7534
7535 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
7536 l_balance_type_code <> 'B' THEN
7537 IF NVL(p_source_48,'
7538 ') = 'FREIGHT'
7539 THEN
7540
7541 --
7542 XLA_AE_LINES_PKG.SetNewLine;
7543
7544 p_balance_type_code := l_balance_type_code;
7545 -- set the flag so later we will know whether the gain loss line needs to be created
7546
7547 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
7548 p_actual_flag :='A';
7549 END IF;
7550
7551 --
7552 -- bulk performance
7553 --
7554 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
7555 p_header_num => 0); -- 4262811
7556 --
7557 -- set accounting line options
7558 --
7559 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
7560 p_natural_side_code => 'C'
7561 , p_gain_or_loss_flag => 'N'
7562 , p_gl_transfer_mode_code => 'S'
7563 , p_acct_entry_type_code => 'A'
7564 , p_switch_side_flag => 'Y'
7565 , p_merge_duplicate_code => 'A'
7566 );
7567 --
7568 l_acc_rev_natural_side_code := 'D'; -- 4262811
7569 --
7570 --
7571 -- set accounting line type info
7572 --
7573 xla_ae_lines_pkg.SetAcctLineType
7574 (p_component_type => l_component_type
7575 ,p_event_type_code => l_event_type_code
7576 ,p_line_definition_owner_code => l_line_definition_owner_code
7577 ,p_line_definition_code => l_line_definition_code
7578 ,p_accounting_line_code => l_component_code
7579 ,p_accounting_line_type_code => l_component_type_code
7580 ,p_accounting_line_appl_id => l_component_appl_id
7581 ,p_amb_context_code => l_amb_context_code
7582 ,p_entity_code => l_entity_code
7583 ,p_event_class_code => l_event_class_code);
7584 --
7585 -- set accounting class
7586 --
7587 xla_ae_lines_pkg.SetAcctClass(
7588 p_accounting_class_code => 'FREIGHT'
7589 , p_ae_header_id => l_ae_header_id
7590 );
7591
7592 --
7593 -- set rounding class
7594 --
7595 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
7596 'RECEIVABLE';
7597
7598 --
7599 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
7600 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
7601 --
7602 -- bulk performance
7603 --
7604 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
7605
7606 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
7607 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
7608
7609 -- 4955764
7610 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7611 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
7612
7613 -- 4458381 Public Sector Enh
7614
7615 --
7616 -- set accounting attributes for the line type
7617 --
7618 l_entered_amt_idx := 3;
7619 l_accted_amt_idx := 9;
7620 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7621 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
7622 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_37);
7623 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
7624 l_rec_acct_attrs.array_char_value(2) := p_source_38;
7628 l_rec_acct_attrs.array_char_value(4) := p_source_39;
7625 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
7626 l_rec_acct_attrs.array_num_value(3) := p_source_49;
7627 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
7629 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
7630 l_rec_acct_attrs.array_date_value(5) := p_source_40;
7631 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
7632 l_rec_acct_attrs.array_num_value(6) := p_source_41;
7633 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
7634 l_rec_acct_attrs.array_char_value(7) := p_source_42;
7635 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
7636 l_rec_acct_attrs.array_char_value(8) := p_source_43;
7637 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
7638 l_rec_acct_attrs.array_num_value(9) := p_source_44;
7639 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
7640 l_rec_acct_attrs.array_num_value(10) := p_source_45;
7641 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
7642 l_rec_acct_attrs.array_num_value(11) := p_source_46;
7643 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
7644 l_rec_acct_attrs.array_char_value(12) := p_source_27;
7645 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
7646 l_rec_acct_attrs.array_num_value(13) := p_source_47;
7647
7648 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
7649 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
7650
7651 ---------------------------------------------------------------------------------------------------------------
7652 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
7653 ---------------------------------------------------------------------------------------------------------------
7654 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
7655
7656 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7657 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7658
7659 IF xla_accounting_cache_pkg.GetValueChar
7660 (p_source_code => 'LEDGER_CATEGORY_CODE'
7661 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
7662 AND l_bflow_method_code = 'PRIOR_ENTRY'
7663 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
7664 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
7665 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
7666 )
7667 THEN
7668 xla_ae_lines_pkg.BflowUpgEntry
7669 (p_business_method_code => l_bflow_method_code
7670 ,p_business_class_code => l_bflow_class_code
7671 ,p_balance_type => l_balance_type_code);
7672 ELSE
7673 NULL;
7674 -- No business flow processing for business flow method of NONE.
7675 END IF;
7676
7677 --
7678 -- call analytical criteria
7679 --
7680
7681 --
7682 -- call description
7683 --
7684 -- No description or it is inherited.
7685 --
7686 -- call ADRs
7687 -- Bug 4922099
7688 --
7689 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7690 (NVL(l_actual_upg_option, 'N') = 'O') OR
7691 (NVL(l_enc_upg_option, 'N') = 'O')
7692 )
7693 THEN
7694 NULL;
7695 --
7696 --
7697
7698 l_ccid := AcctDerRule_10(
7699 p_application_id => p_application_id
7700 , p_ae_header_id => l_ae_header_id
7701 , p_source_9 => p_source_9
7702 , x_transaction_coa_id => l_adr_transaction_coa_id
7703 , x_accounting_coa_id => l_adr_accounting_coa_id
7704 , x_value_type_code => l_adr_value_type_code
7705 , p_side => 'NA'
7706 );
7707
7708 xla_ae_lines_pkg.set_ccid(
7709 p_code_combination_id => l_ccid
7710 , p_value_type_code => l_adr_value_type_code
7711 , p_transaction_coa_id => l_adr_transaction_coa_id
7712 , p_accounting_coa_id => l_adr_accounting_coa_id
7713 , p_adr_code => 'CM_DIST_CCID'
7714 , p_adr_type_code => 'S'
7715 , p_component_type => l_component_type
7716 , p_component_code => l_component_code
7717 , p_component_type_code => l_component_type_code
7718 , p_component_appl_id => l_component_appl_id
7719 , p_amb_context_code => l_amb_context_code
7720 , p_side => 'NA'
7721 );
7722
7723
7724 --
7725 --
7726 END IF;
7727 --
7728 -- Bug 4922099
7729 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
7730 (NVL(l_enc_upg_option, 'N') = 'O')
7731 ) AND
7732 (l_bflow_method_code = 'PRIOR_ENTRY')
7733 )
7734 THEN
7735 IF
7736 --
7737 1 = 2
7738 --
7739 THEN
7740 xla_accounting_err_pkg.build_message
7741 (p_appli_s_name => 'XLA'
7742 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7743 ,p_token_1 => 'LINE_NUMBER'
7744 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
7745 ,p_token_2 => 'LINE_TYPE_NAME'
7746 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
7750 ,l_component_appl_id
7747 l_component_type
7748 ,l_component_code
7749 ,l_component_type_code
7751 ,l_amb_context_code
7752 ,l_entity_code
7753 ,l_event_class_code
7754 )
7755 ,p_token_3 => 'OWNER'
7756 ,p_value_3 => xla_lookups_pkg.get_meaning(
7757 p_lookup_type => 'XLA_OWNER_TYPE'
7758 ,p_lookup_code => l_component_type_code
7759 )
7760 ,p_token_4 => 'PRODUCT_NAME'
7761 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
7762 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
7763 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
7764 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
7765 ,p_ae_header_id => NULL
7766 );
7767
7768 IF (C_LEVEL_ERROR>= g_log_level) THEN
7769 trace
7770 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7771 ,p_level => C_LEVEL_ERROR
7772 ,p_module => l_log_module);
7773 END IF;
7774 END IF;
7775 END IF;
7776 --
7777 --
7778 ------------------------------------------------------------------------------------------------
7779 -- 4219869 Business Flow
7780 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
7781 -- Prior Entry. Currently, the following code is always generated.
7782 ------------------------------------------------------------------------------------------------
7783 XLA_AE_LINES_PKG.ValidateCurrentLine;
7784
7785 ------------------------------------------------------------------------------------
7786 -- 4219869 Business Flow
7787 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
7788 ------------------------------------------------------------------------------------
7789 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7790
7791 ----------------------------------------------------------------------------------
7792 -- 4219869 Business Flow
7793 -- Update journal entry status -- Need to generate this within IF <condition>
7794 ----------------------------------------------------------------------------------
7795 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7796 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
7797 ,p_balance_type_code => l_balance_type_code
7798 );
7799
7800 -------------------------------------------------------------------------------------------
7801 -- 4262811 - Generate the Accrual Reversal lines
7802 -------------------------------------------------------------------------------------------
7803 BEGIN
7804 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
7805 (g_array_event(p_event_id).array_value_num('header_index'));
7806 IF l_acc_rev_flag IS NULL THEN
7807 l_acc_rev_flag := 'N';
7808 END IF;
7809 EXCEPTION
7810 WHEN OTHERS THEN
7811 l_acc_rev_flag := 'N';
7812 END;
7813 --
7814 IF (l_acc_rev_flag = 'Y') THEN
7815
7816 -- 4645092 ------------------------------------------------------------------------------
7817 -- To allow MPA report to determine if it should generate report process
7818 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
7819 ------------------------------------------------------------------------------------------
7820
7821 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
7822 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
7823 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
7824 -- call ADRs
7825 -- Bug 4922099
7826 --
7827 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7828 (NVL(l_actual_upg_option, 'N') = 'O') OR
7829 (NVL(l_enc_upg_option, 'N') = 'O')
7830 )
7831 THEN
7832 NULL;
7833 --
7834 --
7835
7836 l_ccid := AcctDerRule_10(
7837 p_application_id => p_application_id
7838 , p_ae_header_id => l_ae_header_id
7839 , p_source_9 => p_source_9
7840 , x_transaction_coa_id => l_adr_transaction_coa_id
7841 , x_accounting_coa_id => l_adr_accounting_coa_id
7842 , x_value_type_code => l_adr_value_type_code
7843 , p_side => 'NA'
7844 );
7845
7846 xla_ae_lines_pkg.set_ccid(
7847 p_code_combination_id => l_ccid
7848 , p_value_type_code => l_adr_value_type_code
7849 , p_transaction_coa_id => l_adr_transaction_coa_id
7850 , p_accounting_coa_id => l_adr_accounting_coa_id
7851 , p_adr_code => 'CM_DIST_CCID'
7855 , p_component_type_code => l_component_type_code
7852 , p_adr_type_code => 'S'
7853 , p_component_type => l_component_type
7854 , p_component_code => l_component_code
7856 , p_component_appl_id => l_component_appl_id
7857 , p_amb_context_code => l_amb_context_code
7858 , p_side => 'NA'
7859 );
7860
7861
7862 --
7863 --
7864 END IF;
7865
7866 --
7867 -- Update the line information that should be overwritten
7868 --
7869 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
7870 p_header_num => 1);
7871 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
7872
7873 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
7874
7875 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
7876 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
7877 END IF;
7878
7879 --
7880 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
7881 --
7882 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
7883 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
7884 ELSE
7885 ---------------------------------------------------------------------------------------------------
7886 -- 4262811a Switch Sign
7887 ---------------------------------------------------------------------------------------------------
7888 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
7889 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7890 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7891 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7892 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7893 -- 5132302
7894 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
7895 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7896
7897 END IF;
7898
7899 -- 4955764
7900 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7901 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
7902
7903
7904 XLA_AE_LINES_PKG.ValidateCurrentLine;
7905 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7906
7907 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7908 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
7909 ,p_balance_type_code => l_balance_type_code);
7910
7911 END IF;
7912
7913 -----------------------------------------------------------------------------------------
7914 -- 4262811 Multiperiod Accounting
7915 -----------------------------------------------------------------------------------------
7916 -- No MPA option is assigned.
7917
7918
7919 END IF;
7920 END IF;
7921 --
7922
7923 --
7924 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7925 trace
7926 (p_msg => 'END of AcctLineType_28'
7927 ,p_level => C_LEVEL_PROCEDURE
7928 ,p_module => l_log_module);
7929 END IF;
7930 --
7931 EXCEPTION
7932 WHEN xla_exceptions_pkg.application_exception THEN
7933 RAISE;
7934 WHEN OTHERS THEN
7935 xla_exceptions_pkg.raise_message
7936 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_28');
7937 END AcctLineType_28;
7938 --
7939
7940 ---------------------------------------
7941 --
7942 -- PRIVATE FUNCTION
7943 -- AcctLineType_29
7944 --
7945 ---------------------------------------
7946 PROCEDURE AcctLineType_29 (
7947 p_application_id IN NUMBER
7948 ,p_event_id IN NUMBER
7949 ,p_calculate_acctd_flag IN VARCHAR2
7950 ,p_calculate_g_l_flag IN VARCHAR2
7951 ,p_actual_flag IN OUT VARCHAR2
7952 ,p_balance_type_code OUT VARCHAR2
7953 ,p_gain_or_loss_ref OUT VARCHAR2
7954
7955 --Credit Memo Distribution GL Account
7956 , p_source_9 IN NUMBER
7957 --SLA Party Type
7958 , p_source_27 IN VARCHAR2
7959 --Credit Memo Distribution Identifier
7960 , p_source_37 IN NUMBER
7961 --Credit memo distributions type
7962 , p_source_38 IN VARCHAR2
7963 --Credit Memo Currency Code
7964 , p_source_39 IN VARCHAR2
7965 --Credit Memo Exchange Date
7966 , p_source_40 IN DATE
7967 --Credit Memo Exchange Rate
7968 , p_source_41 IN NUMBER
7969 --Credit Memo Exchange Rate Type
7970 , p_source_42 IN VARCHAR2
7971 --Gain Loss Reference
7972 , p_source_43 IN VARCHAR2
7973 --Credit Memo Accounting Amount
7974 , p_source_44 IN NUMBER
7975 --Credit Memo Bill To Customer Account Identifier
7976 , p_source_45 IN NUMBER
7977 --Credit Memo Bill To Customer Site Use Identifier
7978 , p_source_46 IN NUMBER
7979 --Credit Memo Tax Line Identifier
7980 , p_source_47 IN NUMBER
7981 --Credit Memo Distribution Account Class
7982 , p_source_48 IN VARCHAR2
7983 --Credit Memo Distribution Entered Amount
7984 , p_source_49 IN NUMBER
7985 )
7989 l_component_code VARCHAR2(30);
7986 IS
7987
7988 l_component_type VARCHAR2(80);
7990 l_component_type_code VARCHAR2(1);
7991 l_component_appl_id INTEGER;
7992 l_amb_context_code VARCHAR2(30);
7993 l_entity_code VARCHAR2(30);
7994 l_event_class_code VARCHAR2(30);
7995 l_ae_header_id NUMBER;
7996 l_event_type_code VARCHAR2(30);
7997 l_line_definition_code VARCHAR2(30);
7998 l_line_definition_owner_code VARCHAR2(1);
7999 --
8000 -- adr variables
8001 l_segment VARCHAR2(30);
8002 l_ccid NUMBER;
8003 l_adr_transaction_coa_id NUMBER;
8004 l_adr_accounting_coa_id NUMBER;
8005 l_adr_flexfield_segment_code VARCHAR2(30);
8006 l_adr_flex_value_set_id NUMBER;
8007 l_adr_value_type_code VARCHAR2(30);
8008 l_adr_value_combination_id NUMBER;
8009 l_adr_value_segment_code VARCHAR2(30);
8010
8011 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
8012 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
8013 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
8014 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
8015
8016 -- 4262811 Variables ------------------------------------------------------------------------------------------
8017 l_entered_amt_idx NUMBER;
8018 l_accted_amt_idx NUMBER;
8019 l_acc_rev_flag VARCHAR2(1);
8020 l_accrual_line_num NUMBER;
8021 l_tmp_amt NUMBER;
8022 l_acc_rev_natural_side_code VARCHAR2(1);
8023
8024 l_num_entries NUMBER;
8025 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
8026 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
8027 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
8028 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
8029 l_recog_line_1 NUMBER;
8030 l_recog_line_2 NUMBER;
8031
8032 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
8033 l_bflow_applied_to_amt NUMBER; -- 5132302
8034 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
8035
8036 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
8037
8038 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
8039 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
8040
8041 ---------------------------------------------------------------------------------------------------------------
8042
8043
8044 --
8045 -- bulk performance
8046 --
8047 l_balance_type_code VARCHAR2(1);
8048 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
8049 l_log_module VARCHAR2(240);
8050
8051 --
8052 -- Upgrade strategy
8053 --
8054 l_actual_upg_option VARCHAR2(1);
8055 l_enc_upg_option VARCHAR2(1);
8056
8057 --
8058 BEGIN
8059 --
8060 IF g_log_enabled THEN
8061 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_29';
8062 END IF;
8063 --
8064 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8065
8066 trace
8067 (p_msg => 'BEGIN of AcctLineType_29'
8068 ,p_level => C_LEVEL_PROCEDURE
8069 ,p_module => l_log_module);
8070
8071 END IF;
8072 --
8073 l_component_type := 'AMB_JLT';
8074 l_component_code := 'CM_DEFAULT_REV';
8075 l_component_type_code := 'S';
8076 l_component_appl_id := 222;
8077 l_amb_context_code := 'DEFAULT';
8078 l_entity_code := 'TRANSACTIONS';
8079 l_event_class_code := 'CREDIT_MEMO';
8080 l_event_type_code := 'CREDIT_MEMO_ALL';
8081 l_line_definition_owner_code := 'S';
8082 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
8083 --
8084 l_balance_type_code := 'A';
8085 l_segment := NULL;
8086 l_ccid := NULL;
8087 l_adr_transaction_coa_id := NULL;
8088 l_adr_accounting_coa_id := NULL;
8089 l_adr_flexfield_segment_code := NULL;
8090 l_adr_flex_value_set_id := NULL;
8091 l_adr_value_type_code := NULL;
8092 l_adr_value_combination_id := NULL;
8093 l_adr_value_segment_code := NULL;
8094
8095 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
8096 l_bflow_class_code := ''; -- 4219869 Business Flow
8097 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
8098 l_budgetary_control_flag := 'N';
8099
8100 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8101 l_bflow_applied_to_amt := NULL; -- 5132302
8102 l_entered_amt_idx := NULL; -- 4262811
8103 l_accted_amt_idx := NULL; -- 4262811
8104 l_acc_rev_flag := NULL; -- 4262811
8105 l_accrual_line_num := NULL; -- 4262811
8106 l_tmp_amt := NULL; -- 4262811
8107 --
8108
8109 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
8110 l_balance_type_code <> 'B' THEN
8111 IF NVL(p_source_48,'
8112 ') = 'REV'
8113 THEN
8114
8115 --
8116 XLA_AE_LINES_PKG.SetNewLine;
8117
8118 p_balance_type_code := l_balance_type_code;
8119 -- set the flag so later we will know whether the gain loss line needs to be created
8120
8121 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
8122 p_actual_flag :='A';
8123 END IF;
8124
8128 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
8125 --
8126 -- bulk performance
8127 --
8129 p_header_num => 0); -- 4262811
8130 --
8131 -- set accounting line options
8132 --
8133 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
8134 p_natural_side_code => 'C'
8135 , p_gain_or_loss_flag => 'N'
8136 , p_gl_transfer_mode_code => 'S'
8137 , p_acct_entry_type_code => 'A'
8138 , p_switch_side_flag => 'Y'
8139 , p_merge_duplicate_code => 'A'
8140 );
8141 --
8142 l_acc_rev_natural_side_code := 'D'; -- 4262811
8143 --
8144 --
8145 -- set accounting line type info
8146 --
8147 xla_ae_lines_pkg.SetAcctLineType
8148 (p_component_type => l_component_type
8149 ,p_event_type_code => l_event_type_code
8150 ,p_line_definition_owner_code => l_line_definition_owner_code
8151 ,p_line_definition_code => l_line_definition_code
8152 ,p_accounting_line_code => l_component_code
8153 ,p_accounting_line_type_code => l_component_type_code
8154 ,p_accounting_line_appl_id => l_component_appl_id
8155 ,p_amb_context_code => l_amb_context_code
8156 ,p_entity_code => l_entity_code
8157 ,p_event_class_code => l_event_class_code);
8158 --
8159 -- set accounting class
8160 --
8161 xla_ae_lines_pkg.SetAcctClass(
8162 p_accounting_class_code => 'REVENUE'
8163 , p_ae_header_id => l_ae_header_id
8164 );
8165
8166 --
8167 -- set rounding class
8168 --
8169 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
8170 'RECEIVABLE';
8171
8172 --
8173 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
8174 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
8175 --
8176 -- bulk performance
8177 --
8178 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
8179
8180 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
8181 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
8182
8183 -- 4955764
8184 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8185 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
8186
8187 -- 4458381 Public Sector Enh
8188
8189 --
8190 -- set accounting attributes for the line type
8191 --
8192 l_entered_amt_idx := 3;
8193 l_accted_amt_idx := 9;
8194 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8195 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
8196 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_37);
8197 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
8198 l_rec_acct_attrs.array_char_value(2) := p_source_38;
8199 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
8200 l_rec_acct_attrs.array_num_value(3) := p_source_49;
8201 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
8202 l_rec_acct_attrs.array_char_value(4) := p_source_39;
8203 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
8204 l_rec_acct_attrs.array_date_value(5) := p_source_40;
8205 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
8206 l_rec_acct_attrs.array_num_value(6) := p_source_41;
8207 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
8208 l_rec_acct_attrs.array_char_value(7) := p_source_42;
8209 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
8210 l_rec_acct_attrs.array_char_value(8) := p_source_43;
8211 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
8212 l_rec_acct_attrs.array_num_value(9) := p_source_44;
8213 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
8214 l_rec_acct_attrs.array_num_value(10) := p_source_45;
8215 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
8216 l_rec_acct_attrs.array_num_value(11) := p_source_46;
8217 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
8218 l_rec_acct_attrs.array_char_value(12) := p_source_27;
8219 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
8220 l_rec_acct_attrs.array_num_value(13) := p_source_47;
8221
8222 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
8223 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
8224
8225 ---------------------------------------------------------------------------------------------------------------
8226 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
8227 ---------------------------------------------------------------------------------------------------------------
8228 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
8229
8230 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8231 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8232
8233 IF xla_accounting_cache_pkg.GetValueChar
8234 (p_source_code => 'LEDGER_CATEGORY_CODE'
8235 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
8236 AND l_bflow_method_code = 'PRIOR_ENTRY'
8237 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
8238 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
8242 xla_ae_lines_pkg.BflowUpgEntry
8239 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
8240 )
8241 THEN
8243 (p_business_method_code => l_bflow_method_code
8244 ,p_business_class_code => l_bflow_class_code
8245 ,p_balance_type => l_balance_type_code);
8246 ELSE
8247 NULL;
8248 -- No business flow processing for business flow method of NONE.
8249 END IF;
8250
8251 --
8252 -- call analytical criteria
8253 --
8254
8255 --
8256 -- call description
8257 --
8258 -- No description or it is inherited.
8259 --
8260 -- call ADRs
8261 -- Bug 4922099
8262 --
8263 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8264 (NVL(l_actual_upg_option, 'N') = 'O') OR
8265 (NVL(l_enc_upg_option, 'N') = 'O')
8266 )
8267 THEN
8268 NULL;
8269 --
8270 --
8271
8272 l_ccid := AcctDerRule_10(
8273 p_application_id => p_application_id
8274 , p_ae_header_id => l_ae_header_id
8275 , p_source_9 => p_source_9
8276 , x_transaction_coa_id => l_adr_transaction_coa_id
8277 , x_accounting_coa_id => l_adr_accounting_coa_id
8278 , x_value_type_code => l_adr_value_type_code
8279 , p_side => 'NA'
8280 );
8281
8282 xla_ae_lines_pkg.set_ccid(
8283 p_code_combination_id => l_ccid
8284 , p_value_type_code => l_adr_value_type_code
8285 , p_transaction_coa_id => l_adr_transaction_coa_id
8286 , p_accounting_coa_id => l_adr_accounting_coa_id
8287 , p_adr_code => 'CM_DIST_CCID'
8288 , p_adr_type_code => 'S'
8289 , p_component_type => l_component_type
8290 , p_component_code => l_component_code
8291 , p_component_type_code => l_component_type_code
8292 , p_component_appl_id => l_component_appl_id
8293 , p_amb_context_code => l_amb_context_code
8294 , p_side => 'NA'
8295 );
8296
8297
8298 --
8299 --
8300 END IF;
8301 --
8302 -- Bug 4922099
8303 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
8304 (NVL(l_enc_upg_option, 'N') = 'O')
8305 ) AND
8306 (l_bflow_method_code = 'PRIOR_ENTRY')
8307 )
8308 THEN
8309 IF
8310 --
8311 1 = 2
8312 --
8313 THEN
8314 xla_accounting_err_pkg.build_message
8315 (p_appli_s_name => 'XLA'
8316 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8317 ,p_token_1 => 'LINE_NUMBER'
8318 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
8319 ,p_token_2 => 'LINE_TYPE_NAME'
8320 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
8321 l_component_type
8322 ,l_component_code
8323 ,l_component_type_code
8324 ,l_component_appl_id
8325 ,l_amb_context_code
8326 ,l_entity_code
8327 ,l_event_class_code
8328 )
8329 ,p_token_3 => 'OWNER'
8330 ,p_value_3 => xla_lookups_pkg.get_meaning(
8331 p_lookup_type => 'XLA_OWNER_TYPE'
8332 ,p_lookup_code => l_component_type_code
8333 )
8334 ,p_token_4 => 'PRODUCT_NAME'
8335 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
8336 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
8337 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
8338 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
8339 ,p_ae_header_id => NULL
8340 );
8341
8342 IF (C_LEVEL_ERROR>= g_log_level) THEN
8343 trace
8344 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8345 ,p_level => C_LEVEL_ERROR
8346 ,p_module => l_log_module);
8347 END IF;
8348 END IF;
8349 END IF;
8350 --
8351 --
8352 ------------------------------------------------------------------------------------------------
8353 -- 4219869 Business Flow
8354 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
8355 -- Prior Entry. Currently, the following code is always generated.
8356 ------------------------------------------------------------------------------------------------
8357 XLA_AE_LINES_PKG.ValidateCurrentLine;
8358
8362 ------------------------------------------------------------------------------------
8359 ------------------------------------------------------------------------------------
8360 -- 4219869 Business Flow
8361 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
8363 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8364
8365 ----------------------------------------------------------------------------------
8366 -- 4219869 Business Flow
8367 -- Update journal entry status -- Need to generate this within IF <condition>
8368 ----------------------------------------------------------------------------------
8369 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8370 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
8371 ,p_balance_type_code => l_balance_type_code
8372 );
8373
8374 -------------------------------------------------------------------------------------------
8375 -- 4262811 - Generate the Accrual Reversal lines
8376 -------------------------------------------------------------------------------------------
8377 BEGIN
8378 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
8379 (g_array_event(p_event_id).array_value_num('header_index'));
8380 IF l_acc_rev_flag IS NULL THEN
8381 l_acc_rev_flag := 'N';
8382 END IF;
8383 EXCEPTION
8384 WHEN OTHERS THEN
8385 l_acc_rev_flag := 'N';
8386 END;
8387 --
8388 IF (l_acc_rev_flag = 'Y') THEN
8389
8390 -- 4645092 ------------------------------------------------------------------------------
8391 -- To allow MPA report to determine if it should generate report process
8392 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
8393 ------------------------------------------------------------------------------------------
8394
8395 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
8396 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
8397 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
8398 -- call ADRs
8399 -- Bug 4922099
8400 --
8401 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8402 (NVL(l_actual_upg_option, 'N') = 'O') OR
8403 (NVL(l_enc_upg_option, 'N') = 'O')
8404 )
8405 THEN
8406 NULL;
8407 --
8408 --
8409
8410 l_ccid := AcctDerRule_10(
8411 p_application_id => p_application_id
8412 , p_ae_header_id => l_ae_header_id
8413 , p_source_9 => p_source_9
8414 , x_transaction_coa_id => l_adr_transaction_coa_id
8415 , x_accounting_coa_id => l_adr_accounting_coa_id
8416 , x_value_type_code => l_adr_value_type_code
8417 , p_side => 'NA'
8418 );
8419
8420 xla_ae_lines_pkg.set_ccid(
8421 p_code_combination_id => l_ccid
8422 , p_value_type_code => l_adr_value_type_code
8423 , p_transaction_coa_id => l_adr_transaction_coa_id
8424 , p_accounting_coa_id => l_adr_accounting_coa_id
8425 , p_adr_code => 'CM_DIST_CCID'
8426 , p_adr_type_code => 'S'
8427 , p_component_type => l_component_type
8428 , p_component_code => l_component_code
8429 , p_component_type_code => l_component_type_code
8430 , p_component_appl_id => l_component_appl_id
8431 , p_amb_context_code => l_amb_context_code
8432 , p_side => 'NA'
8433 );
8434
8435
8436 --
8437 --
8438 END IF;
8439
8440 --
8441 -- Update the line information that should be overwritten
8442 --
8443 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
8444 p_header_num => 1);
8445 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
8446
8447 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
8448
8449 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
8450 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
8451 END IF;
8452
8453 --
8454 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
8455 --
8456 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
8457 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
8458 ELSE
8459 ---------------------------------------------------------------------------------------------------
8460 -- 4262811a Switch Sign
8461 ---------------------------------------------------------------------------------------------------
8462 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
8463 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8464 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8465 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8466 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8467 -- 5132302
8468 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
8469 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8470
8471 END IF;
8472
8473 -- 4955764
8477
8474 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8475 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
8476
8478 XLA_AE_LINES_PKG.ValidateCurrentLine;
8479 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8480
8481 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8482 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
8483 ,p_balance_type_code => l_balance_type_code);
8484
8485 END IF;
8486
8487 -----------------------------------------------------------------------------------------
8488 -- 4262811 Multiperiod Accounting
8489 -----------------------------------------------------------------------------------------
8490 -- No MPA option is assigned.
8491
8492
8493 END IF;
8494 END IF;
8495 --
8496
8497 --
8498 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8499 trace
8500 (p_msg => 'END of AcctLineType_29'
8501 ,p_level => C_LEVEL_PROCEDURE
8502 ,p_module => l_log_module);
8503 END IF;
8504 --
8505 EXCEPTION
8506 WHEN xla_exceptions_pkg.application_exception THEN
8507 RAISE;
8508 WHEN OTHERS THEN
8509 xla_exceptions_pkg.raise_message
8510 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_29');
8511 END AcctLineType_29;
8512 --
8513
8514 ---------------------------------------
8515 --
8516 -- PRIVATE FUNCTION
8517 -- AcctLineType_30
8518 --
8519 ---------------------------------------
8520 PROCEDURE AcctLineType_30 (
8521 p_application_id IN NUMBER
8522 ,p_event_id IN NUMBER
8523 ,p_calculate_acctd_flag IN VARCHAR2
8524 ,p_calculate_g_l_flag IN VARCHAR2
8525 ,p_actual_flag IN OUT VARCHAR2
8526 ,p_balance_type_code OUT VARCHAR2
8527 ,p_gain_or_loss_ref OUT VARCHAR2
8528
8529 --Credit Memo Distribution GL Account
8530 , p_source_9 IN NUMBER
8531 --SLA Party Type
8532 , p_source_27 IN VARCHAR2
8533 --Credit Memo Distribution Identifier
8534 , p_source_37 IN NUMBER
8535 --Credit memo distributions type
8536 , p_source_38 IN VARCHAR2
8537 --Credit Memo Currency Code
8538 , p_source_39 IN VARCHAR2
8539 --Credit Memo Exchange Date
8540 , p_source_40 IN DATE
8541 --Credit Memo Exchange Rate
8542 , p_source_41 IN NUMBER
8543 --Credit Memo Exchange Rate Type
8544 , p_source_42 IN VARCHAR2
8545 --Gain Loss Reference
8546 , p_source_43 IN VARCHAR2
8547 --Credit Memo Accounting Amount
8548 , p_source_44 IN NUMBER
8549 --Credit Memo Bill To Customer Account Identifier
8550 , p_source_45 IN NUMBER
8551 --Credit Memo Bill To Customer Site Use Identifier
8552 , p_source_46 IN NUMBER
8553 --Credit Memo Tax Line Identifier
8554 , p_source_47 IN NUMBER
8555 --Credit Memo Distribution Account Class
8556 , p_source_48 IN VARCHAR2
8557 --Credit Memo Distribution Entered Amount
8558 , p_source_49 IN NUMBER
8559 )
8560 IS
8561
8562 l_component_type VARCHAR2(80);
8563 l_component_code VARCHAR2(30);
8564 l_component_type_code VARCHAR2(1);
8565 l_component_appl_id INTEGER;
8566 l_amb_context_code VARCHAR2(30);
8567 l_entity_code VARCHAR2(30);
8568 l_event_class_code VARCHAR2(30);
8569 l_ae_header_id NUMBER;
8570 l_event_type_code VARCHAR2(30);
8571 l_line_definition_code VARCHAR2(30);
8572 l_line_definition_owner_code VARCHAR2(1);
8573 --
8574 -- adr variables
8575 l_segment VARCHAR2(30);
8576 l_ccid NUMBER;
8577 l_adr_transaction_coa_id NUMBER;
8578 l_adr_accounting_coa_id NUMBER;
8579 l_adr_flexfield_segment_code VARCHAR2(30);
8580 l_adr_flex_value_set_id NUMBER;
8581 l_adr_value_type_code VARCHAR2(30);
8582 l_adr_value_combination_id NUMBER;
8583 l_adr_value_segment_code VARCHAR2(30);
8584
8585 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
8586 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
8587 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
8588 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
8589
8590 -- 4262811 Variables ------------------------------------------------------------------------------------------
8591 l_entered_amt_idx NUMBER;
8592 l_accted_amt_idx NUMBER;
8593 l_acc_rev_flag VARCHAR2(1);
8594 l_accrual_line_num NUMBER;
8595 l_tmp_amt NUMBER;
8596 l_acc_rev_natural_side_code VARCHAR2(1);
8597
8598 l_num_entries NUMBER;
8599 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
8600 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
8601 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
8602 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
8603 l_recog_line_1 NUMBER;
8604 l_recog_line_2 NUMBER;
8605
8606 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
8607 l_bflow_applied_to_amt NUMBER; -- 5132302
8608 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
8609
8610 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
8611
8612 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
8616
8613 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
8614
8615 ---------------------------------------------------------------------------------------------------------------
8617
8618 --
8619 -- bulk performance
8620 --
8621 l_balance_type_code VARCHAR2(1);
8622 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
8623 l_log_module VARCHAR2(240);
8624
8625 --
8626 -- Upgrade strategy
8627 --
8628 l_actual_upg_option VARCHAR2(1);
8629 l_enc_upg_option VARCHAR2(1);
8630
8631 --
8632 BEGIN
8633 --
8634 IF g_log_enabled THEN
8635 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_30';
8636 END IF;
8637 --
8638 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8639
8640 trace
8641 (p_msg => 'BEGIN of AcctLineType_30'
8642 ,p_level => C_LEVEL_PROCEDURE
8643 ,p_module => l_log_module);
8644
8645 END IF;
8646 --
8647 l_component_type := 'AMB_JLT';
8648 l_component_code := 'CM_DEFAULT_TAX';
8649 l_component_type_code := 'S';
8650 l_component_appl_id := 222;
8651 l_amb_context_code := 'DEFAULT';
8652 l_entity_code := 'TRANSACTIONS';
8653 l_event_class_code := 'CREDIT_MEMO';
8654 l_event_type_code := 'CREDIT_MEMO_ALL';
8655 l_line_definition_owner_code := 'S';
8656 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
8657 --
8658 l_balance_type_code := 'A';
8659 l_segment := NULL;
8660 l_ccid := NULL;
8661 l_adr_transaction_coa_id := NULL;
8662 l_adr_accounting_coa_id := NULL;
8663 l_adr_flexfield_segment_code := NULL;
8664 l_adr_flex_value_set_id := NULL;
8665 l_adr_value_type_code := NULL;
8666 l_adr_value_combination_id := NULL;
8667 l_adr_value_segment_code := NULL;
8668
8669 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
8670 l_bflow_class_code := ''; -- 4219869 Business Flow
8671 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
8672 l_budgetary_control_flag := 'N';
8673
8674 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8675 l_bflow_applied_to_amt := NULL; -- 5132302
8676 l_entered_amt_idx := NULL; -- 4262811
8677 l_accted_amt_idx := NULL; -- 4262811
8678 l_acc_rev_flag := NULL; -- 4262811
8679 l_accrual_line_num := NULL; -- 4262811
8680 l_tmp_amt := NULL; -- 4262811
8681 --
8682
8683 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
8684 l_balance_type_code <> 'B' THEN
8685 IF NVL(p_source_48,'
8686 ') = 'TAX'
8687 THEN
8688
8689 --
8690 XLA_AE_LINES_PKG.SetNewLine;
8691
8692 p_balance_type_code := l_balance_type_code;
8693 -- set the flag so later we will know whether the gain loss line needs to be created
8694
8695 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
8696 p_actual_flag :='A';
8697 END IF;
8698
8699 --
8700 -- bulk performance
8701 --
8702 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
8703 p_header_num => 0); -- 4262811
8704 --
8705 -- set accounting line options
8706 --
8707 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
8708 p_natural_side_code => 'C'
8709 , p_gain_or_loss_flag => 'N'
8710 , p_gl_transfer_mode_code => 'S'
8711 , p_acct_entry_type_code => 'A'
8712 , p_switch_side_flag => 'Y'
8713 , p_merge_duplicate_code => 'A'
8714 );
8715 --
8716 l_acc_rev_natural_side_code := 'D'; -- 4262811
8717 --
8718 --
8719 -- set accounting line type info
8720 --
8721 xla_ae_lines_pkg.SetAcctLineType
8722 (p_component_type => l_component_type
8723 ,p_event_type_code => l_event_type_code
8724 ,p_line_definition_owner_code => l_line_definition_owner_code
8725 ,p_line_definition_code => l_line_definition_code
8726 ,p_accounting_line_code => l_component_code
8727 ,p_accounting_line_type_code => l_component_type_code
8728 ,p_accounting_line_appl_id => l_component_appl_id
8729 ,p_amb_context_code => l_amb_context_code
8730 ,p_entity_code => l_entity_code
8731 ,p_event_class_code => l_event_class_code);
8732 --
8733 -- set accounting class
8734 --
8735 xla_ae_lines_pkg.SetAcctClass(
8736 p_accounting_class_code => 'TAX'
8737 , p_ae_header_id => l_ae_header_id
8738 );
8739
8740 --
8741 -- set rounding class
8742 --
8743 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
8744 'RECEIVABLE';
8745
8746 --
8747 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
8748 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
8749 --
8750 -- bulk performance
8751 --
8752 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
8753
8757 -- 4955764
8754 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
8755 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
8756
8758 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8759 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
8760
8761 -- 4458381 Public Sector Enh
8762
8763 --
8764 -- set accounting attributes for the line type
8765 --
8766 l_entered_amt_idx := 3;
8767 l_accted_amt_idx := 9;
8768 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8769 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
8770 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_37);
8771 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
8772 l_rec_acct_attrs.array_char_value(2) := p_source_38;
8773 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
8774 l_rec_acct_attrs.array_num_value(3) := p_source_49;
8775 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
8776 l_rec_acct_attrs.array_char_value(4) := p_source_39;
8777 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
8778 l_rec_acct_attrs.array_date_value(5) := p_source_40;
8779 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
8780 l_rec_acct_attrs.array_num_value(6) := p_source_41;
8781 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
8782 l_rec_acct_attrs.array_char_value(7) := p_source_42;
8783 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
8784 l_rec_acct_attrs.array_char_value(8) := p_source_43;
8785 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
8786 l_rec_acct_attrs.array_num_value(9) := p_source_44;
8787 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
8788 l_rec_acct_attrs.array_num_value(10) := p_source_45;
8789 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
8790 l_rec_acct_attrs.array_num_value(11) := p_source_46;
8791 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
8792 l_rec_acct_attrs.array_char_value(12) := p_source_27;
8793 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
8794 l_rec_acct_attrs.array_num_value(13) := p_source_47;
8795
8796 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
8797 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
8798
8799 ---------------------------------------------------------------------------------------------------------------
8800 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
8801 ---------------------------------------------------------------------------------------------------------------
8802 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
8803
8804 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8805 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8806
8807 IF xla_accounting_cache_pkg.GetValueChar
8808 (p_source_code => 'LEDGER_CATEGORY_CODE'
8809 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
8810 AND l_bflow_method_code = 'PRIOR_ENTRY'
8811 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
8812 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
8813 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
8814 )
8815 THEN
8816 xla_ae_lines_pkg.BflowUpgEntry
8817 (p_business_method_code => l_bflow_method_code
8818 ,p_business_class_code => l_bflow_class_code
8819 ,p_balance_type => l_balance_type_code);
8820 ELSE
8821 NULL;
8822 -- No business flow processing for business flow method of NONE.
8823 END IF;
8824
8825 --
8826 -- call analytical criteria
8827 --
8828
8829 --
8830 -- call description
8831 --
8832 -- No description or it is inherited.
8833 --
8834 -- call ADRs
8835 -- Bug 4922099
8836 --
8837 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8838 (NVL(l_actual_upg_option, 'N') = 'O') OR
8839 (NVL(l_enc_upg_option, 'N') = 'O')
8840 )
8841 THEN
8842 NULL;
8843 --
8844 --
8845
8846 l_ccid := AcctDerRule_10(
8847 p_application_id => p_application_id
8848 , p_ae_header_id => l_ae_header_id
8849 , p_source_9 => p_source_9
8850 , x_transaction_coa_id => l_adr_transaction_coa_id
8851 , x_accounting_coa_id => l_adr_accounting_coa_id
8852 , x_value_type_code => l_adr_value_type_code
8853 , p_side => 'NA'
8854 );
8855
8856 xla_ae_lines_pkg.set_ccid(
8857 p_code_combination_id => l_ccid
8858 , p_value_type_code => l_adr_value_type_code
8859 , p_transaction_coa_id => l_adr_transaction_coa_id
8860 , p_accounting_coa_id => l_adr_accounting_coa_id
8861 , p_adr_code => 'CM_DIST_CCID'
8862 , p_adr_type_code => 'S'
8863 , p_component_type => l_component_type
8864 , p_component_code => l_component_code
8865 , p_component_type_code => l_component_type_code
8866 , p_component_appl_id => l_component_appl_id
8867 , p_amb_context_code => l_amb_context_code
8868 , p_side => 'NA'
8869 );
8870
8871
8872 --
8873 --
8874 END IF;
8875 --
8876 -- Bug 4922099
8877 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
8878 (NVL(l_enc_upg_option, 'N') = 'O')
8879 ) AND
8880 (l_bflow_method_code = 'PRIOR_ENTRY')
8881 )
8882 THEN
8883 IF
8884 --
8885 1 = 2
8886 --
8887 THEN
8888 xla_accounting_err_pkg.build_message
8889 (p_appli_s_name => 'XLA'
8890 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8891 ,p_token_1 => 'LINE_NUMBER'
8892 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
8893 ,p_token_2 => 'LINE_TYPE_NAME'
8894 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
8895 l_component_type
8896 ,l_component_code
8897 ,l_component_type_code
8898 ,l_component_appl_id
8899 ,l_amb_context_code
8900 ,l_entity_code
8901 ,l_event_class_code
8902 )
8903 ,p_token_3 => 'OWNER'
8904 ,p_value_3 => xla_lookups_pkg.get_meaning(
8905 p_lookup_type => 'XLA_OWNER_TYPE'
8906 ,p_lookup_code => l_component_type_code
8907 )
8908 ,p_token_4 => 'PRODUCT_NAME'
8909 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
8910 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
8911 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
8912 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
8913 ,p_ae_header_id => NULL
8914 );
8915
8916 IF (C_LEVEL_ERROR>= g_log_level) THEN
8917 trace
8918 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8919 ,p_level => C_LEVEL_ERROR
8920 ,p_module => l_log_module);
8921 END IF;
8922 END IF;
8923 END IF;
8924 --
8925 --
8926 ------------------------------------------------------------------------------------------------
8927 -- 4219869 Business Flow
8928 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
8929 -- Prior Entry. Currently, the following code is always generated.
8930 ------------------------------------------------------------------------------------------------
8931 XLA_AE_LINES_PKG.ValidateCurrentLine;
8932
8933 ------------------------------------------------------------------------------------
8934 -- 4219869 Business Flow
8935 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
8936 ------------------------------------------------------------------------------------
8937 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8938
8939 ----------------------------------------------------------------------------------
8940 -- 4219869 Business Flow
8941 -- Update journal entry status -- Need to generate this within IF <condition>
8942 ----------------------------------------------------------------------------------
8943 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8944 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
8945 ,p_balance_type_code => l_balance_type_code
8946 );
8947
8948 -------------------------------------------------------------------------------------------
8949 -- 4262811 - Generate the Accrual Reversal lines
8950 -------------------------------------------------------------------------------------------
8951 BEGIN
8952 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
8953 (g_array_event(p_event_id).array_value_num('header_index'));
8954 IF l_acc_rev_flag IS NULL THEN
8955 l_acc_rev_flag := 'N';
8956 END IF;
8957 EXCEPTION
8958 WHEN OTHERS THEN
8959 l_acc_rev_flag := 'N';
8960 END;
8961 --
8962 IF (l_acc_rev_flag = 'Y') THEN
8963
8964 -- 4645092 ------------------------------------------------------------------------------
8965 -- To allow MPA report to determine if it should generate report process
8966 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
8967 ------------------------------------------------------------------------------------------
8968
8969 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
8970 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
8971 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
8972 -- call ADRs
8973 -- Bug 4922099
8974 --
8975 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8976 (NVL(l_actual_upg_option, 'N') = 'O') OR
8977 (NVL(l_enc_upg_option, 'N') = 'O')
8978 )
8979 THEN
8980 NULL;
8981 --
8982 --
8983
8984 l_ccid := AcctDerRule_10(
8985 p_application_id => p_application_id
8986 , p_ae_header_id => l_ae_header_id
8987 , p_source_9 => p_source_9
8988 , x_transaction_coa_id => l_adr_transaction_coa_id
8989 , x_accounting_coa_id => l_adr_accounting_coa_id
8990 , x_value_type_code => l_adr_value_type_code
8991 , p_side => 'NA'
8992 );
8993
8994 xla_ae_lines_pkg.set_ccid(
8995 p_code_combination_id => l_ccid
8996 , p_value_type_code => l_adr_value_type_code
8997 , p_transaction_coa_id => l_adr_transaction_coa_id
8998 , p_accounting_coa_id => l_adr_accounting_coa_id
8999 , p_adr_code => 'CM_DIST_CCID'
9000 , p_adr_type_code => 'S'
9001 , p_component_type => l_component_type
9002 , p_component_code => l_component_code
9003 , p_component_type_code => l_component_type_code
9004 , p_component_appl_id => l_component_appl_id
9005 , p_amb_context_code => l_amb_context_code
9006 , p_side => 'NA'
9007 );
9008
9009
9010 --
9011 --
9012 END IF;
9013
9014 --
9015 -- Update the line information that should be overwritten
9016 --
9017 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
9018 p_header_num => 1);
9019 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
9020
9021 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
9022
9023 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
9024 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
9025 END IF;
9026
9027 --
9028 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
9029 --
9030 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
9031 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
9032 ELSE
9033 ---------------------------------------------------------------------------------------------------
9034 -- 4262811a Switch Sign
9035 ---------------------------------------------------------------------------------------------------
9036 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
9037 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9038 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9039 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9040 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9041 -- 5132302
9042 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
9043 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9044
9045 END IF;
9046
9047 -- 4955764
9048 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9052 XLA_AE_LINES_PKG.ValidateCurrentLine;
9049 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
9050
9051
9053 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9054
9055 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9056 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
9057 ,p_balance_type_code => l_balance_type_code);
9058
9059 END IF;
9060
9061 -----------------------------------------------------------------------------------------
9062 -- 4262811 Multiperiod Accounting
9063 -----------------------------------------------------------------------------------------
9064 -- No MPA option is assigned.
9065
9066
9067 END IF;
9068 END IF;
9069 --
9070
9071 --
9072 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9073 trace
9074 (p_msg => 'END of AcctLineType_30'
9075 ,p_level => C_LEVEL_PROCEDURE
9076 ,p_module => l_log_module);
9077 END IF;
9078 --
9079 EXCEPTION
9080 WHEN xla_exceptions_pkg.application_exception THEN
9081 RAISE;
9082 WHEN OTHERS THEN
9083 xla_exceptions_pkg.raise_message
9084 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_30');
9085 END AcctLineType_30;
9086 --
9087
9088 ---------------------------------------
9089 --
9090 -- PRIVATE FUNCTION
9091 -- AcctLineType_31
9092 --
9093 ---------------------------------------
9094 PROCEDURE AcctLineType_31 (
9095 p_application_id IN NUMBER
9096 ,p_event_id IN NUMBER
9097 ,p_calculate_acctd_flag IN VARCHAR2
9098 ,p_calculate_g_l_flag IN VARCHAR2
9099 ,p_actual_flag IN OUT VARCHAR2
9100 ,p_balance_type_code OUT VARCHAR2
9101 ,p_gain_or_loss_ref OUT VARCHAR2
9102
9103 --System Gain Account
9104 , p_source_12 IN NUMBER
9105 --System Loss Account
9106 , p_source_13 IN NUMBER
9107 --SLA Party Type
9108 , p_source_27 IN VARCHAR2
9109 --Credit Memo Distribution Identifier
9110 , p_source_37 IN NUMBER
9111 --Credit memo distributions type
9112 , p_source_38 IN VARCHAR2
9113 --Gain Loss Reference
9114 , p_source_43 IN VARCHAR2
9115 --Credit Memo Accounting Amount
9116 , p_source_44 IN NUMBER
9117 --Credit Memo Bill To Customer Account Identifier
9118 , p_source_45 IN NUMBER
9119 --Credit Memo Bill To Customer Site Use Identifier
9120 , p_source_46 IN NUMBER
9121 --Credit Memo Tax Line Identifier
9122 , p_source_47 IN NUMBER
9123 )
9124 IS
9125
9126 l_component_type VARCHAR2(80);
9127 l_component_code VARCHAR2(30);
9128 l_component_type_code VARCHAR2(1);
9129 l_component_appl_id INTEGER;
9130 l_amb_context_code VARCHAR2(30);
9131 l_entity_code VARCHAR2(30);
9132 l_event_class_code VARCHAR2(30);
9133 l_ae_header_id NUMBER;
9134 l_event_type_code VARCHAR2(30);
9135 l_line_definition_code VARCHAR2(30);
9136 l_line_definition_owner_code VARCHAR2(1);
9137 --
9138 -- adr variables
9139 l_segment VARCHAR2(30);
9140 l_ccid NUMBER;
9141 l_adr_transaction_coa_id NUMBER;
9142 l_adr_accounting_coa_id NUMBER;
9143 l_adr_flexfield_segment_code VARCHAR2(30);
9144 l_adr_flex_value_set_id NUMBER;
9145 l_adr_value_type_code VARCHAR2(30);
9146 l_adr_value_combination_id NUMBER;
9147 l_adr_value_segment_code VARCHAR2(30);
9148
9149 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
9150 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
9151 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
9152 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
9153
9154 -- 4262811 Variables ------------------------------------------------------------------------------------------
9155 l_entered_amt_idx NUMBER;
9156 l_accted_amt_idx NUMBER;
9157 l_acc_rev_flag VARCHAR2(1);
9158 l_accrual_line_num NUMBER;
9159 l_tmp_amt NUMBER;
9160 l_acc_rev_natural_side_code VARCHAR2(1);
9161
9162 l_num_entries NUMBER;
9163 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
9164 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
9165 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
9166 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
9167 l_recog_line_1 NUMBER;
9168 l_recog_line_2 NUMBER;
9169
9170 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
9171 l_bflow_applied_to_amt NUMBER; -- 5132302
9172 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
9173
9174 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
9175
9176 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
9177 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
9178
9179 ---------------------------------------------------------------------------------------------------------------
9180
9181
9182 --
9183 -- bulk performance
9184 --
9185 l_balance_type_code VARCHAR2(1);
9186 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
9187 l_log_module VARCHAR2(240);
9188
9189 --
9190 -- Upgrade strategy
9191 --
9192 l_actual_upg_option VARCHAR2(1);
9193 l_enc_upg_option VARCHAR2(1);
9194
9195 --
9196 BEGIN
9197 --
9198 IF g_log_enabled THEN
9199 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_31';
9200 END IF;
9201 --
9202 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9203
9204 trace
9205 (p_msg => 'BEGIN of AcctLineType_31'
9206 ,p_level => C_LEVEL_PROCEDURE
9207 ,p_module => l_log_module);
9208
9209 END IF;
9210 --
9211 l_component_type := 'AMB_JLT';
9212 l_component_code := 'CM_EXCH_GAIN_LOSS';
9213 l_component_type_code := 'S';
9214 l_component_appl_id := 222;
9215 l_amb_context_code := 'DEFAULT';
9216 l_entity_code := 'TRANSACTIONS';
9217 l_event_class_code := 'CREDIT_MEMO';
9218 l_event_type_code := 'CREDIT_MEMO_ALL';
9219 l_line_definition_owner_code := 'S';
9220 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
9221 --
9222 l_balance_type_code := 'A';
9223 l_segment := NULL;
9224 l_ccid := NULL;
9225 l_adr_transaction_coa_id := NULL;
9226 l_adr_accounting_coa_id := NULL;
9227 l_adr_flexfield_segment_code := NULL;
9228 l_adr_flex_value_set_id := NULL;
9229 l_adr_value_type_code := NULL;
9230 l_adr_value_combination_id := NULL;
9231 l_adr_value_segment_code := NULL;
9232
9233 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
9234 l_bflow_class_code := ''; -- 4219869 Business Flow
9235 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
9236 l_budgetary_control_flag := 'N';
9237
9238 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9239 l_bflow_applied_to_amt := NULL; -- 5132302
9240 l_entered_amt_idx := NULL; -- 4262811
9241 l_accted_amt_idx := NULL; -- 4262811
9242 l_acc_rev_flag := NULL; -- 4262811
9243 l_accrual_line_num := NULL; -- 4262811
9244 l_tmp_amt := NULL; -- 4262811
9245 --
9246 IF NOT ((p_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
9247 (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
9248 return;
9249 END IF;
9250
9251 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
9252 l_balance_type_code <> 'B' THEN
9253
9254 --
9255 XLA_AE_LINES_PKG.SetNewLine;
9256
9257 p_balance_type_code := l_balance_type_code;
9258 -- set the flag so later we will know whether the gain loss line needs to be created
9259
9260 IF(l_balance_type_code = 'A' ) THEN
9261 p_actual_flag :='G';
9262 END IF;
9263
9264 --
9265 -- bulk performance
9266 --
9267 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
9268 p_header_num => 0); -- 4262811
9269 --
9270 -- set accounting line options
9271 --
9272 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
9273 p_natural_side_code => 'G'
9274 , p_gain_or_loss_flag => 'N'
9275 , p_gl_transfer_mode_code => 'S'
9276 , p_acct_entry_type_code => 'A'
9277 , p_switch_side_flag => ''
9278 , p_merge_duplicate_code => 'A'
9279 );
9280 --
9281 l_acc_rev_natural_side_code := 'C'; -- 4262811
9282 --
9283 --
9284 -- set accounting line type info
9285 --
9286 xla_ae_lines_pkg.SetAcctLineType
9287 (p_component_type => l_component_type
9288 ,p_event_type_code => l_event_type_code
9289 ,p_line_definition_owner_code => l_line_definition_owner_code
9290 ,p_line_definition_code => l_line_definition_code
9291 ,p_accounting_line_code => l_component_code
9292 ,p_accounting_line_type_code => l_component_type_code
9293 ,p_accounting_line_appl_id => l_component_appl_id
9294 ,p_amb_context_code => l_amb_context_code
9295 ,p_entity_code => l_entity_code
9296 ,p_event_class_code => l_event_class_code);
9297 --
9298 -- set accounting class
9299 --
9300 xla_ae_lines_pkg.SetAcctClass(
9301 p_accounting_class_code => 'EXCHANGE_GAIN_LOSS'
9302 , p_ae_header_id => l_ae_header_id
9303 );
9304
9305 --
9306 -- set rounding class
9307 --
9308 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
9309 'EXCHANGE_GAIN_LOSS';
9310
9311 --
9312 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
9313 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
9314 --
9315 -- bulk performance
9316 --
9317 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
9318
9319 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
9320 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
9321
9322 -- 4955764
9323 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9324 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
9325
9326 -- 4458381 Public Sector Enh
9327
9328 --
9329 -- set accounting attributes for the line type
9330 --
9331 l_entered_amt_idx := NULL;
9332 l_accted_amt_idx := 4;
9333 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9334 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
9335 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_37);
9336 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
9337 l_rec_acct_attrs.array_char_value(2) := p_source_38;
9338 l_rec_acct_attrs.array_acct_attr_code(3) := 'GAIN_LOSS_REFERENCE';
9339 l_rec_acct_attrs.array_char_value(3) := p_source_43;
9340 l_rec_acct_attrs.array_acct_attr_code(4) := 'LEDGER_AMOUNT';
9341 l_rec_acct_attrs.array_num_value(4) := p_source_44;
9342 l_rec_acct_attrs.array_acct_attr_code(5) := 'PARTY_ID';
9343 l_rec_acct_attrs.array_num_value(5) := p_source_45;
9344 l_rec_acct_attrs.array_acct_attr_code(6) := 'PARTY_SITE_ID';
9345 l_rec_acct_attrs.array_num_value(6) := p_source_46;
9346 l_rec_acct_attrs.array_acct_attr_code(7) := 'PARTY_TYPE';
9347 l_rec_acct_attrs.array_char_value(7) := p_source_27;
9348 l_rec_acct_attrs.array_acct_attr_code(8) := 'TAX_LINE_REF_ID';
9349 l_rec_acct_attrs.array_num_value(8) := p_source_47;
9350
9351 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
9352 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
9353
9354 ---------------------------------------------------------------------------------------------------------------
9355 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
9356 ---------------------------------------------------------------------------------------------------------------
9357 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
9358
9359 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9360 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9361
9362 IF xla_accounting_cache_pkg.GetValueChar
9363 (p_source_code => 'LEDGER_CATEGORY_CODE'
9364 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
9365 AND l_bflow_method_code = 'PRIOR_ENTRY'
9366 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
9367 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
9368 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
9369 )
9370 THEN
9371 xla_ae_lines_pkg.BflowUpgEntry
9372 (p_business_method_code => l_bflow_method_code
9373 ,p_business_class_code => l_bflow_class_code
9374 ,p_balance_type => l_balance_type_code);
9375 ELSE
9376 NULL;
9377 -- No business flow processing for business flow method of NONE.
9378 END IF;
9379
9380 --
9381 -- call analytical criteria
9382 --
9383
9384 --
9385 -- call description
9386 --
9387 -- No description or it is inherited.
9388 --
9389 -- call ADRs
9390 -- Bug 4922099
9391 --
9392 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9393 (NVL(l_actual_upg_option, 'N') = 'O') OR
9394 (NVL(l_enc_upg_option, 'N') = 'O')
9395 )
9396 THEN
9397 NULL;
9398 --
9399 --
9400
9401 l_ccid := AcctDerRule_16(
9402 p_application_id => p_application_id
9403 , p_ae_header_id => l_ae_header_id
9404 , p_source_12 => p_source_12
9405 , x_transaction_coa_id => l_adr_transaction_coa_id
9406 , x_accounting_coa_id => l_adr_accounting_coa_id
9407 , x_value_type_code => l_adr_value_type_code
9408 , p_side => 'CREDIT'
9409 );
9410
9411 xla_ae_lines_pkg.set_ccid(
9412 p_code_combination_id => l_ccid
9413 , p_value_type_code => l_adr_value_type_code
9414 , p_transaction_coa_id => l_adr_transaction_coa_id
9415 , p_accounting_coa_id => l_adr_accounting_coa_id
9416 , p_adr_code => 'SYS_GAIN_CCID'
9417 , p_adr_type_code => 'S'
9418 , p_component_type => l_component_type
9419 , p_component_code => l_component_code
9420 , p_component_type_code => l_component_type_code
9421 , p_component_appl_id => l_component_appl_id
9422 , p_amb_context_code => l_amb_context_code
9423 , p_side => 'CREDIT'
9424 );
9425
9426
9427 l_ccid := AcctDerRule_17(
9428 p_application_id => p_application_id
9429 , p_ae_header_id => l_ae_header_id
9430 , p_source_13 => p_source_13
9431 , x_transaction_coa_id => l_adr_transaction_coa_id
9432 , x_accounting_coa_id => l_adr_accounting_coa_id
9433 , x_value_type_code => l_adr_value_type_code
9434 , p_side => 'DEBIT'
9435 );
9436
9437 xla_ae_lines_pkg.set_ccid(
9438 p_code_combination_id => l_ccid
9439 , p_value_type_code => l_adr_value_type_code
9440 , p_transaction_coa_id => l_adr_transaction_coa_id
9441 , p_accounting_coa_id => l_adr_accounting_coa_id
9442 , p_adr_code => 'SYS_LOSS_CCID'
9443 , p_adr_type_code => 'S'
9444 , p_component_type => l_component_type
9445 , p_component_code => l_component_code
9446 , p_component_type_code => l_component_type_code
9447 , p_component_appl_id => l_component_appl_id
9448 , p_amb_context_code => l_amb_context_code
9449 , p_side => 'DEBIT'
9450 );
9451
9452
9453 --
9454 --
9455 END IF;
9456 --
9457 -- Bug 4922099
9458 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
9459 (NVL(l_enc_upg_option, 'N') = 'O')
9460 ) AND
9461 (l_bflow_method_code = 'PRIOR_ENTRY')
9462 )
9463 THEN
9464 IF
9465 --
9466 1 = 2
9467 --
9468 THEN
9469 xla_accounting_err_pkg.build_message
9470 (p_appli_s_name => 'XLA'
9471 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9472 ,p_token_1 => 'LINE_NUMBER'
9473 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
9474 ,p_token_2 => 'LINE_TYPE_NAME'
9475 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
9476 l_component_type
9477 ,l_component_code
9478 ,l_component_type_code
9479 ,l_component_appl_id
9480 ,l_amb_context_code
9481 ,l_entity_code
9482 ,l_event_class_code
9483 )
9484 ,p_token_3 => 'OWNER'
9485 ,p_value_3 => xla_lookups_pkg.get_meaning(
9486 p_lookup_type => 'XLA_OWNER_TYPE'
9487 ,p_lookup_code => l_component_type_code
9488 )
9489 ,p_token_4 => 'PRODUCT_NAME'
9490 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
9491 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
9492 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
9493 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
9494 ,p_ae_header_id => NULL
9495 );
9496
9497 IF (C_LEVEL_ERROR>= g_log_level) THEN
9498 trace
9499 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9500 ,p_level => C_LEVEL_ERROR
9501 ,p_module => l_log_module);
9502 END IF;
9503 END IF;
9504 END IF;
9505 --
9506 --
9507 ------------------------------------------------------------------------------------------------
9508 -- 4219869 Business Flow
9509 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
9510 -- Prior Entry. Currently, the following code is always generated.
9511 ------------------------------------------------------------------------------------------------
9512 XLA_AE_LINES_PKG.ValidateCurrentLine;
9513
9514 ------------------------------------------------------------------------------------
9515 -- 4219869 Business Flow
9516 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
9517 ------------------------------------------------------------------------------------
9518 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9519
9520 ----------------------------------------------------------------------------------
9521 -- 4219869 Business Flow
9522 -- Update journal entry status -- Need to generate this within IF <condition>
9523 ----------------------------------------------------------------------------------
9524 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9525 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
9526 ,p_balance_type_code => l_balance_type_code
9527 );
9528
9529 -------------------------------------------------------------------------------------------
9530 -- 4262811 - Generate the Accrual Reversal lines
9531 -------------------------------------------------------------------------------------------
9532 BEGIN
9533 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
9534 (g_array_event(p_event_id).array_value_num('header_index'));
9535 IF l_acc_rev_flag IS NULL THEN
9536 l_acc_rev_flag := 'N';
9537 END IF;
9538 EXCEPTION
9539 WHEN OTHERS THEN
9540 l_acc_rev_flag := 'N';
9541 END;
9542 --
9543 IF (l_acc_rev_flag = 'Y') THEN
9544
9545 -- 4645092 ------------------------------------------------------------------------------
9546 -- To allow MPA report to determine if it should generate report process
9547 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
9548 ------------------------------------------------------------------------------------------
9549
9550 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
9551 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
9552 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
9553 -- call ADRs
9554 -- Bug 4922099
9555 --
9556 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9557 (NVL(l_actual_upg_option, 'N') = 'O') OR
9558 (NVL(l_enc_upg_option, 'N') = 'O')
9559 )
9560 THEN
9561 NULL;
9562 --
9563 --
9564
9565 l_ccid := AcctDerRule_16(
9566 p_application_id => p_application_id
9567 , p_ae_header_id => l_ae_header_id
9568 , p_source_12 => p_source_12
9569 , x_transaction_coa_id => l_adr_transaction_coa_id
9570 , x_accounting_coa_id => l_adr_accounting_coa_id
9571 , x_value_type_code => l_adr_value_type_code
9572 , p_side => 'CREDIT'
9573 );
9574
9575 xla_ae_lines_pkg.set_ccid(
9576 p_code_combination_id => l_ccid
9577 , p_value_type_code => l_adr_value_type_code
9578 , p_transaction_coa_id => l_adr_transaction_coa_id
9579 , p_accounting_coa_id => l_adr_accounting_coa_id
9580 , p_adr_code => 'SYS_GAIN_CCID'
9581 , p_adr_type_code => 'S'
9582 , p_component_type => l_component_type
9583 , p_component_code => l_component_code
9584 , p_component_type_code => l_component_type_code
9585 , p_component_appl_id => l_component_appl_id
9586 , p_amb_context_code => l_amb_context_code
9587 , p_side => 'CREDIT'
9588 );
9589
9590
9591 l_ccid := AcctDerRule_17(
9592 p_application_id => p_application_id
9593 , p_ae_header_id => l_ae_header_id
9594 , p_source_13 => p_source_13
9595 , x_transaction_coa_id => l_adr_transaction_coa_id
9596 , x_accounting_coa_id => l_adr_accounting_coa_id
9597 , x_value_type_code => l_adr_value_type_code
9598 , p_side => 'DEBIT'
9599 );
9600
9601 xla_ae_lines_pkg.set_ccid(
9602 p_code_combination_id => l_ccid
9603 , p_value_type_code => l_adr_value_type_code
9604 , p_transaction_coa_id => l_adr_transaction_coa_id
9605 , p_accounting_coa_id => l_adr_accounting_coa_id
9606 , p_adr_code => 'SYS_LOSS_CCID'
9607 , p_adr_type_code => 'S'
9608 , p_component_type => l_component_type
9609 , p_component_code => l_component_code
9610 , p_component_type_code => l_component_type_code
9611 , p_component_appl_id => l_component_appl_id
9612 , p_amb_context_code => l_amb_context_code
9613 , p_side => 'DEBIT'
9614 );
9615
9616
9617 --
9618 --
9619 END IF;
9620
9621 --
9622 -- Update the line information that should be overwritten
9623 --
9624 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
9625 p_header_num => 1);
9626 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
9627
9628 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
9629
9630 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
9631 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
9632 END IF;
9633
9634 --
9635 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
9636 --
9637 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
9638 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
9639 ELSE
9640 ---------------------------------------------------------------------------------------------------
9641 -- 4262811a Switch Sign
9642 ---------------------------------------------------------------------------------------------------
9643 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
9644 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9645 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9646 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9647 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9648 -- 5132302
9649 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
9650 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9651
9652 END IF;
9653
9654 -- 4955764
9655 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9656 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
9657
9658
9659 XLA_AE_LINES_PKG.ValidateCurrentLine;
9660 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9661
9662 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9663 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
9664 ,p_balance_type_code => l_balance_type_code);
9665
9666 END IF;
9667
9668 -----------------------------------------------------------------------------------------
9669 -- 4262811 Multiperiod Accounting
9670 -----------------------------------------------------------------------------------------
9671 -- No MPA option is assigned.
9672
9673
9674 END IF;
9675 --
9676
9677 --
9678 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9679 trace
9680 (p_msg => 'END of AcctLineType_31'
9681 ,p_level => C_LEVEL_PROCEDURE
9682 ,p_module => l_log_module);
9683 END IF;
9684 --
9685 EXCEPTION
9686 WHEN xla_exceptions_pkg.application_exception THEN
9687 RAISE;
9688 WHEN OTHERS THEN
9689 xla_exceptions_pkg.raise_message
9690 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_31');
9691 END AcctLineType_31;
9692 --
9693
9694 ---------------------------------------
9695 --
9696 -- PRIVATE FUNCTION
9697 -- AcctLineType_32
9698 --
9699 ---------------------------------------
9700 PROCEDURE AcctLineType_32 (
9701 p_application_id IN NUMBER
9702 ,p_event_id IN NUMBER
9703 ,p_calculate_acctd_flag IN VARCHAR2
9704 ,p_calculate_g_l_flag IN VARCHAR2
9705 ,p_actual_flag IN OUT VARCHAR2
9706 ,p_balance_type_code OUT VARCHAR2
9707 ,p_gain_or_loss_ref OUT VARCHAR2
9708
9709 --Credit Memo Distribution GL Account
9710 , p_source_9 IN NUMBER
9711 --SLA Party Type
9712 , p_source_27 IN VARCHAR2
9713 --Credit Memo Distribution Identifier
9714 , p_source_37 IN NUMBER
9715 --Credit memo distributions type
9716 , p_source_38 IN VARCHAR2
9717 --Credit Memo Currency Code
9718 , p_source_39 IN VARCHAR2
9719 --Credit Memo Exchange Date
9720 , p_source_40 IN DATE
9721 --Credit Memo Exchange Rate
9722 , p_source_41 IN NUMBER
9723 --Credit Memo Exchange Rate Type
9724 , p_source_42 IN VARCHAR2
9725 --Gain Loss Reference
9726 , p_source_43 IN VARCHAR2
9727 --Credit Memo Accounting Amount
9728 , p_source_44 IN NUMBER
9729 --Credit Memo Bill To Customer Account Identifier
9730 , p_source_45 IN NUMBER
9731 --Credit Memo Bill To Customer Site Use Identifier
9732 , p_source_46 IN NUMBER
9733 --Credit Memo Tax Line Identifier
9734 , p_source_47 IN NUMBER
9735 --Credit Memo Distribution Account Class
9736 , p_source_48 IN VARCHAR2
9737 --Credit Memo Distribution Entered Amount
9738 , p_source_49 IN NUMBER
9739 )
9740 IS
9741
9742 l_component_type VARCHAR2(80);
9743 l_component_code VARCHAR2(30);
9744 l_component_type_code VARCHAR2(1);
9745 l_component_appl_id INTEGER;
9746 l_amb_context_code VARCHAR2(30);
9747 l_entity_code VARCHAR2(30);
9748 l_event_class_code VARCHAR2(30);
9749 l_ae_header_id NUMBER;
9750 l_event_type_code VARCHAR2(30);
9751 l_line_definition_code VARCHAR2(30);
9752 l_line_definition_owner_code VARCHAR2(1);
9753 --
9754 -- adr variables
9755 l_segment VARCHAR2(30);
9756 l_ccid NUMBER;
9757 l_adr_transaction_coa_id NUMBER;
9758 l_adr_accounting_coa_id NUMBER;
9759 l_adr_flexfield_segment_code VARCHAR2(30);
9760 l_adr_flex_value_set_id NUMBER;
9761 l_adr_value_type_code VARCHAR2(30);
9762 l_adr_value_combination_id NUMBER;
9763 l_adr_value_segment_code VARCHAR2(30);
9764
9765 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
9766 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
9767 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
9768 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
9769
9770 -- 4262811 Variables ------------------------------------------------------------------------------------------
9771 l_entered_amt_idx NUMBER;
9772 l_accted_amt_idx NUMBER;
9773 l_acc_rev_flag VARCHAR2(1);
9774 l_accrual_line_num NUMBER;
9775 l_tmp_amt NUMBER;
9776 l_acc_rev_natural_side_code VARCHAR2(1);
9777
9778 l_num_entries NUMBER;
9779 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
9780 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
9781 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
9782 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
9783 l_recog_line_1 NUMBER;
9784 l_recog_line_2 NUMBER;
9785
9786 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
9787 l_bflow_applied_to_amt NUMBER; -- 5132302
9788 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
9789
9790 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
9791
9792 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
9793 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
9794
9795 ---------------------------------------------------------------------------------------------------------------
9796
9797
9798 --
9799 -- bulk performance
9800 --
9801 l_balance_type_code VARCHAR2(1);
9802 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
9803 l_log_module VARCHAR2(240);
9804
9805 --
9806 -- Upgrade strategy
9807 --
9808 l_actual_upg_option VARCHAR2(1);
9809 l_enc_upg_option VARCHAR2(1);
9810
9811 --
9812 BEGIN
9813 --
9814 IF g_log_enabled THEN
9815 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_32';
9816 END IF;
9817 --
9818 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9819
9820 trace
9821 (p_msg => 'BEGIN of AcctLineType_32'
9822 ,p_level => C_LEVEL_PROCEDURE
9823 ,p_module => l_log_module);
9824
9825 END IF;
9826 --
9830 l_component_appl_id := 222;
9827 l_component_type := 'AMB_JLT';
9828 l_component_code := 'CM_ROUND';
9829 l_component_type_code := 'S';
9831 l_amb_context_code := 'DEFAULT';
9832 l_entity_code := 'TRANSACTIONS';
9833 l_event_class_code := 'CREDIT_MEMO';
9834 l_event_type_code := 'CREDIT_MEMO_ALL';
9835 l_line_definition_owner_code := 'S';
9836 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
9837 --
9838 l_balance_type_code := 'A';
9839 l_segment := NULL;
9840 l_ccid := NULL;
9841 l_adr_transaction_coa_id := NULL;
9842 l_adr_accounting_coa_id := NULL;
9843 l_adr_flexfield_segment_code := NULL;
9844 l_adr_flex_value_set_id := NULL;
9845 l_adr_value_type_code := NULL;
9846 l_adr_value_combination_id := NULL;
9847 l_adr_value_segment_code := NULL;
9848
9849 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
9850 l_bflow_class_code := ''; -- 4219869 Business Flow
9851 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
9852 l_budgetary_control_flag := 'N';
9853
9854 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9855 l_bflow_applied_to_amt := NULL; -- 5132302
9856 l_entered_amt_idx := NULL; -- 4262811
9857 l_accted_amt_idx := NULL; -- 4262811
9858 l_acc_rev_flag := NULL; -- 4262811
9859 l_accrual_line_num := NULL; -- 4262811
9860 l_tmp_amt := NULL; -- 4262811
9861 --
9862
9863 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
9864 l_balance_type_code <> 'B' THEN
9865 IF NVL(p_source_48,'
9866 ') = 'ROUND'
9867 THEN
9868
9869 --
9870 XLA_AE_LINES_PKG.SetNewLine;
9871
9872 p_balance_type_code := l_balance_type_code;
9873 -- set the flag so later we will know whether the gain loss line needs to be created
9874
9875 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
9876 p_actual_flag :='A';
9877 END IF;
9878
9879 --
9880 -- bulk performance
9881 --
9882 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
9883 p_header_num => 0); -- 4262811
9884 --
9885 -- set accounting line options
9886 --
9887 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
9888 p_natural_side_code => 'C'
9889 , p_gain_or_loss_flag => 'N'
9890 , p_gl_transfer_mode_code => 'S'
9891 , p_acct_entry_type_code => 'A'
9892 , p_switch_side_flag => 'Y'
9893 , p_merge_duplicate_code => 'A'
9894 );
9895 --
9896 l_acc_rev_natural_side_code := 'D'; -- 4262811
9897 --
9898 --
9899 -- set accounting line type info
9900 --
9901 xla_ae_lines_pkg.SetAcctLineType
9902 (p_component_type => l_component_type
9903 ,p_event_type_code => l_event_type_code
9904 ,p_line_definition_owner_code => l_line_definition_owner_code
9905 ,p_line_definition_code => l_line_definition_code
9906 ,p_accounting_line_code => l_component_code
9907 ,p_accounting_line_type_code => l_component_type_code
9908 ,p_accounting_line_appl_id => l_component_appl_id
9909 ,p_amb_context_code => l_amb_context_code
9910 ,p_entity_code => l_entity_code
9911 ,p_event_class_code => l_event_class_code);
9912 --
9913 -- set accounting class
9914 --
9915 xla_ae_lines_pkg.SetAcctClass(
9916 p_accounting_class_code => 'ROUNDING'
9917 , p_ae_header_id => l_ae_header_id
9918 );
9919
9920 --
9921 -- set rounding class
9922 --
9923 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
9924 'RECEIVABLE';
9925
9926 --
9927 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
9928 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
9929 --
9930 -- bulk performance
9931 --
9932 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
9933
9934 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
9935 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
9936
9937 -- 4955764
9938 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9939 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
9940
9941 -- 4458381 Public Sector Enh
9942
9943 --
9944 -- set accounting attributes for the line type
9945 --
9946 l_entered_amt_idx := 3;
9947 l_accted_amt_idx := 9;
9948 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9949 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
9950 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_37);
9951 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
9952 l_rec_acct_attrs.array_char_value(2) := p_source_38;
9953 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
9954 l_rec_acct_attrs.array_num_value(3) := p_source_49;
9955 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
9956 l_rec_acct_attrs.array_char_value(4) := p_source_39;
9957 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
9958 l_rec_acct_attrs.array_date_value(5) := p_source_40;
9959 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
9960 l_rec_acct_attrs.array_num_value(6) := p_source_41;
9961 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
9962 l_rec_acct_attrs.array_char_value(7) := p_source_42;
9963 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
9964 l_rec_acct_attrs.array_char_value(8) := p_source_43;
9965 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
9966 l_rec_acct_attrs.array_num_value(9) := p_source_44;
9967 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
9968 l_rec_acct_attrs.array_num_value(10) := p_source_45;
9969 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
9970 l_rec_acct_attrs.array_num_value(11) := p_source_46;
9971 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
9972 l_rec_acct_attrs.array_char_value(12) := p_source_27;
9973 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
9974 l_rec_acct_attrs.array_num_value(13) := p_source_47;
9975
9976 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
9977 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
9978
9979 ---------------------------------------------------------------------------------------------------------------
9980 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
9981 ---------------------------------------------------------------------------------------------------------------
9982 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
9983
9984 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9985 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9986
9987 IF xla_accounting_cache_pkg.GetValueChar
9988 (p_source_code => 'LEDGER_CATEGORY_CODE'
9989 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
9990 AND l_bflow_method_code = 'PRIOR_ENTRY'
9991 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
9992 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
9993 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
9994 )
9995 THEN
9996 xla_ae_lines_pkg.BflowUpgEntry
9997 (p_business_method_code => l_bflow_method_code
9998 ,p_business_class_code => l_bflow_class_code
9999 ,p_balance_type => l_balance_type_code);
10000 ELSE
10001 NULL;
10002 -- No business flow processing for business flow method of NONE.
10003 END IF;
10004
10005 --
10006 -- call analytical criteria
10007 --
10008
10009 --
10010 -- call description
10011 --
10012 -- No description or it is inherited.
10013 --
10014 -- call ADRs
10015 -- Bug 4922099
10016 --
10017 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10018 (NVL(l_actual_upg_option, 'N') = 'O') OR
10019 (NVL(l_enc_upg_option, 'N') = 'O')
10020 )
10021 THEN
10022 NULL;
10023 --
10024 --
10025
10026 l_ccid := AcctDerRule_10(
10027 p_application_id => p_application_id
10028 , p_ae_header_id => l_ae_header_id
10029 , p_source_9 => p_source_9
10030 , x_transaction_coa_id => l_adr_transaction_coa_id
10031 , x_accounting_coa_id => l_adr_accounting_coa_id
10032 , x_value_type_code => l_adr_value_type_code
10033 , p_side => 'NA'
10034 );
10035
10036 xla_ae_lines_pkg.set_ccid(
10037 p_code_combination_id => l_ccid
10038 , p_value_type_code => l_adr_value_type_code
10039 , p_transaction_coa_id => l_adr_transaction_coa_id
10040 , p_accounting_coa_id => l_adr_accounting_coa_id
10041 , p_adr_code => 'CM_DIST_CCID'
10042 , p_adr_type_code => 'S'
10043 , p_component_type => l_component_type
10044 , p_component_code => l_component_code
10045 , p_component_type_code => l_component_type_code
10046 , p_component_appl_id => l_component_appl_id
10047 , p_amb_context_code => l_amb_context_code
10048 , p_side => 'NA'
10049 );
10050
10051
10052 --
10053 --
10054 END IF;
10055 --
10056 -- Bug 4922099
10057 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
10058 (NVL(l_enc_upg_option, 'N') = 'O')
10059 ) AND
10060 (l_bflow_method_code = 'PRIOR_ENTRY')
10061 )
10062 THEN
10066 --
10063 IF
10064 --
10065 1 = 2
10067 THEN
10068 xla_accounting_err_pkg.build_message
10069 (p_appli_s_name => 'XLA'
10070 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10071 ,p_token_1 => 'LINE_NUMBER'
10072 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
10073 ,p_token_2 => 'LINE_TYPE_NAME'
10074 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
10075 l_component_type
10076 ,l_component_code
10077 ,l_component_type_code
10078 ,l_component_appl_id
10079 ,l_amb_context_code
10080 ,l_entity_code
10081 ,l_event_class_code
10082 )
10083 ,p_token_3 => 'OWNER'
10084 ,p_value_3 => xla_lookups_pkg.get_meaning(
10085 p_lookup_type => 'XLA_OWNER_TYPE'
10086 ,p_lookup_code => l_component_type_code
10087 )
10088 ,p_token_4 => 'PRODUCT_NAME'
10089 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
10090 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
10091 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
10092 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
10093 ,p_ae_header_id => NULL
10094 );
10095
10096 IF (C_LEVEL_ERROR>= g_log_level) THEN
10097 trace
10098 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10099 ,p_level => C_LEVEL_ERROR
10100 ,p_module => l_log_module);
10101 END IF;
10102 END IF;
10103 END IF;
10104 --
10105 --
10106 ------------------------------------------------------------------------------------------------
10107 -- 4219869 Business Flow
10108 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
10109 -- Prior Entry. Currently, the following code is always generated.
10110 ------------------------------------------------------------------------------------------------
10111 XLA_AE_LINES_PKG.ValidateCurrentLine;
10112
10113 ------------------------------------------------------------------------------------
10114 -- 4219869 Business Flow
10115 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
10116 ------------------------------------------------------------------------------------
10117 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10118
10119 ----------------------------------------------------------------------------------
10120 -- 4219869 Business Flow
10121 -- Update journal entry status -- Need to generate this within IF <condition>
10122 ----------------------------------------------------------------------------------
10123 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10124 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
10125 ,p_balance_type_code => l_balance_type_code
10126 );
10127
10128 -------------------------------------------------------------------------------------------
10129 -- 4262811 - Generate the Accrual Reversal lines
10130 -------------------------------------------------------------------------------------------
10131 BEGIN
10132 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
10133 (g_array_event(p_event_id).array_value_num('header_index'));
10134 IF l_acc_rev_flag IS NULL THEN
10135 l_acc_rev_flag := 'N';
10136 END IF;
10137 EXCEPTION
10138 WHEN OTHERS THEN
10139 l_acc_rev_flag := 'N';
10140 END;
10141 --
10142 IF (l_acc_rev_flag = 'Y') THEN
10143
10144 -- 4645092 ------------------------------------------------------------------------------
10145 -- To allow MPA report to determine if it should generate report process
10146 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
10147 ------------------------------------------------------------------------------------------
10148
10149 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
10150 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
10151 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
10152 -- call ADRs
10153 -- Bug 4922099
10154 --
10155 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10156 (NVL(l_actual_upg_option, 'N') = 'O') OR
10157 (NVL(l_enc_upg_option, 'N') = 'O')
10158 )
10159 THEN
10160 NULL;
10161 --
10162 --
10163
10164 l_ccid := AcctDerRule_10(
10165 p_application_id => p_application_id
10166 , p_ae_header_id => l_ae_header_id
10167 , p_source_9 => p_source_9
10168 , x_transaction_coa_id => l_adr_transaction_coa_id
10169 , x_accounting_coa_id => l_adr_accounting_coa_id
10170 , x_value_type_code => l_adr_value_type_code
10171 , p_side => 'NA'
10172 );
10173
10174 xla_ae_lines_pkg.set_ccid(
10175 p_code_combination_id => l_ccid
10176 , p_value_type_code => l_adr_value_type_code
10177 , p_transaction_coa_id => l_adr_transaction_coa_id
10178 , p_accounting_coa_id => l_adr_accounting_coa_id
10179 , p_adr_code => 'CM_DIST_CCID'
10180 , p_adr_type_code => 'S'
10181 , p_component_type => l_component_type
10182 , p_component_code => l_component_code
10183 , p_component_type_code => l_component_type_code
10184 , p_component_appl_id => l_component_appl_id
10185 , p_amb_context_code => l_amb_context_code
10186 , p_side => 'NA'
10187 );
10188
10189
10190 --
10191 --
10192 END IF;
10193
10194 --
10195 -- Update the line information that should be overwritten
10196 --
10197 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
10198 p_header_num => 1);
10199 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
10200
10201 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
10202
10203 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
10204 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
10205 END IF;
10206
10207 --
10208 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
10209 --
10210 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
10211 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
10212 ELSE
10213 ---------------------------------------------------------------------------------------------------
10214 -- 4262811a Switch Sign
10215 ---------------------------------------------------------------------------------------------------
10216 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
10217 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10218 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10219 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10220 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10221 -- 5132302
10222 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
10223 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10224
10225 END IF;
10226
10227 -- 4955764
10228 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10229 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
10230
10231
10232 XLA_AE_LINES_PKG.ValidateCurrentLine;
10233 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10234
10235 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10236 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
10237 ,p_balance_type_code => l_balance_type_code);
10238
10239 END IF;
10240
10241 -----------------------------------------------------------------------------------------
10242 -- 4262811 Multiperiod Accounting
10243 -----------------------------------------------------------------------------------------
10244 -- No MPA option is assigned.
10245
10246
10247 END IF;
10248 END IF;
10249 --
10250
10251 --
10252 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10253 trace
10254 (p_msg => 'END of AcctLineType_32'
10255 ,p_level => C_LEVEL_PROCEDURE
10256 ,p_module => l_log_module);
10257 END IF;
10258 --
10259 EXCEPTION
10260 WHEN xla_exceptions_pkg.application_exception THEN
10261 RAISE;
10262 WHEN OTHERS THEN
10263 xla_exceptions_pkg.raise_message
10264 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_32');
10265 END AcctLineType_32;
10266 --
10267
10268 ---------------------------------------
10269 --
10270 -- PRIVATE FUNCTION
10271 -- AcctLineType_33
10272 --
10273 ---------------------------------------
10274 PROCEDURE AcctLineType_33 (
10275 p_application_id IN NUMBER
10276 ,p_event_id IN NUMBER
10277 ,p_calculate_acctd_flag IN VARCHAR2
10278 ,p_calculate_g_l_flag IN VARCHAR2
10279 ,p_actual_flag IN OUT VARCHAR2
10280 ,p_balance_type_code OUT VARCHAR2
10281 ,p_gain_or_loss_ref OUT VARCHAR2
10282
10283 --Credit Memo Distribution GL Account
10284 , p_source_9 IN NUMBER
10285 --SLA Party Type
10286 , p_source_27 IN VARCHAR2
10287 --Credit Memo Distribution Identifier
10288 , p_source_37 IN NUMBER
10289 --Credit memo distributions type
10290 , p_source_38 IN VARCHAR2
10291 --Credit Memo Currency Code
10292 , p_source_39 IN VARCHAR2
10293 --Credit Memo Exchange Date
10294 , p_source_40 IN DATE
10295 --Credit Memo Exchange Rate
10296 , p_source_41 IN NUMBER
10297 --Credit Memo Exchange Rate Type
10298 , p_source_42 IN VARCHAR2
10299 --Gain Loss Reference
10300 , p_source_43 IN VARCHAR2
10301 --Credit Memo Accounting Amount
10302 , p_source_44 IN NUMBER
10303 --Credit Memo Bill To Customer Account Identifier
10304 , p_source_45 IN NUMBER
10305 --Credit Memo Bill To Customer Site Use Identifier
10306 , p_source_46 IN NUMBER
10307 --Credit Memo Tax Line Identifier
10308 , p_source_47 IN NUMBER
10309 --Credit Memo Distribution Account Class
10310 , p_source_48 IN VARCHAR2
10311 --Credit Memo Distribution Entered Amount
10312 , p_source_49 IN NUMBER
10313 )
10314 IS
10315
10316 l_component_type VARCHAR2(80);
10317 l_component_code VARCHAR2(30);
10318 l_component_type_code VARCHAR2(1);
10319 l_component_appl_id INTEGER;
10320 l_amb_context_code VARCHAR2(30);
10321 l_entity_code VARCHAR2(30);
10322 l_event_class_code VARCHAR2(30);
10323 l_ae_header_id NUMBER;
10324 l_event_type_code VARCHAR2(30);
10325 l_line_definition_code VARCHAR2(30);
10326 l_line_definition_owner_code VARCHAR2(1);
10327 --
10328 -- adr variables
10329 l_segment VARCHAR2(30);
10330 l_ccid NUMBER;
10331 l_adr_transaction_coa_id NUMBER;
10332 l_adr_accounting_coa_id NUMBER;
10333 l_adr_flexfield_segment_code VARCHAR2(30);
10334 l_adr_flex_value_set_id NUMBER;
10335 l_adr_value_type_code VARCHAR2(30);
10336 l_adr_value_combination_id NUMBER;
10337 l_adr_value_segment_code VARCHAR2(30);
10338
10339 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
10340 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
10341 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
10342 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
10343
10344 -- 4262811 Variables ------------------------------------------------------------------------------------------
10345 l_entered_amt_idx NUMBER;
10346 l_accted_amt_idx NUMBER;
10347 l_acc_rev_flag VARCHAR2(1);
10348 l_accrual_line_num NUMBER;
10349 l_tmp_amt NUMBER;
10350 l_acc_rev_natural_side_code VARCHAR2(1);
10351
10352 l_num_entries NUMBER;
10353 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
10354 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
10355 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
10356 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
10357 l_recog_line_1 NUMBER;
10358 l_recog_line_2 NUMBER;
10359
10360 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
10361 l_bflow_applied_to_amt NUMBER; -- 5132302
10362 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
10363
10364 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
10365
10366 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
10367 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
10368
10369 ---------------------------------------------------------------------------------------------------------------
10370
10371
10372 --
10373 -- bulk performance
10374 --
10375 l_balance_type_code VARCHAR2(1);
10376 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
10377 l_log_module VARCHAR2(240);
10378
10379 --
10380 -- Upgrade strategy
10381 --
10382 l_actual_upg_option VARCHAR2(1);
10383 l_enc_upg_option VARCHAR2(1);
10384
10385 --
10386 BEGIN
10387 --
10388 IF g_log_enabled THEN
10389 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_33';
10390 END IF;
10391 --
10392 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10393
10394 trace
10395 (p_msg => 'BEGIN of AcctLineType_33'
10396 ,p_level => C_LEVEL_PROCEDURE
10400 --
10397 ,p_module => l_log_module);
10398
10399 END IF;
10401 l_component_type := 'AMB_JLT';
10402 l_component_code := 'CM_UNBILL';
10403 l_component_type_code := 'S';
10404 l_component_appl_id := 222;
10405 l_amb_context_code := 'DEFAULT';
10406 l_entity_code := 'TRANSACTIONS';
10407 l_event_class_code := 'CREDIT_MEMO';
10408 l_event_type_code := 'CREDIT_MEMO_ALL';
10409 l_line_definition_owner_code := 'S';
10410 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
10411 --
10412 l_balance_type_code := 'A';
10413 l_segment := NULL;
10414 l_ccid := NULL;
10415 l_adr_transaction_coa_id := NULL;
10416 l_adr_accounting_coa_id := NULL;
10417 l_adr_flexfield_segment_code := NULL;
10418 l_adr_flex_value_set_id := NULL;
10419 l_adr_value_type_code := NULL;
10420 l_adr_value_combination_id := NULL;
10421 l_adr_value_segment_code := NULL;
10422
10423 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
10424 l_bflow_class_code := ''; -- 4219869 Business Flow
10425 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
10426 l_budgetary_control_flag := 'N';
10427
10428 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10429 l_bflow_applied_to_amt := NULL; -- 5132302
10430 l_entered_amt_idx := NULL; -- 4262811
10431 l_accted_amt_idx := NULL; -- 4262811
10432 l_acc_rev_flag := NULL; -- 4262811
10433 l_accrual_line_num := NULL; -- 4262811
10434 l_tmp_amt := NULL; -- 4262811
10435 --
10436
10437 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
10438 l_balance_type_code <> 'B' THEN
10439 IF NVL(p_source_48,'
10440 ') = 'UNBILL'
10441 THEN
10442
10443 --
10444 XLA_AE_LINES_PKG.SetNewLine;
10445
10446 p_balance_type_code := l_balance_type_code;
10447 -- set the flag so later we will know whether the gain loss line needs to be created
10448
10449 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
10450 p_actual_flag :='A';
10451 END IF;
10452
10453 --
10454 -- bulk performance
10455 --
10456 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
10457 p_header_num => 0); -- 4262811
10458 --
10459 -- set accounting line options
10460 --
10461 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
10462 p_natural_side_code => 'C'
10463 , p_gain_or_loss_flag => 'N'
10464 , p_gl_transfer_mode_code => 'S'
10465 , p_acct_entry_type_code => 'A'
10466 , p_switch_side_flag => 'Y'
10467 , p_merge_duplicate_code => 'A'
10468 );
10469 --
10470 l_acc_rev_natural_side_code := 'D'; -- 4262811
10471 --
10472 --
10473 -- set accounting line type info
10474 --
10475 xla_ae_lines_pkg.SetAcctLineType
10476 (p_component_type => l_component_type
10477 ,p_event_type_code => l_event_type_code
10478 ,p_line_definition_owner_code => l_line_definition_owner_code
10479 ,p_line_definition_code => l_line_definition_code
10480 ,p_accounting_line_code => l_component_code
10481 ,p_accounting_line_type_code => l_component_type_code
10482 ,p_accounting_line_appl_id => l_component_appl_id
10483 ,p_amb_context_code => l_amb_context_code
10484 ,p_entity_code => l_entity_code
10485 ,p_event_class_code => l_event_class_code);
10486 --
10487 -- set accounting class
10488 --
10489 xla_ae_lines_pkg.SetAcctClass(
10490 p_accounting_class_code => 'UNBILL'
10491 , p_ae_header_id => l_ae_header_id
10492 );
10493
10494 --
10495 -- set rounding class
10496 --
10497 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
10498 'RECEIVABLE';
10499
10500 --
10501 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
10502 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
10503 --
10504 -- bulk performance
10505 --
10506 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
10507
10508 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
10509 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
10510
10511 -- 4955764
10512 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10513 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
10514
10515 -- 4458381 Public Sector Enh
10516
10517 --
10518 -- set accounting attributes for the line type
10519 --
10520 l_entered_amt_idx := 3;
10521 l_accted_amt_idx := 9;
10522 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10523 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
10524 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_37);
10525 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
10526 l_rec_acct_attrs.array_char_value(2) := p_source_38;
10527 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
10528 l_rec_acct_attrs.array_num_value(3) := p_source_49;
10532 l_rec_acct_attrs.array_date_value(5) := p_source_40;
10529 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
10530 l_rec_acct_attrs.array_char_value(4) := p_source_39;
10531 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
10533 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
10534 l_rec_acct_attrs.array_num_value(6) := p_source_41;
10535 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
10536 l_rec_acct_attrs.array_char_value(7) := p_source_42;
10537 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
10538 l_rec_acct_attrs.array_char_value(8) := p_source_43;
10539 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
10540 l_rec_acct_attrs.array_num_value(9) := p_source_44;
10541 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
10542 l_rec_acct_attrs.array_num_value(10) := p_source_45;
10543 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
10544 l_rec_acct_attrs.array_num_value(11) := p_source_46;
10545 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
10546 l_rec_acct_attrs.array_char_value(12) := p_source_27;
10547 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
10548 l_rec_acct_attrs.array_num_value(13) := p_source_47;
10549
10550 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
10551 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
10552
10553 ---------------------------------------------------------------------------------------------------------------
10554 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
10555 ---------------------------------------------------------------------------------------------------------------
10556 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
10557
10558 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10559 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10560
10561 IF xla_accounting_cache_pkg.GetValueChar
10562 (p_source_code => 'LEDGER_CATEGORY_CODE'
10563 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
10564 AND l_bflow_method_code = 'PRIOR_ENTRY'
10565 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
10566 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
10567 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
10568 )
10569 THEN
10570 xla_ae_lines_pkg.BflowUpgEntry
10571 (p_business_method_code => l_bflow_method_code
10572 ,p_business_class_code => l_bflow_class_code
10573 ,p_balance_type => l_balance_type_code);
10574 ELSE
10575 NULL;
10576 -- No business flow processing for business flow method of NONE.
10577 END IF;
10578
10579 --
10580 -- call analytical criteria
10581 --
10582
10583 --
10584 -- call description
10585 --
10586 -- No description or it is inherited.
10587 --
10588 -- call ADRs
10589 -- Bug 4922099
10590 --
10591 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10592 (NVL(l_actual_upg_option, 'N') = 'O') OR
10593 (NVL(l_enc_upg_option, 'N') = 'O')
10594 )
10595 THEN
10596 NULL;
10597 --
10598 --
10599
10600 l_ccid := AcctDerRule_10(
10601 p_application_id => p_application_id
10602 , p_ae_header_id => l_ae_header_id
10603 , p_source_9 => p_source_9
10604 , x_transaction_coa_id => l_adr_transaction_coa_id
10605 , x_accounting_coa_id => l_adr_accounting_coa_id
10606 , x_value_type_code => l_adr_value_type_code
10607 , p_side => 'NA'
10608 );
10609
10610 xla_ae_lines_pkg.set_ccid(
10611 p_code_combination_id => l_ccid
10612 , p_value_type_code => l_adr_value_type_code
10613 , p_transaction_coa_id => l_adr_transaction_coa_id
10614 , p_accounting_coa_id => l_adr_accounting_coa_id
10615 , p_adr_code => 'CM_DIST_CCID'
10616 , p_adr_type_code => 'S'
10617 , p_component_type => l_component_type
10618 , p_component_code => l_component_code
10619 , p_component_type_code => l_component_type_code
10620 , p_component_appl_id => l_component_appl_id
10621 , p_amb_context_code => l_amb_context_code
10622 , p_side => 'NA'
10623 );
10624
10625
10626 --
10627 --
10628 END IF;
10629 --
10630 -- Bug 4922099
10631 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
10632 (NVL(l_enc_upg_option, 'N') = 'O')
10633 ) AND
10634 (l_bflow_method_code = 'PRIOR_ENTRY')
10635 )
10636 THEN
10637 IF
10638 --
10639 1 = 2
10640 --
10641 THEN
10642 xla_accounting_err_pkg.build_message
10643 (p_appli_s_name => 'XLA'
10644 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10645 ,p_token_1 => 'LINE_NUMBER'
10646 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
10647 ,p_token_2 => 'LINE_TYPE_NAME'
10651 ,l_component_type_code
10648 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
10649 l_component_type
10650 ,l_component_code
10652 ,l_component_appl_id
10653 ,l_amb_context_code
10654 ,l_entity_code
10655 ,l_event_class_code
10656 )
10657 ,p_token_3 => 'OWNER'
10658 ,p_value_3 => xla_lookups_pkg.get_meaning(
10659 p_lookup_type => 'XLA_OWNER_TYPE'
10660 ,p_lookup_code => l_component_type_code
10661 )
10662 ,p_token_4 => 'PRODUCT_NAME'
10663 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
10664 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
10665 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
10666 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
10667 ,p_ae_header_id => NULL
10668 );
10669
10670 IF (C_LEVEL_ERROR>= g_log_level) THEN
10671 trace
10672 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10673 ,p_level => C_LEVEL_ERROR
10674 ,p_module => l_log_module);
10675 END IF;
10676 END IF;
10677 END IF;
10678 --
10679 --
10680 ------------------------------------------------------------------------------------------------
10681 -- 4219869 Business Flow
10682 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
10683 -- Prior Entry. Currently, the following code is always generated.
10684 ------------------------------------------------------------------------------------------------
10685 XLA_AE_LINES_PKG.ValidateCurrentLine;
10686
10687 ------------------------------------------------------------------------------------
10688 -- 4219869 Business Flow
10689 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
10690 ------------------------------------------------------------------------------------
10691 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10692
10693 ----------------------------------------------------------------------------------
10694 -- 4219869 Business Flow
10695 -- Update journal entry status -- Need to generate this within IF <condition>
10696 ----------------------------------------------------------------------------------
10697 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10698 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
10699 ,p_balance_type_code => l_balance_type_code
10700 );
10701
10702 -------------------------------------------------------------------------------------------
10703 -- 4262811 - Generate the Accrual Reversal lines
10704 -------------------------------------------------------------------------------------------
10705 BEGIN
10706 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
10707 (g_array_event(p_event_id).array_value_num('header_index'));
10708 IF l_acc_rev_flag IS NULL THEN
10709 l_acc_rev_flag := 'N';
10710 END IF;
10711 EXCEPTION
10712 WHEN OTHERS THEN
10713 l_acc_rev_flag := 'N';
10714 END;
10715 --
10716 IF (l_acc_rev_flag = 'Y') THEN
10717
10718 -- 4645092 ------------------------------------------------------------------------------
10719 -- To allow MPA report to determine if it should generate report process
10720 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
10721 ------------------------------------------------------------------------------------------
10722
10723 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
10724 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
10725 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
10726 -- call ADRs
10727 -- Bug 4922099
10728 --
10729 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10730 (NVL(l_actual_upg_option, 'N') = 'O') OR
10731 (NVL(l_enc_upg_option, 'N') = 'O')
10732 )
10733 THEN
10734 NULL;
10735 --
10736 --
10737
10738 l_ccid := AcctDerRule_10(
10739 p_application_id => p_application_id
10740 , p_ae_header_id => l_ae_header_id
10741 , p_source_9 => p_source_9
10742 , x_transaction_coa_id => l_adr_transaction_coa_id
10743 , x_accounting_coa_id => l_adr_accounting_coa_id
10744 , x_value_type_code => l_adr_value_type_code
10745 , p_side => 'NA'
10746 );
10747
10751 , p_transaction_coa_id => l_adr_transaction_coa_id
10748 xla_ae_lines_pkg.set_ccid(
10749 p_code_combination_id => l_ccid
10750 , p_value_type_code => l_adr_value_type_code
10752 , p_accounting_coa_id => l_adr_accounting_coa_id
10753 , p_adr_code => 'CM_DIST_CCID'
10754 , p_adr_type_code => 'S'
10755 , p_component_type => l_component_type
10756 , p_component_code => l_component_code
10757 , p_component_type_code => l_component_type_code
10758 , p_component_appl_id => l_component_appl_id
10759 , p_amb_context_code => l_amb_context_code
10760 , p_side => 'NA'
10761 );
10762
10763
10764 --
10765 --
10766 END IF;
10767
10768 --
10769 -- Update the line information that should be overwritten
10770 --
10771 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
10772 p_header_num => 1);
10773 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
10774
10775 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
10776
10777 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
10778 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
10779 END IF;
10780
10781 --
10782 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
10783 --
10784 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
10785 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
10786 ELSE
10787 ---------------------------------------------------------------------------------------------------
10788 -- 4262811a Switch Sign
10789 ---------------------------------------------------------------------------------------------------
10790 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
10791 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10792 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10793 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10794 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10795 -- 5132302
10796 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
10797 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10798
10799 END IF;
10800
10801 -- 4955764
10802 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10803 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
10804
10805
10806 XLA_AE_LINES_PKG.ValidateCurrentLine;
10807 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10808
10809 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10810 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
10811 ,p_balance_type_code => l_balance_type_code);
10812
10813 END IF;
10814
10815 -----------------------------------------------------------------------------------------
10816 -- 4262811 Multiperiod Accounting
10817 -----------------------------------------------------------------------------------------
10818 -- No MPA option is assigned.
10819
10820
10821 END IF;
10822 END IF;
10823 --
10824
10825 --
10826 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10827 trace
10828 (p_msg => 'END of AcctLineType_33'
10829 ,p_level => C_LEVEL_PROCEDURE
10830 ,p_module => l_log_module);
10831 END IF;
10832 --
10833 EXCEPTION
10834 WHEN xla_exceptions_pkg.application_exception THEN
10835 RAISE;
10836 WHEN OTHERS THEN
10837 xla_exceptions_pkg.raise_message
10838 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_33');
10839 END AcctLineType_33;
10840 --
10841
10842 ---------------------------------------
10843 --
10844 -- PRIVATE FUNCTION
10845 -- AcctLineType_34
10846 --
10847 ---------------------------------------
10848 PROCEDURE AcctLineType_34 (
10849 p_application_id IN NUMBER
10850 ,p_event_id IN NUMBER
10851 ,p_calculate_acctd_flag IN VARCHAR2
10852 ,p_calculate_g_l_flag IN VARCHAR2
10853 ,p_actual_flag IN OUT VARCHAR2
10854 ,p_balance_type_code OUT VARCHAR2
10855 ,p_gain_or_loss_ref OUT VARCHAR2
10856
10857 --Credit Memo Distribution GL Account
10858 , p_source_9 IN NUMBER
10859 --SLA Party Type
10860 , p_source_27 IN VARCHAR2
10861 --Credit Memo Distribution Identifier
10862 , p_source_37 IN NUMBER
10863 --Credit memo distributions type
10864 , p_source_38 IN VARCHAR2
10865 --Credit Memo Currency Code
10866 , p_source_39 IN VARCHAR2
10867 --Credit Memo Exchange Date
10868 , p_source_40 IN DATE
10869 --Credit Memo Exchange Rate
10870 , p_source_41 IN NUMBER
10871 --Credit Memo Exchange Rate Type
10872 , p_source_42 IN VARCHAR2
10873 --Gain Loss Reference
10874 , p_source_43 IN VARCHAR2
10875 --Credit Memo Accounting Amount
10876 , p_source_44 IN NUMBER
10880 , p_source_46 IN NUMBER
10877 --Credit Memo Bill To Customer Account Identifier
10878 , p_source_45 IN NUMBER
10879 --Credit Memo Bill To Customer Site Use Identifier
10881 --Credit Memo Tax Line Identifier
10882 , p_source_47 IN NUMBER
10883 --Credit Memo Distribution Account Class
10884 , p_source_48 IN VARCHAR2
10885 --Credit Memo Distribution Entered Amount
10886 , p_source_49 IN NUMBER
10887 )
10888 IS
10889
10890 l_component_type VARCHAR2(80);
10891 l_component_code VARCHAR2(30);
10892 l_component_type_code VARCHAR2(1);
10893 l_component_appl_id INTEGER;
10894 l_amb_context_code VARCHAR2(30);
10895 l_entity_code VARCHAR2(30);
10896 l_event_class_code VARCHAR2(30);
10897 l_ae_header_id NUMBER;
10898 l_event_type_code VARCHAR2(30);
10899 l_line_definition_code VARCHAR2(30);
10900 l_line_definition_owner_code VARCHAR2(1);
10901 --
10902 -- adr variables
10903 l_segment VARCHAR2(30);
10904 l_ccid NUMBER;
10905 l_adr_transaction_coa_id NUMBER;
10906 l_adr_accounting_coa_id NUMBER;
10907 l_adr_flexfield_segment_code VARCHAR2(30);
10908 l_adr_flex_value_set_id NUMBER;
10909 l_adr_value_type_code VARCHAR2(30);
10910 l_adr_value_combination_id NUMBER;
10911 l_adr_value_segment_code VARCHAR2(30);
10912
10913 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
10914 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
10915 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
10916 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
10917
10918 -- 4262811 Variables ------------------------------------------------------------------------------------------
10919 l_entered_amt_idx NUMBER;
10920 l_accted_amt_idx NUMBER;
10921 l_acc_rev_flag VARCHAR2(1);
10922 l_accrual_line_num NUMBER;
10923 l_tmp_amt NUMBER;
10924 l_acc_rev_natural_side_code VARCHAR2(1);
10925
10926 l_num_entries NUMBER;
10927 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
10928 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
10929 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
10930 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
10931 l_recog_line_1 NUMBER;
10932 l_recog_line_2 NUMBER;
10933
10934 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
10935 l_bflow_applied_to_amt NUMBER; -- 5132302
10936 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
10937
10938 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
10939
10940 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
10941 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
10942
10943 ---------------------------------------------------------------------------------------------------------------
10944
10945
10946 --
10947 -- bulk performance
10948 --
10949 l_balance_type_code VARCHAR2(1);
10950 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
10951 l_log_module VARCHAR2(240);
10952
10953 --
10954 -- Upgrade strategy
10955 --
10956 l_actual_upg_option VARCHAR2(1);
10957 l_enc_upg_option VARCHAR2(1);
10958
10959 --
10960 BEGIN
10961 --
10962 IF g_log_enabled THEN
10963 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_34';
10964 END IF;
10965 --
10966 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10967
10968 trace
10969 (p_msg => 'BEGIN of AcctLineType_34'
10970 ,p_level => C_LEVEL_PROCEDURE
10971 ,p_module => l_log_module);
10972
10973 END IF;
10974 --
10975 l_component_type := 'AMB_JLT';
10976 l_component_code := 'CM_UNEARN';
10977 l_component_type_code := 'S';
10978 l_component_appl_id := 222;
10979 l_amb_context_code := 'DEFAULT';
10980 l_entity_code := 'TRANSACTIONS';
10981 l_event_class_code := 'CREDIT_MEMO';
10982 l_event_type_code := 'CREDIT_MEMO_ALL';
10983 l_line_definition_owner_code := 'S';
10984 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
10985 --
10986 l_balance_type_code := 'A';
10987 l_segment := NULL;
10988 l_ccid := NULL;
10989 l_adr_transaction_coa_id := NULL;
10990 l_adr_accounting_coa_id := NULL;
10991 l_adr_flexfield_segment_code := NULL;
10992 l_adr_flex_value_set_id := NULL;
10993 l_adr_value_type_code := NULL;
10994 l_adr_value_combination_id := NULL;
10995 l_adr_value_segment_code := NULL;
10996
10997 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
10998 l_bflow_class_code := ''; -- 4219869 Business Flow
10999 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
11000 l_budgetary_control_flag := 'N';
11001
11002 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11003 l_bflow_applied_to_amt := NULL; -- 5132302
11004 l_entered_amt_idx := NULL; -- 4262811
11005 l_accted_amt_idx := NULL; -- 4262811
11006 l_acc_rev_flag := NULL; -- 4262811
11007 l_accrual_line_num := NULL; -- 4262811
11008 l_tmp_amt := NULL; -- 4262811
11009 --
11010
11014 ') = 'UNEARN'
11011 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
11012 l_balance_type_code <> 'B' THEN
11013 IF NVL(p_source_48,'
11015 THEN
11016
11017 --
11018 XLA_AE_LINES_PKG.SetNewLine;
11019
11020 p_balance_type_code := l_balance_type_code;
11021 -- set the flag so later we will know whether the gain loss line needs to be created
11022
11023 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
11024 p_actual_flag :='A';
11025 END IF;
11026
11027 --
11028 -- bulk performance
11029 --
11030 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
11031 p_header_num => 0); -- 4262811
11032 --
11033 -- set accounting line options
11034 --
11035 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
11036 p_natural_side_code => 'C'
11037 , p_gain_or_loss_flag => 'N'
11038 , p_gl_transfer_mode_code => 'S'
11039 , p_acct_entry_type_code => 'A'
11040 , p_switch_side_flag => 'Y'
11041 , p_merge_duplicate_code => 'A'
11042 );
11043 --
11044 l_acc_rev_natural_side_code := 'D'; -- 4262811
11045 --
11046 --
11047 -- set accounting line type info
11048 --
11049 xla_ae_lines_pkg.SetAcctLineType
11050 (p_component_type => l_component_type
11051 ,p_event_type_code => l_event_type_code
11052 ,p_line_definition_owner_code => l_line_definition_owner_code
11053 ,p_line_definition_code => l_line_definition_code
11054 ,p_accounting_line_code => l_component_code
11055 ,p_accounting_line_type_code => l_component_type_code
11056 ,p_accounting_line_appl_id => l_component_appl_id
11057 ,p_amb_context_code => l_amb_context_code
11058 ,p_entity_code => l_entity_code
11059 ,p_event_class_code => l_event_class_code);
11060 --
11061 -- set accounting class
11062 --
11063 xla_ae_lines_pkg.SetAcctClass(
11064 p_accounting_class_code => 'UNEARNED_REVENUE'
11065 , p_ae_header_id => l_ae_header_id
11066 );
11067
11068 --
11069 -- set rounding class
11070 --
11071 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
11072 'RECEIVABLE';
11073
11074 --
11075 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
11076 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
11077 --
11078 -- bulk performance
11079 --
11080 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
11081
11082 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
11083 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
11084
11085 -- 4955764
11086 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11087 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
11088
11089 -- 4458381 Public Sector Enh
11090
11091 --
11092 -- set accounting attributes for the line type
11093 --
11094 l_entered_amt_idx := 3;
11095 l_accted_amt_idx := 9;
11096 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11097 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
11098 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_37);
11099 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
11100 l_rec_acct_attrs.array_char_value(2) := p_source_38;
11101 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
11102 l_rec_acct_attrs.array_num_value(3) := p_source_49;
11103 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
11104 l_rec_acct_attrs.array_char_value(4) := p_source_39;
11105 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
11106 l_rec_acct_attrs.array_date_value(5) := p_source_40;
11107 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
11108 l_rec_acct_attrs.array_num_value(6) := p_source_41;
11109 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
11110 l_rec_acct_attrs.array_char_value(7) := p_source_42;
11111 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
11112 l_rec_acct_attrs.array_char_value(8) := p_source_43;
11113 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
11114 l_rec_acct_attrs.array_num_value(9) := p_source_44;
11115 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
11116 l_rec_acct_attrs.array_num_value(10) := p_source_45;
11117 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
11118 l_rec_acct_attrs.array_num_value(11) := p_source_46;
11119 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
11120 l_rec_acct_attrs.array_char_value(12) := p_source_27;
11121 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
11122 l_rec_acct_attrs.array_num_value(13) := p_source_47;
11123
11124 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
11125 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
11126
11127 ---------------------------------------------------------------------------------------------------------------
11128 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
11129 ---------------------------------------------------------------------------------------------------------------
11133 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11130 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
11131
11132 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11134
11135 IF xla_accounting_cache_pkg.GetValueChar
11136 (p_source_code => 'LEDGER_CATEGORY_CODE'
11137 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
11138 AND l_bflow_method_code = 'PRIOR_ENTRY'
11139 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
11140 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
11141 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
11142 )
11143 THEN
11144 xla_ae_lines_pkg.BflowUpgEntry
11145 (p_business_method_code => l_bflow_method_code
11146 ,p_business_class_code => l_bflow_class_code
11147 ,p_balance_type => l_balance_type_code);
11148 ELSE
11149 NULL;
11150 -- No business flow processing for business flow method of NONE.
11151 END IF;
11152
11153 --
11154 -- call analytical criteria
11155 --
11156
11157 --
11158 -- call description
11159 --
11160 -- No description or it is inherited.
11161 --
11162 -- call ADRs
11163 -- Bug 4922099
11164 --
11165 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11166 (NVL(l_actual_upg_option, 'N') = 'O') OR
11167 (NVL(l_enc_upg_option, 'N') = 'O')
11168 )
11169 THEN
11170 NULL;
11171 --
11172 --
11173
11174 l_ccid := AcctDerRule_10(
11175 p_application_id => p_application_id
11176 , p_ae_header_id => l_ae_header_id
11177 , p_source_9 => p_source_9
11178 , x_transaction_coa_id => l_adr_transaction_coa_id
11179 , x_accounting_coa_id => l_adr_accounting_coa_id
11180 , x_value_type_code => l_adr_value_type_code
11181 , p_side => 'NA'
11182 );
11183
11184 xla_ae_lines_pkg.set_ccid(
11185 p_code_combination_id => l_ccid
11186 , p_value_type_code => l_adr_value_type_code
11187 , p_transaction_coa_id => l_adr_transaction_coa_id
11188 , p_accounting_coa_id => l_adr_accounting_coa_id
11189 , p_adr_code => 'CM_DIST_CCID'
11190 , p_adr_type_code => 'S'
11191 , p_component_type => l_component_type
11192 , p_component_code => l_component_code
11193 , p_component_type_code => l_component_type_code
11194 , p_component_appl_id => l_component_appl_id
11195 , p_amb_context_code => l_amb_context_code
11196 , p_side => 'NA'
11197 );
11198
11199
11200 --
11201 --
11202 END IF;
11203 --
11204 -- Bug 4922099
11205 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
11206 (NVL(l_enc_upg_option, 'N') = 'O')
11207 ) AND
11208 (l_bflow_method_code = 'PRIOR_ENTRY')
11209 )
11210 THEN
11211 IF
11212 --
11213 1 = 2
11214 --
11215 THEN
11216 xla_accounting_err_pkg.build_message
11217 (p_appli_s_name => 'XLA'
11218 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11219 ,p_token_1 => 'LINE_NUMBER'
11220 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
11221 ,p_token_2 => 'LINE_TYPE_NAME'
11222 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
11223 l_component_type
11224 ,l_component_code
11225 ,l_component_type_code
11226 ,l_component_appl_id
11227 ,l_amb_context_code
11228 ,l_entity_code
11229 ,l_event_class_code
11230 )
11231 ,p_token_3 => 'OWNER'
11232 ,p_value_3 => xla_lookups_pkg.get_meaning(
11233 p_lookup_type => 'XLA_OWNER_TYPE'
11234 ,p_lookup_code => l_component_type_code
11235 )
11236 ,p_token_4 => 'PRODUCT_NAME'
11237 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
11238 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
11239 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
11240 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
11241 ,p_ae_header_id => NULL
11242 );
11243
11247 ,p_level => C_LEVEL_ERROR
11244 IF (C_LEVEL_ERROR>= g_log_level) THEN
11245 trace
11246 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11248 ,p_module => l_log_module);
11249 END IF;
11250 END IF;
11251 END IF;
11252 --
11253 --
11254 ------------------------------------------------------------------------------------------------
11255 -- 4219869 Business Flow
11256 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
11257 -- Prior Entry. Currently, the following code is always generated.
11258 ------------------------------------------------------------------------------------------------
11259 XLA_AE_LINES_PKG.ValidateCurrentLine;
11260
11261 ------------------------------------------------------------------------------------
11262 -- 4219869 Business Flow
11263 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
11264 ------------------------------------------------------------------------------------
11265 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11266
11267 ----------------------------------------------------------------------------------
11268 -- 4219869 Business Flow
11269 -- Update journal entry status -- Need to generate this within IF <condition>
11270 ----------------------------------------------------------------------------------
11271 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11272 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
11273 ,p_balance_type_code => l_balance_type_code
11274 );
11275
11276 -------------------------------------------------------------------------------------------
11277 -- 4262811 - Generate the Accrual Reversal lines
11278 -------------------------------------------------------------------------------------------
11279 BEGIN
11280 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
11281 (g_array_event(p_event_id).array_value_num('header_index'));
11282 IF l_acc_rev_flag IS NULL THEN
11283 l_acc_rev_flag := 'N';
11284 END IF;
11285 EXCEPTION
11286 WHEN OTHERS THEN
11287 l_acc_rev_flag := 'N';
11288 END;
11289 --
11290 IF (l_acc_rev_flag = 'Y') THEN
11291
11292 -- 4645092 ------------------------------------------------------------------------------
11293 -- To allow MPA report to determine if it should generate report process
11294 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
11295 ------------------------------------------------------------------------------------------
11296
11297 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
11298 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
11299 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
11300 -- call ADRs
11301 -- Bug 4922099
11302 --
11303 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11304 (NVL(l_actual_upg_option, 'N') = 'O') OR
11305 (NVL(l_enc_upg_option, 'N') = 'O')
11306 )
11307 THEN
11308 NULL;
11309 --
11310 --
11311
11312 l_ccid := AcctDerRule_10(
11313 p_application_id => p_application_id
11314 , p_ae_header_id => l_ae_header_id
11315 , p_source_9 => p_source_9
11316 , x_transaction_coa_id => l_adr_transaction_coa_id
11317 , x_accounting_coa_id => l_adr_accounting_coa_id
11318 , x_value_type_code => l_adr_value_type_code
11319 , p_side => 'NA'
11320 );
11321
11322 xla_ae_lines_pkg.set_ccid(
11323 p_code_combination_id => l_ccid
11324 , p_value_type_code => l_adr_value_type_code
11325 , p_transaction_coa_id => l_adr_transaction_coa_id
11326 , p_accounting_coa_id => l_adr_accounting_coa_id
11327 , p_adr_code => 'CM_DIST_CCID'
11328 , p_adr_type_code => 'S'
11329 , p_component_type => l_component_type
11330 , p_component_code => l_component_code
11331 , p_component_type_code => l_component_type_code
11332 , p_component_appl_id => l_component_appl_id
11333 , p_amb_context_code => l_amb_context_code
11334 , p_side => 'NA'
11335 );
11336
11337
11338 --
11339 --
11340 END IF;
11341
11342 --
11343 -- Update the line information that should be overwritten
11344 --
11345 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
11346 p_header_num => 1);
11347 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
11348
11349 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
11350
11351 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
11352 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
11353 END IF;
11354
11355 --
11356 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
11357 --
11358 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
11359 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
11360 ELSE
11361 ---------------------------------------------------------------------------------------------------
11362 -- 4262811a Switch Sign
11366 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11363 ---------------------------------------------------------------------------------------------------
11364 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
11365 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11367 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11368 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11369 -- 5132302
11370 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
11371 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11372
11373 END IF;
11374
11375 -- 4955764
11376 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11377 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
11378
11379
11380 XLA_AE_LINES_PKG.ValidateCurrentLine;
11381 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11382
11383 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11384 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
11385 ,p_balance_type_code => l_balance_type_code);
11386
11387 END IF;
11388
11389 -----------------------------------------------------------------------------------------
11390 -- 4262811 Multiperiod Accounting
11391 -----------------------------------------------------------------------------------------
11392 -- No MPA option is assigned.
11393
11394
11395 END IF;
11396 END IF;
11397 --
11398
11399 --
11400 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11401 trace
11402 (p_msg => 'END of AcctLineType_34'
11403 ,p_level => C_LEVEL_PROCEDURE
11404 ,p_module => l_log_module);
11405 END IF;
11406 --
11407 EXCEPTION
11408 WHEN xla_exceptions_pkg.application_exception THEN
11409 RAISE;
11410 WHEN OTHERS THEN
11411 xla_exceptions_pkg.raise_message
11412 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_34');
11413 END AcctLineType_34;
11414 --
11415
11416 ---------------------------------------
11417 --
11418 -- PRIVATE FUNCTION
11419 -- AcctLineType_35
11420 --
11421 ---------------------------------------
11422 PROCEDURE AcctLineType_35 (
11423 p_application_id IN NUMBER
11424 ,p_event_id IN NUMBER
11425 ,p_calculate_acctd_flag IN VARCHAR2
11426 ,p_calculate_g_l_flag IN VARCHAR2
11427 ,p_actual_flag IN OUT VARCHAR2
11428 ,p_balance_type_code OUT VARCHAR2
11429 ,p_gain_or_loss_ref OUT VARCHAR2
11430
11431 --Transaction Distribution GL Account
11432 , p_source_14 IN NUMBER
11433 --Bill To Customer Account Identifier
11434 , p_source_25 IN NUMBER
11435 --Bill To Customer Site Use Identifier
11436 , p_source_26 IN NUMBER
11437 --SLA Party Type
11438 , p_source_27 IN VARCHAR2
11439 --Transaction Distribution Account Class
11440 , p_source_28 IN VARCHAR2
11441 --Transaction Distribution Identifier
11442 , p_source_29 IN NUMBER
11443 --Transaction Distribution Type
11444 , p_source_30 IN VARCHAR2
11445 --Transaction Distribution Entered Amount
11446 , p_source_31 IN NUMBER
11447 --Transaction Currency Code
11448 , p_source_32 IN VARCHAR2
11449 --Transaction Exchange Date
11450 , p_source_33 IN DATE
11451 --Transaction Exchange Rate
11452 , p_source_34 IN NUMBER
11453 --Transaction Exchange Rate Type
11454 , p_source_35 IN VARCHAR2
11455 --Transaction Accounting Amount
11456 , p_source_36 IN NUMBER
11457 )
11458 IS
11459
11460 l_component_type VARCHAR2(80);
11461 l_component_code VARCHAR2(30);
11462 l_component_type_code VARCHAR2(1);
11463 l_component_appl_id INTEGER;
11464 l_amb_context_code VARCHAR2(30);
11465 l_entity_code VARCHAR2(30);
11466 l_event_class_code VARCHAR2(30);
11467 l_ae_header_id NUMBER;
11468 l_event_type_code VARCHAR2(30);
11469 l_line_definition_code VARCHAR2(30);
11470 l_line_definition_owner_code VARCHAR2(1);
11471 --
11472 -- adr variables
11473 l_segment VARCHAR2(30);
11474 l_ccid NUMBER;
11475 l_adr_transaction_coa_id NUMBER;
11476 l_adr_accounting_coa_id NUMBER;
11477 l_adr_flexfield_segment_code VARCHAR2(30);
11478 l_adr_flex_value_set_id NUMBER;
11479 l_adr_value_type_code VARCHAR2(30);
11480 l_adr_value_combination_id NUMBER;
11481 l_adr_value_segment_code VARCHAR2(30);
11482
11483 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
11484 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
11485 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
11486 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
11487
11488 -- 4262811 Variables ------------------------------------------------------------------------------------------
11489 l_entered_amt_idx NUMBER;
11490 l_accted_amt_idx NUMBER;
11491 l_acc_rev_flag VARCHAR2(1);
11492 l_accrual_line_num NUMBER;
11493 l_tmp_amt NUMBER;
11494 l_acc_rev_natural_side_code VARCHAR2(1);
11495
11499 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
11496 l_num_entries NUMBER;
11497 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
11498 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
11500 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
11501 l_recog_line_1 NUMBER;
11502 l_recog_line_2 NUMBER;
11503
11504 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
11505 l_bflow_applied_to_amt NUMBER; -- 5132302
11506 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
11507
11508 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
11509
11510 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
11511 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
11512
11513 ---------------------------------------------------------------------------------------------------------------
11514
11515
11516 --
11517 -- bulk performance
11518 --
11519 l_balance_type_code VARCHAR2(1);
11520 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
11521 l_log_module VARCHAR2(240);
11522
11523 --
11524 -- Upgrade strategy
11525 --
11526 l_actual_upg_option VARCHAR2(1);
11527 l_enc_upg_option VARCHAR2(1);
11528
11529 --
11530 BEGIN
11531 --
11532 IF g_log_enabled THEN
11533 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_35';
11534 END IF;
11535 --
11536 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11537
11538 trace
11539 (p_msg => 'BEGIN of AcctLineType_35'
11540 ,p_level => C_LEVEL_PROCEDURE
11541 ,p_module => l_log_module);
11542
11543 END IF;
11544 --
11545 l_component_type := 'AMB_JLT';
11546 l_component_code := 'DEP_DEFAULT_REC';
11547 l_component_type_code := 'S';
11548 l_component_appl_id := 222;
11549 l_amb_context_code := 'DEFAULT';
11550 l_entity_code := 'TRANSACTIONS';
11551 l_event_class_code := 'DEPOSIT';
11552 l_event_type_code := 'DEPOSIT_ALL';
11553 l_line_definition_owner_code := 'S';
11554 l_line_definition_code := 'AR_DEP_DEFAULT_ACCRUAL';
11555 --
11556 l_balance_type_code := 'A';
11557 l_segment := NULL;
11558 l_ccid := NULL;
11559 l_adr_transaction_coa_id := NULL;
11560 l_adr_accounting_coa_id := NULL;
11561 l_adr_flexfield_segment_code := NULL;
11562 l_adr_flex_value_set_id := NULL;
11563 l_adr_value_type_code := NULL;
11564 l_adr_value_combination_id := NULL;
11565 l_adr_value_segment_code := NULL;
11566
11567 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
11568 l_bflow_class_code := ''; -- 4219869 Business Flow
11569 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
11570 l_budgetary_control_flag := 'N';
11571
11572 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11573 l_bflow_applied_to_amt := NULL; -- 5132302
11574 l_entered_amt_idx := NULL; -- 4262811
11575 l_accted_amt_idx := NULL; -- 4262811
11576 l_acc_rev_flag := NULL; -- 4262811
11577 l_accrual_line_num := NULL; -- 4262811
11578 l_tmp_amt := NULL; -- 4262811
11579 --
11580
11581 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
11582 l_balance_type_code <> 'B' THEN
11583 IF NVL(p_source_28,'
11584 ') = 'REC'
11585 THEN
11586
11587 --
11588 XLA_AE_LINES_PKG.SetNewLine;
11589
11590 p_balance_type_code := l_balance_type_code;
11591 -- set the flag so later we will know whether the gain loss line needs to be created
11592
11593 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
11594 p_actual_flag :='A';
11595 END IF;
11596
11597 --
11598 -- bulk performance
11599 --
11600 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
11601 p_header_num => 0); -- 4262811
11602 --
11603 -- set accounting line options
11604 --
11605 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
11606 p_natural_side_code => 'D'
11607 , p_gain_or_loss_flag => 'N'
11608 , p_gl_transfer_mode_code => 'S'
11609 , p_acct_entry_type_code => 'A'
11610 , p_switch_side_flag => 'Y'
11611 , p_merge_duplicate_code => 'A'
11612 );
11613 --
11614 l_acc_rev_natural_side_code := 'C'; -- 4262811
11615 --
11616 --
11617 -- set accounting line type info
11618 --
11619 xla_ae_lines_pkg.SetAcctLineType
11620 (p_component_type => l_component_type
11621 ,p_event_type_code => l_event_type_code
11622 ,p_line_definition_owner_code => l_line_definition_owner_code
11623 ,p_line_definition_code => l_line_definition_code
11624 ,p_accounting_line_code => l_component_code
11625 ,p_accounting_line_type_code => l_component_type_code
11626 ,p_accounting_line_appl_id => l_component_appl_id
11627 ,p_amb_context_code => l_amb_context_code
11631 -- set accounting class
11628 ,p_entity_code => l_entity_code
11629 ,p_event_class_code => l_event_class_code);
11630 --
11632 --
11633 xla_ae_lines_pkg.SetAcctClass(
11634 p_accounting_class_code => 'RECEIVABLE'
11635 , p_ae_header_id => l_ae_header_id
11636 );
11637
11638 --
11639 -- set rounding class
11640 --
11641 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
11642 'RECEIVABLE';
11643
11644 --
11645 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
11646 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
11647 --
11648 -- bulk performance
11649 --
11650 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
11651
11652 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
11653 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
11654
11655 -- 4955764
11656 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11657 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
11658
11659 -- 4458381 Public Sector Enh
11660
11661 --
11662 -- set accounting attributes for the line type
11663 --
11664 l_entered_amt_idx := 3;
11665 l_accted_amt_idx := 8;
11666 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11667 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
11668 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
11669 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
11670 l_rec_acct_attrs.array_char_value(2) := p_source_30;
11671 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
11672 l_rec_acct_attrs.array_num_value(3) := p_source_31;
11673 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
11674 l_rec_acct_attrs.array_char_value(4) := p_source_32;
11675 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
11676 l_rec_acct_attrs.array_date_value(5) := p_source_33;
11677 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
11678 l_rec_acct_attrs.array_num_value(6) := p_source_34;
11679 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
11680 l_rec_acct_attrs.array_char_value(7) := p_source_35;
11681 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
11682 l_rec_acct_attrs.array_num_value(8) := p_source_36;
11683 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
11684 l_rec_acct_attrs.array_num_value(9) := p_source_25;
11685 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
11686 l_rec_acct_attrs.array_num_value(10) := p_source_26;
11687 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
11688 l_rec_acct_attrs.array_char_value(11) := p_source_27;
11689
11690 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
11691 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
11692
11693 ---------------------------------------------------------------------------------------------------------------
11694 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
11695 ---------------------------------------------------------------------------------------------------------------
11696 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
11697
11698 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11699 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11700
11701 IF xla_accounting_cache_pkg.GetValueChar
11702 (p_source_code => 'LEDGER_CATEGORY_CODE'
11703 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
11704 AND l_bflow_method_code = 'PRIOR_ENTRY'
11705 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
11706 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
11707 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
11708 )
11709 THEN
11710 xla_ae_lines_pkg.BflowUpgEntry
11711 (p_business_method_code => l_bflow_method_code
11712 ,p_business_class_code => l_bflow_class_code
11713 ,p_balance_type => l_balance_type_code);
11714 ELSE
11715 NULL;
11716 -- No business flow processing for business flow method of NONE.
11717 END IF;
11718
11719 --
11720 -- call analytical criteria
11721 --
11722
11723 --
11724 -- call description
11725 --
11726 -- No description or it is inherited.
11727 --
11728 -- call ADRs
11729 -- Bug 4922099
11730 --
11731 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11732 (NVL(l_actual_upg_option, 'N') = 'O') OR
11733 (NVL(l_enc_upg_option, 'N') = 'O')
11734 )
11735 THEN
11736 NULL;
11737 --
11738 --
11739
11740 l_ccid := AcctDerRule_18(
11741 p_application_id => p_application_id
11742 , p_ae_header_id => l_ae_header_id
11743 , p_source_14 => p_source_14
11744 , x_transaction_coa_id => l_adr_transaction_coa_id
11748 );
11745 , x_accounting_coa_id => l_adr_accounting_coa_id
11746 , x_value_type_code => l_adr_value_type_code
11747 , p_side => 'NA'
11749
11750 xla_ae_lines_pkg.set_ccid(
11751 p_code_combination_id => l_ccid
11752 , p_value_type_code => l_adr_value_type_code
11753 , p_transaction_coa_id => l_adr_transaction_coa_id
11754 , p_accounting_coa_id => l_adr_accounting_coa_id
11755 , p_adr_code => 'TRX_DIST_CCID'
11756 , p_adr_type_code => 'S'
11757 , p_component_type => l_component_type
11758 , p_component_code => l_component_code
11759 , p_component_type_code => l_component_type_code
11760 , p_component_appl_id => l_component_appl_id
11761 , p_amb_context_code => l_amb_context_code
11762 , p_side => 'NA'
11763 );
11764
11765
11766 --
11767 --
11768 END IF;
11769 --
11770 -- Bug 4922099
11771 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
11772 (NVL(l_enc_upg_option, 'N') = 'O')
11773 ) AND
11774 (l_bflow_method_code = 'PRIOR_ENTRY')
11775 )
11776 THEN
11777 IF
11778 --
11779 1 = 2
11780 --
11781 THEN
11782 xla_accounting_err_pkg.build_message
11783 (p_appli_s_name => 'XLA'
11784 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11785 ,p_token_1 => 'LINE_NUMBER'
11786 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
11787 ,p_token_2 => 'LINE_TYPE_NAME'
11788 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
11789 l_component_type
11790 ,l_component_code
11791 ,l_component_type_code
11792 ,l_component_appl_id
11793 ,l_amb_context_code
11794 ,l_entity_code
11795 ,l_event_class_code
11796 )
11797 ,p_token_3 => 'OWNER'
11798 ,p_value_3 => xla_lookups_pkg.get_meaning(
11799 p_lookup_type => 'XLA_OWNER_TYPE'
11800 ,p_lookup_code => l_component_type_code
11801 )
11802 ,p_token_4 => 'PRODUCT_NAME'
11803 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
11804 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
11805 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
11806 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
11807 ,p_ae_header_id => NULL
11808 );
11809
11810 IF (C_LEVEL_ERROR>= g_log_level) THEN
11811 trace
11812 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11813 ,p_level => C_LEVEL_ERROR
11814 ,p_module => l_log_module);
11815 END IF;
11816 END IF;
11817 END IF;
11818 --
11819 --
11820 ------------------------------------------------------------------------------------------------
11821 -- 4219869 Business Flow
11822 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
11823 -- Prior Entry. Currently, the following code is always generated.
11824 ------------------------------------------------------------------------------------------------
11825 XLA_AE_LINES_PKG.ValidateCurrentLine;
11826
11827 ------------------------------------------------------------------------------------
11828 -- 4219869 Business Flow
11829 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
11830 ------------------------------------------------------------------------------------
11831 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11832
11833 ----------------------------------------------------------------------------------
11834 -- 4219869 Business Flow
11835 -- Update journal entry status -- Need to generate this within IF <condition>
11836 ----------------------------------------------------------------------------------
11837 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11838 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
11839 ,p_balance_type_code => l_balance_type_code
11840 );
11841
11842 -------------------------------------------------------------------------------------------
11843 -- 4262811 - Generate the Accrual Reversal lines
11844 -------------------------------------------------------------------------------------------
11845 BEGIN
11846 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
11850 END IF;
11847 (g_array_event(p_event_id).array_value_num('header_index'));
11848 IF l_acc_rev_flag IS NULL THEN
11849 l_acc_rev_flag := 'N';
11851 EXCEPTION
11852 WHEN OTHERS THEN
11853 l_acc_rev_flag := 'N';
11854 END;
11855 --
11856 IF (l_acc_rev_flag = 'Y') THEN
11857
11858 -- 4645092 ------------------------------------------------------------------------------
11859 -- To allow MPA report to determine if it should generate report process
11860 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
11861 ------------------------------------------------------------------------------------------
11862
11863 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
11864 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
11865 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
11866 -- call ADRs
11867 -- Bug 4922099
11868 --
11869 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11870 (NVL(l_actual_upg_option, 'N') = 'O') OR
11871 (NVL(l_enc_upg_option, 'N') = 'O')
11872 )
11873 THEN
11874 NULL;
11875 --
11876 --
11877
11878 l_ccid := AcctDerRule_18(
11879 p_application_id => p_application_id
11880 , p_ae_header_id => l_ae_header_id
11881 , p_source_14 => p_source_14
11882 , x_transaction_coa_id => l_adr_transaction_coa_id
11883 , x_accounting_coa_id => l_adr_accounting_coa_id
11884 , x_value_type_code => l_adr_value_type_code
11885 , p_side => 'NA'
11886 );
11887
11888 xla_ae_lines_pkg.set_ccid(
11889 p_code_combination_id => l_ccid
11890 , p_value_type_code => l_adr_value_type_code
11891 , p_transaction_coa_id => l_adr_transaction_coa_id
11892 , p_accounting_coa_id => l_adr_accounting_coa_id
11893 , p_adr_code => 'TRX_DIST_CCID'
11894 , p_adr_type_code => 'S'
11895 , p_component_type => l_component_type
11896 , p_component_code => l_component_code
11897 , p_component_type_code => l_component_type_code
11898 , p_component_appl_id => l_component_appl_id
11899 , p_amb_context_code => l_amb_context_code
11900 , p_side => 'NA'
11901 );
11902
11903
11904 --
11905 --
11906 END IF;
11907
11908 --
11909 -- Update the line information that should be overwritten
11910 --
11911 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
11912 p_header_num => 1);
11913 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
11914
11915 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
11916
11917 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
11918 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
11919 END IF;
11920
11921 --
11922 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
11923 --
11924 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
11925 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
11926 ELSE
11927 ---------------------------------------------------------------------------------------------------
11928 -- 4262811a Switch Sign
11929 ---------------------------------------------------------------------------------------------------
11930 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
11931 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11932 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11933 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11934 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11935 -- 5132302
11936 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
11937 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11938
11939 END IF;
11940
11941 -- 4955764
11942 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11943 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
11944
11945
11946 XLA_AE_LINES_PKG.ValidateCurrentLine;
11947 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11948
11949 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11950 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
11951 ,p_balance_type_code => l_balance_type_code);
11952
11953 END IF;
11954
11955 -----------------------------------------------------------------------------------------
11956 -- 4262811 Multiperiod Accounting
11957 -----------------------------------------------------------------------------------------
11958 -- No MPA option is assigned.
11959
11960
11961 END IF;
11962 END IF;
11963 --
11964
11965 --
11966 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11970 ,p_module => l_log_module);
11967 trace
11968 (p_msg => 'END of AcctLineType_35'
11969 ,p_level => C_LEVEL_PROCEDURE
11971 END IF;
11972 --
11973 EXCEPTION
11974 WHEN xla_exceptions_pkg.application_exception THEN
11975 RAISE;
11976 WHEN OTHERS THEN
11977 xla_exceptions_pkg.raise_message
11978 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_35');
11979 END AcctLineType_35;
11980 --
11981
11982 ---------------------------------------
11983 --
11984 -- PRIVATE FUNCTION
11985 -- AcctLineType_36
11986 --
11987 ---------------------------------------
11988 PROCEDURE AcctLineType_36 (
11989 p_application_id IN NUMBER
11990 ,p_event_id IN NUMBER
11991 ,p_calculate_acctd_flag IN VARCHAR2
11992 ,p_calculate_g_l_flag IN VARCHAR2
11993 ,p_actual_flag IN OUT VARCHAR2
11994 ,p_balance_type_code OUT VARCHAR2
11995 ,p_gain_or_loss_ref OUT VARCHAR2
11996
11997 --Transaction Distribution GL Account
11998 , p_source_14 IN NUMBER
11999 --Bill To Customer Account Identifier
12000 , p_source_25 IN NUMBER
12001 --Bill To Customer Site Use Identifier
12002 , p_source_26 IN NUMBER
12003 --SLA Party Type
12004 , p_source_27 IN VARCHAR2
12005 --Transaction Distribution Account Class
12006 , p_source_28 IN VARCHAR2
12007 --Transaction Distribution Identifier
12008 , p_source_29 IN NUMBER
12009 --Transaction Distribution Type
12010 , p_source_30 IN VARCHAR2
12011 --Transaction Distribution Entered Amount
12012 , p_source_31 IN NUMBER
12013 --Transaction Currency Code
12014 , p_source_32 IN VARCHAR2
12015 --Transaction Exchange Date
12016 , p_source_33 IN DATE
12017 --Transaction Exchange Rate
12018 , p_source_34 IN NUMBER
12019 --Transaction Exchange Rate Type
12020 , p_source_35 IN VARCHAR2
12021 --Transaction Accounting Amount
12022 , p_source_36 IN NUMBER
12023 )
12024 IS
12025
12026 l_component_type VARCHAR2(80);
12027 l_component_code VARCHAR2(30);
12028 l_component_type_code VARCHAR2(1);
12029 l_component_appl_id INTEGER;
12030 l_amb_context_code VARCHAR2(30);
12031 l_entity_code VARCHAR2(30);
12032 l_event_class_code VARCHAR2(30);
12033 l_ae_header_id NUMBER;
12034 l_event_type_code VARCHAR2(30);
12035 l_line_definition_code VARCHAR2(30);
12036 l_line_definition_owner_code VARCHAR2(1);
12037 --
12038 -- adr variables
12039 l_segment VARCHAR2(30);
12040 l_ccid NUMBER;
12041 l_adr_transaction_coa_id NUMBER;
12042 l_adr_accounting_coa_id NUMBER;
12043 l_adr_flexfield_segment_code VARCHAR2(30);
12044 l_adr_flex_value_set_id NUMBER;
12045 l_adr_value_type_code VARCHAR2(30);
12046 l_adr_value_combination_id NUMBER;
12047 l_adr_value_segment_code VARCHAR2(30);
12048
12049 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
12050 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
12051 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
12052 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
12053
12054 -- 4262811 Variables ------------------------------------------------------------------------------------------
12055 l_entered_amt_idx NUMBER;
12056 l_accted_amt_idx NUMBER;
12057 l_acc_rev_flag VARCHAR2(1);
12058 l_accrual_line_num NUMBER;
12059 l_tmp_amt NUMBER;
12060 l_acc_rev_natural_side_code VARCHAR2(1);
12061
12062 l_num_entries NUMBER;
12063 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
12064 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
12065 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
12066 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
12067 l_recog_line_1 NUMBER;
12068 l_recog_line_2 NUMBER;
12069
12070 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
12071 l_bflow_applied_to_amt NUMBER; -- 5132302
12072 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
12073
12074 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
12075
12076 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
12077 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
12078
12079 ---------------------------------------------------------------------------------------------------------------
12080
12081
12082 --
12083 -- bulk performance
12084 --
12085 l_balance_type_code VARCHAR2(1);
12086 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
12087 l_log_module VARCHAR2(240);
12088
12089 --
12090 -- Upgrade strategy
12091 --
12092 l_actual_upg_option VARCHAR2(1);
12093 l_enc_upg_option VARCHAR2(1);
12094
12095 --
12096 BEGIN
12097 --
12098 IF g_log_enabled THEN
12099 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_36';
12100 END IF;
12101 --
12102 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12103
12104 trace
12105 (p_msg => 'BEGIN of AcctLineType_36'
12109 END IF;
12106 ,p_level => C_LEVEL_PROCEDURE
12107 ,p_module => l_log_module);
12108
12110 --
12111 l_component_type := 'AMB_JLT';
12112 l_component_code := 'DEP_OFFSET';
12113 l_component_type_code := 'S';
12114 l_component_appl_id := 222;
12115 l_amb_context_code := 'DEFAULT';
12116 l_entity_code := 'TRANSACTIONS';
12117 l_event_class_code := 'DEPOSIT';
12118 l_event_type_code := 'DEPOSIT_ALL';
12119 l_line_definition_owner_code := 'S';
12120 l_line_definition_code := 'AR_DEP_DEFAULT_ACCRUAL';
12121 --
12122 l_balance_type_code := 'A';
12123 l_segment := NULL;
12124 l_ccid := NULL;
12125 l_adr_transaction_coa_id := NULL;
12126 l_adr_accounting_coa_id := NULL;
12127 l_adr_flexfield_segment_code := NULL;
12128 l_adr_flex_value_set_id := NULL;
12129 l_adr_value_type_code := NULL;
12130 l_adr_value_combination_id := NULL;
12131 l_adr_value_segment_code := NULL;
12132
12133 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
12134 l_bflow_class_code := ''; -- 4219869 Business Flow
12135 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
12136 l_budgetary_control_flag := 'N';
12137
12138 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12139 l_bflow_applied_to_amt := NULL; -- 5132302
12140 l_entered_amt_idx := NULL; -- 4262811
12141 l_accted_amt_idx := NULL; -- 4262811
12142 l_acc_rev_flag := NULL; -- 4262811
12143 l_accrual_line_num := NULL; -- 4262811
12144 l_tmp_amt := NULL; -- 4262811
12145 --
12146
12147 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
12148 l_balance_type_code <> 'B' THEN
12149 IF NVL(p_source_28,'
12150 ') = 'REV'
12151 THEN
12152
12153 --
12154 XLA_AE_LINES_PKG.SetNewLine;
12155
12156 p_balance_type_code := l_balance_type_code;
12157 -- set the flag so later we will know whether the gain loss line needs to be created
12158
12159 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
12160 p_actual_flag :='A';
12161 END IF;
12162
12163 --
12164 -- bulk performance
12165 --
12166 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
12167 p_header_num => 0); -- 4262811
12168 --
12169 -- set accounting line options
12170 --
12171 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
12172 p_natural_side_code => 'C'
12173 , p_gain_or_loss_flag => 'N'
12174 , p_gl_transfer_mode_code => 'S'
12175 , p_acct_entry_type_code => 'A'
12176 , p_switch_side_flag => 'Y'
12177 , p_merge_duplicate_code => 'A'
12178 );
12179 --
12180 l_acc_rev_natural_side_code := 'D'; -- 4262811
12181 --
12182 --
12183 -- set accounting line type info
12184 --
12185 xla_ae_lines_pkg.SetAcctLineType
12186 (p_component_type => l_component_type
12187 ,p_event_type_code => l_event_type_code
12188 ,p_line_definition_owner_code => l_line_definition_owner_code
12189 ,p_line_definition_code => l_line_definition_code
12190 ,p_accounting_line_code => l_component_code
12191 ,p_accounting_line_type_code => l_component_type_code
12192 ,p_accounting_line_appl_id => l_component_appl_id
12193 ,p_amb_context_code => l_amb_context_code
12194 ,p_entity_code => l_entity_code
12195 ,p_event_class_code => l_event_class_code);
12196 --
12197 -- set accounting class
12198 --
12199 xla_ae_lines_pkg.SetAcctClass(
12200 p_accounting_class_code => 'ACCRUAL'
12201 , p_ae_header_id => l_ae_header_id
12202 );
12203
12204 --
12205 -- set rounding class
12206 --
12207 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
12208 'RECEIVABLE';
12209
12210 --
12211 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
12212 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
12213 --
12214 -- bulk performance
12215 --
12216 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
12217
12218 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
12219 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
12220
12221 -- 4955764
12222 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12223 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
12224
12225 -- 4458381 Public Sector Enh
12226
12227 --
12228 -- set accounting attributes for the line type
12229 --
12230 l_entered_amt_idx := 3;
12231 l_accted_amt_idx := 8;
12232 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12233 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
12234 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
12235 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
12236 l_rec_acct_attrs.array_char_value(2) := p_source_30;
12240 l_rec_acct_attrs.array_char_value(4) := p_source_32;
12237 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
12238 l_rec_acct_attrs.array_num_value(3) := p_source_31;
12239 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
12241 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
12242 l_rec_acct_attrs.array_date_value(5) := p_source_33;
12243 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
12244 l_rec_acct_attrs.array_num_value(6) := p_source_34;
12245 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
12246 l_rec_acct_attrs.array_char_value(7) := p_source_35;
12247 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
12248 l_rec_acct_attrs.array_num_value(8) := p_source_36;
12249 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
12250 l_rec_acct_attrs.array_num_value(9) := p_source_25;
12251 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
12252 l_rec_acct_attrs.array_num_value(10) := p_source_26;
12253 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
12254 l_rec_acct_attrs.array_char_value(11) := p_source_27;
12255
12256 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
12257 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
12258
12259 ---------------------------------------------------------------------------------------------------------------
12260 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
12261 ---------------------------------------------------------------------------------------------------------------
12262 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
12263
12264 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12265 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12266
12267 IF xla_accounting_cache_pkg.GetValueChar
12268 (p_source_code => 'LEDGER_CATEGORY_CODE'
12269 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
12270 AND l_bflow_method_code = 'PRIOR_ENTRY'
12271 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
12272 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
12273 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
12274 )
12275 THEN
12276 xla_ae_lines_pkg.BflowUpgEntry
12277 (p_business_method_code => l_bflow_method_code
12278 ,p_business_class_code => l_bflow_class_code
12279 ,p_balance_type => l_balance_type_code);
12280 ELSE
12281 NULL;
12282 -- No business flow processing for business flow method of NONE.
12283 END IF;
12284
12285 --
12286 -- call analytical criteria
12287 --
12288
12289 --
12290 -- call description
12291 --
12292 -- No description or it is inherited.
12293 --
12294 -- call ADRs
12295 -- Bug 4922099
12296 --
12297 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12298 (NVL(l_actual_upg_option, 'N') = 'O') OR
12299 (NVL(l_enc_upg_option, 'N') = 'O')
12300 )
12301 THEN
12302 NULL;
12303 --
12304 --
12305
12306 l_ccid := AcctDerRule_18(
12307 p_application_id => p_application_id
12308 , p_ae_header_id => l_ae_header_id
12309 , p_source_14 => p_source_14
12310 , x_transaction_coa_id => l_adr_transaction_coa_id
12311 , x_accounting_coa_id => l_adr_accounting_coa_id
12312 , x_value_type_code => l_adr_value_type_code
12313 , p_side => 'NA'
12314 );
12315
12316 xla_ae_lines_pkg.set_ccid(
12317 p_code_combination_id => l_ccid
12318 , p_value_type_code => l_adr_value_type_code
12319 , p_transaction_coa_id => l_adr_transaction_coa_id
12320 , p_accounting_coa_id => l_adr_accounting_coa_id
12321 , p_adr_code => 'TRX_DIST_CCID'
12322 , p_adr_type_code => 'S'
12323 , p_component_type => l_component_type
12324 , p_component_code => l_component_code
12325 , p_component_type_code => l_component_type_code
12326 , p_component_appl_id => l_component_appl_id
12327 , p_amb_context_code => l_amb_context_code
12328 , p_side => 'NA'
12329 );
12330
12331
12332 --
12333 --
12334 END IF;
12335 --
12336 -- Bug 4922099
12337 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
12338 (NVL(l_enc_upg_option, 'N') = 'O')
12339 ) AND
12340 (l_bflow_method_code = 'PRIOR_ENTRY')
12341 )
12342 THEN
12343 IF
12344 --
12345 1 = 2
12346 --
12347 THEN
12348 xla_accounting_err_pkg.build_message
12349 (p_appli_s_name => 'XLA'
12350 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12351 ,p_token_1 => 'LINE_NUMBER'
12352 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
12353 ,p_token_2 => 'LINE_TYPE_NAME'
12354 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
12355 l_component_type
12359 ,l_amb_context_code
12356 ,l_component_code
12357 ,l_component_type_code
12358 ,l_component_appl_id
12360 ,l_entity_code
12361 ,l_event_class_code
12362 )
12363 ,p_token_3 => 'OWNER'
12364 ,p_value_3 => xla_lookups_pkg.get_meaning(
12365 p_lookup_type => 'XLA_OWNER_TYPE'
12366 ,p_lookup_code => l_component_type_code
12367 )
12368 ,p_token_4 => 'PRODUCT_NAME'
12369 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
12370 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
12371 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
12372 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
12373 ,p_ae_header_id => NULL
12374 );
12375
12376 IF (C_LEVEL_ERROR>= g_log_level) THEN
12377 trace
12378 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12379 ,p_level => C_LEVEL_ERROR
12380 ,p_module => l_log_module);
12381 END IF;
12382 END IF;
12383 END IF;
12384 --
12385 --
12386 ------------------------------------------------------------------------------------------------
12387 -- 4219869 Business Flow
12388 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
12389 -- Prior Entry. Currently, the following code is always generated.
12390 ------------------------------------------------------------------------------------------------
12391 XLA_AE_LINES_PKG.ValidateCurrentLine;
12392
12393 ------------------------------------------------------------------------------------
12394 -- 4219869 Business Flow
12395 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
12396 ------------------------------------------------------------------------------------
12397 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12398
12399 ----------------------------------------------------------------------------------
12400 -- 4219869 Business Flow
12401 -- Update journal entry status -- Need to generate this within IF <condition>
12402 ----------------------------------------------------------------------------------
12403 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12404 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
12405 ,p_balance_type_code => l_balance_type_code
12406 );
12407
12408 -------------------------------------------------------------------------------------------
12409 -- 4262811 - Generate the Accrual Reversal lines
12410 -------------------------------------------------------------------------------------------
12411 BEGIN
12412 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
12413 (g_array_event(p_event_id).array_value_num('header_index'));
12414 IF l_acc_rev_flag IS NULL THEN
12415 l_acc_rev_flag := 'N';
12416 END IF;
12417 EXCEPTION
12418 WHEN OTHERS THEN
12419 l_acc_rev_flag := 'N';
12420 END;
12421 --
12422 IF (l_acc_rev_flag = 'Y') THEN
12423
12424 -- 4645092 ------------------------------------------------------------------------------
12425 -- To allow MPA report to determine if it should generate report process
12426 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
12427 ------------------------------------------------------------------------------------------
12428
12429 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
12430 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
12431 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
12432 -- call ADRs
12433 -- Bug 4922099
12434 --
12435 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12436 (NVL(l_actual_upg_option, 'N') = 'O') OR
12437 (NVL(l_enc_upg_option, 'N') = 'O')
12438 )
12439 THEN
12440 NULL;
12441 --
12442 --
12443
12444 l_ccid := AcctDerRule_18(
12445 p_application_id => p_application_id
12446 , p_ae_header_id => l_ae_header_id
12447 , p_source_14 => p_source_14
12448 , x_transaction_coa_id => l_adr_transaction_coa_id
12449 , x_accounting_coa_id => l_adr_accounting_coa_id
12450 , x_value_type_code => l_adr_value_type_code
12451 , p_side => 'NA'
12452 );
12453
12454 xla_ae_lines_pkg.set_ccid(
12455 p_code_combination_id => l_ccid
12459 , p_adr_code => 'TRX_DIST_CCID'
12456 , p_value_type_code => l_adr_value_type_code
12457 , p_transaction_coa_id => l_adr_transaction_coa_id
12458 , p_accounting_coa_id => l_adr_accounting_coa_id
12460 , p_adr_type_code => 'S'
12461 , p_component_type => l_component_type
12462 , p_component_code => l_component_code
12463 , p_component_type_code => l_component_type_code
12464 , p_component_appl_id => l_component_appl_id
12465 , p_amb_context_code => l_amb_context_code
12466 , p_side => 'NA'
12467 );
12468
12469
12470 --
12471 --
12472 END IF;
12473
12474 --
12475 -- Update the line information that should be overwritten
12476 --
12477 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
12478 p_header_num => 1);
12479 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
12480
12481 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
12482
12483 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
12484 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
12485 END IF;
12486
12487 --
12488 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
12489 --
12490 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
12491 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
12492 ELSE
12493 ---------------------------------------------------------------------------------------------------
12494 -- 4262811a Switch Sign
12495 ---------------------------------------------------------------------------------------------------
12496 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
12497 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12498 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12499 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12500 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12501 -- 5132302
12502 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
12503 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12504
12505 END IF;
12506
12507 -- 4955764
12508 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12509 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
12510
12511
12512 XLA_AE_LINES_PKG.ValidateCurrentLine;
12513 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12514
12515 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12516 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
12517 ,p_balance_type_code => l_balance_type_code);
12518
12519 END IF;
12520
12521 -----------------------------------------------------------------------------------------
12522 -- 4262811 Multiperiod Accounting
12523 -----------------------------------------------------------------------------------------
12524 -- No MPA option is assigned.
12525
12526
12527 END IF;
12528 END IF;
12529 --
12530
12531 --
12532 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12533 trace
12534 (p_msg => 'END of AcctLineType_36'
12535 ,p_level => C_LEVEL_PROCEDURE
12536 ,p_module => l_log_module);
12537 END IF;
12538 --
12539 EXCEPTION
12540 WHEN xla_exceptions_pkg.application_exception THEN
12541 RAISE;
12542 WHEN OTHERS THEN
12543 xla_exceptions_pkg.raise_message
12544 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_36');
12545 END AcctLineType_36;
12546 --
12547
12548 ---------------------------------------
12549 --
12550 -- PRIVATE FUNCTION
12551 -- AcctLineType_37
12552 --
12553 ---------------------------------------
12554 PROCEDURE AcctLineType_37 (
12555 p_application_id IN NUMBER
12556 ,p_event_id IN NUMBER
12557 ,p_calculate_acctd_flag IN VARCHAR2
12558 ,p_calculate_g_l_flag IN VARCHAR2
12559 ,p_actual_flag IN OUT VARCHAR2
12560 ,p_balance_type_code OUT VARCHAR2
12561 ,p_gain_or_loss_ref OUT VARCHAR2
12562
12563 --Transaction Distribution GL Account
12564 , p_source_14 IN NUMBER
12565 --Bill To Customer Account Identifier
12566 , p_source_25 IN NUMBER
12567 --Bill To Customer Site Use Identifier
12568 , p_source_26 IN NUMBER
12569 --SLA Party Type
12570 , p_source_27 IN VARCHAR2
12571 --Transaction Distribution Account Class
12572 , p_source_28 IN VARCHAR2
12573 --Transaction Distribution Identifier
12574 , p_source_29 IN NUMBER
12575 --Transaction Distribution Type
12576 , p_source_30 IN VARCHAR2
12577 --Transaction Distribution Entered Amount
12578 , p_source_31 IN NUMBER
12579 --Transaction Currency Code
12580 , p_source_32 IN VARCHAR2
12581 --Transaction Exchange Date
12582 , p_source_33 IN DATE
12583 --Transaction Exchange Rate
12587 --Transaction Accounting Amount
12584 , p_source_34 IN NUMBER
12585 --Transaction Exchange Rate Type
12586 , p_source_35 IN VARCHAR2
12588 , p_source_36 IN NUMBER
12589 --Transaction Tax Line Identifier
12590 , p_source_50 IN NUMBER
12591 )
12592 IS
12593
12594 l_component_type VARCHAR2(80);
12595 l_component_code VARCHAR2(30);
12596 l_component_type_code VARCHAR2(1);
12597 l_component_appl_id INTEGER;
12598 l_amb_context_code VARCHAR2(30);
12599 l_entity_code VARCHAR2(30);
12600 l_event_class_code VARCHAR2(30);
12601 l_ae_header_id NUMBER;
12602 l_event_type_code VARCHAR2(30);
12603 l_line_definition_code VARCHAR2(30);
12604 l_line_definition_owner_code VARCHAR2(1);
12605 --
12606 -- adr variables
12607 l_segment VARCHAR2(30);
12608 l_ccid NUMBER;
12609 l_adr_transaction_coa_id NUMBER;
12610 l_adr_accounting_coa_id NUMBER;
12611 l_adr_flexfield_segment_code VARCHAR2(30);
12612 l_adr_flex_value_set_id NUMBER;
12613 l_adr_value_type_code VARCHAR2(30);
12614 l_adr_value_combination_id NUMBER;
12615 l_adr_value_segment_code VARCHAR2(30);
12616
12617 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
12618 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
12619 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
12620 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
12621
12622 -- 4262811 Variables ------------------------------------------------------------------------------------------
12623 l_entered_amt_idx NUMBER;
12624 l_accted_amt_idx NUMBER;
12625 l_acc_rev_flag VARCHAR2(1);
12626 l_accrual_line_num NUMBER;
12627 l_tmp_amt NUMBER;
12628 l_acc_rev_natural_side_code VARCHAR2(1);
12629
12630 l_num_entries NUMBER;
12631 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
12632 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
12633 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
12634 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
12635 l_recog_line_1 NUMBER;
12636 l_recog_line_2 NUMBER;
12637
12638 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
12639 l_bflow_applied_to_amt NUMBER; -- 5132302
12640 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
12641
12642 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
12643
12644 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
12645 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
12646
12647 ---------------------------------------------------------------------------------------------------------------
12648
12649
12650 --
12651 -- bulk performance
12652 --
12653 l_balance_type_code VARCHAR2(1);
12654 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
12655 l_log_module VARCHAR2(240);
12656
12657 --
12658 -- Upgrade strategy
12659 --
12660 l_actual_upg_option VARCHAR2(1);
12661 l_enc_upg_option VARCHAR2(1);
12662
12663 --
12664 BEGIN
12665 --
12666 IF g_log_enabled THEN
12667 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_37';
12668 END IF;
12669 --
12670 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12671
12672 trace
12673 (p_msg => 'BEGIN of AcctLineType_37'
12674 ,p_level => C_LEVEL_PROCEDURE
12675 ,p_module => l_log_module);
12676
12677 END IF;
12678 --
12679 l_component_type := 'AMB_JLT';
12680 l_component_code := 'DM_CHARGES';
12681 l_component_type_code := 'S';
12682 l_component_appl_id := 222;
12683 l_amb_context_code := 'DEFAULT';
12684 l_entity_code := 'TRANSACTIONS';
12685 l_event_class_code := 'DEBIT_MEMO';
12686 l_event_type_code := 'DEBIT_MEMO_ALL';
12687 l_line_definition_owner_code := 'S';
12688 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
12689 --
12690 l_balance_type_code := 'A';
12691 l_segment := NULL;
12692 l_ccid := NULL;
12693 l_adr_transaction_coa_id := NULL;
12694 l_adr_accounting_coa_id := NULL;
12695 l_adr_flexfield_segment_code := NULL;
12696 l_adr_flex_value_set_id := NULL;
12697 l_adr_value_type_code := NULL;
12698 l_adr_value_combination_id := NULL;
12699 l_adr_value_segment_code := NULL;
12700
12701 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
12702 l_bflow_class_code := ''; -- 4219869 Business Flow
12703 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
12704 l_budgetary_control_flag := 'N';
12705
12706 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12707 l_bflow_applied_to_amt := NULL; -- 5132302
12708 l_entered_amt_idx := NULL; -- 4262811
12709 l_accted_amt_idx := NULL; -- 4262811
12710 l_acc_rev_flag := NULL; -- 4262811
12711 l_accrual_line_num := NULL; -- 4262811
12712 l_tmp_amt := NULL; -- 4262811
12713 --
12714
12715 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
12716 l_balance_type_code <> 'B' THEN
12717 IF NVL(p_source_28,'
12718 ') = 'CHARGES'
12719 THEN
12720
12721 --
12722 XLA_AE_LINES_PKG.SetNewLine;
12723
12724 p_balance_type_code := l_balance_type_code;
12725 -- set the flag so later we will know whether the gain loss line needs to be created
12726
12727 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
12728 p_actual_flag :='A';
12729 END IF;
12730
12731 --
12732 -- bulk performance
12733 --
12734 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
12735 p_header_num => 0); -- 4262811
12736 --
12737 -- set accounting line options
12738 --
12739 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
12740 p_natural_side_code => 'C'
12741 , p_gain_or_loss_flag => 'N'
12742 , p_gl_transfer_mode_code => 'S'
12743 , p_acct_entry_type_code => 'A'
12744 , p_switch_side_flag => 'Y'
12745 , p_merge_duplicate_code => 'A'
12746 );
12747 --
12748 l_acc_rev_natural_side_code := 'D'; -- 4262811
12749 --
12750 --
12751 -- set accounting line type info
12752 --
12753 xla_ae_lines_pkg.SetAcctLineType
12754 (p_component_type => l_component_type
12755 ,p_event_type_code => l_event_type_code
12756 ,p_line_definition_owner_code => l_line_definition_owner_code
12757 ,p_line_definition_code => l_line_definition_code
12758 ,p_accounting_line_code => l_component_code
12759 ,p_accounting_line_type_code => l_component_type_code
12760 ,p_accounting_line_appl_id => l_component_appl_id
12761 ,p_amb_context_code => l_amb_context_code
12762 ,p_entity_code => l_entity_code
12763 ,p_event_class_code => l_event_class_code);
12764 --
12765 -- set accounting class
12766 --
12767 xla_ae_lines_pkg.SetAcctClass(
12768 p_accounting_class_code => 'CHARGES'
12769 , p_ae_header_id => l_ae_header_id
12770 );
12771
12772 --
12773 -- set rounding class
12774 --
12775 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
12776 'RECEIVABLE';
12777
12778 --
12779 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
12780 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
12781 --
12782 -- bulk performance
12783 --
12784 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
12785
12786 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
12787 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
12788
12789 -- 4955764
12790 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12791 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
12792
12793 -- 4458381 Public Sector Enh
12794
12795 --
12796 -- set accounting attributes for the line type
12797 --
12798 l_entered_amt_idx := 3;
12799 l_accted_amt_idx := 8;
12800 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12801 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
12802 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
12803 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
12804 l_rec_acct_attrs.array_char_value(2) := p_source_30;
12805 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
12806 l_rec_acct_attrs.array_num_value(3) := p_source_31;
12807 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
12808 l_rec_acct_attrs.array_char_value(4) := p_source_32;
12809 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
12810 l_rec_acct_attrs.array_date_value(5) := p_source_33;
12811 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
12812 l_rec_acct_attrs.array_num_value(6) := p_source_34;
12813 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
12814 l_rec_acct_attrs.array_char_value(7) := p_source_35;
12815 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
12816 l_rec_acct_attrs.array_num_value(8) := p_source_36;
12817 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
12818 l_rec_acct_attrs.array_num_value(9) := p_source_25;
12819 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
12820 l_rec_acct_attrs.array_num_value(10) := p_source_26;
12821 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
12822 l_rec_acct_attrs.array_char_value(11) := p_source_27;
12823 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
12824 l_rec_acct_attrs.array_num_value(12) := p_source_50;
12825
12826 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
12827 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
12828
12829 ---------------------------------------------------------------------------------------------------------------
12830 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
12831 ---------------------------------------------------------------------------------------------------------------
12832 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
12833
12834 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12835 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12836
12837 IF xla_accounting_cache_pkg.GetValueChar
12838 (p_source_code => 'LEDGER_CATEGORY_CODE'
12839 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
12840 AND l_bflow_method_code = 'PRIOR_ENTRY'
12841 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
12842 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
12843 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
12844 )
12845 THEN
12846 xla_ae_lines_pkg.BflowUpgEntry
12847 (p_business_method_code => l_bflow_method_code
12848 ,p_business_class_code => l_bflow_class_code
12849 ,p_balance_type => l_balance_type_code);
12850 ELSE
12851 NULL;
12852 -- No business flow processing for business flow method of NONE.
12853 END IF;
12854
12855 --
12856 -- call analytical criteria
12857 --
12858
12859 --
12860 -- call description
12861 --
12862 -- No description or it is inherited.
12863 --
12864 -- call ADRs
12865 -- Bug 4922099
12866 --
12867 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12868 (NVL(l_actual_upg_option, 'N') = 'O') OR
12869 (NVL(l_enc_upg_option, 'N') = 'O')
12870 )
12871 THEN
12872 NULL;
12873 --
12874 --
12875
12876 l_ccid := AcctDerRule_18(
12877 p_application_id => p_application_id
12878 , p_ae_header_id => l_ae_header_id
12879 , p_source_14 => p_source_14
12880 , x_transaction_coa_id => l_adr_transaction_coa_id
12881 , x_accounting_coa_id => l_adr_accounting_coa_id
12882 , x_value_type_code => l_adr_value_type_code
12883 , p_side => 'NA'
12884 );
12885
12886 xla_ae_lines_pkg.set_ccid(
12887 p_code_combination_id => l_ccid
12888 , p_value_type_code => l_adr_value_type_code
12889 , p_transaction_coa_id => l_adr_transaction_coa_id
12890 , p_accounting_coa_id => l_adr_accounting_coa_id
12891 , p_adr_code => 'TRX_DIST_CCID'
12892 , p_adr_type_code => 'S'
12893 , p_component_type => l_component_type
12894 , p_component_code => l_component_code
12895 , p_component_type_code => l_component_type_code
12896 , p_component_appl_id => l_component_appl_id
12897 , p_amb_context_code => l_amb_context_code
12898 , p_side => 'NA'
12899 );
12900
12901
12902 --
12903 --
12904 END IF;
12905 --
12906 -- Bug 4922099
12907 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
12908 (NVL(l_enc_upg_option, 'N') = 'O')
12909 ) AND
12910 (l_bflow_method_code = 'PRIOR_ENTRY')
12911 )
12912 THEN
12913 IF
12914 --
12915 1 = 2
12916 --
12917 THEN
12918 xla_accounting_err_pkg.build_message
12919 (p_appli_s_name => 'XLA'
12920 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12924 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
12921 ,p_token_1 => 'LINE_NUMBER'
12922 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
12923 ,p_token_2 => 'LINE_TYPE_NAME'
12925 l_component_type
12926 ,l_component_code
12927 ,l_component_type_code
12928 ,l_component_appl_id
12929 ,l_amb_context_code
12930 ,l_entity_code
12931 ,l_event_class_code
12932 )
12933 ,p_token_3 => 'OWNER'
12934 ,p_value_3 => xla_lookups_pkg.get_meaning(
12935 p_lookup_type => 'XLA_OWNER_TYPE'
12936 ,p_lookup_code => l_component_type_code
12937 )
12938 ,p_token_4 => 'PRODUCT_NAME'
12939 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
12940 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
12941 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
12942 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
12943 ,p_ae_header_id => NULL
12944 );
12945
12946 IF (C_LEVEL_ERROR>= g_log_level) THEN
12947 trace
12948 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12949 ,p_level => C_LEVEL_ERROR
12950 ,p_module => l_log_module);
12951 END IF;
12952 END IF;
12953 END IF;
12954 --
12955 --
12956 ------------------------------------------------------------------------------------------------
12957 -- 4219869 Business Flow
12958 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
12959 -- Prior Entry. Currently, the following code is always generated.
12960 ------------------------------------------------------------------------------------------------
12961 XLA_AE_LINES_PKG.ValidateCurrentLine;
12962
12963 ------------------------------------------------------------------------------------
12964 -- 4219869 Business Flow
12965 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
12966 ------------------------------------------------------------------------------------
12967 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12968
12969 ----------------------------------------------------------------------------------
12970 -- 4219869 Business Flow
12971 -- Update journal entry status -- Need to generate this within IF <condition>
12972 ----------------------------------------------------------------------------------
12973 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12974 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
12975 ,p_balance_type_code => l_balance_type_code
12976 );
12977
12978 -------------------------------------------------------------------------------------------
12979 -- 4262811 - Generate the Accrual Reversal lines
12980 -------------------------------------------------------------------------------------------
12981 BEGIN
12982 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
12983 (g_array_event(p_event_id).array_value_num('header_index'));
12984 IF l_acc_rev_flag IS NULL THEN
12985 l_acc_rev_flag := 'N';
12986 END IF;
12987 EXCEPTION
12988 WHEN OTHERS THEN
12989 l_acc_rev_flag := 'N';
12990 END;
12991 --
12992 IF (l_acc_rev_flag = 'Y') THEN
12993
12994 -- 4645092 ------------------------------------------------------------------------------
12995 -- To allow MPA report to determine if it should generate report process
12996 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
12997 ------------------------------------------------------------------------------------------
12998
12999 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
13000 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
13001 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
13002 -- call ADRs
13003 -- Bug 4922099
13004 --
13005 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13006 (NVL(l_actual_upg_option, 'N') = 'O') OR
13007 (NVL(l_enc_upg_option, 'N') = 'O')
13008 )
13009 THEN
13010 NULL;
13011 --
13012 --
13013
13014 l_ccid := AcctDerRule_18(
13015 p_application_id => p_application_id
13016 , p_ae_header_id => l_ae_header_id
13017 , p_source_14 => p_source_14
13018 , x_transaction_coa_id => l_adr_transaction_coa_id
13019 , x_accounting_coa_id => l_adr_accounting_coa_id
13020 , x_value_type_code => l_adr_value_type_code
13021 , p_side => 'NA'
13022 );
13023
13024 xla_ae_lines_pkg.set_ccid(
13025 p_code_combination_id => l_ccid
13026 , p_value_type_code => l_adr_value_type_code
13027 , p_transaction_coa_id => l_adr_transaction_coa_id
13028 , p_accounting_coa_id => l_adr_accounting_coa_id
13029 , p_adr_code => 'TRX_DIST_CCID'
13030 , p_adr_type_code => 'S'
13031 , p_component_type => l_component_type
13032 , p_component_code => l_component_code
13033 , p_component_type_code => l_component_type_code
13034 , p_component_appl_id => l_component_appl_id
13035 , p_amb_context_code => l_amb_context_code
13036 , p_side => 'NA'
13037 );
13038
13039
13040 --
13041 --
13042 END IF;
13043
13044 --
13045 -- Update the line information that should be overwritten
13046 --
13047 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
13048 p_header_num => 1);
13049 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
13050
13051 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
13052
13053 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
13054 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
13055 END IF;
13056
13057 --
13058 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
13059 --
13060 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
13061 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
13062 ELSE
13063 ---------------------------------------------------------------------------------------------------
13064 -- 4262811a Switch Sign
13065 ---------------------------------------------------------------------------------------------------
13066 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
13067 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13068 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13069 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13070 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13071 -- 5132302
13072 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
13073 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13074
13075 END IF;
13076
13077 -- 4955764
13078 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13079 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
13080
13081
13082 XLA_AE_LINES_PKG.ValidateCurrentLine;
13083 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13084
13085 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13086 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
13087 ,p_balance_type_code => l_balance_type_code);
13088
13089 END IF;
13090
13091 -----------------------------------------------------------------------------------------
13092 -- 4262811 Multiperiod Accounting
13093 -----------------------------------------------------------------------------------------
13094 -- No MPA option is assigned.
13095
13096
13097 END IF;
13098 END IF;
13099 --
13100
13101 --
13102 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13103 trace
13104 (p_msg => 'END of AcctLineType_37'
13105 ,p_level => C_LEVEL_PROCEDURE
13106 ,p_module => l_log_module);
13107 END IF;
13108 --
13109 EXCEPTION
13110 WHEN xla_exceptions_pkg.application_exception THEN
13111 RAISE;
13112 WHEN OTHERS THEN
13113 xla_exceptions_pkg.raise_message
13114 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_37');
13115 END AcctLineType_37;
13116 --
13117
13118 ---------------------------------------
13119 --
13120 -- PRIVATE FUNCTION
13121 -- AcctLineType_38
13122 --
13123 ---------------------------------------
13124 PROCEDURE AcctLineType_38 (
13125 p_application_id IN NUMBER
13126 ,p_event_id IN NUMBER
13127 ,p_calculate_acctd_flag IN VARCHAR2
13128 ,p_calculate_g_l_flag IN VARCHAR2
13129 ,p_actual_flag IN OUT VARCHAR2
13130 ,p_balance_type_code OUT VARCHAR2
13131 ,p_gain_or_loss_ref OUT VARCHAR2
13132
13133 --Transaction Distribution GL Account
13134 , p_source_14 IN NUMBER
13135 --Bill To Customer Account Identifier
13136 , p_source_25 IN NUMBER
13137 --Bill To Customer Site Use Identifier
13138 , p_source_26 IN NUMBER
13139 --SLA Party Type
13140 , p_source_27 IN VARCHAR2
13141 --Transaction Distribution Account Class
13142 , p_source_28 IN VARCHAR2
13143 --Transaction Distribution Identifier
13144 , p_source_29 IN NUMBER
13145 --Transaction Distribution Type
13146 , p_source_30 IN VARCHAR2
13147 --Transaction Distribution Entered Amount
13148 , p_source_31 IN NUMBER
13149 --Transaction Currency Code
13150 , p_source_32 IN VARCHAR2
13151 --Transaction Exchange Date
13152 , p_source_33 IN DATE
13153 --Transaction Exchange Rate
13154 , p_source_34 IN NUMBER
13155 --Transaction Exchange Rate Type
13156 , p_source_35 IN VARCHAR2
13157 --Transaction Accounting Amount
13158 , p_source_36 IN NUMBER
13159 --Transaction Tax Line Identifier
13160 , p_source_50 IN NUMBER
13161 )
13162 IS
13163
13164 l_component_type VARCHAR2(80);
13165 l_component_code VARCHAR2(30);
13166 l_component_type_code VARCHAR2(1);
13167 l_component_appl_id INTEGER;
13168 l_amb_context_code VARCHAR2(30);
13169 l_entity_code VARCHAR2(30);
13170 l_event_class_code VARCHAR2(30);
13171 l_ae_header_id NUMBER;
13172 l_event_type_code VARCHAR2(30);
13173 l_line_definition_code VARCHAR2(30);
13174 l_line_definition_owner_code VARCHAR2(1);
13175 --
13176 -- adr variables
13177 l_segment VARCHAR2(30);
13178 l_ccid NUMBER;
13179 l_adr_transaction_coa_id NUMBER;
13180 l_adr_accounting_coa_id NUMBER;
13181 l_adr_flexfield_segment_code VARCHAR2(30);
13182 l_adr_flex_value_set_id NUMBER;
13183 l_adr_value_type_code VARCHAR2(30);
13184 l_adr_value_combination_id NUMBER;
13185 l_adr_value_segment_code VARCHAR2(30);
13186
13187 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
13188 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
13189 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
13190 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
13191
13192 -- 4262811 Variables ------------------------------------------------------------------------------------------
13193 l_entered_amt_idx NUMBER;
13194 l_accted_amt_idx NUMBER;
13195 l_acc_rev_flag VARCHAR2(1);
13196 l_accrual_line_num NUMBER;
13197 l_tmp_amt NUMBER;
13198 l_acc_rev_natural_side_code VARCHAR2(1);
13199
13200 l_num_entries NUMBER;
13201 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
13202 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
13203 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
13204 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
13205 l_recog_line_1 NUMBER;
13206 l_recog_line_2 NUMBER;
13207
13208 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
13212 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
13209 l_bflow_applied_to_amt NUMBER; -- 5132302
13210 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
13211
13213
13214 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
13215 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
13216
13217 ---------------------------------------------------------------------------------------------------------------
13218
13219
13220 --
13221 -- bulk performance
13222 --
13223 l_balance_type_code VARCHAR2(1);
13224 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
13225 l_log_module VARCHAR2(240);
13226
13227 --
13228 -- Upgrade strategy
13229 --
13230 l_actual_upg_option VARCHAR2(1);
13231 l_enc_upg_option VARCHAR2(1);
13232
13233 --
13234 BEGIN
13235 --
13236 IF g_log_enabled THEN
13237 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_38';
13238 END IF;
13239 --
13240 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13241
13242 trace
13243 (p_msg => 'BEGIN of AcctLineType_38'
13244 ,p_level => C_LEVEL_PROCEDURE
13245 ,p_module => l_log_module);
13246
13247 END IF;
13248 --
13249 l_component_type := 'AMB_JLT';
13250 l_component_code := 'DM_FREIGHT';
13251 l_component_type_code := 'S';
13252 l_component_appl_id := 222;
13253 l_amb_context_code := 'DEFAULT';
13254 l_entity_code := 'TRANSACTIONS';
13255 l_event_class_code := 'DEBIT_MEMO';
13256 l_event_type_code := 'DEBIT_MEMO_ALL';
13257 l_line_definition_owner_code := 'S';
13258 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
13259 --
13260 l_balance_type_code := 'A';
13261 l_segment := NULL;
13262 l_ccid := NULL;
13263 l_adr_transaction_coa_id := NULL;
13264 l_adr_accounting_coa_id := NULL;
13265 l_adr_flexfield_segment_code := NULL;
13266 l_adr_flex_value_set_id := NULL;
13267 l_adr_value_type_code := NULL;
13268 l_adr_value_combination_id := NULL;
13269 l_adr_value_segment_code := NULL;
13270
13271 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
13272 l_bflow_class_code := ''; -- 4219869 Business Flow
13273 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
13274 l_budgetary_control_flag := 'N';
13275
13276 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13277 l_bflow_applied_to_amt := NULL; -- 5132302
13278 l_entered_amt_idx := NULL; -- 4262811
13279 l_accted_amt_idx := NULL; -- 4262811
13280 l_acc_rev_flag := NULL; -- 4262811
13281 l_accrual_line_num := NULL; -- 4262811
13282 l_tmp_amt := NULL; -- 4262811
13283 --
13284
13285 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
13286 l_balance_type_code <> 'B' THEN
13287 IF NVL(p_source_28,'
13288 ') = 'FREIGHT'
13289 THEN
13290
13291 --
13292 XLA_AE_LINES_PKG.SetNewLine;
13293
13294 p_balance_type_code := l_balance_type_code;
13295 -- set the flag so later we will know whether the gain loss line needs to be created
13296
13297 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
13298 p_actual_flag :='A';
13299 END IF;
13300
13301 --
13302 -- bulk performance
13303 --
13304 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
13305 p_header_num => 0); -- 4262811
13306 --
13307 -- set accounting line options
13308 --
13309 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
13310 p_natural_side_code => 'C'
13311 , p_gain_or_loss_flag => 'N'
13312 , p_gl_transfer_mode_code => 'S'
13313 , p_acct_entry_type_code => 'A'
13314 , p_switch_side_flag => 'Y'
13315 , p_merge_duplicate_code => 'A'
13316 );
13317 --
13318 l_acc_rev_natural_side_code := 'D'; -- 4262811
13319 --
13320 --
13321 -- set accounting line type info
13322 --
13323 xla_ae_lines_pkg.SetAcctLineType
13324 (p_component_type => l_component_type
13325 ,p_event_type_code => l_event_type_code
13326 ,p_line_definition_owner_code => l_line_definition_owner_code
13327 ,p_line_definition_code => l_line_definition_code
13328 ,p_accounting_line_code => l_component_code
13329 ,p_accounting_line_type_code => l_component_type_code
13330 ,p_accounting_line_appl_id => l_component_appl_id
13331 ,p_amb_context_code => l_amb_context_code
13332 ,p_entity_code => l_entity_code
13333 ,p_event_class_code => l_event_class_code);
13334 --
13335 -- set accounting class
13336 --
13337 xla_ae_lines_pkg.SetAcctClass(
13338 p_accounting_class_code => 'FREIGHT'
13339 , p_ae_header_id => l_ae_header_id
13340 );
13341
13342 --
13343 -- set rounding class
13344 --
13345 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
13346 'RECEIVABLE';
13347
13348 --
13349 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
13350 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
13351 --
13352 -- bulk performance
13353 --
13354 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
13355
13356 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
13357 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
13358
13359 -- 4955764
13360 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13361 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
13362
13363 -- 4458381 Public Sector Enh
13364
13365 --
13366 -- set accounting attributes for the line type
13367 --
13368 l_entered_amt_idx := 3;
13369 l_accted_amt_idx := 8;
13370 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13371 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
13372 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
13373 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
13374 l_rec_acct_attrs.array_char_value(2) := p_source_30;
13375 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
13376 l_rec_acct_attrs.array_num_value(3) := p_source_31;
13377 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
13378 l_rec_acct_attrs.array_char_value(4) := p_source_32;
13379 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
13380 l_rec_acct_attrs.array_date_value(5) := p_source_33;
13381 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
13382 l_rec_acct_attrs.array_num_value(6) := p_source_34;
13383 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
13384 l_rec_acct_attrs.array_char_value(7) := p_source_35;
13385 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
13386 l_rec_acct_attrs.array_num_value(8) := p_source_36;
13387 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
13388 l_rec_acct_attrs.array_num_value(9) := p_source_25;
13389 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
13390 l_rec_acct_attrs.array_num_value(10) := p_source_26;
13391 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
13392 l_rec_acct_attrs.array_char_value(11) := p_source_27;
13393 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
13394 l_rec_acct_attrs.array_num_value(12) := p_source_50;
13395
13396 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
13397 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
13398
13399 ---------------------------------------------------------------------------------------------------------------
13400 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
13401 ---------------------------------------------------------------------------------------------------------------
13402 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
13403
13404 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13405 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13406
13407 IF xla_accounting_cache_pkg.GetValueChar
13408 (p_source_code => 'LEDGER_CATEGORY_CODE'
13409 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
13410 AND l_bflow_method_code = 'PRIOR_ENTRY'
13411 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
13412 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
13413 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
13414 )
13415 THEN
13416 xla_ae_lines_pkg.BflowUpgEntry
13417 (p_business_method_code => l_bflow_method_code
13418 ,p_business_class_code => l_bflow_class_code
13419 ,p_balance_type => l_balance_type_code);
13420 ELSE
13421 NULL;
13422 -- No business flow processing for business flow method of NONE.
13423 END IF;
13424
13425 --
13426 -- call analytical criteria
13427 --
13428
13429 --
13430 -- call description
13431 --
13432 -- No description or it is inherited.
13433 --
13434 -- call ADRs
13435 -- Bug 4922099
13436 --
13437 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13438 (NVL(l_actual_upg_option, 'N') = 'O') OR
13439 (NVL(l_enc_upg_option, 'N') = 'O')
13440 )
13441 THEN
13442 NULL;
13443 --
13444 --
13445
13446 l_ccid := AcctDerRule_18(
13447 p_application_id => p_application_id
13448 , p_ae_header_id => l_ae_header_id
13449 , p_source_14 => p_source_14
13450 , x_transaction_coa_id => l_adr_transaction_coa_id
13451 , x_accounting_coa_id => l_adr_accounting_coa_id
13452 , x_value_type_code => l_adr_value_type_code
13453 , p_side => 'NA'
13454 );
13455
13456 xla_ae_lines_pkg.set_ccid(
13457 p_code_combination_id => l_ccid
13458 , p_value_type_code => l_adr_value_type_code
13459 , p_transaction_coa_id => l_adr_transaction_coa_id
13460 , p_accounting_coa_id => l_adr_accounting_coa_id
13461 , p_adr_code => 'TRX_DIST_CCID'
13462 , p_adr_type_code => 'S'
13463 , p_component_type => l_component_type
13464 , p_component_code => l_component_code
13465 , p_component_type_code => l_component_type_code
13466 , p_component_appl_id => l_component_appl_id
13467 , p_amb_context_code => l_amb_context_code
13468 , p_side => 'NA'
13469 );
13470
13471
13472 --
13473 --
13474 END IF;
13475 --
13476 -- Bug 4922099
13477 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
13478 (NVL(l_enc_upg_option, 'N') = 'O')
13479 ) AND
13480 (l_bflow_method_code = 'PRIOR_ENTRY')
13481 )
13482 THEN
13483 IF
13484 --
13485 1 = 2
13486 --
13487 THEN
13488 xla_accounting_err_pkg.build_message
13489 (p_appli_s_name => 'XLA'
13490 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13491 ,p_token_1 => 'LINE_NUMBER'
13492 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
13493 ,p_token_2 => 'LINE_TYPE_NAME'
13494 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
13495 l_component_type
13496 ,l_component_code
13497 ,l_component_type_code
13498 ,l_component_appl_id
13499 ,l_amb_context_code
13500 ,l_entity_code
13501 ,l_event_class_code
13502 )
13503 ,p_token_3 => 'OWNER'
13504 ,p_value_3 => xla_lookups_pkg.get_meaning(
13505 p_lookup_type => 'XLA_OWNER_TYPE'
13506 ,p_lookup_code => l_component_type_code
13507 )
13508 ,p_token_4 => 'PRODUCT_NAME'
13509 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
13510 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
13511 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
13512 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
13513 ,p_ae_header_id => NULL
13514 );
13515
13516 IF (C_LEVEL_ERROR>= g_log_level) THEN
13517 trace
13518 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13519 ,p_level => C_LEVEL_ERROR
13520 ,p_module => l_log_module);
13521 END IF;
13522 END IF;
13523 END IF;
13524 --
13525 --
13526 ------------------------------------------------------------------------------------------------
13527 -- 4219869 Business Flow
13528 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
13529 -- Prior Entry. Currently, the following code is always generated.
13530 ------------------------------------------------------------------------------------------------
13531 XLA_AE_LINES_PKG.ValidateCurrentLine;
13532
13533 ------------------------------------------------------------------------------------
13534 -- 4219869 Business Flow
13535 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
13536 ------------------------------------------------------------------------------------
13537 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13538
13539 ----------------------------------------------------------------------------------
13540 -- 4219869 Business Flow
13541 -- Update journal entry status -- Need to generate this within IF <condition>
13542 ----------------------------------------------------------------------------------
13543 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13544 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
13545 ,p_balance_type_code => l_balance_type_code
13546 );
13547
13548 -------------------------------------------------------------------------------------------
13549 -- 4262811 - Generate the Accrual Reversal lines
13550 -------------------------------------------------------------------------------------------
13551 BEGIN
13552 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
13553 (g_array_event(p_event_id).array_value_num('header_index'));
13554 IF l_acc_rev_flag IS NULL THEN
13555 l_acc_rev_flag := 'N';
13556 END IF;
13557 EXCEPTION
13558 WHEN OTHERS THEN
13559 l_acc_rev_flag := 'N';
13560 END;
13561 --
13562 IF (l_acc_rev_flag = 'Y') THEN
13563
13564 -- 4645092 ------------------------------------------------------------------------------
13565 -- To allow MPA report to determine if it should generate report process
13566 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
13567 ------------------------------------------------------------------------------------------
13568
13569 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
13570 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
13571 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
13572 -- call ADRs
13573 -- Bug 4922099
13574 --
13575 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13576 (NVL(l_actual_upg_option, 'N') = 'O') OR
13577 (NVL(l_enc_upg_option, 'N') = 'O')
13578 )
13579 THEN
13580 NULL;
13581 --
13582 --
13583
13584 l_ccid := AcctDerRule_18(
13585 p_application_id => p_application_id
13586 , p_ae_header_id => l_ae_header_id
13587 , p_source_14 => p_source_14
13588 , x_transaction_coa_id => l_adr_transaction_coa_id
13589 , x_accounting_coa_id => l_adr_accounting_coa_id
13590 , x_value_type_code => l_adr_value_type_code
13591 , p_side => 'NA'
13592 );
13593
13594 xla_ae_lines_pkg.set_ccid(
13595 p_code_combination_id => l_ccid
13596 , p_value_type_code => l_adr_value_type_code
13597 , p_transaction_coa_id => l_adr_transaction_coa_id
13598 , p_accounting_coa_id => l_adr_accounting_coa_id
13599 , p_adr_code => 'TRX_DIST_CCID'
13600 , p_adr_type_code => 'S'
13601 , p_component_type => l_component_type
13602 , p_component_code => l_component_code
13603 , p_component_type_code => l_component_type_code
13604 , p_component_appl_id => l_component_appl_id
13605 , p_amb_context_code => l_amb_context_code
13606 , p_side => 'NA'
13607 );
13608
13609
13610 --
13611 --
13612 END IF;
13613
13614 --
13615 -- Update the line information that should be overwritten
13616 --
13617 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
13618 p_header_num => 1);
13619 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
13620
13621 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
13622
13623 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
13624 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
13625 END IF;
13626
13627 --
13628 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
13629 --
13630 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
13631 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
13632 ELSE
13633 ---------------------------------------------------------------------------------------------------
13634 -- 4262811a Switch Sign
13635 ---------------------------------------------------------------------------------------------------
13636 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
13637 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13638 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13639 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13640 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13641 -- 5132302
13642 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
13643 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13644
13645 END IF;
13646
13647 -- 4955764
13648 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13649 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
13650
13651
13652 XLA_AE_LINES_PKG.ValidateCurrentLine;
13653 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13654
13655 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13656 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
13657 ,p_balance_type_code => l_balance_type_code);
13658
13659 END IF;
13660
13661 -----------------------------------------------------------------------------------------
13662 -- 4262811 Multiperiod Accounting
13663 -----------------------------------------------------------------------------------------
13664 -- No MPA option is assigned.
13665
13666
13667 END IF;
13668 END IF;
13669 --
13670
13671 --
13672 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13673 trace
13674 (p_msg => 'END of AcctLineType_38'
13675 ,p_level => C_LEVEL_PROCEDURE
13676 ,p_module => l_log_module);
13677 END IF;
13678 --
13679 EXCEPTION
13680 WHEN xla_exceptions_pkg.application_exception THEN
13681 RAISE;
13682 WHEN OTHERS THEN
13683 xla_exceptions_pkg.raise_message
13684 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_38');
13685 END AcctLineType_38;
13686 --
13687
13688 ---------------------------------------
13689 --
13690 -- PRIVATE FUNCTION
13691 -- AcctLineType_39
13692 --
13693 ---------------------------------------
13694 PROCEDURE AcctLineType_39 (
13695 p_application_id IN NUMBER
13696 ,p_event_id IN NUMBER
13697 ,p_calculate_acctd_flag IN VARCHAR2
13698 ,p_calculate_g_l_flag IN VARCHAR2
13699 ,p_actual_flag IN OUT VARCHAR2
13700 ,p_balance_type_code OUT VARCHAR2
13701 ,p_gain_or_loss_ref OUT VARCHAR2
13702
13703 --Transaction Distribution GL Account
13704 , p_source_14 IN NUMBER
13705 --Bill To Customer Account Identifier
13706 , p_source_25 IN NUMBER
13707 --Bill To Customer Site Use Identifier
13708 , p_source_26 IN NUMBER
13709 --SLA Party Type
13710 , p_source_27 IN VARCHAR2
13711 --Transaction Distribution Account Class
13712 , p_source_28 IN VARCHAR2
13713 --Transaction Distribution Identifier
13714 , p_source_29 IN NUMBER
13715 --Transaction Distribution Type
13716 , p_source_30 IN VARCHAR2
13717 --Transaction Distribution Entered Amount
13718 , p_source_31 IN NUMBER
13719 --Transaction Currency Code
13720 , p_source_32 IN VARCHAR2
13721 --Transaction Exchange Date
13722 , p_source_33 IN DATE
13723 --Transaction Exchange Rate
13724 , p_source_34 IN NUMBER
13725 --Transaction Exchange Rate Type
13726 , p_source_35 IN VARCHAR2
13727 --Transaction Accounting Amount
13728 , p_source_36 IN NUMBER
13729 --Transaction Tax Line Identifier
13730 , p_source_50 IN NUMBER
13731 )
13732 IS
13733
13734 l_component_type VARCHAR2(80);
13735 l_component_code VARCHAR2(30);
13736 l_component_type_code VARCHAR2(1);
13737 l_component_appl_id INTEGER;
13738 l_amb_context_code VARCHAR2(30);
13739 l_entity_code VARCHAR2(30);
13740 l_event_class_code VARCHAR2(30);
13741 l_ae_header_id NUMBER;
13742 l_event_type_code VARCHAR2(30);
13743 l_line_definition_code VARCHAR2(30);
13744 l_line_definition_owner_code VARCHAR2(1);
13745 --
13746 -- adr variables
13747 l_segment VARCHAR2(30);
13748 l_ccid NUMBER;
13749 l_adr_transaction_coa_id NUMBER;
13750 l_adr_accounting_coa_id NUMBER;
13751 l_adr_flexfield_segment_code VARCHAR2(30);
13752 l_adr_flex_value_set_id NUMBER;
13753 l_adr_value_type_code VARCHAR2(30);
13754 l_adr_value_combination_id NUMBER;
13755 l_adr_value_segment_code VARCHAR2(30);
13756
13757 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
13758 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
13759 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
13760 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
13761
13762 -- 4262811 Variables ------------------------------------------------------------------------------------------
13763 l_entered_amt_idx NUMBER;
13764 l_accted_amt_idx NUMBER;
13765 l_acc_rev_flag VARCHAR2(1);
13766 l_accrual_line_num NUMBER;
13767 l_tmp_amt NUMBER;
13768 l_acc_rev_natural_side_code VARCHAR2(1);
13769
13770 l_num_entries NUMBER;
13771 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
13772 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
13773 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
13774 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
13775 l_recog_line_1 NUMBER;
13776 l_recog_line_2 NUMBER;
13777
13778 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
13779 l_bflow_applied_to_amt NUMBER; -- 5132302
13780 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
13781
13782 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
13783
13784 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
13785 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
13786
13787 ---------------------------------------------------------------------------------------------------------------
13788
13789
13790 --
13791 -- bulk performance
13792 --
13793 l_balance_type_code VARCHAR2(1);
13794 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
13795 l_log_module VARCHAR2(240);
13796
13797 --
13798 -- Upgrade strategy
13799 --
13800 l_actual_upg_option VARCHAR2(1);
13801 l_enc_upg_option VARCHAR2(1);
13802
13803 --
13804 BEGIN
13805 --
13806 IF g_log_enabled THEN
13807 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_39';
13808 END IF;
13809 --
13810 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13811
13812 trace
13813 (p_msg => 'BEGIN of AcctLineType_39'
13814 ,p_level => C_LEVEL_PROCEDURE
13815 ,p_module => l_log_module);
13816
13817 END IF;
13818 --
13819 l_component_type := 'AMB_JLT';
13820 l_component_code := 'DM_REV';
13821 l_component_type_code := 'S';
13822 l_component_appl_id := 222;
13823 l_amb_context_code := 'DEFAULT';
13824 l_entity_code := 'TRANSACTIONS';
13825 l_event_class_code := 'DEBIT_MEMO';
13826 l_event_type_code := 'DEBIT_MEMO_ALL';
13827 l_line_definition_owner_code := 'S';
13828 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
13829 --
13830 l_balance_type_code := 'A';
13831 l_segment := NULL;
13832 l_ccid := NULL;
13833 l_adr_transaction_coa_id := NULL;
13834 l_adr_accounting_coa_id := NULL;
13835 l_adr_flexfield_segment_code := NULL;
13836 l_adr_flex_value_set_id := NULL;
13837 l_adr_value_type_code := NULL;
13838 l_adr_value_combination_id := NULL;
13839 l_adr_value_segment_code := NULL;
13840
13841 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
13842 l_bflow_class_code := ''; -- 4219869 Business Flow
13843 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
13844 l_budgetary_control_flag := 'N';
13845
13846 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13847 l_bflow_applied_to_amt := NULL; -- 5132302
13848 l_entered_amt_idx := NULL; -- 4262811
13849 l_accted_amt_idx := NULL; -- 4262811
13850 l_acc_rev_flag := NULL; -- 4262811
13851 l_accrual_line_num := NULL; -- 4262811
13852 l_tmp_amt := NULL; -- 4262811
13853 --
13854
13855 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
13856 l_balance_type_code <> 'B' THEN
13857 IF NVL(p_source_28,'
13858 ') = 'REV'
13859 THEN
13860
13861 --
13862 XLA_AE_LINES_PKG.SetNewLine;
13863
13864 p_balance_type_code := l_balance_type_code;
13865 -- set the flag so later we will know whether the gain loss line needs to be created
13866
13867 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
13868 p_actual_flag :='A';
13869 END IF;
13870
13871 --
13872 -- bulk performance
13873 --
13874 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
13875 p_header_num => 0); -- 4262811
13876 --
13877 -- set accounting line options
13878 --
13879 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
13880 p_natural_side_code => 'C'
13881 , p_gain_or_loss_flag => 'N'
13882 , p_gl_transfer_mode_code => 'S'
13883 , p_acct_entry_type_code => 'A'
13884 , p_switch_side_flag => 'Y'
13885 , p_merge_duplicate_code => 'A'
13886 );
13887 --
13888 l_acc_rev_natural_side_code := 'D'; -- 4262811
13889 --
13890 --
13891 -- set accounting line type info
13892 --
13893 xla_ae_lines_pkg.SetAcctLineType
13894 (p_component_type => l_component_type
13895 ,p_event_type_code => l_event_type_code
13896 ,p_line_definition_owner_code => l_line_definition_owner_code
13897 ,p_line_definition_code => l_line_definition_code
13898 ,p_accounting_line_code => l_component_code
13899 ,p_accounting_line_type_code => l_component_type_code
13900 ,p_accounting_line_appl_id => l_component_appl_id
13901 ,p_amb_context_code => l_amb_context_code
13902 ,p_entity_code => l_entity_code
13903 ,p_event_class_code => l_event_class_code);
13904 --
13905 -- set accounting class
13906 --
13907 xla_ae_lines_pkg.SetAcctClass(
13908 p_accounting_class_code => 'REVENUE'
13909 , p_ae_header_id => l_ae_header_id
13910 );
13911
13912 --
13913 -- set rounding class
13914 --
13915 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
13916 'RECEIVABLE';
13917
13918 --
13919 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
13920 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
13921 --
13922 -- bulk performance
13923 --
13924 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
13925
13929 -- 4955764
13926 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
13927 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
13928
13930 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13931 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
13932
13933 -- 4458381 Public Sector Enh
13934
13935 --
13936 -- set accounting attributes for the line type
13937 --
13938 l_entered_amt_idx := 3;
13939 l_accted_amt_idx := 8;
13940 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13941 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
13942 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
13943 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
13944 l_rec_acct_attrs.array_char_value(2) := p_source_30;
13945 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
13946 l_rec_acct_attrs.array_num_value(3) := p_source_31;
13947 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
13948 l_rec_acct_attrs.array_char_value(4) := p_source_32;
13949 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
13950 l_rec_acct_attrs.array_date_value(5) := p_source_33;
13951 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
13952 l_rec_acct_attrs.array_num_value(6) := p_source_34;
13953 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
13954 l_rec_acct_attrs.array_char_value(7) := p_source_35;
13955 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
13956 l_rec_acct_attrs.array_num_value(8) := p_source_36;
13957 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
13958 l_rec_acct_attrs.array_num_value(9) := p_source_25;
13959 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
13960 l_rec_acct_attrs.array_num_value(10) := p_source_26;
13961 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
13962 l_rec_acct_attrs.array_char_value(11) := p_source_27;
13963 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
13964 l_rec_acct_attrs.array_num_value(12) := p_source_50;
13965
13966 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
13967 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
13968
13969 ---------------------------------------------------------------------------------------------------------------
13970 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
13971 ---------------------------------------------------------------------------------------------------------------
13972 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
13973
13974 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13975 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13976
13977 IF xla_accounting_cache_pkg.GetValueChar
13978 (p_source_code => 'LEDGER_CATEGORY_CODE'
13979 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
13980 AND l_bflow_method_code = 'PRIOR_ENTRY'
13981 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
13982 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
13983 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
13984 )
13985 THEN
13986 xla_ae_lines_pkg.BflowUpgEntry
13987 (p_business_method_code => l_bflow_method_code
13988 ,p_business_class_code => l_bflow_class_code
13989 ,p_balance_type => l_balance_type_code);
13990 ELSE
13991 NULL;
13992 -- No business flow processing for business flow method of NONE.
13993 END IF;
13994
13995 --
13996 -- call analytical criteria
13997 --
13998
13999 --
14000 -- call description
14001 --
14002 -- No description or it is inherited.
14003 --
14004 -- call ADRs
14005 -- Bug 4922099
14006 --
14007 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14008 (NVL(l_actual_upg_option, 'N') = 'O') OR
14009 (NVL(l_enc_upg_option, 'N') = 'O')
14010 )
14011 THEN
14012 NULL;
14013 --
14014 --
14015
14016 l_ccid := AcctDerRule_18(
14017 p_application_id => p_application_id
14018 , p_ae_header_id => l_ae_header_id
14019 , p_source_14 => p_source_14
14020 , x_transaction_coa_id => l_adr_transaction_coa_id
14021 , x_accounting_coa_id => l_adr_accounting_coa_id
14022 , x_value_type_code => l_adr_value_type_code
14023 , p_side => 'NA'
14024 );
14025
14026 xla_ae_lines_pkg.set_ccid(
14027 p_code_combination_id => l_ccid
14028 , p_value_type_code => l_adr_value_type_code
14029 , p_transaction_coa_id => l_adr_transaction_coa_id
14030 , p_accounting_coa_id => l_adr_accounting_coa_id
14031 , p_adr_code => 'TRX_DIST_CCID'
14032 , p_adr_type_code => 'S'
14033 , p_component_type => l_component_type
14034 , p_component_code => l_component_code
14035 , p_component_type_code => l_component_type_code
14036 , p_component_appl_id => l_component_appl_id
14037 , p_amb_context_code => l_amb_context_code
14038 , p_side => 'NA'
14039 );
14040
14041
14042 --
14043 --
14044 END IF;
14045 --
14046 -- Bug 4922099
14047 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
14048 (NVL(l_enc_upg_option, 'N') = 'O')
14049 ) AND
14050 (l_bflow_method_code = 'PRIOR_ENTRY')
14051 )
14052 THEN
14053 IF
14054 --
14055 1 = 2
14056 --
14057 THEN
14058 xla_accounting_err_pkg.build_message
14059 (p_appli_s_name => 'XLA'
14060 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14061 ,p_token_1 => 'LINE_NUMBER'
14062 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
14063 ,p_token_2 => 'LINE_TYPE_NAME'
14064 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
14065 l_component_type
14066 ,l_component_code
14067 ,l_component_type_code
14068 ,l_component_appl_id
14069 ,l_amb_context_code
14070 ,l_entity_code
14071 ,l_event_class_code
14072 )
14073 ,p_token_3 => 'OWNER'
14074 ,p_value_3 => xla_lookups_pkg.get_meaning(
14075 p_lookup_type => 'XLA_OWNER_TYPE'
14076 ,p_lookup_code => l_component_type_code
14077 )
14078 ,p_token_4 => 'PRODUCT_NAME'
14079 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
14080 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
14081 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
14082 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
14083 ,p_ae_header_id => NULL
14084 );
14085
14086 IF (C_LEVEL_ERROR>= g_log_level) THEN
14087 trace
14088 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14089 ,p_level => C_LEVEL_ERROR
14090 ,p_module => l_log_module);
14091 END IF;
14092 END IF;
14093 END IF;
14094 --
14095 --
14096 ------------------------------------------------------------------------------------------------
14097 -- 4219869 Business Flow
14098 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
14099 -- Prior Entry. Currently, the following code is always generated.
14100 ------------------------------------------------------------------------------------------------
14101 XLA_AE_LINES_PKG.ValidateCurrentLine;
14102
14103 ------------------------------------------------------------------------------------
14104 -- 4219869 Business Flow
14105 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
14106 ------------------------------------------------------------------------------------
14107 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14108
14109 ----------------------------------------------------------------------------------
14110 -- 4219869 Business Flow
14111 -- Update journal entry status -- Need to generate this within IF <condition>
14112 ----------------------------------------------------------------------------------
14113 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14114 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
14115 ,p_balance_type_code => l_balance_type_code
14116 );
14117
14118 -------------------------------------------------------------------------------------------
14119 -- 4262811 - Generate the Accrual Reversal lines
14120 -------------------------------------------------------------------------------------------
14121 BEGIN
14122 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
14123 (g_array_event(p_event_id).array_value_num('header_index'));
14124 IF l_acc_rev_flag IS NULL THEN
14125 l_acc_rev_flag := 'N';
14126 END IF;
14127 EXCEPTION
14128 WHEN OTHERS THEN
14129 l_acc_rev_flag := 'N';
14130 END;
14131 --
14132 IF (l_acc_rev_flag = 'Y') THEN
14133
14134 -- 4645092 ------------------------------------------------------------------------------
14135 -- To allow MPA report to determine if it should generate report process
14136 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
14137 ------------------------------------------------------------------------------------------
14138
14139 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
14140 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
14141 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
14142 -- call ADRs
14143 -- Bug 4922099
14144 --
14145 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14146 (NVL(l_actual_upg_option, 'N') = 'O') OR
14147 (NVL(l_enc_upg_option, 'N') = 'O')
14148 )
14149 THEN
14150 NULL;
14151 --
14152 --
14153
14154 l_ccid := AcctDerRule_18(
14155 p_application_id => p_application_id
14156 , p_ae_header_id => l_ae_header_id
14157 , p_source_14 => p_source_14
14158 , x_transaction_coa_id => l_adr_transaction_coa_id
14159 , x_accounting_coa_id => l_adr_accounting_coa_id
14160 , x_value_type_code => l_adr_value_type_code
14161 , p_side => 'NA'
14162 );
14163
14164 xla_ae_lines_pkg.set_ccid(
14165 p_code_combination_id => l_ccid
14166 , p_value_type_code => l_adr_value_type_code
14167 , p_transaction_coa_id => l_adr_transaction_coa_id
14168 , p_accounting_coa_id => l_adr_accounting_coa_id
14169 , p_adr_code => 'TRX_DIST_CCID'
14170 , p_adr_type_code => 'S'
14171 , p_component_type => l_component_type
14172 , p_component_code => l_component_code
14173 , p_component_type_code => l_component_type_code
14174 , p_component_appl_id => l_component_appl_id
14175 , p_amb_context_code => l_amb_context_code
14176 , p_side => 'NA'
14177 );
14178
14179
14180 --
14181 --
14182 END IF;
14183
14184 --
14185 -- Update the line information that should be overwritten
14186 --
14187 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
14188 p_header_num => 1);
14189 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
14190
14191 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
14192
14193 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
14194 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
14195 END IF;
14196
14197 --
14198 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
14199 --
14200 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
14201 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
14202 ELSE
14203 ---------------------------------------------------------------------------------------------------
14204 -- 4262811a Switch Sign
14205 ---------------------------------------------------------------------------------------------------
14206 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
14207 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14208 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14209 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14210 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14211 -- 5132302
14212 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
14213 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14214
14215 END IF;
14216
14217 -- 4955764
14218 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14219 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
14220
14221
14222 XLA_AE_LINES_PKG.ValidateCurrentLine;
14223 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14224
14225 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14226 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
14227 ,p_balance_type_code => l_balance_type_code);
14228
14229 END IF;
14230
14231 -----------------------------------------------------------------------------------------
14232 -- 4262811 Multiperiod Accounting
14233 -----------------------------------------------------------------------------------------
14234 -- No MPA option is assigned.
14235
14236
14237 END IF;
14238 END IF;
14239 --
14240
14241 --
14242 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14243 trace
14244 (p_msg => 'END of AcctLineType_39'
14245 ,p_level => C_LEVEL_PROCEDURE
14246 ,p_module => l_log_module);
14247 END IF;
14248 --
14249 EXCEPTION
14250 WHEN xla_exceptions_pkg.application_exception THEN
14251 RAISE;
14252 WHEN OTHERS THEN
14253 xla_exceptions_pkg.raise_message
14254 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_39');
14255 END AcctLineType_39;
14256 --
14257
14258 ---------------------------------------
14259 --
14260 -- PRIVATE FUNCTION
14261 -- AcctLineType_40
14262 --
14263 ---------------------------------------
14264 PROCEDURE AcctLineType_40 (
14265 p_application_id IN NUMBER
14266 ,p_event_id IN NUMBER
14267 ,p_calculate_acctd_flag IN VARCHAR2
14268 ,p_calculate_g_l_flag IN VARCHAR2
14269 ,p_actual_flag IN OUT VARCHAR2
14270 ,p_balance_type_code OUT VARCHAR2
14271 ,p_gain_or_loss_ref OUT VARCHAR2
14272
14273 --Transaction Distribution GL Account
14274 , p_source_14 IN NUMBER
14275 --Bill To Customer Account Identifier
14276 , p_source_25 IN NUMBER
14277 --Bill To Customer Site Use Identifier
14278 , p_source_26 IN NUMBER
14279 --SLA Party Type
14280 , p_source_27 IN VARCHAR2
14281 --Transaction Distribution Account Class
14282 , p_source_28 IN VARCHAR2
14283 --Transaction Distribution Identifier
14284 , p_source_29 IN NUMBER
14285 --Transaction Distribution Type
14286 , p_source_30 IN VARCHAR2
14287 --Transaction Distribution Entered Amount
14288 , p_source_31 IN NUMBER
14289 --Transaction Currency Code
14290 , p_source_32 IN VARCHAR2
14291 --Transaction Exchange Date
14292 , p_source_33 IN DATE
14293 --Transaction Exchange Rate
14294 , p_source_34 IN NUMBER
14295 --Transaction Exchange Rate Type
14296 , p_source_35 IN VARCHAR2
14297 --Transaction Accounting Amount
14298 , p_source_36 IN NUMBER
14299 --Transaction Tax Line Identifier
14300 , p_source_50 IN NUMBER
14301 )
14302 IS
14303
14304 l_component_type VARCHAR2(80);
14305 l_component_code VARCHAR2(30);
14306 l_component_type_code VARCHAR2(1);
14307 l_component_appl_id INTEGER;
14308 l_amb_context_code VARCHAR2(30);
14309 l_entity_code VARCHAR2(30);
14310 l_event_class_code VARCHAR2(30);
14311 l_ae_header_id NUMBER;
14312 l_event_type_code VARCHAR2(30);
14313 l_line_definition_code VARCHAR2(30);
14314 l_line_definition_owner_code VARCHAR2(1);
14315 --
14316 -- adr variables
14317 l_segment VARCHAR2(30);
14318 l_ccid NUMBER;
14319 l_adr_transaction_coa_id NUMBER;
14320 l_adr_accounting_coa_id NUMBER;
14321 l_adr_flexfield_segment_code VARCHAR2(30);
14322 l_adr_flex_value_set_id NUMBER;
14323 l_adr_value_type_code VARCHAR2(30);
14324 l_adr_value_combination_id NUMBER;
14325 l_adr_value_segment_code VARCHAR2(30);
14326
14327 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
14328 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
14329 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
14330 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
14331
14332 -- 4262811 Variables ------------------------------------------------------------------------------------------
14333 l_entered_amt_idx NUMBER;
14334 l_accted_amt_idx NUMBER;
14335 l_acc_rev_flag VARCHAR2(1);
14336 l_accrual_line_num NUMBER;
14337 l_tmp_amt NUMBER;
14338 l_acc_rev_natural_side_code VARCHAR2(1);
14339
14340 l_num_entries NUMBER;
14341 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
14342 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
14343 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
14344 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
14345 l_recog_line_1 NUMBER;
14346 l_recog_line_2 NUMBER;
14347
14348 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
14349 l_bflow_applied_to_amt NUMBER; -- 5132302
14350 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
14351
14352 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
14353
14354 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
14355 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
14356
14357 ---------------------------------------------------------------------------------------------------------------
14358
14359
14360 --
14361 -- bulk performance
14362 --
14366
14363 l_balance_type_code VARCHAR2(1);
14364 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
14365 l_log_module VARCHAR2(240);
14367 --
14368 -- Upgrade strategy
14369 --
14370 l_actual_upg_option VARCHAR2(1);
14371 l_enc_upg_option VARCHAR2(1);
14372
14373 --
14374 BEGIN
14375 --
14376 IF g_log_enabled THEN
14377 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_40';
14378 END IF;
14379 --
14380 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14381
14382 trace
14383 (p_msg => 'BEGIN of AcctLineType_40'
14384 ,p_level => C_LEVEL_PROCEDURE
14385 ,p_module => l_log_module);
14386
14387 END IF;
14388 --
14389 l_component_type := 'AMB_JLT';
14390 l_component_code := 'DM_ROUND';
14391 l_component_type_code := 'S';
14392 l_component_appl_id := 222;
14393 l_amb_context_code := 'DEFAULT';
14394 l_entity_code := 'TRANSACTIONS';
14395 l_event_class_code := 'DEBIT_MEMO';
14396 l_event_type_code := 'DEBIT_MEMO_ALL';
14397 l_line_definition_owner_code := 'S';
14398 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
14399 --
14400 l_balance_type_code := 'A';
14401 l_segment := NULL;
14402 l_ccid := NULL;
14403 l_adr_transaction_coa_id := NULL;
14404 l_adr_accounting_coa_id := NULL;
14405 l_adr_flexfield_segment_code := NULL;
14406 l_adr_flex_value_set_id := NULL;
14407 l_adr_value_type_code := NULL;
14408 l_adr_value_combination_id := NULL;
14409 l_adr_value_segment_code := NULL;
14410
14411 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
14412 l_bflow_class_code := ''; -- 4219869 Business Flow
14413 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
14414 l_budgetary_control_flag := 'N';
14415
14416 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14417 l_bflow_applied_to_amt := NULL; -- 5132302
14418 l_entered_amt_idx := NULL; -- 4262811
14419 l_accted_amt_idx := NULL; -- 4262811
14420 l_acc_rev_flag := NULL; -- 4262811
14421 l_accrual_line_num := NULL; -- 4262811
14422 l_tmp_amt := NULL; -- 4262811
14423 --
14424
14425 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
14426 l_balance_type_code <> 'B' THEN
14427 IF NVL(p_source_28,'
14428 ') = 'ROUND'
14429 THEN
14430
14431 --
14432 XLA_AE_LINES_PKG.SetNewLine;
14433
14434 p_balance_type_code := l_balance_type_code;
14435 -- set the flag so later we will know whether the gain loss line needs to be created
14436
14437 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
14438 p_actual_flag :='A';
14439 END IF;
14440
14441 --
14442 -- bulk performance
14443 --
14444 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
14445 p_header_num => 0); -- 4262811
14446 --
14447 -- set accounting line options
14448 --
14449 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
14450 p_natural_side_code => 'C'
14451 , p_gain_or_loss_flag => 'N'
14452 , p_gl_transfer_mode_code => 'S'
14453 , p_acct_entry_type_code => 'A'
14454 , p_switch_side_flag => 'Y'
14455 , p_merge_duplicate_code => 'A'
14456 );
14457 --
14458 l_acc_rev_natural_side_code := 'D'; -- 4262811
14459 --
14460 --
14461 -- set accounting line type info
14462 --
14463 xla_ae_lines_pkg.SetAcctLineType
14464 (p_component_type => l_component_type
14465 ,p_event_type_code => l_event_type_code
14466 ,p_line_definition_owner_code => l_line_definition_owner_code
14467 ,p_line_definition_code => l_line_definition_code
14468 ,p_accounting_line_code => l_component_code
14469 ,p_accounting_line_type_code => l_component_type_code
14470 ,p_accounting_line_appl_id => l_component_appl_id
14471 ,p_amb_context_code => l_amb_context_code
14472 ,p_entity_code => l_entity_code
14473 ,p_event_class_code => l_event_class_code);
14474 --
14475 -- set accounting class
14476 --
14477 xla_ae_lines_pkg.SetAcctClass(
14478 p_accounting_class_code => 'ROUNDING'
14479 , p_ae_header_id => l_ae_header_id
14480 );
14481
14482 --
14483 -- set rounding class
14484 --
14485 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
14486 'RECEIVABLE';
14487
14488 --
14489 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
14490 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
14491 --
14492 -- bulk performance
14493 --
14494 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
14495
14496 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
14497 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
14498
14499 -- 4955764
14503 -- 4458381 Public Sector Enh
14500 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14501 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
14502
14504
14505 --
14506 -- set accounting attributes for the line type
14507 --
14508 l_entered_amt_idx := 3;
14509 l_accted_amt_idx := 8;
14510 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14511 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
14512 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
14513 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
14514 l_rec_acct_attrs.array_char_value(2) := p_source_30;
14515 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
14516 l_rec_acct_attrs.array_num_value(3) := p_source_31;
14517 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
14518 l_rec_acct_attrs.array_char_value(4) := p_source_32;
14519 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
14520 l_rec_acct_attrs.array_date_value(5) := p_source_33;
14521 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
14522 l_rec_acct_attrs.array_num_value(6) := p_source_34;
14523 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
14524 l_rec_acct_attrs.array_char_value(7) := p_source_35;
14525 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
14526 l_rec_acct_attrs.array_num_value(8) := p_source_36;
14527 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
14528 l_rec_acct_attrs.array_num_value(9) := p_source_25;
14529 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
14530 l_rec_acct_attrs.array_num_value(10) := p_source_26;
14531 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
14532 l_rec_acct_attrs.array_char_value(11) := p_source_27;
14533 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
14534 l_rec_acct_attrs.array_num_value(12) := p_source_50;
14535
14536 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
14537 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
14538
14539 ---------------------------------------------------------------------------------------------------------------
14540 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
14541 ---------------------------------------------------------------------------------------------------------------
14542 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
14543
14544 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
14545 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
14546
14547 IF xla_accounting_cache_pkg.GetValueChar
14548 (p_source_code => 'LEDGER_CATEGORY_CODE'
14549 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
14550 AND l_bflow_method_code = 'PRIOR_ENTRY'
14551 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
14552 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
14553 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
14554 )
14555 THEN
14556 xla_ae_lines_pkg.BflowUpgEntry
14557 (p_business_method_code => l_bflow_method_code
14558 ,p_business_class_code => l_bflow_class_code
14559 ,p_balance_type => l_balance_type_code);
14560 ELSE
14561 NULL;
14562 -- No business flow processing for business flow method of NONE.
14563 END IF;
14564
14565 --
14566 -- call analytical criteria
14567 --
14568
14569 --
14570 -- call description
14571 --
14572 -- No description or it is inherited.
14573 --
14574 -- call ADRs
14575 -- Bug 4922099
14576 --
14577 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14578 (NVL(l_actual_upg_option, 'N') = 'O') OR
14579 (NVL(l_enc_upg_option, 'N') = 'O')
14580 )
14581 THEN
14582 NULL;
14583 --
14584 --
14585
14586 l_ccid := AcctDerRule_18(
14587 p_application_id => p_application_id
14588 , p_ae_header_id => l_ae_header_id
14589 , p_source_14 => p_source_14
14590 , x_transaction_coa_id => l_adr_transaction_coa_id
14591 , x_accounting_coa_id => l_adr_accounting_coa_id
14592 , x_value_type_code => l_adr_value_type_code
14593 , p_side => 'NA'
14594 );
14595
14596 xla_ae_lines_pkg.set_ccid(
14597 p_code_combination_id => l_ccid
14598 , p_value_type_code => l_adr_value_type_code
14599 , p_transaction_coa_id => l_adr_transaction_coa_id
14600 , p_accounting_coa_id => l_adr_accounting_coa_id
14601 , p_adr_code => 'TRX_DIST_CCID'
14602 , p_adr_type_code => 'S'
14603 , p_component_type => l_component_type
14604 , p_component_code => l_component_code
14605 , p_component_type_code => l_component_type_code
14606 , p_component_appl_id => l_component_appl_id
14607 , p_amb_context_code => l_amb_context_code
14608 , p_side => 'NA'
14609 );
14610
14611
14612 --
14613 --
14614 END IF;
14615 --
14616 -- Bug 4922099
14617 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
14621 )
14618 (NVL(l_enc_upg_option, 'N') = 'O')
14619 ) AND
14620 (l_bflow_method_code = 'PRIOR_ENTRY')
14622 THEN
14623 IF
14624 --
14625 1 = 2
14626 --
14627 THEN
14628 xla_accounting_err_pkg.build_message
14629 (p_appli_s_name => 'XLA'
14630 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14631 ,p_token_1 => 'LINE_NUMBER'
14632 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
14633 ,p_token_2 => 'LINE_TYPE_NAME'
14634 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
14635 l_component_type
14636 ,l_component_code
14637 ,l_component_type_code
14638 ,l_component_appl_id
14639 ,l_amb_context_code
14640 ,l_entity_code
14641 ,l_event_class_code
14642 )
14643 ,p_token_3 => 'OWNER'
14644 ,p_value_3 => xla_lookups_pkg.get_meaning(
14645 p_lookup_type => 'XLA_OWNER_TYPE'
14646 ,p_lookup_code => l_component_type_code
14647 )
14648 ,p_token_4 => 'PRODUCT_NAME'
14649 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
14650 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
14651 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
14652 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
14653 ,p_ae_header_id => NULL
14654 );
14655
14656 IF (C_LEVEL_ERROR>= g_log_level) THEN
14657 trace
14658 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14659 ,p_level => C_LEVEL_ERROR
14660 ,p_module => l_log_module);
14661 END IF;
14662 END IF;
14663 END IF;
14664 --
14665 --
14666 ------------------------------------------------------------------------------------------------
14667 -- 4219869 Business Flow
14668 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
14669 -- Prior Entry. Currently, the following code is always generated.
14670 ------------------------------------------------------------------------------------------------
14671 XLA_AE_LINES_PKG.ValidateCurrentLine;
14672
14673 ------------------------------------------------------------------------------------
14674 -- 4219869 Business Flow
14675 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
14676 ------------------------------------------------------------------------------------
14677 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14678
14679 ----------------------------------------------------------------------------------
14680 -- 4219869 Business Flow
14681 -- Update journal entry status -- Need to generate this within IF <condition>
14682 ----------------------------------------------------------------------------------
14683 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14684 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
14685 ,p_balance_type_code => l_balance_type_code
14686 );
14687
14688 -------------------------------------------------------------------------------------------
14689 -- 4262811 - Generate the Accrual Reversal lines
14690 -------------------------------------------------------------------------------------------
14691 BEGIN
14692 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
14693 (g_array_event(p_event_id).array_value_num('header_index'));
14694 IF l_acc_rev_flag IS NULL THEN
14695 l_acc_rev_flag := 'N';
14696 END IF;
14697 EXCEPTION
14698 WHEN OTHERS THEN
14699 l_acc_rev_flag := 'N';
14700 END;
14701 --
14702 IF (l_acc_rev_flag = 'Y') THEN
14703
14704 -- 4645092 ------------------------------------------------------------------------------
14705 -- To allow MPA report to determine if it should generate report process
14706 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
14707 ------------------------------------------------------------------------------------------
14708
14709 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
14710 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
14711 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
14712 -- call ADRs
14713 -- Bug 4922099
14714 --
14715 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14716 (NVL(l_actual_upg_option, 'N') = 'O') OR
14717 (NVL(l_enc_upg_option, 'N') = 'O')
14718 )
14722 --
14719 THEN
14720 NULL;
14721 --
14723
14724 l_ccid := AcctDerRule_18(
14725 p_application_id => p_application_id
14726 , p_ae_header_id => l_ae_header_id
14727 , p_source_14 => p_source_14
14728 , x_transaction_coa_id => l_adr_transaction_coa_id
14729 , x_accounting_coa_id => l_adr_accounting_coa_id
14730 , x_value_type_code => l_adr_value_type_code
14731 , p_side => 'NA'
14732 );
14733
14734 xla_ae_lines_pkg.set_ccid(
14735 p_code_combination_id => l_ccid
14736 , p_value_type_code => l_adr_value_type_code
14737 , p_transaction_coa_id => l_adr_transaction_coa_id
14738 , p_accounting_coa_id => l_adr_accounting_coa_id
14739 , p_adr_code => 'TRX_DIST_CCID'
14740 , p_adr_type_code => 'S'
14741 , p_component_type => l_component_type
14742 , p_component_code => l_component_code
14743 , p_component_type_code => l_component_type_code
14744 , p_component_appl_id => l_component_appl_id
14745 , p_amb_context_code => l_amb_context_code
14746 , p_side => 'NA'
14747 );
14748
14749
14750 --
14751 --
14752 END IF;
14753
14754 --
14755 -- Update the line information that should be overwritten
14756 --
14757 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
14758 p_header_num => 1);
14759 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
14760
14761 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
14762
14763 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
14764 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
14765 END IF;
14766
14767 --
14768 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
14769 --
14770 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
14771 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
14772 ELSE
14773 ---------------------------------------------------------------------------------------------------
14774 -- 4262811a Switch Sign
14775 ---------------------------------------------------------------------------------------------------
14776 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
14777 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14778 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14779 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14780 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14781 -- 5132302
14782 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
14783 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14784
14785 END IF;
14786
14787 -- 4955764
14788 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14789 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
14790
14791
14792 XLA_AE_LINES_PKG.ValidateCurrentLine;
14793 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14794
14795 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14796 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
14797 ,p_balance_type_code => l_balance_type_code);
14798
14799 END IF;
14800
14801 -----------------------------------------------------------------------------------------
14802 -- 4262811 Multiperiod Accounting
14803 -----------------------------------------------------------------------------------------
14804 -- No MPA option is assigned.
14805
14806
14807 END IF;
14808 END IF;
14809 --
14810
14811 --
14812 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14813 trace
14814 (p_msg => 'END of AcctLineType_40'
14815 ,p_level => C_LEVEL_PROCEDURE
14816 ,p_module => l_log_module);
14817 END IF;
14818 --
14819 EXCEPTION
14820 WHEN xla_exceptions_pkg.application_exception THEN
14821 RAISE;
14822 WHEN OTHERS THEN
14823 xla_exceptions_pkg.raise_message
14824 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_40');
14825 END AcctLineType_40;
14826 --
14827
14828 ---------------------------------------
14829 --
14830 -- PRIVATE FUNCTION
14831 -- AcctLineType_41
14832 --
14833 ---------------------------------------
14834 PROCEDURE AcctLineType_41 (
14835 p_application_id IN NUMBER
14836 ,p_event_id IN NUMBER
14837 ,p_calculate_acctd_flag IN VARCHAR2
14838 ,p_calculate_g_l_flag IN VARCHAR2
14839 ,p_actual_flag IN OUT VARCHAR2
14840 ,p_balance_type_code OUT VARCHAR2
14841 ,p_gain_or_loss_ref OUT VARCHAR2
14842
14843 --Transaction Distribution GL Account
14844 , p_source_14 IN NUMBER
14845 --Bill To Customer Account Identifier
14846 , p_source_25 IN NUMBER
14847 --Bill To Customer Site Use Identifier
14848 , p_source_26 IN NUMBER
14852 , p_source_28 IN VARCHAR2
14849 --SLA Party Type
14850 , p_source_27 IN VARCHAR2
14851 --Transaction Distribution Account Class
14853 --Transaction Distribution Identifier
14854 , p_source_29 IN NUMBER
14855 --Transaction Distribution Type
14856 , p_source_30 IN VARCHAR2
14857 --Transaction Distribution Entered Amount
14858 , p_source_31 IN NUMBER
14859 --Transaction Currency Code
14860 , p_source_32 IN VARCHAR2
14861 --Transaction Exchange Date
14862 , p_source_33 IN DATE
14863 --Transaction Exchange Rate
14864 , p_source_34 IN NUMBER
14865 --Transaction Exchange Rate Type
14866 , p_source_35 IN VARCHAR2
14867 --Transaction Accounting Amount
14868 , p_source_36 IN NUMBER
14869 --Transaction Tax Line Identifier
14870 , p_source_50 IN NUMBER
14871 )
14872 IS
14873
14874 l_component_type VARCHAR2(80);
14875 l_component_code VARCHAR2(30);
14876 l_component_type_code VARCHAR2(1);
14877 l_component_appl_id INTEGER;
14878 l_amb_context_code VARCHAR2(30);
14879 l_entity_code VARCHAR2(30);
14880 l_event_class_code VARCHAR2(30);
14881 l_ae_header_id NUMBER;
14882 l_event_type_code VARCHAR2(30);
14883 l_line_definition_code VARCHAR2(30);
14884 l_line_definition_owner_code VARCHAR2(1);
14885 --
14886 -- adr variables
14887 l_segment VARCHAR2(30);
14888 l_ccid NUMBER;
14889 l_adr_transaction_coa_id NUMBER;
14890 l_adr_accounting_coa_id NUMBER;
14891 l_adr_flexfield_segment_code VARCHAR2(30);
14892 l_adr_flex_value_set_id NUMBER;
14893 l_adr_value_type_code VARCHAR2(30);
14894 l_adr_value_combination_id NUMBER;
14895 l_adr_value_segment_code VARCHAR2(30);
14896
14897 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
14898 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
14899 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
14900 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
14901
14902 -- 4262811 Variables ------------------------------------------------------------------------------------------
14903 l_entered_amt_idx NUMBER;
14904 l_accted_amt_idx NUMBER;
14905 l_acc_rev_flag VARCHAR2(1);
14906 l_accrual_line_num NUMBER;
14907 l_tmp_amt NUMBER;
14908 l_acc_rev_natural_side_code VARCHAR2(1);
14909
14910 l_num_entries NUMBER;
14911 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
14912 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
14913 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
14914 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
14915 l_recog_line_1 NUMBER;
14916 l_recog_line_2 NUMBER;
14917
14918 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
14919 l_bflow_applied_to_amt NUMBER; -- 5132302
14920 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
14921
14922 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
14923
14924 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
14925 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
14926
14927 ---------------------------------------------------------------------------------------------------------------
14928
14929
14930 --
14931 -- bulk performance
14932 --
14933 l_balance_type_code VARCHAR2(1);
14934 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
14935 l_log_module VARCHAR2(240);
14936
14937 --
14938 -- Upgrade strategy
14939 --
14940 l_actual_upg_option VARCHAR2(1);
14941 l_enc_upg_option VARCHAR2(1);
14942
14943 --
14944 BEGIN
14945 --
14946 IF g_log_enabled THEN
14947 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_41';
14948 END IF;
14949 --
14950 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14951
14952 trace
14953 (p_msg => 'BEGIN of AcctLineType_41'
14954 ,p_level => C_LEVEL_PROCEDURE
14955 ,p_module => l_log_module);
14956
14957 END IF;
14958 --
14959 l_component_type := 'AMB_JLT';
14960 l_component_code := 'DM_TAX';
14961 l_component_type_code := 'S';
14962 l_component_appl_id := 222;
14963 l_amb_context_code := 'DEFAULT';
14964 l_entity_code := 'TRANSACTIONS';
14965 l_event_class_code := 'DEBIT_MEMO';
14966 l_event_type_code := 'DEBIT_MEMO_ALL';
14967 l_line_definition_owner_code := 'S';
14968 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
14969 --
14970 l_balance_type_code := 'A';
14971 l_segment := NULL;
14972 l_ccid := NULL;
14973 l_adr_transaction_coa_id := NULL;
14974 l_adr_accounting_coa_id := NULL;
14975 l_adr_flexfield_segment_code := NULL;
14976 l_adr_flex_value_set_id := NULL;
14977 l_adr_value_type_code := NULL;
14978 l_adr_value_combination_id := NULL;
14979 l_adr_value_segment_code := NULL;
14980
14981 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
14982 l_bflow_class_code := ''; -- 4219869 Business Flow
14983 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
14984 l_budgetary_control_flag := 'N';
14985
14989 l_accted_amt_idx := NULL; -- 4262811
14986 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14987 l_bflow_applied_to_amt := NULL; -- 5132302
14988 l_entered_amt_idx := NULL; -- 4262811
14990 l_acc_rev_flag := NULL; -- 4262811
14991 l_accrual_line_num := NULL; -- 4262811
14992 l_tmp_amt := NULL; -- 4262811
14993 --
14994
14995 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
14996 l_balance_type_code <> 'B' THEN
14997 IF NVL(p_source_28,'
14998 ') = 'TAX'
14999 THEN
15000
15001 --
15002 XLA_AE_LINES_PKG.SetNewLine;
15003
15004 p_balance_type_code := l_balance_type_code;
15005 -- set the flag so later we will know whether the gain loss line needs to be created
15006
15007 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
15008 p_actual_flag :='A';
15009 END IF;
15010
15011 --
15012 -- bulk performance
15013 --
15014 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
15015 p_header_num => 0); -- 4262811
15016 --
15017 -- set accounting line options
15018 --
15019 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
15020 p_natural_side_code => 'C'
15021 , p_gain_or_loss_flag => 'N'
15022 , p_gl_transfer_mode_code => 'S'
15023 , p_acct_entry_type_code => 'A'
15024 , p_switch_side_flag => 'Y'
15025 , p_merge_duplicate_code => 'A'
15026 );
15027 --
15028 l_acc_rev_natural_side_code := 'D'; -- 4262811
15029 --
15030 --
15031 -- set accounting line type info
15032 --
15033 xla_ae_lines_pkg.SetAcctLineType
15034 (p_component_type => l_component_type
15035 ,p_event_type_code => l_event_type_code
15036 ,p_line_definition_owner_code => l_line_definition_owner_code
15037 ,p_line_definition_code => l_line_definition_code
15038 ,p_accounting_line_code => l_component_code
15039 ,p_accounting_line_type_code => l_component_type_code
15040 ,p_accounting_line_appl_id => l_component_appl_id
15041 ,p_amb_context_code => l_amb_context_code
15042 ,p_entity_code => l_entity_code
15043 ,p_event_class_code => l_event_class_code);
15044 --
15045 -- set accounting class
15046 --
15047 xla_ae_lines_pkg.SetAcctClass(
15048 p_accounting_class_code => 'TAX'
15049 , p_ae_header_id => l_ae_header_id
15050 );
15051
15052 --
15053 -- set rounding class
15054 --
15055 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
15056 'RECEIVABLE';
15057
15058 --
15059 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
15060 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
15061 --
15062 -- bulk performance
15063 --
15064 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
15065
15066 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
15067 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
15068
15069 -- 4955764
15070 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15071 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
15072
15073 -- 4458381 Public Sector Enh
15074
15075 --
15076 -- set accounting attributes for the line type
15077 --
15078 l_entered_amt_idx := 3;
15079 l_accted_amt_idx := 8;
15080 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15081 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
15082 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
15083 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
15084 l_rec_acct_attrs.array_char_value(2) := p_source_30;
15085 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
15086 l_rec_acct_attrs.array_num_value(3) := p_source_31;
15087 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
15088 l_rec_acct_attrs.array_char_value(4) := p_source_32;
15089 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
15090 l_rec_acct_attrs.array_date_value(5) := p_source_33;
15091 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
15092 l_rec_acct_attrs.array_num_value(6) := p_source_34;
15093 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
15094 l_rec_acct_attrs.array_char_value(7) := p_source_35;
15095 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
15096 l_rec_acct_attrs.array_num_value(8) := p_source_36;
15097 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
15098 l_rec_acct_attrs.array_num_value(9) := p_source_25;
15099 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
15100 l_rec_acct_attrs.array_num_value(10) := p_source_26;
15101 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
15102 l_rec_acct_attrs.array_char_value(11) := p_source_27;
15103 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
15104 l_rec_acct_attrs.array_num_value(12) := p_source_50;
15105
15106 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
15107 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
15108
15112 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
15109 ---------------------------------------------------------------------------------------------------------------
15110 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
15111 ---------------------------------------------------------------------------------------------------------------
15113
15114 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15115 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15116
15117 IF xla_accounting_cache_pkg.GetValueChar
15118 (p_source_code => 'LEDGER_CATEGORY_CODE'
15119 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
15120 AND l_bflow_method_code = 'PRIOR_ENTRY'
15121 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
15122 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
15123 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
15124 )
15125 THEN
15126 xla_ae_lines_pkg.BflowUpgEntry
15127 (p_business_method_code => l_bflow_method_code
15128 ,p_business_class_code => l_bflow_class_code
15129 ,p_balance_type => l_balance_type_code);
15130 ELSE
15131 NULL;
15132 -- No business flow processing for business flow method of NONE.
15133 END IF;
15134
15135 --
15136 -- call analytical criteria
15137 --
15138
15139 --
15140 -- call description
15141 --
15142 -- No description or it is inherited.
15143 --
15144 -- call ADRs
15145 -- Bug 4922099
15146 --
15147 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15148 (NVL(l_actual_upg_option, 'N') = 'O') OR
15149 (NVL(l_enc_upg_option, 'N') = 'O')
15150 )
15151 THEN
15152 NULL;
15153 --
15154 --
15155
15156 l_ccid := AcctDerRule_18(
15157 p_application_id => p_application_id
15158 , p_ae_header_id => l_ae_header_id
15159 , p_source_14 => p_source_14
15160 , x_transaction_coa_id => l_adr_transaction_coa_id
15161 , x_accounting_coa_id => l_adr_accounting_coa_id
15162 , x_value_type_code => l_adr_value_type_code
15163 , p_side => 'NA'
15164 );
15165
15166 xla_ae_lines_pkg.set_ccid(
15167 p_code_combination_id => l_ccid
15168 , p_value_type_code => l_adr_value_type_code
15169 , p_transaction_coa_id => l_adr_transaction_coa_id
15170 , p_accounting_coa_id => l_adr_accounting_coa_id
15171 , p_adr_code => 'TRX_DIST_CCID'
15172 , p_adr_type_code => 'S'
15173 , p_component_type => l_component_type
15174 , p_component_code => l_component_code
15175 , p_component_type_code => l_component_type_code
15176 , p_component_appl_id => l_component_appl_id
15177 , p_amb_context_code => l_amb_context_code
15178 , p_side => 'NA'
15179 );
15180
15181
15182 --
15183 --
15184 END IF;
15185 --
15186 -- Bug 4922099
15187 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
15188 (NVL(l_enc_upg_option, 'N') = 'O')
15189 ) AND
15190 (l_bflow_method_code = 'PRIOR_ENTRY')
15191 )
15192 THEN
15193 IF
15194 --
15195 1 = 2
15196 --
15197 THEN
15198 xla_accounting_err_pkg.build_message
15199 (p_appli_s_name => 'XLA'
15200 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15201 ,p_token_1 => 'LINE_NUMBER'
15202 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
15203 ,p_token_2 => 'LINE_TYPE_NAME'
15204 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
15205 l_component_type
15206 ,l_component_code
15207 ,l_component_type_code
15208 ,l_component_appl_id
15209 ,l_amb_context_code
15210 ,l_entity_code
15211 ,l_event_class_code
15212 )
15213 ,p_token_3 => 'OWNER'
15214 ,p_value_3 => xla_lookups_pkg.get_meaning(
15215 p_lookup_type => 'XLA_OWNER_TYPE'
15216 ,p_lookup_code => l_component_type_code
15217 )
15218 ,p_token_4 => 'PRODUCT_NAME'
15219 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
15220 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
15224 );
15221 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
15222 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
15223 ,p_ae_header_id => NULL
15225
15226 IF (C_LEVEL_ERROR>= g_log_level) THEN
15227 trace
15228 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15229 ,p_level => C_LEVEL_ERROR
15230 ,p_module => l_log_module);
15231 END IF;
15232 END IF;
15233 END IF;
15234 --
15235 --
15236 ------------------------------------------------------------------------------------------------
15237 -- 4219869 Business Flow
15238 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
15239 -- Prior Entry. Currently, the following code is always generated.
15240 ------------------------------------------------------------------------------------------------
15241 XLA_AE_LINES_PKG.ValidateCurrentLine;
15242
15243 ------------------------------------------------------------------------------------
15244 -- 4219869 Business Flow
15245 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
15246 ------------------------------------------------------------------------------------
15247 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15248
15249 ----------------------------------------------------------------------------------
15250 -- 4219869 Business Flow
15251 -- Update journal entry status -- Need to generate this within IF <condition>
15252 ----------------------------------------------------------------------------------
15253 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15254 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
15255 ,p_balance_type_code => l_balance_type_code
15256 );
15257
15258 -------------------------------------------------------------------------------------------
15259 -- 4262811 - Generate the Accrual Reversal lines
15260 -------------------------------------------------------------------------------------------
15261 BEGIN
15262 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
15263 (g_array_event(p_event_id).array_value_num('header_index'));
15264 IF l_acc_rev_flag IS NULL THEN
15265 l_acc_rev_flag := 'N';
15266 END IF;
15267 EXCEPTION
15268 WHEN OTHERS THEN
15269 l_acc_rev_flag := 'N';
15270 END;
15271 --
15272 IF (l_acc_rev_flag = 'Y') THEN
15273
15274 -- 4645092 ------------------------------------------------------------------------------
15275 -- To allow MPA report to determine if it should generate report process
15276 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
15277 ------------------------------------------------------------------------------------------
15278
15279 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
15280 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
15281 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
15282 -- call ADRs
15283 -- Bug 4922099
15284 --
15285 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15286 (NVL(l_actual_upg_option, 'N') = 'O') OR
15287 (NVL(l_enc_upg_option, 'N') = 'O')
15288 )
15289 THEN
15290 NULL;
15291 --
15292 --
15293
15294 l_ccid := AcctDerRule_18(
15295 p_application_id => p_application_id
15296 , p_ae_header_id => l_ae_header_id
15297 , p_source_14 => p_source_14
15298 , x_transaction_coa_id => l_adr_transaction_coa_id
15299 , x_accounting_coa_id => l_adr_accounting_coa_id
15300 , x_value_type_code => l_adr_value_type_code
15301 , p_side => 'NA'
15302 );
15303
15304 xla_ae_lines_pkg.set_ccid(
15305 p_code_combination_id => l_ccid
15306 , p_value_type_code => l_adr_value_type_code
15307 , p_transaction_coa_id => l_adr_transaction_coa_id
15308 , p_accounting_coa_id => l_adr_accounting_coa_id
15309 , p_adr_code => 'TRX_DIST_CCID'
15310 , p_adr_type_code => 'S'
15311 , p_component_type => l_component_type
15312 , p_component_code => l_component_code
15313 , p_component_type_code => l_component_type_code
15314 , p_component_appl_id => l_component_appl_id
15315 , p_amb_context_code => l_amb_context_code
15316 , p_side => 'NA'
15317 );
15318
15319
15320 --
15321 --
15322 END IF;
15323
15324 --
15325 -- Update the line information that should be overwritten
15326 --
15327 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
15328 p_header_num => 1);
15329 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
15330
15331 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
15332
15333 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
15334 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
15335 END IF;
15336
15337 --
15338 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
15339 --
15343 ---------------------------------------------------------------------------------------------------
15340 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
15341 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
15342 ELSE
15344 -- 4262811a Switch Sign
15345 ---------------------------------------------------------------------------------------------------
15346 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
15347 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15348 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15349 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15350 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15351 -- 5132302
15352 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
15353 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15354
15355 END IF;
15356
15357 -- 4955764
15358 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15359 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
15360
15361
15362 XLA_AE_LINES_PKG.ValidateCurrentLine;
15363 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15364
15365 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15366 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
15367 ,p_balance_type_code => l_balance_type_code);
15368
15369 END IF;
15370
15371 -----------------------------------------------------------------------------------------
15372 -- 4262811 Multiperiod Accounting
15373 -----------------------------------------------------------------------------------------
15374 -- No MPA option is assigned.
15375
15376
15377 END IF;
15378 END IF;
15379 --
15380
15381 --
15382 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15383 trace
15384 (p_msg => 'END of AcctLineType_41'
15385 ,p_level => C_LEVEL_PROCEDURE
15386 ,p_module => l_log_module);
15387 END IF;
15388 --
15389 EXCEPTION
15390 WHEN xla_exceptions_pkg.application_exception THEN
15391 RAISE;
15392 WHEN OTHERS THEN
15393 xla_exceptions_pkg.raise_message
15394 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_41');
15395 END AcctLineType_41;
15396 --
15397
15398 ---------------------------------------
15399 --
15400 -- PRIVATE FUNCTION
15401 -- AcctLineType_42
15402 --
15403 ---------------------------------------
15404 PROCEDURE AcctLineType_42 (
15405 p_application_id IN NUMBER
15406 ,p_event_id IN NUMBER
15407 ,p_calculate_acctd_flag IN VARCHAR2
15408 ,p_calculate_g_l_flag IN VARCHAR2
15409 ,p_actual_flag IN OUT VARCHAR2
15410 ,p_balance_type_code OUT VARCHAR2
15411 ,p_gain_or_loss_ref OUT VARCHAR2
15412
15413 --Transaction Distribution GL Account
15414 , p_source_14 IN NUMBER
15415 --Bill To Customer Account Identifier
15416 , p_source_25 IN NUMBER
15417 --Bill To Customer Site Use Identifier
15418 , p_source_26 IN NUMBER
15419 --SLA Party Type
15420 , p_source_27 IN VARCHAR2
15421 --Transaction Distribution Account Class
15422 , p_source_28 IN VARCHAR2
15423 --Transaction Distribution Identifier
15424 , p_source_29 IN NUMBER
15425 --Transaction Distribution Type
15426 , p_source_30 IN VARCHAR2
15427 --Transaction Distribution Entered Amount
15428 , p_source_31 IN NUMBER
15429 --Transaction Currency Code
15430 , p_source_32 IN VARCHAR2
15431 --Transaction Exchange Date
15432 , p_source_33 IN DATE
15433 --Transaction Exchange Rate
15434 , p_source_34 IN NUMBER
15435 --Transaction Exchange Rate Type
15436 , p_source_35 IN VARCHAR2
15437 --Transaction Accounting Amount
15438 , p_source_36 IN NUMBER
15439 --Transaction Tax Line Identifier
15440 , p_source_50 IN NUMBER
15441 )
15442 IS
15443
15444 l_component_type VARCHAR2(80);
15445 l_component_code VARCHAR2(30);
15446 l_component_type_code VARCHAR2(1);
15447 l_component_appl_id INTEGER;
15448 l_amb_context_code VARCHAR2(30);
15449 l_entity_code VARCHAR2(30);
15450 l_event_class_code VARCHAR2(30);
15451 l_ae_header_id NUMBER;
15452 l_event_type_code VARCHAR2(30);
15453 l_line_definition_code VARCHAR2(30);
15454 l_line_definition_owner_code VARCHAR2(1);
15455 --
15456 -- adr variables
15457 l_segment VARCHAR2(30);
15458 l_ccid NUMBER;
15459 l_adr_transaction_coa_id NUMBER;
15460 l_adr_accounting_coa_id NUMBER;
15461 l_adr_flexfield_segment_code VARCHAR2(30);
15462 l_adr_flex_value_set_id NUMBER;
15463 l_adr_value_type_code VARCHAR2(30);
15464 l_adr_value_combination_id NUMBER;
15465 l_adr_value_segment_code VARCHAR2(30);
15466
15467 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
15468 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
15469 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
15470 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
15474 l_accted_amt_idx NUMBER;
15471
15472 -- 4262811 Variables ------------------------------------------------------------------------------------------
15473 l_entered_amt_idx NUMBER;
15475 l_acc_rev_flag VARCHAR2(1);
15476 l_accrual_line_num NUMBER;
15477 l_tmp_amt NUMBER;
15478 l_acc_rev_natural_side_code VARCHAR2(1);
15479
15480 l_num_entries NUMBER;
15481 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
15482 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
15483 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
15484 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
15485 l_recog_line_1 NUMBER;
15486 l_recog_line_2 NUMBER;
15487
15488 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
15489 l_bflow_applied_to_amt NUMBER; -- 5132302
15490 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
15491
15492 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
15493
15494 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
15495 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
15496
15497 ---------------------------------------------------------------------------------------------------------------
15498
15499
15500 --
15501 -- bulk performance
15502 --
15503 l_balance_type_code VARCHAR2(1);
15504 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
15505 l_log_module VARCHAR2(240);
15506
15507 --
15508 -- Upgrade strategy
15509 --
15510 l_actual_upg_option VARCHAR2(1);
15511 l_enc_upg_option VARCHAR2(1);
15512
15513 --
15514 BEGIN
15515 --
15516 IF g_log_enabled THEN
15517 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_42';
15518 END IF;
15519 --
15520 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15521
15522 trace
15523 (p_msg => 'BEGIN of AcctLineType_42'
15524 ,p_level => C_LEVEL_PROCEDURE
15525 ,p_module => l_log_module);
15526
15527 END IF;
15528 --
15529 l_component_type := 'AMB_JLT';
15530 l_component_code := 'DM_UNBILL';
15531 l_component_type_code := 'S';
15532 l_component_appl_id := 222;
15533 l_amb_context_code := 'DEFAULT';
15534 l_entity_code := 'TRANSACTIONS';
15535 l_event_class_code := 'DEBIT_MEMO';
15536 l_event_type_code := 'DEBIT_MEMO_ALL';
15537 l_line_definition_owner_code := 'S';
15538 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
15539 --
15540 l_balance_type_code := 'A';
15541 l_segment := NULL;
15542 l_ccid := NULL;
15543 l_adr_transaction_coa_id := NULL;
15544 l_adr_accounting_coa_id := NULL;
15545 l_adr_flexfield_segment_code := NULL;
15546 l_adr_flex_value_set_id := NULL;
15547 l_adr_value_type_code := NULL;
15548 l_adr_value_combination_id := NULL;
15549 l_adr_value_segment_code := NULL;
15550
15551 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
15552 l_bflow_class_code := ''; -- 4219869 Business Flow
15553 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
15554 l_budgetary_control_flag := 'N';
15555
15556 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15557 l_bflow_applied_to_amt := NULL; -- 5132302
15558 l_entered_amt_idx := NULL; -- 4262811
15559 l_accted_amt_idx := NULL; -- 4262811
15560 l_acc_rev_flag := NULL; -- 4262811
15561 l_accrual_line_num := NULL; -- 4262811
15562 l_tmp_amt := NULL; -- 4262811
15563 --
15564
15565 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
15566 l_balance_type_code <> 'B' THEN
15567 IF NVL(p_source_28,'
15568 ') = 'UNBILL'
15569 THEN
15570
15571 --
15572 XLA_AE_LINES_PKG.SetNewLine;
15573
15574 p_balance_type_code := l_balance_type_code;
15575 -- set the flag so later we will know whether the gain loss line needs to be created
15576
15577 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
15578 p_actual_flag :='A';
15579 END IF;
15580
15581 --
15582 -- bulk performance
15583 --
15584 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
15585 p_header_num => 0); -- 4262811
15586 --
15587 -- set accounting line options
15588 --
15589 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
15590 p_natural_side_code => 'D'
15591 , p_gain_or_loss_flag => 'N'
15592 , p_gl_transfer_mode_code => 'S'
15593 , p_acct_entry_type_code => 'A'
15594 , p_switch_side_flag => 'Y'
15595 , p_merge_duplicate_code => 'A'
15596 );
15597 --
15598 l_acc_rev_natural_side_code := 'C'; -- 4262811
15599 --
15600 --
15601 -- set accounting line type info
15602 --
15603 xla_ae_lines_pkg.SetAcctLineType
15604 (p_component_type => l_component_type
15605 ,p_event_type_code => l_event_type_code
15606 ,p_line_definition_owner_code => l_line_definition_owner_code
15607 ,p_line_definition_code => l_line_definition_code
15611 ,p_amb_context_code => l_amb_context_code
15608 ,p_accounting_line_code => l_component_code
15609 ,p_accounting_line_type_code => l_component_type_code
15610 ,p_accounting_line_appl_id => l_component_appl_id
15612 ,p_entity_code => l_entity_code
15613 ,p_event_class_code => l_event_class_code);
15614 --
15615 -- set accounting class
15616 --
15617 xla_ae_lines_pkg.SetAcctClass(
15618 p_accounting_class_code => 'UNBILL'
15619 , p_ae_header_id => l_ae_header_id
15620 );
15621
15622 --
15623 -- set rounding class
15624 --
15625 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
15626 'RECEIVABLE';
15627
15628 --
15629 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
15630 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
15631 --
15632 -- bulk performance
15633 --
15634 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
15635
15636 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
15637 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
15638
15639 -- 4955764
15640 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15641 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
15642
15643 -- 4458381 Public Sector Enh
15644
15645 --
15646 -- set accounting attributes for the line type
15647 --
15648 l_entered_amt_idx := 3;
15649 l_accted_amt_idx := 8;
15650 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15651 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
15652 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
15653 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
15654 l_rec_acct_attrs.array_char_value(2) := p_source_30;
15655 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
15656 l_rec_acct_attrs.array_num_value(3) := p_source_31;
15657 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
15658 l_rec_acct_attrs.array_char_value(4) := p_source_32;
15659 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
15660 l_rec_acct_attrs.array_date_value(5) := p_source_33;
15661 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
15662 l_rec_acct_attrs.array_num_value(6) := p_source_34;
15663 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
15664 l_rec_acct_attrs.array_char_value(7) := p_source_35;
15665 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
15666 l_rec_acct_attrs.array_num_value(8) := p_source_36;
15667 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
15668 l_rec_acct_attrs.array_num_value(9) := p_source_25;
15669 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
15670 l_rec_acct_attrs.array_num_value(10) := p_source_26;
15671 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
15672 l_rec_acct_attrs.array_char_value(11) := p_source_27;
15673 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
15674 l_rec_acct_attrs.array_num_value(12) := p_source_50;
15675
15676 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
15677 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
15678
15679 ---------------------------------------------------------------------------------------------------------------
15680 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
15681 ---------------------------------------------------------------------------------------------------------------
15682 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
15683
15684 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15685 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15686
15687 IF xla_accounting_cache_pkg.GetValueChar
15688 (p_source_code => 'LEDGER_CATEGORY_CODE'
15689 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
15690 AND l_bflow_method_code = 'PRIOR_ENTRY'
15691 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
15692 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
15693 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
15694 )
15695 THEN
15696 xla_ae_lines_pkg.BflowUpgEntry
15697 (p_business_method_code => l_bflow_method_code
15698 ,p_business_class_code => l_bflow_class_code
15699 ,p_balance_type => l_balance_type_code);
15700 ELSE
15701 NULL;
15702 -- No business flow processing for business flow method of NONE.
15703 END IF;
15704
15705 --
15706 -- call analytical criteria
15707 --
15708
15709 --
15710 -- call description
15711 --
15712 -- No description or it is inherited.
15713 --
15714 -- call ADRs
15715 -- Bug 4922099
15716 --
15717 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15718 (NVL(l_actual_upg_option, 'N') = 'O') OR
15719 (NVL(l_enc_upg_option, 'N') = 'O')
15720 )
15721 THEN
15725
15722 NULL;
15723 --
15724 --
15726 l_ccid := AcctDerRule_18(
15727 p_application_id => p_application_id
15728 , p_ae_header_id => l_ae_header_id
15729 , p_source_14 => p_source_14
15730 , x_transaction_coa_id => l_adr_transaction_coa_id
15731 , x_accounting_coa_id => l_adr_accounting_coa_id
15732 , x_value_type_code => l_adr_value_type_code
15733 , p_side => 'NA'
15734 );
15735
15736 xla_ae_lines_pkg.set_ccid(
15737 p_code_combination_id => l_ccid
15738 , p_value_type_code => l_adr_value_type_code
15739 , p_transaction_coa_id => l_adr_transaction_coa_id
15740 , p_accounting_coa_id => l_adr_accounting_coa_id
15741 , p_adr_code => 'TRX_DIST_CCID'
15742 , p_adr_type_code => 'S'
15743 , p_component_type => l_component_type
15744 , p_component_code => l_component_code
15745 , p_component_type_code => l_component_type_code
15746 , p_component_appl_id => l_component_appl_id
15747 , p_amb_context_code => l_amb_context_code
15748 , p_side => 'NA'
15749 );
15750
15751
15752 --
15753 --
15754 END IF;
15755 --
15756 -- Bug 4922099
15757 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
15758 (NVL(l_enc_upg_option, 'N') = 'O')
15759 ) AND
15760 (l_bflow_method_code = 'PRIOR_ENTRY')
15761 )
15762 THEN
15763 IF
15764 --
15765 1 = 2
15766 --
15767 THEN
15768 xla_accounting_err_pkg.build_message
15769 (p_appli_s_name => 'XLA'
15770 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15771 ,p_token_1 => 'LINE_NUMBER'
15772 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
15773 ,p_token_2 => 'LINE_TYPE_NAME'
15774 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
15775 l_component_type
15776 ,l_component_code
15777 ,l_component_type_code
15778 ,l_component_appl_id
15779 ,l_amb_context_code
15780 ,l_entity_code
15781 ,l_event_class_code
15782 )
15783 ,p_token_3 => 'OWNER'
15784 ,p_value_3 => xla_lookups_pkg.get_meaning(
15785 p_lookup_type => 'XLA_OWNER_TYPE'
15786 ,p_lookup_code => l_component_type_code
15787 )
15788 ,p_token_4 => 'PRODUCT_NAME'
15789 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
15790 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
15791 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
15792 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
15793 ,p_ae_header_id => NULL
15794 );
15795
15796 IF (C_LEVEL_ERROR>= g_log_level) THEN
15797 trace
15798 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15799 ,p_level => C_LEVEL_ERROR
15800 ,p_module => l_log_module);
15801 END IF;
15802 END IF;
15803 END IF;
15804 --
15805 --
15806 ------------------------------------------------------------------------------------------------
15807 -- 4219869 Business Flow
15808 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
15809 -- Prior Entry. Currently, the following code is always generated.
15810 ------------------------------------------------------------------------------------------------
15811 XLA_AE_LINES_PKG.ValidateCurrentLine;
15812
15813 ------------------------------------------------------------------------------------
15814 -- 4219869 Business Flow
15815 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
15816 ------------------------------------------------------------------------------------
15817 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15818
15819 ----------------------------------------------------------------------------------
15820 -- 4219869 Business Flow
15821 -- Update journal entry status -- Need to generate this within IF <condition>
15822 ----------------------------------------------------------------------------------
15823 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15824 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
15825 ,p_balance_type_code => l_balance_type_code
15826 );
15827
15831 BEGIN
15828 -------------------------------------------------------------------------------------------
15829 -- 4262811 - Generate the Accrual Reversal lines
15830 -------------------------------------------------------------------------------------------
15832 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
15833 (g_array_event(p_event_id).array_value_num('header_index'));
15834 IF l_acc_rev_flag IS NULL THEN
15835 l_acc_rev_flag := 'N';
15836 END IF;
15837 EXCEPTION
15838 WHEN OTHERS THEN
15839 l_acc_rev_flag := 'N';
15840 END;
15841 --
15842 IF (l_acc_rev_flag = 'Y') THEN
15843
15844 -- 4645092 ------------------------------------------------------------------------------
15845 -- To allow MPA report to determine if it should generate report process
15846 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
15847 ------------------------------------------------------------------------------------------
15848
15849 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
15850 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
15851 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
15852 -- call ADRs
15853 -- Bug 4922099
15854 --
15855 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15856 (NVL(l_actual_upg_option, 'N') = 'O') OR
15857 (NVL(l_enc_upg_option, 'N') = 'O')
15858 )
15859 THEN
15860 NULL;
15861 --
15862 --
15863
15864 l_ccid := AcctDerRule_18(
15865 p_application_id => p_application_id
15866 , p_ae_header_id => l_ae_header_id
15867 , p_source_14 => p_source_14
15868 , x_transaction_coa_id => l_adr_transaction_coa_id
15869 , x_accounting_coa_id => l_adr_accounting_coa_id
15870 , x_value_type_code => l_adr_value_type_code
15871 , p_side => 'NA'
15872 );
15873
15874 xla_ae_lines_pkg.set_ccid(
15875 p_code_combination_id => l_ccid
15876 , p_value_type_code => l_adr_value_type_code
15877 , p_transaction_coa_id => l_adr_transaction_coa_id
15878 , p_accounting_coa_id => l_adr_accounting_coa_id
15879 , p_adr_code => 'TRX_DIST_CCID'
15880 , p_adr_type_code => 'S'
15881 , p_component_type => l_component_type
15882 , p_component_code => l_component_code
15883 , p_component_type_code => l_component_type_code
15884 , p_component_appl_id => l_component_appl_id
15885 , p_amb_context_code => l_amb_context_code
15886 , p_side => 'NA'
15887 );
15888
15889
15890 --
15891 --
15892 END IF;
15893
15894 --
15895 -- Update the line information that should be overwritten
15896 --
15897 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
15898 p_header_num => 1);
15899 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
15900
15901 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
15902
15903 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
15904 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
15905 END IF;
15906
15907 --
15908 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
15909 --
15910 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
15911 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
15912 ELSE
15913 ---------------------------------------------------------------------------------------------------
15914 -- 4262811a Switch Sign
15915 ---------------------------------------------------------------------------------------------------
15916 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
15917 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15918 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15919 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15920 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15921 -- 5132302
15922 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
15923 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15924
15925 END IF;
15926
15927 -- 4955764
15928 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15929 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
15930
15931
15932 XLA_AE_LINES_PKG.ValidateCurrentLine;
15933 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15934
15935 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15936 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
15937 ,p_balance_type_code => l_balance_type_code);
15938
15939 END IF;
15940
15941 -----------------------------------------------------------------------------------------
15942 -- 4262811 Multiperiod Accounting
15946
15943 -----------------------------------------------------------------------------------------
15944 -- No MPA option is assigned.
15945
15947 END IF;
15948 END IF;
15949 --
15950
15951 --
15952 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15953 trace
15954 (p_msg => 'END of AcctLineType_42'
15955 ,p_level => C_LEVEL_PROCEDURE
15956 ,p_module => l_log_module);
15957 END IF;
15958 --
15959 EXCEPTION
15960 WHEN xla_exceptions_pkg.application_exception THEN
15961 RAISE;
15962 WHEN OTHERS THEN
15963 xla_exceptions_pkg.raise_message
15964 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_42');
15965 END AcctLineType_42;
15966 --
15967
15968 ---------------------------------------
15969 --
15970 -- PRIVATE FUNCTION
15971 -- AcctLineType_43
15972 --
15973 ---------------------------------------
15974 PROCEDURE AcctLineType_43 (
15975 p_application_id IN NUMBER
15976 ,p_event_id IN NUMBER
15977 ,p_calculate_acctd_flag IN VARCHAR2
15978 ,p_calculate_g_l_flag IN VARCHAR2
15979 ,p_actual_flag IN OUT VARCHAR2
15980 ,p_balance_type_code OUT VARCHAR2
15981 ,p_gain_or_loss_ref OUT VARCHAR2
15982
15983 --Transaction Distribution GL Account
15984 , p_source_14 IN NUMBER
15985 --Bill To Customer Account Identifier
15986 , p_source_25 IN NUMBER
15987 --Bill To Customer Site Use Identifier
15988 , p_source_26 IN NUMBER
15989 --SLA Party Type
15990 , p_source_27 IN VARCHAR2
15991 --Transaction Distribution Account Class
15992 , p_source_28 IN VARCHAR2
15993 --Transaction Distribution Identifier
15994 , p_source_29 IN NUMBER
15995 --Transaction Distribution Type
15996 , p_source_30 IN VARCHAR2
15997 --Transaction Distribution Entered Amount
15998 , p_source_31 IN NUMBER
15999 --Transaction Currency Code
16000 , p_source_32 IN VARCHAR2
16001 --Transaction Exchange Date
16002 , p_source_33 IN DATE
16003 --Transaction Exchange Rate
16004 , p_source_34 IN NUMBER
16005 --Transaction Exchange Rate Type
16006 , p_source_35 IN VARCHAR2
16007 --Transaction Accounting Amount
16008 , p_source_36 IN NUMBER
16009 --Transaction Tax Line Identifier
16010 , p_source_50 IN NUMBER
16011 )
16012 IS
16013
16014 l_component_type VARCHAR2(80);
16015 l_component_code VARCHAR2(30);
16016 l_component_type_code VARCHAR2(1);
16017 l_component_appl_id INTEGER;
16018 l_amb_context_code VARCHAR2(30);
16019 l_entity_code VARCHAR2(30);
16020 l_event_class_code VARCHAR2(30);
16021 l_ae_header_id NUMBER;
16022 l_event_type_code VARCHAR2(30);
16023 l_line_definition_code VARCHAR2(30);
16024 l_line_definition_owner_code VARCHAR2(1);
16025 --
16026 -- adr variables
16027 l_segment VARCHAR2(30);
16028 l_ccid NUMBER;
16029 l_adr_transaction_coa_id NUMBER;
16030 l_adr_accounting_coa_id NUMBER;
16031 l_adr_flexfield_segment_code VARCHAR2(30);
16032 l_adr_flex_value_set_id NUMBER;
16033 l_adr_value_type_code VARCHAR2(30);
16034 l_adr_value_combination_id NUMBER;
16035 l_adr_value_segment_code VARCHAR2(30);
16036
16037 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
16038 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
16039 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
16040 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
16041
16042 -- 4262811 Variables ------------------------------------------------------------------------------------------
16043 l_entered_amt_idx NUMBER;
16044 l_accted_amt_idx NUMBER;
16045 l_acc_rev_flag VARCHAR2(1);
16046 l_accrual_line_num NUMBER;
16047 l_tmp_amt NUMBER;
16048 l_acc_rev_natural_side_code VARCHAR2(1);
16049
16050 l_num_entries NUMBER;
16051 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
16052 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
16053 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
16054 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
16055 l_recog_line_1 NUMBER;
16056 l_recog_line_2 NUMBER;
16057
16058 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
16059 l_bflow_applied_to_amt NUMBER; -- 5132302
16060 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
16061
16062 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
16063
16064 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
16065 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
16066
16067 ---------------------------------------------------------------------------------------------------------------
16068
16069
16070 --
16071 -- bulk performance
16072 --
16073 l_balance_type_code VARCHAR2(1);
16074 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
16075 l_log_module VARCHAR2(240);
16076
16077 --
16078 -- Upgrade strategy
16079 --
16080 l_actual_upg_option VARCHAR2(1);
16081 l_enc_upg_option VARCHAR2(1);
16082
16083 --
16084 BEGIN
16085 --
16086 IF g_log_enabled THEN
16090 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16087 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_43';
16088 END IF;
16089 --
16091
16092 trace
16093 (p_msg => 'BEGIN of AcctLineType_43'
16094 ,p_level => C_LEVEL_PROCEDURE
16095 ,p_module => l_log_module);
16096
16097 END IF;
16098 --
16099 l_component_type := 'AMB_JLT';
16100 l_component_code := 'DM_UNEARN';
16101 l_component_type_code := 'S';
16102 l_component_appl_id := 222;
16103 l_amb_context_code := 'DEFAULT';
16104 l_entity_code := 'TRANSACTIONS';
16105 l_event_class_code := 'DEBIT_MEMO';
16106 l_event_type_code := 'DEBIT_MEMO_ALL';
16107 l_line_definition_owner_code := 'S';
16108 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
16109 --
16110 l_balance_type_code := 'A';
16111 l_segment := NULL;
16112 l_ccid := NULL;
16113 l_adr_transaction_coa_id := NULL;
16114 l_adr_accounting_coa_id := NULL;
16115 l_adr_flexfield_segment_code := NULL;
16116 l_adr_flex_value_set_id := NULL;
16117 l_adr_value_type_code := NULL;
16118 l_adr_value_combination_id := NULL;
16119 l_adr_value_segment_code := NULL;
16120
16121 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
16122 l_bflow_class_code := ''; -- 4219869 Business Flow
16123 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
16124 l_budgetary_control_flag := 'N';
16125
16126 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16127 l_bflow_applied_to_amt := NULL; -- 5132302
16128 l_entered_amt_idx := NULL; -- 4262811
16129 l_accted_amt_idx := NULL; -- 4262811
16130 l_acc_rev_flag := NULL; -- 4262811
16131 l_accrual_line_num := NULL; -- 4262811
16132 l_tmp_amt := NULL; -- 4262811
16133 --
16134
16135 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
16136 l_balance_type_code <> 'B' THEN
16137 IF NVL(p_source_28,'
16138 ') = 'UNEARN'
16139 THEN
16140
16141 --
16142 XLA_AE_LINES_PKG.SetNewLine;
16143
16144 p_balance_type_code := l_balance_type_code;
16145 -- set the flag so later we will know whether the gain loss line needs to be created
16146
16147 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
16148 p_actual_flag :='A';
16149 END IF;
16150
16151 --
16152 -- bulk performance
16153 --
16154 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
16155 p_header_num => 0); -- 4262811
16156 --
16157 -- set accounting line options
16158 --
16159 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
16160 p_natural_side_code => 'C'
16161 , p_gain_or_loss_flag => 'N'
16162 , p_gl_transfer_mode_code => 'S'
16163 , p_acct_entry_type_code => 'A'
16164 , p_switch_side_flag => 'Y'
16165 , p_merge_duplicate_code => 'A'
16166 );
16167 --
16168 l_acc_rev_natural_side_code := 'D'; -- 4262811
16169 --
16170 --
16171 -- set accounting line type info
16172 --
16173 xla_ae_lines_pkg.SetAcctLineType
16174 (p_component_type => l_component_type
16175 ,p_event_type_code => l_event_type_code
16176 ,p_line_definition_owner_code => l_line_definition_owner_code
16177 ,p_line_definition_code => l_line_definition_code
16178 ,p_accounting_line_code => l_component_code
16179 ,p_accounting_line_type_code => l_component_type_code
16180 ,p_accounting_line_appl_id => l_component_appl_id
16181 ,p_amb_context_code => l_amb_context_code
16182 ,p_entity_code => l_entity_code
16183 ,p_event_class_code => l_event_class_code);
16184 --
16185 -- set accounting class
16186 --
16187 xla_ae_lines_pkg.SetAcctClass(
16188 p_accounting_class_code => 'UNEARNED_REVENUE'
16189 , p_ae_header_id => l_ae_header_id
16190 );
16191
16192 --
16193 -- set rounding class
16194 --
16195 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
16196 'RECEIVABLE';
16197
16198 --
16199 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
16200 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
16201 --
16202 -- bulk performance
16203 --
16204 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
16205
16206 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
16207 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
16208
16209 -- 4955764
16210 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16211 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
16212
16213 -- 4458381 Public Sector Enh
16214
16215 --
16216 -- set accounting attributes for the line type
16217 --
16218 l_entered_amt_idx := 3;
16219 l_accted_amt_idx := 8;
16220 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16224 l_rec_acct_attrs.array_char_value(2) := p_source_30;
16221 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
16222 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
16223 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
16225 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
16226 l_rec_acct_attrs.array_num_value(3) := p_source_31;
16227 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
16228 l_rec_acct_attrs.array_char_value(4) := p_source_32;
16229 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
16230 l_rec_acct_attrs.array_date_value(5) := p_source_33;
16231 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
16232 l_rec_acct_attrs.array_num_value(6) := p_source_34;
16233 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
16234 l_rec_acct_attrs.array_char_value(7) := p_source_35;
16235 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
16236 l_rec_acct_attrs.array_num_value(8) := p_source_36;
16237 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
16238 l_rec_acct_attrs.array_num_value(9) := p_source_25;
16239 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
16240 l_rec_acct_attrs.array_num_value(10) := p_source_26;
16241 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
16242 l_rec_acct_attrs.array_char_value(11) := p_source_27;
16243 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
16244 l_rec_acct_attrs.array_num_value(12) := p_source_50;
16245
16246 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
16247 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
16248
16249 ---------------------------------------------------------------------------------------------------------------
16250 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
16251 ---------------------------------------------------------------------------------------------------------------
16252 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
16253
16254 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16255 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16256
16257 IF xla_accounting_cache_pkg.GetValueChar
16258 (p_source_code => 'LEDGER_CATEGORY_CODE'
16259 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
16260 AND l_bflow_method_code = 'PRIOR_ENTRY'
16261 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
16262 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
16263 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
16264 )
16265 THEN
16266 xla_ae_lines_pkg.BflowUpgEntry
16267 (p_business_method_code => l_bflow_method_code
16268 ,p_business_class_code => l_bflow_class_code
16269 ,p_balance_type => l_balance_type_code);
16270 ELSE
16271 NULL;
16272 -- No business flow processing for business flow method of NONE.
16273 END IF;
16274
16275 --
16276 -- call analytical criteria
16277 --
16278
16279 --
16280 -- call description
16281 --
16282 -- No description or it is inherited.
16283 --
16284 -- call ADRs
16285 -- Bug 4922099
16286 --
16287 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16288 (NVL(l_actual_upg_option, 'N') = 'O') OR
16289 (NVL(l_enc_upg_option, 'N') = 'O')
16290 )
16291 THEN
16292 NULL;
16293 --
16294 --
16295
16296 l_ccid := AcctDerRule_18(
16297 p_application_id => p_application_id
16298 , p_ae_header_id => l_ae_header_id
16299 , p_source_14 => p_source_14
16300 , x_transaction_coa_id => l_adr_transaction_coa_id
16301 , x_accounting_coa_id => l_adr_accounting_coa_id
16302 , x_value_type_code => l_adr_value_type_code
16303 , p_side => 'NA'
16304 );
16305
16306 xla_ae_lines_pkg.set_ccid(
16307 p_code_combination_id => l_ccid
16308 , p_value_type_code => l_adr_value_type_code
16309 , p_transaction_coa_id => l_adr_transaction_coa_id
16310 , p_accounting_coa_id => l_adr_accounting_coa_id
16311 , p_adr_code => 'TRX_DIST_CCID'
16312 , p_adr_type_code => 'S'
16313 , p_component_type => l_component_type
16314 , p_component_code => l_component_code
16315 , p_component_type_code => l_component_type_code
16316 , p_component_appl_id => l_component_appl_id
16317 , p_amb_context_code => l_amb_context_code
16318 , p_side => 'NA'
16319 );
16320
16321
16322 --
16323 --
16324 END IF;
16325 --
16326 -- Bug 4922099
16327 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
16328 (NVL(l_enc_upg_option, 'N') = 'O')
16329 ) AND
16330 (l_bflow_method_code = 'PRIOR_ENTRY')
16331 )
16332 THEN
16333 IF
16334 --
16335 1 = 2
16336 --
16337 THEN
16338 xla_accounting_err_pkg.build_message
16339 (p_appli_s_name => 'XLA'
16340 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16344 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
16341 ,p_token_1 => 'LINE_NUMBER'
16342 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
16343 ,p_token_2 => 'LINE_TYPE_NAME'
16345 l_component_type
16346 ,l_component_code
16347 ,l_component_type_code
16348 ,l_component_appl_id
16349 ,l_amb_context_code
16350 ,l_entity_code
16351 ,l_event_class_code
16352 )
16353 ,p_token_3 => 'OWNER'
16354 ,p_value_3 => xla_lookups_pkg.get_meaning(
16355 p_lookup_type => 'XLA_OWNER_TYPE'
16356 ,p_lookup_code => l_component_type_code
16357 )
16358 ,p_token_4 => 'PRODUCT_NAME'
16359 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
16360 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
16361 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
16362 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
16363 ,p_ae_header_id => NULL
16364 );
16365
16366 IF (C_LEVEL_ERROR>= g_log_level) THEN
16367 trace
16368 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16369 ,p_level => C_LEVEL_ERROR
16370 ,p_module => l_log_module);
16371 END IF;
16372 END IF;
16373 END IF;
16374 --
16375 --
16376 ------------------------------------------------------------------------------------------------
16377 -- 4219869 Business Flow
16378 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
16379 -- Prior Entry. Currently, the following code is always generated.
16380 ------------------------------------------------------------------------------------------------
16381 XLA_AE_LINES_PKG.ValidateCurrentLine;
16382
16383 ------------------------------------------------------------------------------------
16384 -- 4219869 Business Flow
16385 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
16386 ------------------------------------------------------------------------------------
16387 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
16388
16389 ----------------------------------------------------------------------------------
16390 -- 4219869 Business Flow
16391 -- Update journal entry status -- Need to generate this within IF <condition>
16392 ----------------------------------------------------------------------------------
16393 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
16394 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
16395 ,p_balance_type_code => l_balance_type_code
16396 );
16397
16398 -------------------------------------------------------------------------------------------
16399 -- 4262811 - Generate the Accrual Reversal lines
16400 -------------------------------------------------------------------------------------------
16401 BEGIN
16402 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
16403 (g_array_event(p_event_id).array_value_num('header_index'));
16404 IF l_acc_rev_flag IS NULL THEN
16405 l_acc_rev_flag := 'N';
16406 END IF;
16407 EXCEPTION
16408 WHEN OTHERS THEN
16409 l_acc_rev_flag := 'N';
16410 END;
16411 --
16412 IF (l_acc_rev_flag = 'Y') THEN
16413
16414 -- 4645092 ------------------------------------------------------------------------------
16415 -- To allow MPA report to determine if it should generate report process
16416 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
16417 ------------------------------------------------------------------------------------------
16418
16419 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
16420 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
16421 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
16422 -- call ADRs
16423 -- Bug 4922099
16424 --
16425 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16426 (NVL(l_actual_upg_option, 'N') = 'O') OR
16427 (NVL(l_enc_upg_option, 'N') = 'O')
16428 )
16429 THEN
16430 NULL;
16431 --
16432 --
16433
16434 l_ccid := AcctDerRule_18(
16435 p_application_id => p_application_id
16436 , p_ae_header_id => l_ae_header_id
16437 , p_source_14 => p_source_14
16438 , x_transaction_coa_id => l_adr_transaction_coa_id
16442 );
16439 , x_accounting_coa_id => l_adr_accounting_coa_id
16440 , x_value_type_code => l_adr_value_type_code
16441 , p_side => 'NA'
16443
16444 xla_ae_lines_pkg.set_ccid(
16445 p_code_combination_id => l_ccid
16446 , p_value_type_code => l_adr_value_type_code
16447 , p_transaction_coa_id => l_adr_transaction_coa_id
16448 , p_accounting_coa_id => l_adr_accounting_coa_id
16449 , p_adr_code => 'TRX_DIST_CCID'
16450 , p_adr_type_code => 'S'
16451 , p_component_type => l_component_type
16452 , p_component_code => l_component_code
16453 , p_component_type_code => l_component_type_code
16454 , p_component_appl_id => l_component_appl_id
16455 , p_amb_context_code => l_amb_context_code
16456 , p_side => 'NA'
16457 );
16458
16459
16460 --
16461 --
16462 END IF;
16463
16464 --
16465 -- Update the line information that should be overwritten
16466 --
16467 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
16468 p_header_num => 1);
16469 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
16470
16471 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
16472
16473 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
16474 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
16475 END IF;
16476
16477 --
16478 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
16479 --
16480 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
16481 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
16482 ELSE
16483 ---------------------------------------------------------------------------------------------------
16484 -- 4262811a Switch Sign
16485 ---------------------------------------------------------------------------------------------------
16486 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
16487 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16488 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16489 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16490 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16491 -- 5132302
16492 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
16493 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16494
16495 END IF;
16496
16497 -- 4955764
16498 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16499 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
16500
16501
16502 XLA_AE_LINES_PKG.ValidateCurrentLine;
16503 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
16504
16505 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
16506 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
16507 ,p_balance_type_code => l_balance_type_code);
16508
16509 END IF;
16510
16511 -----------------------------------------------------------------------------------------
16512 -- 4262811 Multiperiod Accounting
16513 -----------------------------------------------------------------------------------------
16514 -- No MPA option is assigned.
16515
16516
16517 END IF;
16518 END IF;
16519 --
16520
16521 --
16522 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16523 trace
16524 (p_msg => 'END of AcctLineType_43'
16525 ,p_level => C_LEVEL_PROCEDURE
16526 ,p_module => l_log_module);
16527 END IF;
16528 --
16529 EXCEPTION
16530 WHEN xla_exceptions_pkg.application_exception THEN
16531 RAISE;
16532 WHEN OTHERS THEN
16533 xla_exceptions_pkg.raise_message
16534 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_43');
16535 END AcctLineType_43;
16536 --
16537
16538 ---------------------------------------
16539 --
16540 -- PRIVATE FUNCTION
16541 -- AcctLineType_44
16542 --
16543 ---------------------------------------
16544 PROCEDURE AcctLineType_44 (
16545 p_application_id IN NUMBER
16546 ,p_event_id IN NUMBER
16547 ,p_calculate_acctd_flag IN VARCHAR2
16548 ,p_calculate_g_l_flag IN VARCHAR2
16549 ,p_actual_flag IN OUT VARCHAR2
16550 ,p_balance_type_code OUT VARCHAR2
16551 ,p_gain_or_loss_ref OUT VARCHAR2
16552
16553 --Transaction Distribution GL Account
16554 , p_source_14 IN NUMBER
16555 --Bill To Customer Account Identifier
16556 , p_source_25 IN NUMBER
16557 --Bill To Customer Site Use Identifier
16558 , p_source_26 IN NUMBER
16559 --SLA Party Type
16560 , p_source_27 IN VARCHAR2
16561 --Transaction Distribution Account Class
16562 , p_source_28 IN VARCHAR2
16563 --Transaction Distribution Identifier
16564 , p_source_29 IN NUMBER
16568 , p_source_31 IN NUMBER
16565 --Transaction Distribution Type
16566 , p_source_30 IN VARCHAR2
16567 --Transaction Distribution Entered Amount
16569 --Transaction Currency Code
16570 , p_source_32 IN VARCHAR2
16571 --Transaction Exchange Date
16572 , p_source_33 IN DATE
16573 --Transaction Exchange Rate
16574 , p_source_34 IN NUMBER
16575 --Transaction Exchange Rate Type
16576 , p_source_35 IN VARCHAR2
16577 --Transaction Accounting Amount
16578 , p_source_36 IN NUMBER
16579 )
16580 IS
16581
16582 l_component_type VARCHAR2(80);
16583 l_component_code VARCHAR2(30);
16584 l_component_type_code VARCHAR2(1);
16585 l_component_appl_id INTEGER;
16586 l_amb_context_code VARCHAR2(30);
16587 l_entity_code VARCHAR2(30);
16588 l_event_class_code VARCHAR2(30);
16589 l_ae_header_id NUMBER;
16590 l_event_type_code VARCHAR2(30);
16591 l_line_definition_code VARCHAR2(30);
16592 l_line_definition_owner_code VARCHAR2(1);
16593 --
16594 -- adr variables
16595 l_segment VARCHAR2(30);
16596 l_ccid NUMBER;
16597 l_adr_transaction_coa_id NUMBER;
16598 l_adr_accounting_coa_id NUMBER;
16599 l_adr_flexfield_segment_code VARCHAR2(30);
16600 l_adr_flex_value_set_id NUMBER;
16601 l_adr_value_type_code VARCHAR2(30);
16602 l_adr_value_combination_id NUMBER;
16603 l_adr_value_segment_code VARCHAR2(30);
16604
16605 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
16606 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
16607 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
16608 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
16609
16610 -- 4262811 Variables ------------------------------------------------------------------------------------------
16611 l_entered_amt_idx NUMBER;
16612 l_accted_amt_idx NUMBER;
16613 l_acc_rev_flag VARCHAR2(1);
16614 l_accrual_line_num NUMBER;
16615 l_tmp_amt NUMBER;
16616 l_acc_rev_natural_side_code VARCHAR2(1);
16617
16618 l_num_entries NUMBER;
16619 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
16620 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
16621 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
16622 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
16623 l_recog_line_1 NUMBER;
16624 l_recog_line_2 NUMBER;
16625
16626 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
16627 l_bflow_applied_to_amt NUMBER; -- 5132302
16628 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
16629
16630 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
16631
16632 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
16633 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
16634
16635 ---------------------------------------------------------------------------------------------------------------
16636
16637
16638 --
16639 -- bulk performance
16640 --
16641 l_balance_type_code VARCHAR2(1);
16642 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
16643 l_log_module VARCHAR2(240);
16644
16645 --
16646 -- Upgrade strategy
16647 --
16648 l_actual_upg_option VARCHAR2(1);
16649 l_enc_upg_option VARCHAR2(1);
16650
16651 --
16652 BEGIN
16653 --
16654 IF g_log_enabled THEN
16655 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_44';
16656 END IF;
16657 --
16658 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16659
16660 trace
16661 (p_msg => 'BEGIN of AcctLineType_44'
16662 ,p_level => C_LEVEL_PROCEDURE
16663 ,p_module => l_log_module);
16664
16665 END IF;
16666 --
16667 l_component_type := 'AMB_JLT';
16668 l_component_code := 'GUAR_DEFAULT_REC';
16669 l_component_type_code := 'S';
16670 l_component_appl_id := 222;
16671 l_amb_context_code := 'DEFAULT';
16672 l_entity_code := 'TRANSACTIONS';
16673 l_event_class_code := 'GUARANTEE';
16674 l_event_type_code := 'GUARANTEE_ALL';
16675 l_line_definition_owner_code := 'S';
16676 l_line_definition_code := 'AR_GUAR_DEFAULT_ACCRUAL';
16677 --
16678 l_balance_type_code := 'A';
16679 l_segment := NULL;
16680 l_ccid := NULL;
16681 l_adr_transaction_coa_id := NULL;
16682 l_adr_accounting_coa_id := NULL;
16683 l_adr_flexfield_segment_code := NULL;
16684 l_adr_flex_value_set_id := NULL;
16685 l_adr_value_type_code := NULL;
16686 l_adr_value_combination_id := NULL;
16687 l_adr_value_segment_code := NULL;
16688
16689 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
16690 l_bflow_class_code := ''; -- 4219869 Business Flow
16691 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
16692 l_budgetary_control_flag := 'N';
16693
16694 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16695 l_bflow_applied_to_amt := NULL; -- 5132302
16696 l_entered_amt_idx := NULL; -- 4262811
16700 l_tmp_amt := NULL; -- 4262811
16697 l_accted_amt_idx := NULL; -- 4262811
16698 l_acc_rev_flag := NULL; -- 4262811
16699 l_accrual_line_num := NULL; -- 4262811
16701 --
16702
16703 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
16704 l_balance_type_code <> 'B' THEN
16705 IF NVL(p_source_28,'
16706 ') = 'REC'
16707 THEN
16708
16709 --
16710 XLA_AE_LINES_PKG.SetNewLine;
16711
16712 p_balance_type_code := l_balance_type_code;
16713 -- set the flag so later we will know whether the gain loss line needs to be created
16714
16715 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
16716 p_actual_flag :='A';
16717 END IF;
16718
16719 --
16720 -- bulk performance
16721 --
16722 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
16723 p_header_num => 0); -- 4262811
16724 --
16725 -- set accounting line options
16726 --
16727 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
16728 p_natural_side_code => 'D'
16729 , p_gain_or_loss_flag => 'N'
16730 , p_gl_transfer_mode_code => 'S'
16731 , p_acct_entry_type_code => 'A'
16732 , p_switch_side_flag => 'Y'
16733 , p_merge_duplicate_code => 'A'
16734 );
16735 --
16736 l_acc_rev_natural_side_code := 'C'; -- 4262811
16737 --
16738 --
16739 -- set accounting line type info
16740 --
16741 xla_ae_lines_pkg.SetAcctLineType
16742 (p_component_type => l_component_type
16743 ,p_event_type_code => l_event_type_code
16744 ,p_line_definition_owner_code => l_line_definition_owner_code
16745 ,p_line_definition_code => l_line_definition_code
16746 ,p_accounting_line_code => l_component_code
16747 ,p_accounting_line_type_code => l_component_type_code
16748 ,p_accounting_line_appl_id => l_component_appl_id
16749 ,p_amb_context_code => l_amb_context_code
16750 ,p_entity_code => l_entity_code
16751 ,p_event_class_code => l_event_class_code);
16752 --
16753 -- set accounting class
16754 --
16755 xla_ae_lines_pkg.SetAcctClass(
16756 p_accounting_class_code => 'RECEIVABLE'
16757 , p_ae_header_id => l_ae_header_id
16758 );
16759
16760 --
16761 -- set rounding class
16762 --
16763 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
16764 'RECEIVABLE';
16765
16766 --
16767 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
16768 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
16769 --
16770 -- bulk performance
16771 --
16772 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
16773
16774 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
16775 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
16776
16777 -- 4955764
16778 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16779 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
16780
16781 -- 4458381 Public Sector Enh
16782
16783 --
16784 -- set accounting attributes for the line type
16785 --
16786 l_entered_amt_idx := 3;
16787 l_accted_amt_idx := 8;
16788 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16789 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
16790 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
16791 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
16792 l_rec_acct_attrs.array_char_value(2) := p_source_30;
16793 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
16794 l_rec_acct_attrs.array_num_value(3) := p_source_31;
16795 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
16796 l_rec_acct_attrs.array_char_value(4) := p_source_32;
16797 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
16798 l_rec_acct_attrs.array_date_value(5) := p_source_33;
16799 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
16800 l_rec_acct_attrs.array_num_value(6) := p_source_34;
16801 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
16802 l_rec_acct_attrs.array_char_value(7) := p_source_35;
16803 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
16804 l_rec_acct_attrs.array_num_value(8) := p_source_36;
16805 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
16806 l_rec_acct_attrs.array_num_value(9) := p_source_25;
16807 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
16808 l_rec_acct_attrs.array_num_value(10) := p_source_26;
16809 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
16810 l_rec_acct_attrs.array_char_value(11) := p_source_27;
16811
16812 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
16813 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
16814
16815 ---------------------------------------------------------------------------------------------------------------
16819
16816 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
16817 ---------------------------------------------------------------------------------------------------------------
16818 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
16820 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16821 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16822
16823 IF xla_accounting_cache_pkg.GetValueChar
16824 (p_source_code => 'LEDGER_CATEGORY_CODE'
16825 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
16826 AND l_bflow_method_code = 'PRIOR_ENTRY'
16827 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
16828 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
16829 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
16830 )
16831 THEN
16832 xla_ae_lines_pkg.BflowUpgEntry
16833 (p_business_method_code => l_bflow_method_code
16834 ,p_business_class_code => l_bflow_class_code
16835 ,p_balance_type => l_balance_type_code);
16836 ELSE
16837 NULL;
16838 -- No business flow processing for business flow method of NONE.
16839 END IF;
16840
16841 --
16842 -- call analytical criteria
16843 --
16844
16845 --
16846 -- call description
16847 --
16848 -- No description or it is inherited.
16849 --
16850 -- call ADRs
16851 -- Bug 4922099
16852 --
16853 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16854 (NVL(l_actual_upg_option, 'N') = 'O') OR
16855 (NVL(l_enc_upg_option, 'N') = 'O')
16856 )
16857 THEN
16858 NULL;
16859 --
16860 --
16861
16862 l_ccid := AcctDerRule_18(
16863 p_application_id => p_application_id
16864 , p_ae_header_id => l_ae_header_id
16865 , p_source_14 => p_source_14
16866 , x_transaction_coa_id => l_adr_transaction_coa_id
16867 , x_accounting_coa_id => l_adr_accounting_coa_id
16868 , x_value_type_code => l_adr_value_type_code
16869 , p_side => 'NA'
16870 );
16871
16872 xla_ae_lines_pkg.set_ccid(
16873 p_code_combination_id => l_ccid
16874 , p_value_type_code => l_adr_value_type_code
16875 , p_transaction_coa_id => l_adr_transaction_coa_id
16876 , p_accounting_coa_id => l_adr_accounting_coa_id
16877 , p_adr_code => 'TRX_DIST_CCID'
16878 , p_adr_type_code => 'S'
16879 , p_component_type => l_component_type
16880 , p_component_code => l_component_code
16881 , p_component_type_code => l_component_type_code
16882 , p_component_appl_id => l_component_appl_id
16883 , p_amb_context_code => l_amb_context_code
16884 , p_side => 'NA'
16885 );
16886
16887
16888 --
16889 --
16890 END IF;
16891 --
16892 -- Bug 4922099
16893 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
16894 (NVL(l_enc_upg_option, 'N') = 'O')
16895 ) AND
16896 (l_bflow_method_code = 'PRIOR_ENTRY')
16897 )
16898 THEN
16899 IF
16900 --
16901 1 = 2
16902 --
16903 THEN
16904 xla_accounting_err_pkg.build_message
16905 (p_appli_s_name => 'XLA'
16906 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16907 ,p_token_1 => 'LINE_NUMBER'
16908 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
16909 ,p_token_2 => 'LINE_TYPE_NAME'
16910 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
16911 l_component_type
16912 ,l_component_code
16913 ,l_component_type_code
16914 ,l_component_appl_id
16915 ,l_amb_context_code
16916 ,l_entity_code
16917 ,l_event_class_code
16918 )
16919 ,p_token_3 => 'OWNER'
16920 ,p_value_3 => xla_lookups_pkg.get_meaning(
16921 p_lookup_type => 'XLA_OWNER_TYPE'
16922 ,p_lookup_code => l_component_type_code
16923 )
16924 ,p_token_4 => 'PRODUCT_NAME'
16925 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
16929 ,p_ae_header_id => NULL
16926 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
16927 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
16928 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
16930 );
16931
16932 IF (C_LEVEL_ERROR>= g_log_level) THEN
16933 trace
16934 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16935 ,p_level => C_LEVEL_ERROR
16936 ,p_module => l_log_module);
16937 END IF;
16938 END IF;
16939 END IF;
16940 --
16941 --
16942 ------------------------------------------------------------------------------------------------
16943 -- 4219869 Business Flow
16944 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
16945 -- Prior Entry. Currently, the following code is always generated.
16946 ------------------------------------------------------------------------------------------------
16947 XLA_AE_LINES_PKG.ValidateCurrentLine;
16948
16949 ------------------------------------------------------------------------------------
16950 -- 4219869 Business Flow
16951 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
16952 ------------------------------------------------------------------------------------
16953 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
16954
16955 ----------------------------------------------------------------------------------
16956 -- 4219869 Business Flow
16957 -- Update journal entry status -- Need to generate this within IF <condition>
16958 ----------------------------------------------------------------------------------
16959 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
16960 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
16961 ,p_balance_type_code => l_balance_type_code
16962 );
16963
16964 -------------------------------------------------------------------------------------------
16965 -- 4262811 - Generate the Accrual Reversal lines
16966 -------------------------------------------------------------------------------------------
16967 BEGIN
16968 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
16969 (g_array_event(p_event_id).array_value_num('header_index'));
16970 IF l_acc_rev_flag IS NULL THEN
16971 l_acc_rev_flag := 'N';
16972 END IF;
16973 EXCEPTION
16974 WHEN OTHERS THEN
16975 l_acc_rev_flag := 'N';
16976 END;
16977 --
16978 IF (l_acc_rev_flag = 'Y') THEN
16979
16980 -- 4645092 ------------------------------------------------------------------------------
16981 -- To allow MPA report to determine if it should generate report process
16982 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
16983 ------------------------------------------------------------------------------------------
16984
16985 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
16986 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
16987 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
16988 -- call ADRs
16989 -- Bug 4922099
16990 --
16991 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16992 (NVL(l_actual_upg_option, 'N') = 'O') OR
16993 (NVL(l_enc_upg_option, 'N') = 'O')
16994 )
16995 THEN
16996 NULL;
16997 --
16998 --
16999
17000 l_ccid := AcctDerRule_18(
17001 p_application_id => p_application_id
17002 , p_ae_header_id => l_ae_header_id
17003 , p_source_14 => p_source_14
17004 , x_transaction_coa_id => l_adr_transaction_coa_id
17005 , x_accounting_coa_id => l_adr_accounting_coa_id
17006 , x_value_type_code => l_adr_value_type_code
17007 , p_side => 'NA'
17008 );
17009
17010 xla_ae_lines_pkg.set_ccid(
17011 p_code_combination_id => l_ccid
17012 , p_value_type_code => l_adr_value_type_code
17013 , p_transaction_coa_id => l_adr_transaction_coa_id
17014 , p_accounting_coa_id => l_adr_accounting_coa_id
17015 , p_adr_code => 'TRX_DIST_CCID'
17016 , p_adr_type_code => 'S'
17017 , p_component_type => l_component_type
17018 , p_component_code => l_component_code
17019 , p_component_type_code => l_component_type_code
17020 , p_component_appl_id => l_component_appl_id
17021 , p_amb_context_code => l_amb_context_code
17022 , p_side => 'NA'
17023 );
17024
17025
17026 --
17027 --
17028 END IF;
17029
17030 --
17031 -- Update the line information that should be overwritten
17032 --
17033 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
17034 p_header_num => 1);
17035 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
17036
17037 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
17038
17039 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
17043 --
17040 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
17041 END IF;
17042
17044 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
17045 --
17046 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
17047 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
17048 ELSE
17049 ---------------------------------------------------------------------------------------------------
17050 -- 4262811a Switch Sign
17051 ---------------------------------------------------------------------------------------------------
17052 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
17053 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17054 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17055 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17056 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17057 -- 5132302
17058 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
17059 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17060
17061 END IF;
17062
17063 -- 4955764
17064 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17065 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
17066
17067
17068 XLA_AE_LINES_PKG.ValidateCurrentLine;
17069 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17070
17071 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17072 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
17073 ,p_balance_type_code => l_balance_type_code);
17074
17075 END IF;
17076
17077 -----------------------------------------------------------------------------------------
17078 -- 4262811 Multiperiod Accounting
17079 -----------------------------------------------------------------------------------------
17080 -- No MPA option is assigned.
17081
17082
17083 END IF;
17084 END IF;
17085 --
17086
17087 --
17088 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17089 trace
17090 (p_msg => 'END of AcctLineType_44'
17091 ,p_level => C_LEVEL_PROCEDURE
17092 ,p_module => l_log_module);
17093 END IF;
17094 --
17095 EXCEPTION
17096 WHEN xla_exceptions_pkg.application_exception THEN
17097 RAISE;
17098 WHEN OTHERS THEN
17099 xla_exceptions_pkg.raise_message
17100 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_44');
17101 END AcctLineType_44;
17102 --
17103
17104 ---------------------------------------
17105 --
17106 -- PRIVATE FUNCTION
17107 -- AcctLineType_45
17108 --
17109 ---------------------------------------
17110 PROCEDURE AcctLineType_45 (
17111 p_application_id IN NUMBER
17112 ,p_event_id IN NUMBER
17113 ,p_calculate_acctd_flag IN VARCHAR2
17114 ,p_calculate_g_l_flag IN VARCHAR2
17115 ,p_actual_flag IN OUT VARCHAR2
17116 ,p_balance_type_code OUT VARCHAR2
17117 ,p_gain_or_loss_ref OUT VARCHAR2
17118
17119 --Transaction Distribution GL Account
17120 , p_source_14 IN NUMBER
17121 --Bill To Customer Account Identifier
17122 , p_source_25 IN NUMBER
17123 --Bill To Customer Site Use Identifier
17124 , p_source_26 IN NUMBER
17125 --SLA Party Type
17126 , p_source_27 IN VARCHAR2
17127 --Transaction Distribution Account Class
17128 , p_source_28 IN VARCHAR2
17129 --Transaction Distribution Identifier
17130 , p_source_29 IN NUMBER
17131 --Transaction Distribution Type
17132 , p_source_30 IN VARCHAR2
17133 --Transaction Distribution Entered Amount
17134 , p_source_31 IN NUMBER
17135 --Transaction Currency Code
17136 , p_source_32 IN VARCHAR2
17137 --Transaction Exchange Date
17138 , p_source_33 IN DATE
17139 --Transaction Exchange Rate
17140 , p_source_34 IN NUMBER
17141 --Transaction Exchange Rate Type
17142 , p_source_35 IN VARCHAR2
17143 --Transaction Accounting Amount
17144 , p_source_36 IN NUMBER
17145 )
17146 IS
17147
17148 l_component_type VARCHAR2(80);
17149 l_component_code VARCHAR2(30);
17150 l_component_type_code VARCHAR2(1);
17151 l_component_appl_id INTEGER;
17152 l_amb_context_code VARCHAR2(30);
17153 l_entity_code VARCHAR2(30);
17154 l_event_class_code VARCHAR2(30);
17155 l_ae_header_id NUMBER;
17156 l_event_type_code VARCHAR2(30);
17157 l_line_definition_code VARCHAR2(30);
17158 l_line_definition_owner_code VARCHAR2(1);
17159 --
17160 -- adr variables
17161 l_segment VARCHAR2(30);
17162 l_ccid NUMBER;
17163 l_adr_transaction_coa_id NUMBER;
17164 l_adr_accounting_coa_id NUMBER;
17165 l_adr_flexfield_segment_code VARCHAR2(30);
17166 l_adr_flex_value_set_id NUMBER;
17167 l_adr_value_type_code VARCHAR2(30);
17168 l_adr_value_combination_id NUMBER;
17169 l_adr_value_segment_code VARCHAR2(30);
17170
17171 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
17175
17172 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
17173 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
17174 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
17176 -- 4262811 Variables ------------------------------------------------------------------------------------------
17177 l_entered_amt_idx NUMBER;
17178 l_accted_amt_idx NUMBER;
17179 l_acc_rev_flag VARCHAR2(1);
17180 l_accrual_line_num NUMBER;
17181 l_tmp_amt NUMBER;
17182 l_acc_rev_natural_side_code VARCHAR2(1);
17183
17184 l_num_entries NUMBER;
17185 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
17186 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
17187 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
17188 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
17189 l_recog_line_1 NUMBER;
17190 l_recog_line_2 NUMBER;
17191
17192 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
17193 l_bflow_applied_to_amt NUMBER; -- 5132302
17194 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
17195
17196 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
17197
17198 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
17199 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
17200
17201 ---------------------------------------------------------------------------------------------------------------
17202
17203
17204 --
17205 -- bulk performance
17206 --
17207 l_balance_type_code VARCHAR2(1);
17208 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
17209 l_log_module VARCHAR2(240);
17210
17211 --
17212 -- Upgrade strategy
17213 --
17214 l_actual_upg_option VARCHAR2(1);
17215 l_enc_upg_option VARCHAR2(1);
17216
17217 --
17218 BEGIN
17219 --
17220 IF g_log_enabled THEN
17221 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_45';
17222 END IF;
17223 --
17224 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17225
17226 trace
17227 (p_msg => 'BEGIN of AcctLineType_45'
17228 ,p_level => C_LEVEL_PROCEDURE
17229 ,p_module => l_log_module);
17230
17231 END IF;
17232 --
17233 l_component_type := 'AMB_JLT';
17234 l_component_code := 'GUAR_REV';
17235 l_component_type_code := 'S';
17236 l_component_appl_id := 222;
17237 l_amb_context_code := 'DEFAULT';
17238 l_entity_code := 'TRANSACTIONS';
17239 l_event_class_code := 'GUARANTEE';
17240 l_event_type_code := 'GUARANTEE_ALL';
17241 l_line_definition_owner_code := 'S';
17242 l_line_definition_code := 'AR_GUAR_DEFAULT_ACCRUAL';
17243 --
17244 l_balance_type_code := 'A';
17245 l_segment := NULL;
17246 l_ccid := NULL;
17247 l_adr_transaction_coa_id := NULL;
17248 l_adr_accounting_coa_id := NULL;
17249 l_adr_flexfield_segment_code := NULL;
17250 l_adr_flex_value_set_id := NULL;
17251 l_adr_value_type_code := NULL;
17252 l_adr_value_combination_id := NULL;
17253 l_adr_value_segment_code := NULL;
17254
17255 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
17256 l_bflow_class_code := ''; -- 4219869 Business Flow
17257 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
17258 l_budgetary_control_flag := 'N';
17259
17260 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17261 l_bflow_applied_to_amt := NULL; -- 5132302
17262 l_entered_amt_idx := NULL; -- 4262811
17263 l_accted_amt_idx := NULL; -- 4262811
17264 l_acc_rev_flag := NULL; -- 4262811
17265 l_accrual_line_num := NULL; -- 4262811
17266 l_tmp_amt := NULL; -- 4262811
17267 --
17268
17269 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
17270 l_balance_type_code <> 'B' THEN
17271 IF NVL(p_source_28,'
17272 ') = 'REV'
17273 THEN
17274
17275 --
17276 XLA_AE_LINES_PKG.SetNewLine;
17277
17278 p_balance_type_code := l_balance_type_code;
17279 -- set the flag so later we will know whether the gain loss line needs to be created
17280
17281 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
17282 p_actual_flag :='A';
17283 END IF;
17284
17285 --
17286 -- bulk performance
17287 --
17288 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
17289 p_header_num => 0); -- 4262811
17290 --
17291 -- set accounting line options
17292 --
17293 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
17294 p_natural_side_code => 'C'
17295 , p_gain_or_loss_flag => 'N'
17296 , p_gl_transfer_mode_code => 'S'
17297 , p_acct_entry_type_code => 'A'
17298 , p_switch_side_flag => 'Y'
17299 , p_merge_duplicate_code => 'A'
17300 );
17301 --
17302 l_acc_rev_natural_side_code := 'D'; -- 4262811
17303 --
17304 --
17305 -- set accounting line type info
17306 --
17307 xla_ae_lines_pkg.SetAcctLineType
17308 (p_component_type => l_component_type
17312 ,p_accounting_line_code => l_component_code
17309 ,p_event_type_code => l_event_type_code
17310 ,p_line_definition_owner_code => l_line_definition_owner_code
17311 ,p_line_definition_code => l_line_definition_code
17313 ,p_accounting_line_type_code => l_component_type_code
17314 ,p_accounting_line_appl_id => l_component_appl_id
17315 ,p_amb_context_code => l_amb_context_code
17316 ,p_entity_code => l_entity_code
17317 ,p_event_class_code => l_event_class_code);
17318 --
17319 -- set accounting class
17320 --
17321 xla_ae_lines_pkg.SetAcctClass(
17322 p_accounting_class_code => 'REVENUE'
17323 , p_ae_header_id => l_ae_header_id
17324 );
17325
17326 --
17327 -- set rounding class
17328 --
17329 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
17330 'RECEIVABLE';
17331
17332 --
17333 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
17334 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
17335 --
17336 -- bulk performance
17337 --
17338 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
17339
17340 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
17341 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
17342
17343 -- 4955764
17344 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17345 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
17346
17347 -- 4458381 Public Sector Enh
17348
17349 --
17350 -- set accounting attributes for the line type
17351 --
17352 l_entered_amt_idx := 3;
17353 l_accted_amt_idx := 8;
17354 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17355 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
17356 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
17357 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
17358 l_rec_acct_attrs.array_char_value(2) := p_source_30;
17359 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
17360 l_rec_acct_attrs.array_num_value(3) := p_source_31;
17361 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
17362 l_rec_acct_attrs.array_char_value(4) := p_source_32;
17363 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
17364 l_rec_acct_attrs.array_date_value(5) := p_source_33;
17365 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
17366 l_rec_acct_attrs.array_num_value(6) := p_source_34;
17367 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
17368 l_rec_acct_attrs.array_char_value(7) := p_source_35;
17369 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
17370 l_rec_acct_attrs.array_num_value(8) := p_source_36;
17371 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
17372 l_rec_acct_attrs.array_num_value(9) := p_source_25;
17373 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
17374 l_rec_acct_attrs.array_num_value(10) := p_source_26;
17375 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
17376 l_rec_acct_attrs.array_char_value(11) := p_source_27;
17377
17378 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
17379 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
17380
17381 ---------------------------------------------------------------------------------------------------------------
17382 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
17383 ---------------------------------------------------------------------------------------------------------------
17384 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
17385
17386 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17387 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17388
17389 IF xla_accounting_cache_pkg.GetValueChar
17390 (p_source_code => 'LEDGER_CATEGORY_CODE'
17391 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
17392 AND l_bflow_method_code = 'PRIOR_ENTRY'
17393 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
17394 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
17395 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
17396 )
17397 THEN
17398 xla_ae_lines_pkg.BflowUpgEntry
17399 (p_business_method_code => l_bflow_method_code
17400 ,p_business_class_code => l_bflow_class_code
17401 ,p_balance_type => l_balance_type_code);
17402 ELSE
17403 NULL;
17404 -- No business flow processing for business flow method of NONE.
17405 END IF;
17406
17407 --
17408 -- call analytical criteria
17409 --
17410
17411 --
17412 -- call description
17413 --
17414 -- No description or it is inherited.
17415 --
17416 -- call ADRs
17417 -- Bug 4922099
17418 --
17419 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17420 (NVL(l_actual_upg_option, 'N') = 'O') OR
17421 (NVL(l_enc_upg_option, 'N') = 'O')
17422 )
17423 THEN
17424 NULL;
17425 --
17426 --
17427
17428 l_ccid := AcctDerRule_18(
17432 , x_transaction_coa_id => l_adr_transaction_coa_id
17429 p_application_id => p_application_id
17430 , p_ae_header_id => l_ae_header_id
17431 , p_source_14 => p_source_14
17433 , x_accounting_coa_id => l_adr_accounting_coa_id
17434 , x_value_type_code => l_adr_value_type_code
17435 , p_side => 'NA'
17436 );
17437
17438 xla_ae_lines_pkg.set_ccid(
17439 p_code_combination_id => l_ccid
17440 , p_value_type_code => l_adr_value_type_code
17441 , p_transaction_coa_id => l_adr_transaction_coa_id
17442 , p_accounting_coa_id => l_adr_accounting_coa_id
17443 , p_adr_code => 'TRX_DIST_CCID'
17444 , p_adr_type_code => 'S'
17445 , p_component_type => l_component_type
17446 , p_component_code => l_component_code
17447 , p_component_type_code => l_component_type_code
17448 , p_component_appl_id => l_component_appl_id
17449 , p_amb_context_code => l_amb_context_code
17450 , p_side => 'NA'
17451 );
17452
17453
17454 --
17455 --
17456 END IF;
17457 --
17458 -- Bug 4922099
17459 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
17460 (NVL(l_enc_upg_option, 'N') = 'O')
17461 ) AND
17462 (l_bflow_method_code = 'PRIOR_ENTRY')
17463 )
17464 THEN
17465 IF
17466 --
17467 1 = 2
17468 --
17469 THEN
17470 xla_accounting_err_pkg.build_message
17471 (p_appli_s_name => 'XLA'
17472 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17473 ,p_token_1 => 'LINE_NUMBER'
17474 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
17475 ,p_token_2 => 'LINE_TYPE_NAME'
17476 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
17477 l_component_type
17478 ,l_component_code
17479 ,l_component_type_code
17480 ,l_component_appl_id
17481 ,l_amb_context_code
17482 ,l_entity_code
17483 ,l_event_class_code
17484 )
17485 ,p_token_3 => 'OWNER'
17486 ,p_value_3 => xla_lookups_pkg.get_meaning(
17487 p_lookup_type => 'XLA_OWNER_TYPE'
17488 ,p_lookup_code => l_component_type_code
17489 )
17490 ,p_token_4 => 'PRODUCT_NAME'
17491 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
17492 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
17493 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
17494 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
17495 ,p_ae_header_id => NULL
17496 );
17497
17498 IF (C_LEVEL_ERROR>= g_log_level) THEN
17499 trace
17500 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17501 ,p_level => C_LEVEL_ERROR
17502 ,p_module => l_log_module);
17503 END IF;
17504 END IF;
17505 END IF;
17506 --
17507 --
17508 ------------------------------------------------------------------------------------------------
17509 -- 4219869 Business Flow
17510 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
17511 -- Prior Entry. Currently, the following code is always generated.
17512 ------------------------------------------------------------------------------------------------
17513 XLA_AE_LINES_PKG.ValidateCurrentLine;
17514
17515 ------------------------------------------------------------------------------------
17516 -- 4219869 Business Flow
17517 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
17518 ------------------------------------------------------------------------------------
17519 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17520
17521 ----------------------------------------------------------------------------------
17522 -- 4219869 Business Flow
17523 -- Update journal entry status -- Need to generate this within IF <condition>
17524 ----------------------------------------------------------------------------------
17525 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17526 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
17527 ,p_balance_type_code => l_balance_type_code
17528 );
17529
17530 -------------------------------------------------------------------------------------------
17534 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
17531 -- 4262811 - Generate the Accrual Reversal lines
17532 -------------------------------------------------------------------------------------------
17533 BEGIN
17535 (g_array_event(p_event_id).array_value_num('header_index'));
17536 IF l_acc_rev_flag IS NULL THEN
17537 l_acc_rev_flag := 'N';
17538 END IF;
17539 EXCEPTION
17540 WHEN OTHERS THEN
17541 l_acc_rev_flag := 'N';
17542 END;
17543 --
17544 IF (l_acc_rev_flag = 'Y') THEN
17545
17546 -- 4645092 ------------------------------------------------------------------------------
17547 -- To allow MPA report to determine if it should generate report process
17548 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
17549 ------------------------------------------------------------------------------------------
17550
17551 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
17552 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
17553 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
17554 -- call ADRs
17555 -- Bug 4922099
17556 --
17557 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17558 (NVL(l_actual_upg_option, 'N') = 'O') OR
17559 (NVL(l_enc_upg_option, 'N') = 'O')
17560 )
17561 THEN
17562 NULL;
17563 --
17564 --
17565
17566 l_ccid := AcctDerRule_18(
17567 p_application_id => p_application_id
17568 , p_ae_header_id => l_ae_header_id
17569 , p_source_14 => p_source_14
17570 , x_transaction_coa_id => l_adr_transaction_coa_id
17571 , x_accounting_coa_id => l_adr_accounting_coa_id
17572 , x_value_type_code => l_adr_value_type_code
17573 , p_side => 'NA'
17574 );
17575
17576 xla_ae_lines_pkg.set_ccid(
17577 p_code_combination_id => l_ccid
17578 , p_value_type_code => l_adr_value_type_code
17579 , p_transaction_coa_id => l_adr_transaction_coa_id
17580 , p_accounting_coa_id => l_adr_accounting_coa_id
17581 , p_adr_code => 'TRX_DIST_CCID'
17582 , p_adr_type_code => 'S'
17583 , p_component_type => l_component_type
17584 , p_component_code => l_component_code
17585 , p_component_type_code => l_component_type_code
17586 , p_component_appl_id => l_component_appl_id
17587 , p_amb_context_code => l_amb_context_code
17588 , p_side => 'NA'
17589 );
17590
17591
17592 --
17593 --
17594 END IF;
17595
17596 --
17597 -- Update the line information that should be overwritten
17598 --
17599 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
17600 p_header_num => 1);
17601 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
17602
17603 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
17604
17605 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
17606 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
17607 END IF;
17608
17609 --
17610 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
17611 --
17612 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
17613 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
17614 ELSE
17615 ---------------------------------------------------------------------------------------------------
17616 -- 4262811a Switch Sign
17617 ---------------------------------------------------------------------------------------------------
17618 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
17619 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17620 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17621 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17622 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17623 -- 5132302
17624 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
17625 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17626
17627 END IF;
17628
17629 -- 4955764
17630 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17631 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
17632
17633
17634 XLA_AE_LINES_PKG.ValidateCurrentLine;
17635 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17636
17637 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17638 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
17639 ,p_balance_type_code => l_balance_type_code);
17640
17641 END IF;
17642
17643 -----------------------------------------------------------------------------------------
17644 -- 4262811 Multiperiod Accounting
17645 -----------------------------------------------------------------------------------------
17646 -- No MPA option is assigned.
17647
17648
17652
17649 END IF;
17650 END IF;
17651 --
17653 --
17654 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17655 trace
17656 (p_msg => 'END of AcctLineType_45'
17657 ,p_level => C_LEVEL_PROCEDURE
17658 ,p_module => l_log_module);
17659 END IF;
17660 --
17661 EXCEPTION
17662 WHEN xla_exceptions_pkg.application_exception THEN
17663 RAISE;
17664 WHEN OTHERS THEN
17665 xla_exceptions_pkg.raise_message
17666 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_45');
17667 END AcctLineType_45;
17668 --
17669
17670 ---------------------------------------
17671 --
17672 -- PRIVATE FUNCTION
17673 -- AcctLineType_46
17674 --
17675 ---------------------------------------
17676 PROCEDURE AcctLineType_46 (
17677 p_application_id IN NUMBER
17678 ,p_event_id IN NUMBER
17679 ,p_calculate_acctd_flag IN VARCHAR2
17680 ,p_calculate_g_l_flag IN VARCHAR2
17681 ,p_actual_flag IN OUT VARCHAR2
17682 ,p_balance_type_code OUT VARCHAR2
17683 ,p_gain_or_loss_ref OUT VARCHAR2
17684
17685 --Transaction Distribution GL Account
17686 , p_source_14 IN NUMBER
17687 --Bill To Customer Account Identifier
17688 , p_source_25 IN NUMBER
17689 --Bill To Customer Site Use Identifier
17690 , p_source_26 IN NUMBER
17691 --SLA Party Type
17692 , p_source_27 IN VARCHAR2
17693 --Transaction Distribution Account Class
17694 , p_source_28 IN VARCHAR2
17695 --Transaction Distribution Identifier
17696 , p_source_29 IN NUMBER
17697 --Transaction Distribution Type
17698 , p_source_30 IN VARCHAR2
17699 --Transaction Distribution Entered Amount
17700 , p_source_31 IN NUMBER
17701 --Transaction Currency Code
17702 , p_source_32 IN VARCHAR2
17703 --Transaction Exchange Date
17704 , p_source_33 IN DATE
17705 --Transaction Exchange Rate
17706 , p_source_34 IN NUMBER
17707 --Transaction Exchange Rate Type
17708 , p_source_35 IN VARCHAR2
17709 --Transaction Accounting Amount
17710 , p_source_36 IN NUMBER
17711 --Transaction Tax Line Identifier
17712 , p_source_50 IN NUMBER
17713 )
17714 IS
17715
17716 l_component_type VARCHAR2(80);
17717 l_component_code VARCHAR2(30);
17718 l_component_type_code VARCHAR2(1);
17719 l_component_appl_id INTEGER;
17720 l_amb_context_code VARCHAR2(30);
17721 l_entity_code VARCHAR2(30);
17722 l_event_class_code VARCHAR2(30);
17723 l_ae_header_id NUMBER;
17724 l_event_type_code VARCHAR2(30);
17725 l_line_definition_code VARCHAR2(30);
17726 l_line_definition_owner_code VARCHAR2(1);
17727 --
17728 -- adr variables
17729 l_segment VARCHAR2(30);
17730 l_ccid NUMBER;
17731 l_adr_transaction_coa_id NUMBER;
17732 l_adr_accounting_coa_id NUMBER;
17733 l_adr_flexfield_segment_code VARCHAR2(30);
17734 l_adr_flex_value_set_id NUMBER;
17735 l_adr_value_type_code VARCHAR2(30);
17736 l_adr_value_combination_id NUMBER;
17737 l_adr_value_segment_code VARCHAR2(30);
17738
17739 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
17740 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
17741 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
17742 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
17743
17744 -- 4262811 Variables ------------------------------------------------------------------------------------------
17745 l_entered_amt_idx NUMBER;
17746 l_accted_amt_idx NUMBER;
17747 l_acc_rev_flag VARCHAR2(1);
17748 l_accrual_line_num NUMBER;
17749 l_tmp_amt NUMBER;
17750 l_acc_rev_natural_side_code VARCHAR2(1);
17751
17752 l_num_entries NUMBER;
17753 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
17754 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
17755 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
17756 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
17757 l_recog_line_1 NUMBER;
17758 l_recog_line_2 NUMBER;
17759
17760 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
17761 l_bflow_applied_to_amt NUMBER; -- 5132302
17762 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
17763
17764 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
17765
17766 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
17767 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
17768
17769 ---------------------------------------------------------------------------------------------------------------
17770
17771
17772 --
17773 -- bulk performance
17774 --
17775 l_balance_type_code VARCHAR2(1);
17776 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
17777 l_log_module VARCHAR2(240);
17778
17779 --
17780 -- Upgrade strategy
17781 --
17782 l_actual_upg_option VARCHAR2(1);
17783 l_enc_upg_option VARCHAR2(1);
17784
17785 --
17786 BEGIN
17787 --
17788 IF g_log_enabled THEN
17789 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_46';
17790 END IF;
17791 --
17792 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17796 ,p_level => C_LEVEL_PROCEDURE
17793
17794 trace
17795 (p_msg => 'BEGIN of AcctLineType_46'
17797 ,p_module => l_log_module);
17798
17799 END IF;
17800 --
17801 l_component_type := 'AMB_JLT';
17802 l_component_code := 'INV_CHARGES';
17803 l_component_type_code := 'S';
17804 l_component_appl_id := 222;
17805 l_amb_context_code := 'DEFAULT';
17806 l_entity_code := 'TRANSACTIONS';
17807 l_event_class_code := 'INVOICE';
17808 l_event_type_code := 'INVOICE_ALL';
17809 l_line_definition_owner_code := 'S';
17810 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
17811 --
17812 l_balance_type_code := 'A';
17813 l_segment := NULL;
17814 l_ccid := NULL;
17815 l_adr_transaction_coa_id := NULL;
17816 l_adr_accounting_coa_id := NULL;
17817 l_adr_flexfield_segment_code := NULL;
17818 l_adr_flex_value_set_id := NULL;
17819 l_adr_value_type_code := NULL;
17820 l_adr_value_combination_id := NULL;
17821 l_adr_value_segment_code := NULL;
17822
17823 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
17824 l_bflow_class_code := ''; -- 4219869 Business Flow
17825 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
17826 l_budgetary_control_flag := 'N';
17827
17828 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17829 l_bflow_applied_to_amt := NULL; -- 5132302
17830 l_entered_amt_idx := NULL; -- 4262811
17831 l_accted_amt_idx := NULL; -- 4262811
17832 l_acc_rev_flag := NULL; -- 4262811
17833 l_accrual_line_num := NULL; -- 4262811
17834 l_tmp_amt := NULL; -- 4262811
17835 --
17836
17837 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
17838 l_balance_type_code <> 'B' THEN
17839 IF NVL(p_source_28,'
17840 ') = 'CHARGES'
17841 THEN
17842
17843 --
17844 XLA_AE_LINES_PKG.SetNewLine;
17845
17846 p_balance_type_code := l_balance_type_code;
17847 -- set the flag so later we will know whether the gain loss line needs to be created
17848
17849 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
17850 p_actual_flag :='A';
17851 END IF;
17852
17853 --
17854 -- bulk performance
17855 --
17856 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
17857 p_header_num => 0); -- 4262811
17858 --
17859 -- set accounting line options
17860 --
17861 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
17862 p_natural_side_code => 'C'
17863 , p_gain_or_loss_flag => 'N'
17864 , p_gl_transfer_mode_code => 'S'
17865 , p_acct_entry_type_code => 'A'
17866 , p_switch_side_flag => 'Y'
17867 , p_merge_duplicate_code => 'A'
17868 );
17869 --
17870 l_acc_rev_natural_side_code := 'D'; -- 4262811
17871 --
17872 --
17873 -- set accounting line type info
17874 --
17875 xla_ae_lines_pkg.SetAcctLineType
17876 (p_component_type => l_component_type
17877 ,p_event_type_code => l_event_type_code
17878 ,p_line_definition_owner_code => l_line_definition_owner_code
17879 ,p_line_definition_code => l_line_definition_code
17880 ,p_accounting_line_code => l_component_code
17881 ,p_accounting_line_type_code => l_component_type_code
17882 ,p_accounting_line_appl_id => l_component_appl_id
17883 ,p_amb_context_code => l_amb_context_code
17884 ,p_entity_code => l_entity_code
17885 ,p_event_class_code => l_event_class_code);
17886 --
17887 -- set accounting class
17888 --
17889 xla_ae_lines_pkg.SetAcctClass(
17890 p_accounting_class_code => 'CHARGES'
17891 , p_ae_header_id => l_ae_header_id
17892 );
17893
17894 --
17895 -- set rounding class
17896 --
17897 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
17898 'RECEIVABLE';
17899
17900 --
17901 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
17902 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
17903 --
17904 -- bulk performance
17905 --
17906 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
17907
17908 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
17909 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
17910
17911 -- 4955764
17912 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17913 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
17914
17915 -- 4458381 Public Sector Enh
17916
17917 --
17918 -- set accounting attributes for the line type
17919 --
17920 l_entered_amt_idx := 3;
17921 l_accted_amt_idx := 8;
17922 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17923 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
17924 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
17925 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
17926 l_rec_acct_attrs.array_char_value(2) := p_source_30;
17930 l_rec_acct_attrs.array_char_value(4) := p_source_32;
17927 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
17928 l_rec_acct_attrs.array_num_value(3) := p_source_31;
17929 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
17931 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
17932 l_rec_acct_attrs.array_date_value(5) := p_source_33;
17933 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
17934 l_rec_acct_attrs.array_num_value(6) := p_source_34;
17935 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
17936 l_rec_acct_attrs.array_char_value(7) := p_source_35;
17937 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
17938 l_rec_acct_attrs.array_num_value(8) := p_source_36;
17939 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
17940 l_rec_acct_attrs.array_num_value(9) := p_source_25;
17941 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
17942 l_rec_acct_attrs.array_num_value(10) := p_source_26;
17943 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
17944 l_rec_acct_attrs.array_char_value(11) := p_source_27;
17945 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
17946 l_rec_acct_attrs.array_num_value(12) := p_source_50;
17947
17948 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
17949 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
17950
17951 ---------------------------------------------------------------------------------------------------------------
17952 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
17953 ---------------------------------------------------------------------------------------------------------------
17954 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
17955
17956 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17957 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17958
17959 IF xla_accounting_cache_pkg.GetValueChar
17960 (p_source_code => 'LEDGER_CATEGORY_CODE'
17961 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
17962 AND l_bflow_method_code = 'PRIOR_ENTRY'
17963 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
17964 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
17965 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
17966 )
17967 THEN
17968 xla_ae_lines_pkg.BflowUpgEntry
17969 (p_business_method_code => l_bflow_method_code
17970 ,p_business_class_code => l_bflow_class_code
17971 ,p_balance_type => l_balance_type_code);
17972 ELSE
17973 NULL;
17974 -- No business flow processing for business flow method of NONE.
17975 END IF;
17976
17977 --
17978 -- call analytical criteria
17979 --
17980
17981 --
17982 -- call description
17983 --
17984 -- No description or it is inherited.
17985 --
17986 -- call ADRs
17987 -- Bug 4922099
17988 --
17989 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17990 (NVL(l_actual_upg_option, 'N') = 'O') OR
17991 (NVL(l_enc_upg_option, 'N') = 'O')
17992 )
17993 THEN
17994 NULL;
17995 --
17996 --
17997
17998 l_ccid := AcctDerRule_18(
17999 p_application_id => p_application_id
18000 , p_ae_header_id => l_ae_header_id
18001 , p_source_14 => p_source_14
18002 , x_transaction_coa_id => l_adr_transaction_coa_id
18003 , x_accounting_coa_id => l_adr_accounting_coa_id
18004 , x_value_type_code => l_adr_value_type_code
18005 , p_side => 'NA'
18006 );
18007
18008 xla_ae_lines_pkg.set_ccid(
18009 p_code_combination_id => l_ccid
18010 , p_value_type_code => l_adr_value_type_code
18011 , p_transaction_coa_id => l_adr_transaction_coa_id
18012 , p_accounting_coa_id => l_adr_accounting_coa_id
18013 , p_adr_code => 'TRX_DIST_CCID'
18014 , p_adr_type_code => 'S'
18015 , p_component_type => l_component_type
18016 , p_component_code => l_component_code
18017 , p_component_type_code => l_component_type_code
18018 , p_component_appl_id => l_component_appl_id
18019 , p_amb_context_code => l_amb_context_code
18020 , p_side => 'NA'
18021 );
18022
18023
18024 --
18025 --
18026 END IF;
18027 --
18028 -- Bug 4922099
18029 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
18030 (NVL(l_enc_upg_option, 'N') = 'O')
18031 ) AND
18032 (l_bflow_method_code = 'PRIOR_ENTRY')
18033 )
18034 THEN
18035 IF
18036 --
18037 1 = 2
18038 --
18039 THEN
18040 xla_accounting_err_pkg.build_message
18041 (p_appli_s_name => 'XLA'
18042 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18043 ,p_token_1 => 'LINE_NUMBER'
18044 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
18045 ,p_token_2 => 'LINE_TYPE_NAME'
18046 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
18050 ,l_component_appl_id
18047 l_component_type
18048 ,l_component_code
18049 ,l_component_type_code
18051 ,l_amb_context_code
18052 ,l_entity_code
18053 ,l_event_class_code
18054 )
18055 ,p_token_3 => 'OWNER'
18056 ,p_value_3 => xla_lookups_pkg.get_meaning(
18057 p_lookup_type => 'XLA_OWNER_TYPE'
18058 ,p_lookup_code => l_component_type_code
18059 )
18060 ,p_token_4 => 'PRODUCT_NAME'
18061 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
18062 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
18063 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
18064 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
18065 ,p_ae_header_id => NULL
18066 );
18067
18068 IF (C_LEVEL_ERROR>= g_log_level) THEN
18069 trace
18070 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18071 ,p_level => C_LEVEL_ERROR
18072 ,p_module => l_log_module);
18073 END IF;
18074 END IF;
18075 END IF;
18076 --
18077 --
18078 ------------------------------------------------------------------------------------------------
18079 -- 4219869 Business Flow
18080 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
18081 -- Prior Entry. Currently, the following code is always generated.
18082 ------------------------------------------------------------------------------------------------
18083 XLA_AE_LINES_PKG.ValidateCurrentLine;
18084
18085 ------------------------------------------------------------------------------------
18086 -- 4219869 Business Flow
18087 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
18088 ------------------------------------------------------------------------------------
18089 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18090
18091 ----------------------------------------------------------------------------------
18092 -- 4219869 Business Flow
18093 -- Update journal entry status -- Need to generate this within IF <condition>
18094 ----------------------------------------------------------------------------------
18095 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18096 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
18097 ,p_balance_type_code => l_balance_type_code
18098 );
18099
18100 -------------------------------------------------------------------------------------------
18101 -- 4262811 - Generate the Accrual Reversal lines
18102 -------------------------------------------------------------------------------------------
18103 BEGIN
18104 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
18105 (g_array_event(p_event_id).array_value_num('header_index'));
18106 IF l_acc_rev_flag IS NULL THEN
18107 l_acc_rev_flag := 'N';
18108 END IF;
18109 EXCEPTION
18110 WHEN OTHERS THEN
18111 l_acc_rev_flag := 'N';
18112 END;
18113 --
18114 IF (l_acc_rev_flag = 'Y') THEN
18115
18116 -- 4645092 ------------------------------------------------------------------------------
18117 -- To allow MPA report to determine if it should generate report process
18118 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
18119 ------------------------------------------------------------------------------------------
18120
18121 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
18122 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
18123 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
18124 -- call ADRs
18125 -- Bug 4922099
18126 --
18127 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18128 (NVL(l_actual_upg_option, 'N') = 'O') OR
18129 (NVL(l_enc_upg_option, 'N') = 'O')
18130 )
18131 THEN
18132 NULL;
18133 --
18134 --
18135
18136 l_ccid := AcctDerRule_18(
18137 p_application_id => p_application_id
18138 , p_ae_header_id => l_ae_header_id
18139 , p_source_14 => p_source_14
18140 , x_transaction_coa_id => l_adr_transaction_coa_id
18141 , x_accounting_coa_id => l_adr_accounting_coa_id
18142 , x_value_type_code => l_adr_value_type_code
18143 , p_side => 'NA'
18144 );
18145
18146 xla_ae_lines_pkg.set_ccid(
18147 p_code_combination_id => l_ccid
18148 , p_value_type_code => l_adr_value_type_code
18149 , p_transaction_coa_id => l_adr_transaction_coa_id
18153 , p_component_type => l_component_type
18150 , p_accounting_coa_id => l_adr_accounting_coa_id
18151 , p_adr_code => 'TRX_DIST_CCID'
18152 , p_adr_type_code => 'S'
18154 , p_component_code => l_component_code
18155 , p_component_type_code => l_component_type_code
18156 , p_component_appl_id => l_component_appl_id
18157 , p_amb_context_code => l_amb_context_code
18158 , p_side => 'NA'
18159 );
18160
18161
18162 --
18163 --
18164 END IF;
18165
18166 --
18167 -- Update the line information that should be overwritten
18168 --
18169 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
18170 p_header_num => 1);
18171 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
18172
18173 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
18174
18175 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
18176 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
18177 END IF;
18178
18179 --
18180 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
18181 --
18182 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
18183 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
18184 ELSE
18185 ---------------------------------------------------------------------------------------------------
18186 -- 4262811a Switch Sign
18187 ---------------------------------------------------------------------------------------------------
18188 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
18189 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18190 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18191 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18192 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18193 -- 5132302
18194 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
18195 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18196
18197 END IF;
18198
18199 -- 4955764
18200 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18201 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
18202
18203
18204 XLA_AE_LINES_PKG.ValidateCurrentLine;
18205 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18206
18207 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18208 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
18209 ,p_balance_type_code => l_balance_type_code);
18210
18211 END IF;
18212
18213 -----------------------------------------------------------------------------------------
18214 -- 4262811 Multiperiod Accounting
18215 -----------------------------------------------------------------------------------------
18216 -- No MPA option is assigned.
18217
18218
18219 END IF;
18220 END IF;
18221 --
18222
18223 --
18224 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18225 trace
18226 (p_msg => 'END of AcctLineType_46'
18227 ,p_level => C_LEVEL_PROCEDURE
18228 ,p_module => l_log_module);
18229 END IF;
18230 --
18231 EXCEPTION
18232 WHEN xla_exceptions_pkg.application_exception THEN
18233 RAISE;
18234 WHEN OTHERS THEN
18235 xla_exceptions_pkg.raise_message
18236 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_46');
18237 END AcctLineType_46;
18238 --
18239
18240 ---------------------------------------
18241 --
18242 -- PRIVATE FUNCTION
18243 -- AcctLineType_47
18244 --
18245 ---------------------------------------
18246 PROCEDURE AcctLineType_47 (
18247 p_application_id IN NUMBER
18248 ,p_event_id IN NUMBER
18249 ,p_calculate_acctd_flag IN VARCHAR2
18250 ,p_calculate_g_l_flag IN VARCHAR2
18251 ,p_actual_flag IN OUT VARCHAR2
18252 ,p_balance_type_code OUT VARCHAR2
18253 ,p_gain_or_loss_ref OUT VARCHAR2
18254
18255 --Transaction Distribution GL Account
18256 , p_source_14 IN NUMBER
18257 --Bill To Customer Account Identifier
18258 , p_source_25 IN NUMBER
18259 --Bill To Customer Site Use Identifier
18260 , p_source_26 IN NUMBER
18261 --SLA Party Type
18262 , p_source_27 IN VARCHAR2
18263 --Transaction Distribution Account Class
18264 , p_source_28 IN VARCHAR2
18265 --Transaction Distribution Identifier
18266 , p_source_29 IN NUMBER
18267 --Transaction Distribution Type
18268 , p_source_30 IN VARCHAR2
18269 --Transaction Distribution Entered Amount
18270 , p_source_31 IN NUMBER
18271 --Transaction Currency Code
18272 , p_source_32 IN VARCHAR2
18273 --Transaction Exchange Date
18274 , p_source_33 IN DATE
18275 --Transaction Exchange Rate
18276 , p_source_34 IN NUMBER
18277 --Transaction Exchange Rate Type
18278 , p_source_35 IN VARCHAR2
18282 , p_source_50 IN NUMBER
18279 --Transaction Accounting Amount
18280 , p_source_36 IN NUMBER
18281 --Transaction Tax Line Identifier
18283 )
18284 IS
18285
18286 l_component_type VARCHAR2(80);
18287 l_component_code VARCHAR2(30);
18288 l_component_type_code VARCHAR2(1);
18289 l_component_appl_id INTEGER;
18290 l_amb_context_code VARCHAR2(30);
18291 l_entity_code VARCHAR2(30);
18292 l_event_class_code VARCHAR2(30);
18293 l_ae_header_id NUMBER;
18294 l_event_type_code VARCHAR2(30);
18295 l_line_definition_code VARCHAR2(30);
18296 l_line_definition_owner_code VARCHAR2(1);
18297 --
18298 -- adr variables
18299 l_segment VARCHAR2(30);
18300 l_ccid NUMBER;
18301 l_adr_transaction_coa_id NUMBER;
18302 l_adr_accounting_coa_id NUMBER;
18303 l_adr_flexfield_segment_code VARCHAR2(30);
18304 l_adr_flex_value_set_id NUMBER;
18305 l_adr_value_type_code VARCHAR2(30);
18306 l_adr_value_combination_id NUMBER;
18307 l_adr_value_segment_code VARCHAR2(30);
18308
18309 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
18310 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
18311 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
18312 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
18313
18314 -- 4262811 Variables ------------------------------------------------------------------------------------------
18315 l_entered_amt_idx NUMBER;
18316 l_accted_amt_idx NUMBER;
18317 l_acc_rev_flag VARCHAR2(1);
18318 l_accrual_line_num NUMBER;
18319 l_tmp_amt NUMBER;
18320 l_acc_rev_natural_side_code VARCHAR2(1);
18321
18322 l_num_entries NUMBER;
18323 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
18324 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
18325 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
18326 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
18327 l_recog_line_1 NUMBER;
18328 l_recog_line_2 NUMBER;
18329
18330 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
18331 l_bflow_applied_to_amt NUMBER; -- 5132302
18332 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
18333
18334 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
18335
18336 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
18337 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
18338
18339 ---------------------------------------------------------------------------------------------------------------
18340
18341
18342 --
18343 -- bulk performance
18344 --
18345 l_balance_type_code VARCHAR2(1);
18346 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
18347 l_log_module VARCHAR2(240);
18348
18349 --
18350 -- Upgrade strategy
18351 --
18352 l_actual_upg_option VARCHAR2(1);
18353 l_enc_upg_option VARCHAR2(1);
18354
18355 --
18356 BEGIN
18357 --
18358 IF g_log_enabled THEN
18359 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_47';
18360 END IF;
18361 --
18362 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18363
18364 trace
18365 (p_msg => 'BEGIN of AcctLineType_47'
18366 ,p_level => C_LEVEL_PROCEDURE
18367 ,p_module => l_log_module);
18368
18369 END IF;
18370 --
18371 l_component_type := 'AMB_JLT';
18372 l_component_code := 'INV_FREIGHT';
18373 l_component_type_code := 'S';
18374 l_component_appl_id := 222;
18375 l_amb_context_code := 'DEFAULT';
18376 l_entity_code := 'TRANSACTIONS';
18377 l_event_class_code := 'INVOICE';
18378 l_event_type_code := 'INVOICE_ALL';
18379 l_line_definition_owner_code := 'S';
18380 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
18381 --
18382 l_balance_type_code := 'A';
18383 l_segment := NULL;
18384 l_ccid := NULL;
18385 l_adr_transaction_coa_id := NULL;
18386 l_adr_accounting_coa_id := NULL;
18387 l_adr_flexfield_segment_code := NULL;
18388 l_adr_flex_value_set_id := NULL;
18389 l_adr_value_type_code := NULL;
18390 l_adr_value_combination_id := NULL;
18391 l_adr_value_segment_code := NULL;
18392
18393 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
18394 l_bflow_class_code := 'FREIGHT'; -- 4219869 Business Flow
18395 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
18396 l_budgetary_control_flag := 'N';
18397
18398 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18399 l_bflow_applied_to_amt := NULL; -- 5132302
18400 l_entered_amt_idx := NULL; -- 4262811
18401 l_accted_amt_idx := NULL; -- 4262811
18402 l_acc_rev_flag := NULL; -- 4262811
18403 l_accrual_line_num := NULL; -- 4262811
18404 l_tmp_amt := NULL; -- 4262811
18405 --
18406
18407 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
18408 l_balance_type_code <> 'B' THEN
18409 IF NVL(p_source_28,'
18410 ') = 'FREIGHT'
18411 THEN
18412
18413 --
18414 XLA_AE_LINES_PKG.SetNewLine;
18418
18415
18416 p_balance_type_code := l_balance_type_code;
18417 -- set the flag so later we will know whether the gain loss line needs to be created
18419 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
18420 p_actual_flag :='A';
18421 END IF;
18422
18423 --
18424 -- bulk performance
18425 --
18426 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
18427 p_header_num => 0); -- 4262811
18428 --
18429 -- set accounting line options
18430 --
18431 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
18432 p_natural_side_code => 'C'
18433 , p_gain_or_loss_flag => 'N'
18434 , p_gl_transfer_mode_code => 'S'
18435 , p_acct_entry_type_code => 'A'
18436 , p_switch_side_flag => 'Y'
18437 , p_merge_duplicate_code => 'A'
18438 );
18439 --
18440 l_acc_rev_natural_side_code := 'D'; -- 4262811
18441 --
18442 --
18443 -- set accounting line type info
18444 --
18445 xla_ae_lines_pkg.SetAcctLineType
18446 (p_component_type => l_component_type
18447 ,p_event_type_code => l_event_type_code
18448 ,p_line_definition_owner_code => l_line_definition_owner_code
18449 ,p_line_definition_code => l_line_definition_code
18450 ,p_accounting_line_code => l_component_code
18451 ,p_accounting_line_type_code => l_component_type_code
18452 ,p_accounting_line_appl_id => l_component_appl_id
18453 ,p_amb_context_code => l_amb_context_code
18454 ,p_entity_code => l_entity_code
18455 ,p_event_class_code => l_event_class_code);
18456 --
18457 -- set accounting class
18458 --
18459 xla_ae_lines_pkg.SetAcctClass(
18460 p_accounting_class_code => 'FREIGHT'
18461 , p_ae_header_id => l_ae_header_id
18462 );
18463
18464 --
18465 -- set rounding class
18466 --
18467 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
18468 'RECEIVABLE';
18469
18470 --
18471 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
18472 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
18473 --
18474 -- bulk performance
18475 --
18476 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
18477
18478 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
18479 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
18480
18481 -- 4955764
18482 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18483 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
18484
18485 -- 4458381 Public Sector Enh
18486
18487 --
18488 -- set accounting attributes for the line type
18489 --
18490 l_entered_amt_idx := 3;
18491 l_accted_amt_idx := 8;
18492 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18493 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
18494 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
18495 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
18496 l_rec_acct_attrs.array_char_value(2) := p_source_30;
18497 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
18498 l_rec_acct_attrs.array_num_value(3) := p_source_31;
18499 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
18500 l_rec_acct_attrs.array_char_value(4) := p_source_32;
18501 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
18502 l_rec_acct_attrs.array_date_value(5) := p_source_33;
18503 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
18504 l_rec_acct_attrs.array_num_value(6) := p_source_34;
18505 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
18506 l_rec_acct_attrs.array_char_value(7) := p_source_35;
18507 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
18508 l_rec_acct_attrs.array_num_value(8) := p_source_36;
18509 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
18510 l_rec_acct_attrs.array_num_value(9) := p_source_25;
18511 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
18512 l_rec_acct_attrs.array_num_value(10) := p_source_26;
18513 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
18514 l_rec_acct_attrs.array_char_value(11) := p_source_27;
18515 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
18516 l_rec_acct_attrs.array_num_value(12) := p_source_50;
18517
18518 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
18519 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
18520
18521 ---------------------------------------------------------------------------------------------------------------
18522 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
18523 ---------------------------------------------------------------------------------------------------------------
18524 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
18525
18526 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18527 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18528
18529 IF xla_accounting_cache_pkg.GetValueChar
18533 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
18530 (p_source_code => 'LEDGER_CATEGORY_CODE'
18531 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
18532 AND l_bflow_method_code = 'PRIOR_ENTRY'
18534 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
18535 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
18536 )
18537 THEN
18538 xla_ae_lines_pkg.BflowUpgEntry
18539 (p_business_method_code => l_bflow_method_code
18540 ,p_business_class_code => l_bflow_class_code
18541 ,p_balance_type => l_balance_type_code);
18542 ELSE
18543 NULL;
18544 -- No business flow processing for business flow method of NONE.
18545 END IF;
18546
18547 --
18548 -- call analytical criteria
18549 --
18550
18551 --
18552 -- call description
18553 --
18554 -- No description or it is inherited.
18555 --
18556 -- call ADRs
18557 -- Bug 4922099
18558 --
18559 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18560 (NVL(l_actual_upg_option, 'N') = 'O') OR
18561 (NVL(l_enc_upg_option, 'N') = 'O')
18562 )
18563 THEN
18564 NULL;
18565 --
18566 --
18567
18568 l_ccid := AcctDerRule_18(
18569 p_application_id => p_application_id
18570 , p_ae_header_id => l_ae_header_id
18571 , p_source_14 => p_source_14
18572 , x_transaction_coa_id => l_adr_transaction_coa_id
18573 , x_accounting_coa_id => l_adr_accounting_coa_id
18574 , x_value_type_code => l_adr_value_type_code
18575 , p_side => 'NA'
18576 );
18577
18578 xla_ae_lines_pkg.set_ccid(
18579 p_code_combination_id => l_ccid
18580 , p_value_type_code => l_adr_value_type_code
18581 , p_transaction_coa_id => l_adr_transaction_coa_id
18582 , p_accounting_coa_id => l_adr_accounting_coa_id
18583 , p_adr_code => 'TRX_DIST_CCID'
18584 , p_adr_type_code => 'S'
18585 , p_component_type => l_component_type
18586 , p_component_code => l_component_code
18587 , p_component_type_code => l_component_type_code
18588 , p_component_appl_id => l_component_appl_id
18589 , p_amb_context_code => l_amb_context_code
18590 , p_side => 'NA'
18591 );
18592
18593
18594 --
18595 --
18596 END IF;
18597 --
18598 -- Bug 4922099
18599 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
18600 (NVL(l_enc_upg_option, 'N') = 'O')
18601 ) AND
18602 (l_bflow_method_code = 'PRIOR_ENTRY')
18603 )
18604 THEN
18605 IF
18606 --
18607 1 = 2
18608 --
18609 THEN
18610 xla_accounting_err_pkg.build_message
18611 (p_appli_s_name => 'XLA'
18612 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18613 ,p_token_1 => 'LINE_NUMBER'
18614 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
18615 ,p_token_2 => 'LINE_TYPE_NAME'
18616 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
18617 l_component_type
18618 ,l_component_code
18619 ,l_component_type_code
18620 ,l_component_appl_id
18621 ,l_amb_context_code
18622 ,l_entity_code
18623 ,l_event_class_code
18624 )
18625 ,p_token_3 => 'OWNER'
18626 ,p_value_3 => xla_lookups_pkg.get_meaning(
18627 p_lookup_type => 'XLA_OWNER_TYPE'
18628 ,p_lookup_code => l_component_type_code
18629 )
18630 ,p_token_4 => 'PRODUCT_NAME'
18631 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
18632 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
18633 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
18634 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
18635 ,p_ae_header_id => NULL
18636 );
18637
18638 IF (C_LEVEL_ERROR>= g_log_level) THEN
18639 trace
18640 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18641 ,p_level => C_LEVEL_ERROR
18642 ,p_module => l_log_module);
18643 END IF;
18644 END IF;
18645 END IF;
18646 --
18647 --
18651 -- Prior Entry. Currently, the following code is always generated.
18648 ------------------------------------------------------------------------------------------------
18649 -- 4219869 Business Flow
18650 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
18652 ------------------------------------------------------------------------------------------------
18653 XLA_AE_LINES_PKG.ValidateCurrentLine;
18654
18655 ------------------------------------------------------------------------------------
18656 -- 4219869 Business Flow
18657 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
18658 ------------------------------------------------------------------------------------
18659 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18660
18661 ----------------------------------------------------------------------------------
18662 -- 4219869 Business Flow
18663 -- Update journal entry status -- Need to generate this within IF <condition>
18664 ----------------------------------------------------------------------------------
18665 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18666 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
18667 ,p_balance_type_code => l_balance_type_code
18668 );
18669
18670 -------------------------------------------------------------------------------------------
18671 -- 4262811 - Generate the Accrual Reversal lines
18672 -------------------------------------------------------------------------------------------
18673 BEGIN
18674 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
18675 (g_array_event(p_event_id).array_value_num('header_index'));
18676 IF l_acc_rev_flag IS NULL THEN
18677 l_acc_rev_flag := 'N';
18678 END IF;
18679 EXCEPTION
18680 WHEN OTHERS THEN
18681 l_acc_rev_flag := 'N';
18682 END;
18683 --
18684 IF (l_acc_rev_flag = 'Y') THEN
18685
18686 -- 4645092 ------------------------------------------------------------------------------
18687 -- To allow MPA report to determine if it should generate report process
18688 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
18689 ------------------------------------------------------------------------------------------
18690
18691 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
18692 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
18693 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
18694 -- call ADRs
18695 -- Bug 4922099
18696 --
18697 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18698 (NVL(l_actual_upg_option, 'N') = 'O') OR
18699 (NVL(l_enc_upg_option, 'N') = 'O')
18700 )
18701 THEN
18702 NULL;
18703 --
18704 --
18705
18706 l_ccid := AcctDerRule_18(
18707 p_application_id => p_application_id
18708 , p_ae_header_id => l_ae_header_id
18709 , p_source_14 => p_source_14
18710 , x_transaction_coa_id => l_adr_transaction_coa_id
18711 , x_accounting_coa_id => l_adr_accounting_coa_id
18712 , x_value_type_code => l_adr_value_type_code
18713 , p_side => 'NA'
18714 );
18715
18716 xla_ae_lines_pkg.set_ccid(
18717 p_code_combination_id => l_ccid
18718 , p_value_type_code => l_adr_value_type_code
18719 , p_transaction_coa_id => l_adr_transaction_coa_id
18720 , p_accounting_coa_id => l_adr_accounting_coa_id
18721 , p_adr_code => 'TRX_DIST_CCID'
18722 , p_adr_type_code => 'S'
18723 , p_component_type => l_component_type
18724 , p_component_code => l_component_code
18725 , p_component_type_code => l_component_type_code
18726 , p_component_appl_id => l_component_appl_id
18727 , p_amb_context_code => l_amb_context_code
18728 , p_side => 'NA'
18729 );
18730
18731
18732 --
18733 --
18734 END IF;
18735
18736 --
18737 -- Update the line information that should be overwritten
18738 --
18739 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
18740 p_header_num => 1);
18741 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
18742
18743 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
18744
18745 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
18746 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
18747 END IF;
18748
18749 --
18750 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
18751 --
18752 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
18753 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
18754 ELSE
18755 ---------------------------------------------------------------------------------------------------
18756 -- 4262811a Switch Sign
18757 ---------------------------------------------------------------------------------------------------
18758 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
18759 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18760 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18761 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18762 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18763 -- 5132302
18764 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
18765 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18766
18767 END IF;
18768
18769 -- 4955764
18770 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18771 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
18772
18773
18774 XLA_AE_LINES_PKG.ValidateCurrentLine;
18775 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18776
18777 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18778 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
18779 ,p_balance_type_code => l_balance_type_code);
18780
18781 END IF;
18782
18783 -----------------------------------------------------------------------------------------
18784 -- 4262811 Multiperiod Accounting
18785 -----------------------------------------------------------------------------------------
18786 -- No MPA option is assigned.
18787
18788
18789 END IF;
18790 END IF;
18791 --
18792
18793 --
18794 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18795 trace
18796 (p_msg => 'END of AcctLineType_47'
18797 ,p_level => C_LEVEL_PROCEDURE
18798 ,p_module => l_log_module);
18799 END IF;
18800 --
18801 EXCEPTION
18802 WHEN xla_exceptions_pkg.application_exception THEN
18803 RAISE;
18804 WHEN OTHERS THEN
18805 xla_exceptions_pkg.raise_message
18806 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_47');
18807 END AcctLineType_47;
18808 --
18809
18810 ---------------------------------------
18811 --
18812 -- PRIVATE FUNCTION
18813 -- AcctLineType_48
18814 --
18815 ---------------------------------------
18816 PROCEDURE AcctLineType_48 (
18817 p_application_id IN NUMBER
18818 ,p_event_id IN NUMBER
18819 ,p_calculate_acctd_flag IN VARCHAR2
18820 ,p_calculate_g_l_flag IN VARCHAR2
18821 ,p_actual_flag IN OUT VARCHAR2
18822 ,p_balance_type_code OUT VARCHAR2
18823 ,p_gain_or_loss_ref OUT VARCHAR2
18824
18825 --Transaction Distribution GL Account
18826 , p_source_14 IN NUMBER
18827 --Bill To Customer Account Identifier
18828 , p_source_25 IN NUMBER
18829 --Bill To Customer Site Use Identifier
18830 , p_source_26 IN NUMBER
18831 --SLA Party Type
18832 , p_source_27 IN VARCHAR2
18833 --Transaction Distribution Account Class
18834 , p_source_28 IN VARCHAR2
18835 --Transaction Distribution Identifier
18836 , p_source_29 IN NUMBER
18837 --Transaction Distribution Type
18838 , p_source_30 IN VARCHAR2
18839 --Transaction Distribution Entered Amount
18840 , p_source_31 IN NUMBER
18841 --Transaction Currency Code
18842 , p_source_32 IN VARCHAR2
18843 --Transaction Exchange Date
18844 , p_source_33 IN DATE
18845 --Transaction Exchange Rate
18846 , p_source_34 IN NUMBER
18847 --Transaction Exchange Rate Type
18848 , p_source_35 IN VARCHAR2
18849 --Transaction Accounting Amount
18850 , p_source_36 IN NUMBER
18851 --Transaction Tax Line Identifier
18852 , p_source_50 IN NUMBER
18853 --Rounding Correction Flag
18854 , p_source_51 IN VARCHAR2
18855 )
18856 IS
18857
18858 l_component_type VARCHAR2(80);
18859 l_component_code VARCHAR2(30);
18860 l_component_type_code VARCHAR2(1);
18861 l_component_appl_id INTEGER;
18862 l_amb_context_code VARCHAR2(30);
18863 l_entity_code VARCHAR2(30);
18864 l_event_class_code VARCHAR2(30);
18865 l_ae_header_id NUMBER;
18866 l_event_type_code VARCHAR2(30);
18867 l_line_definition_code VARCHAR2(30);
18868 l_line_definition_owner_code VARCHAR2(1);
18869 --
18870 -- adr variables
18871 l_segment VARCHAR2(30);
18872 l_ccid NUMBER;
18873 l_adr_transaction_coa_id NUMBER;
18874 l_adr_accounting_coa_id NUMBER;
18875 l_adr_flexfield_segment_code VARCHAR2(30);
18879 l_adr_value_segment_code VARCHAR2(30);
18876 l_adr_flex_value_set_id NUMBER;
18877 l_adr_value_type_code VARCHAR2(30);
18878 l_adr_value_combination_id NUMBER;
18880
18881 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
18882 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
18883 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
18884 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
18885
18886 -- 4262811 Variables ------------------------------------------------------------------------------------------
18887 l_entered_amt_idx NUMBER;
18888 l_accted_amt_idx NUMBER;
18889 l_acc_rev_flag VARCHAR2(1);
18890 l_accrual_line_num NUMBER;
18891 l_tmp_amt NUMBER;
18892 l_acc_rev_natural_side_code VARCHAR2(1);
18893
18894 l_num_entries NUMBER;
18895 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
18896 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
18897 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
18898 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
18899 l_recog_line_1 NUMBER;
18900 l_recog_line_2 NUMBER;
18901
18902 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
18903 l_bflow_applied_to_amt NUMBER; -- 5132302
18904 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
18905
18906 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
18907
18908 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
18909 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
18910
18911 ---------------------------------------------------------------------------------------------------------------
18912
18913
18914 --
18915 -- bulk performance
18916 --
18917 l_balance_type_code VARCHAR2(1);
18918 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
18919 l_log_module VARCHAR2(240);
18920
18921 --
18922 -- Upgrade strategy
18923 --
18924 l_actual_upg_option VARCHAR2(1);
18925 l_enc_upg_option VARCHAR2(1);
18926
18927 --
18928 BEGIN
18929 --
18930 IF g_log_enabled THEN
18931 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_48';
18932 END IF;
18933 --
18934 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18935
18936 trace
18937 (p_msg => 'BEGIN of AcctLineType_48'
18938 ,p_level => C_LEVEL_PROCEDURE
18939 ,p_module => l_log_module);
18940
18941 END IF;
18942 --
18943 l_component_type := 'AMB_JLT';
18944 l_component_code := 'INV_REV';
18945 l_component_type_code := 'S';
18946 l_component_appl_id := 222;
18947 l_amb_context_code := 'DEFAULT';
18948 l_entity_code := 'TRANSACTIONS';
18949 l_event_class_code := 'INVOICE';
18950 l_event_type_code := 'INVOICE_ALL';
18951 l_line_definition_owner_code := 'S';
18952 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
18953 --
18954 l_balance_type_code := 'A';
18955 l_segment := NULL;
18956 l_ccid := NULL;
18957 l_adr_transaction_coa_id := NULL;
18958 l_adr_accounting_coa_id := NULL;
18959 l_adr_flexfield_segment_code := NULL;
18960 l_adr_flex_value_set_id := NULL;
18961 l_adr_value_type_code := NULL;
18962 l_adr_value_combination_id := NULL;
18963 l_adr_value_segment_code := NULL;
18964
18965 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
18966 l_bflow_class_code := 'REVENUE'; -- 4219869 Business Flow
18967 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
18968 l_budgetary_control_flag := 'N';
18969
18970 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18971 l_bflow_applied_to_amt := NULL; -- 5132302
18972 l_entered_amt_idx := NULL; -- 4262811
18973 l_accted_amt_idx := NULL; -- 4262811
18974 l_acc_rev_flag := NULL; -- 4262811
18975 l_accrual_line_num := NULL; -- 4262811
18976 l_tmp_amt := NULL; -- 4262811
18977 --
18978
18979 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
18980 l_balance_type_code <> 'B' THEN
18981 IF NVL(p_source_28,'
18982 ') = 'REV' AND
18983 p_source_51 IS NULL
18984 THEN
18985
18986 --
18987 XLA_AE_LINES_PKG.SetNewLine;
18988
18989 p_balance_type_code := l_balance_type_code;
18990 -- set the flag so later we will know whether the gain loss line needs to be created
18991
18992 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
18993 p_actual_flag :='A';
18994 END IF;
18995
18996 --
18997 -- bulk performance
18998 --
18999 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
19000 p_header_num => 0); -- 4262811
19001 --
19002 -- set accounting line options
19003 --
19004 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
19005 p_natural_side_code => 'C'
19006 , p_gain_or_loss_flag => 'N'
19007 , p_gl_transfer_mode_code => 'S'
19008 , p_acct_entry_type_code => 'A'
19012 --
19009 , p_switch_side_flag => 'Y'
19010 , p_merge_duplicate_code => 'A'
19011 );
19013 l_acc_rev_natural_side_code := 'D'; -- 4262811
19014 --
19015 --
19016 -- set accounting line type info
19017 --
19018 xla_ae_lines_pkg.SetAcctLineType
19019 (p_component_type => l_component_type
19020 ,p_event_type_code => l_event_type_code
19021 ,p_line_definition_owner_code => l_line_definition_owner_code
19022 ,p_line_definition_code => l_line_definition_code
19023 ,p_accounting_line_code => l_component_code
19024 ,p_accounting_line_type_code => l_component_type_code
19025 ,p_accounting_line_appl_id => l_component_appl_id
19026 ,p_amb_context_code => l_amb_context_code
19027 ,p_entity_code => l_entity_code
19028 ,p_event_class_code => l_event_class_code);
19029 --
19030 -- set accounting class
19031 --
19032 xla_ae_lines_pkg.SetAcctClass(
19033 p_accounting_class_code => 'REVENUE'
19034 , p_ae_header_id => l_ae_header_id
19035 );
19036
19037 --
19038 -- set rounding class
19039 --
19040 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
19041 'RECEIVABLE';
19042
19043 --
19044 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
19045 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
19046 --
19047 -- bulk performance
19048 --
19049 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
19050
19051 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
19052 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
19053
19054 -- 4955764
19055 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19056 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
19057
19058 -- 4458381 Public Sector Enh
19059
19060 --
19061 -- set accounting attributes for the line type
19062 --
19063 l_entered_amt_idx := 3;
19064 l_accted_amt_idx := 8;
19065 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19066 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
19067 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
19068 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
19069 l_rec_acct_attrs.array_char_value(2) := p_source_30;
19070 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
19071 l_rec_acct_attrs.array_num_value(3) := p_source_31;
19072 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
19073 l_rec_acct_attrs.array_char_value(4) := p_source_32;
19074 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
19075 l_rec_acct_attrs.array_date_value(5) := p_source_33;
19076 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
19077 l_rec_acct_attrs.array_num_value(6) := p_source_34;
19078 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
19079 l_rec_acct_attrs.array_char_value(7) := p_source_35;
19080 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
19081 l_rec_acct_attrs.array_num_value(8) := p_source_36;
19082 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
19083 l_rec_acct_attrs.array_num_value(9) := p_source_25;
19084 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
19085 l_rec_acct_attrs.array_num_value(10) := p_source_26;
19086 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
19087 l_rec_acct_attrs.array_char_value(11) := p_source_27;
19088 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
19089 l_rec_acct_attrs.array_num_value(12) := p_source_50;
19090
19091 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
19092 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
19093
19094 ---------------------------------------------------------------------------------------------------------------
19095 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
19096 ---------------------------------------------------------------------------------------------------------------
19097 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
19098
19099 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19100 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19101
19102 IF xla_accounting_cache_pkg.GetValueChar
19103 (p_source_code => 'LEDGER_CATEGORY_CODE'
19104 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
19105 AND l_bflow_method_code = 'PRIOR_ENTRY'
19106 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
19107 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
19108 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
19109 )
19110 THEN
19111 xla_ae_lines_pkg.BflowUpgEntry
19112 (p_business_method_code => l_bflow_method_code
19113 ,p_business_class_code => l_bflow_class_code
19114 ,p_balance_type => l_balance_type_code);
19115 ELSE
19116 NULL;
19117 -- No business flow processing for business flow method of NONE.
19118 END IF;
19122 --
19119
19120 --
19121 -- call analytical criteria
19123
19124 --
19125 -- call description
19126 --
19127 -- No description or it is inherited.
19128 --
19129 -- call ADRs
19130 -- Bug 4922099
19131 --
19132 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19133 (NVL(l_actual_upg_option, 'N') = 'O') OR
19134 (NVL(l_enc_upg_option, 'N') = 'O')
19135 )
19136 THEN
19137 NULL;
19138 --
19139 --
19140
19141 l_ccid := AcctDerRule_18(
19142 p_application_id => p_application_id
19143 , p_ae_header_id => l_ae_header_id
19144 , p_source_14 => p_source_14
19145 , x_transaction_coa_id => l_adr_transaction_coa_id
19146 , x_accounting_coa_id => l_adr_accounting_coa_id
19147 , x_value_type_code => l_adr_value_type_code
19148 , p_side => 'NA'
19149 );
19150
19151 xla_ae_lines_pkg.set_ccid(
19152 p_code_combination_id => l_ccid
19153 , p_value_type_code => l_adr_value_type_code
19154 , p_transaction_coa_id => l_adr_transaction_coa_id
19155 , p_accounting_coa_id => l_adr_accounting_coa_id
19156 , p_adr_code => 'TRX_DIST_CCID'
19157 , p_adr_type_code => 'S'
19158 , p_component_type => l_component_type
19159 , p_component_code => l_component_code
19160 , p_component_type_code => l_component_type_code
19161 , p_component_appl_id => l_component_appl_id
19162 , p_amb_context_code => l_amb_context_code
19163 , p_side => 'NA'
19164 );
19165
19166
19167 --
19168 --
19169 END IF;
19170 --
19171 -- Bug 4922099
19172 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
19173 (NVL(l_enc_upg_option, 'N') = 'O')
19174 ) AND
19175 (l_bflow_method_code = 'PRIOR_ENTRY')
19176 )
19177 THEN
19178 IF
19179 --
19180 1 = 2
19181 --
19182 THEN
19183 xla_accounting_err_pkg.build_message
19184 (p_appli_s_name => 'XLA'
19185 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19186 ,p_token_1 => 'LINE_NUMBER'
19187 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
19188 ,p_token_2 => 'LINE_TYPE_NAME'
19189 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
19190 l_component_type
19191 ,l_component_code
19192 ,l_component_type_code
19193 ,l_component_appl_id
19194 ,l_amb_context_code
19195 ,l_entity_code
19196 ,l_event_class_code
19197 )
19198 ,p_token_3 => 'OWNER'
19199 ,p_value_3 => xla_lookups_pkg.get_meaning(
19200 p_lookup_type => 'XLA_OWNER_TYPE'
19201 ,p_lookup_code => l_component_type_code
19202 )
19203 ,p_token_4 => 'PRODUCT_NAME'
19204 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
19205 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
19206 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
19207 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
19208 ,p_ae_header_id => NULL
19209 );
19210
19211 IF (C_LEVEL_ERROR>= g_log_level) THEN
19212 trace
19213 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19214 ,p_level => C_LEVEL_ERROR
19215 ,p_module => l_log_module);
19216 END IF;
19217 END IF;
19218 END IF;
19219 --
19220 --
19221 ------------------------------------------------------------------------------------------------
19222 -- 4219869 Business Flow
19223 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
19224 -- Prior Entry. Currently, the following code is always generated.
19225 ------------------------------------------------------------------------------------------------
19226 XLA_AE_LINES_PKG.ValidateCurrentLine;
19227
19228 ------------------------------------------------------------------------------------
19229 -- 4219869 Business Flow
19230 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
19234 ----------------------------------------------------------------------------------
19231 ------------------------------------------------------------------------------------
19232 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19233
19235 -- 4219869 Business Flow
19236 -- Update journal entry status -- Need to generate this within IF <condition>
19237 ----------------------------------------------------------------------------------
19238 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19239 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
19240 ,p_balance_type_code => l_balance_type_code
19241 );
19242
19243 -------------------------------------------------------------------------------------------
19244 -- 4262811 - Generate the Accrual Reversal lines
19245 -------------------------------------------------------------------------------------------
19246 BEGIN
19247 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
19248 (g_array_event(p_event_id).array_value_num('header_index'));
19249 IF l_acc_rev_flag IS NULL THEN
19250 l_acc_rev_flag := 'N';
19251 END IF;
19252 EXCEPTION
19253 WHEN OTHERS THEN
19254 l_acc_rev_flag := 'N';
19255 END;
19256 --
19257 IF (l_acc_rev_flag = 'Y') THEN
19258
19259 -- 4645092 ------------------------------------------------------------------------------
19260 -- To allow MPA report to determine if it should generate report process
19261 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
19262 ------------------------------------------------------------------------------------------
19263
19264 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
19265 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
19266 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
19267 -- call ADRs
19268 -- Bug 4922099
19269 --
19270 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19271 (NVL(l_actual_upg_option, 'N') = 'O') OR
19272 (NVL(l_enc_upg_option, 'N') = 'O')
19273 )
19274 THEN
19275 NULL;
19276 --
19277 --
19278
19279 l_ccid := AcctDerRule_18(
19280 p_application_id => p_application_id
19281 , p_ae_header_id => l_ae_header_id
19282 , p_source_14 => p_source_14
19283 , x_transaction_coa_id => l_adr_transaction_coa_id
19284 , x_accounting_coa_id => l_adr_accounting_coa_id
19285 , x_value_type_code => l_adr_value_type_code
19286 , p_side => 'NA'
19287 );
19288
19289 xla_ae_lines_pkg.set_ccid(
19290 p_code_combination_id => l_ccid
19291 , p_value_type_code => l_adr_value_type_code
19292 , p_transaction_coa_id => l_adr_transaction_coa_id
19293 , p_accounting_coa_id => l_adr_accounting_coa_id
19294 , p_adr_code => 'TRX_DIST_CCID'
19295 , p_adr_type_code => 'S'
19296 , p_component_type => l_component_type
19297 , p_component_code => l_component_code
19298 , p_component_type_code => l_component_type_code
19299 , p_component_appl_id => l_component_appl_id
19300 , p_amb_context_code => l_amb_context_code
19301 , p_side => 'NA'
19302 );
19303
19304
19305 --
19306 --
19307 END IF;
19308
19309 --
19310 -- Update the line information that should be overwritten
19311 --
19312 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
19313 p_header_num => 1);
19314 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
19315
19316 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
19317
19318 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
19319 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
19320 END IF;
19321
19322 --
19323 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
19324 --
19325 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
19326 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
19327 ELSE
19328 ---------------------------------------------------------------------------------------------------
19329 -- 4262811a Switch Sign
19330 ---------------------------------------------------------------------------------------------------
19331 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
19332 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19333 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19334 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19335 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19336 -- 5132302
19337 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
19338 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19339
19340 END IF;
19341
19342 -- 4955764
19343 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19347 XLA_AE_LINES_PKG.ValidateCurrentLine;
19344 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
19345
19346
19348 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19349
19350 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19351 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
19352 ,p_balance_type_code => l_balance_type_code);
19353
19354 END IF;
19355
19356 -----------------------------------------------------------------------------------------
19357 -- 4262811 Multiperiod Accounting
19358 -----------------------------------------------------------------------------------------
19359 -- No MPA option is assigned.
19360
19361
19362 END IF;
19363 END IF;
19364 --
19365
19366 --
19367 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19368 trace
19369 (p_msg => 'END of AcctLineType_48'
19370 ,p_level => C_LEVEL_PROCEDURE
19371 ,p_module => l_log_module);
19372 END IF;
19373 --
19374 EXCEPTION
19375 WHEN xla_exceptions_pkg.application_exception THEN
19376 RAISE;
19377 WHEN OTHERS THEN
19378 xla_exceptions_pkg.raise_message
19379 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_48');
19380 END AcctLineType_48;
19381 --
19382
19383 ---------------------------------------
19384 --
19385 -- PRIVATE FUNCTION
19386 -- AcctLineType_49
19387 --
19388 ---------------------------------------
19389 PROCEDURE AcctLineType_49 (
19390 p_application_id IN NUMBER
19391 ,p_event_id IN NUMBER
19392 ,p_calculate_acctd_flag IN VARCHAR2
19393 ,p_calculate_g_l_flag IN VARCHAR2
19394 ,p_actual_flag IN OUT VARCHAR2
19395 ,p_balance_type_code OUT VARCHAR2
19396 ,p_gain_or_loss_ref OUT VARCHAR2
19397
19398 --Transaction Distribution GL Account
19399 , p_source_14 IN NUMBER
19400 --Bill To Customer Account Identifier
19401 , p_source_25 IN NUMBER
19402 --Bill To Customer Site Use Identifier
19403 , p_source_26 IN NUMBER
19404 --SLA Party Type
19405 , p_source_27 IN VARCHAR2
19406 --Transaction Distribution Account Class
19407 , p_source_28 IN VARCHAR2
19408 --Transaction Distribution Identifier
19409 , p_source_29 IN NUMBER
19410 --Transaction Distribution Type
19411 , p_source_30 IN VARCHAR2
19412 --Transaction Distribution Entered Amount
19413 , p_source_31 IN NUMBER
19414 --Transaction Currency Code
19415 , p_source_32 IN VARCHAR2
19416 --Transaction Exchange Date
19417 , p_source_33 IN DATE
19418 --Transaction Exchange Rate
19419 , p_source_34 IN NUMBER
19420 --Transaction Exchange Rate Type
19421 , p_source_35 IN VARCHAR2
19422 --Transaction Accounting Amount
19423 , p_source_36 IN NUMBER
19424 --Transaction Tax Line Identifier
19425 , p_source_50 IN NUMBER
19426 )
19427 IS
19428
19429 l_component_type VARCHAR2(80);
19430 l_component_code VARCHAR2(30);
19431 l_component_type_code VARCHAR2(1);
19432 l_component_appl_id INTEGER;
19433 l_amb_context_code VARCHAR2(30);
19434 l_entity_code VARCHAR2(30);
19435 l_event_class_code VARCHAR2(30);
19436 l_ae_header_id NUMBER;
19437 l_event_type_code VARCHAR2(30);
19438 l_line_definition_code VARCHAR2(30);
19439 l_line_definition_owner_code VARCHAR2(1);
19440 --
19441 -- adr variables
19442 l_segment VARCHAR2(30);
19443 l_ccid NUMBER;
19444 l_adr_transaction_coa_id NUMBER;
19445 l_adr_accounting_coa_id NUMBER;
19446 l_adr_flexfield_segment_code VARCHAR2(30);
19447 l_adr_flex_value_set_id NUMBER;
19448 l_adr_value_type_code VARCHAR2(30);
19449 l_adr_value_combination_id NUMBER;
19450 l_adr_value_segment_code VARCHAR2(30);
19451
19452 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
19453 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
19454 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
19455 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
19456
19457 -- 4262811 Variables ------------------------------------------------------------------------------------------
19458 l_entered_amt_idx NUMBER;
19459 l_accted_amt_idx NUMBER;
19460 l_acc_rev_flag VARCHAR2(1);
19461 l_accrual_line_num NUMBER;
19462 l_tmp_amt NUMBER;
19463 l_acc_rev_natural_side_code VARCHAR2(1);
19464
19465 l_num_entries NUMBER;
19466 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
19467 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
19468 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
19469 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
19470 l_recog_line_1 NUMBER;
19471 l_recog_line_2 NUMBER;
19472
19473 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
19474 l_bflow_applied_to_amt NUMBER; -- 5132302
19475 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
19476
19480 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
19477 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
19478
19479 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
19481
19482 ---------------------------------------------------------------------------------------------------------------
19483
19484
19485 --
19486 -- bulk performance
19487 --
19488 l_balance_type_code VARCHAR2(1);
19489 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
19490 l_log_module VARCHAR2(240);
19491
19492 --
19493 -- Upgrade strategy
19494 --
19495 l_actual_upg_option VARCHAR2(1);
19496 l_enc_upg_option VARCHAR2(1);
19497
19498 --
19499 BEGIN
19500 --
19501 IF g_log_enabled THEN
19502 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_49';
19503 END IF;
19504 --
19505 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19506
19507 trace
19508 (p_msg => 'BEGIN of AcctLineType_49'
19509 ,p_level => C_LEVEL_PROCEDURE
19510 ,p_module => l_log_module);
19511
19512 END IF;
19513 --
19514 l_component_type := 'AMB_JLT';
19515 l_component_code := 'INV_ROUND';
19516 l_component_type_code := 'S';
19517 l_component_appl_id := 222;
19518 l_amb_context_code := 'DEFAULT';
19519 l_entity_code := 'TRANSACTIONS';
19520 l_event_class_code := 'INVOICE';
19521 l_event_type_code := 'INVOICE_ALL';
19522 l_line_definition_owner_code := 'S';
19523 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
19524 --
19525 l_balance_type_code := 'A';
19526 l_segment := NULL;
19527 l_ccid := NULL;
19528 l_adr_transaction_coa_id := NULL;
19529 l_adr_accounting_coa_id := NULL;
19530 l_adr_flexfield_segment_code := NULL;
19531 l_adr_flex_value_set_id := NULL;
19532 l_adr_value_type_code := NULL;
19533 l_adr_value_combination_id := NULL;
19534 l_adr_value_segment_code := NULL;
19535
19536 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
19537 l_bflow_class_code := ''; -- 4219869 Business Flow
19538 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
19539 l_budgetary_control_flag := 'N';
19540
19541 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19542 l_bflow_applied_to_amt := NULL; -- 5132302
19543 l_entered_amt_idx := NULL; -- 4262811
19544 l_accted_amt_idx := NULL; -- 4262811
19545 l_acc_rev_flag := NULL; -- 4262811
19546 l_accrual_line_num := NULL; -- 4262811
19547 l_tmp_amt := NULL; -- 4262811
19548 --
19549
19550 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
19551 l_balance_type_code <> 'B' THEN
19552 IF NVL(p_source_28,'
19553 ') = 'ROUND'
19554 THEN
19555
19556 --
19557 XLA_AE_LINES_PKG.SetNewLine;
19558
19559 p_balance_type_code := l_balance_type_code;
19560 -- set the flag so later we will know whether the gain loss line needs to be created
19561
19562 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
19563 p_actual_flag :='A';
19564 END IF;
19565
19566 --
19567 -- bulk performance
19568 --
19569 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
19570 p_header_num => 0); -- 4262811
19571 --
19572 -- set accounting line options
19573 --
19574 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
19575 p_natural_side_code => 'C'
19576 , p_gain_or_loss_flag => 'N'
19577 , p_gl_transfer_mode_code => 'S'
19578 , p_acct_entry_type_code => 'A'
19579 , p_switch_side_flag => 'Y'
19580 , p_merge_duplicate_code => 'A'
19581 );
19582 --
19583 l_acc_rev_natural_side_code := 'D'; -- 4262811
19584 --
19585 --
19586 -- set accounting line type info
19587 --
19588 xla_ae_lines_pkg.SetAcctLineType
19589 (p_component_type => l_component_type
19590 ,p_event_type_code => l_event_type_code
19591 ,p_line_definition_owner_code => l_line_definition_owner_code
19592 ,p_line_definition_code => l_line_definition_code
19593 ,p_accounting_line_code => l_component_code
19594 ,p_accounting_line_type_code => l_component_type_code
19595 ,p_accounting_line_appl_id => l_component_appl_id
19596 ,p_amb_context_code => l_amb_context_code
19597 ,p_entity_code => l_entity_code
19598 ,p_event_class_code => l_event_class_code);
19599 --
19600 -- set accounting class
19601 --
19602 xla_ae_lines_pkg.SetAcctClass(
19603 p_accounting_class_code => 'ROUNDING'
19604 , p_ae_header_id => l_ae_header_id
19605 );
19606
19607 --
19608 -- set rounding class
19609 --
19610 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
19611 'RECEIVABLE';
19612
19613 --
19614 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
19615 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
19616 --
19617 -- bulk performance
19618 --
19619 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
19620
19621 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
19622 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
19623
19624 -- 4955764
19625 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19626 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
19627
19628 -- 4458381 Public Sector Enh
19629
19630 --
19631 -- set accounting attributes for the line type
19632 --
19633 l_entered_amt_idx := 3;
19634 l_accted_amt_idx := 8;
19635 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19636 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
19637 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
19638 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
19639 l_rec_acct_attrs.array_char_value(2) := p_source_30;
19640 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
19641 l_rec_acct_attrs.array_num_value(3) := p_source_31;
19642 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
19643 l_rec_acct_attrs.array_char_value(4) := p_source_32;
19644 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
19645 l_rec_acct_attrs.array_date_value(5) := p_source_33;
19646 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
19647 l_rec_acct_attrs.array_num_value(6) := p_source_34;
19648 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
19649 l_rec_acct_attrs.array_char_value(7) := p_source_35;
19650 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
19651 l_rec_acct_attrs.array_num_value(8) := p_source_36;
19652 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
19653 l_rec_acct_attrs.array_num_value(9) := p_source_25;
19654 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
19655 l_rec_acct_attrs.array_num_value(10) := p_source_26;
19656 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
19657 l_rec_acct_attrs.array_char_value(11) := p_source_27;
19658 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
19659 l_rec_acct_attrs.array_num_value(12) := p_source_50;
19660
19661 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
19662 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
19663
19664 ---------------------------------------------------------------------------------------------------------------
19665 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
19666 ---------------------------------------------------------------------------------------------------------------
19667 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
19668
19669 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19670 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19671
19672 IF xla_accounting_cache_pkg.GetValueChar
19673 (p_source_code => 'LEDGER_CATEGORY_CODE'
19677 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
19674 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
19675 AND l_bflow_method_code = 'PRIOR_ENTRY'
19676 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
19678 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
19679 )
19680 THEN
19681 xla_ae_lines_pkg.BflowUpgEntry
19682 (p_business_method_code => l_bflow_method_code
19683 ,p_business_class_code => l_bflow_class_code
19684 ,p_balance_type => l_balance_type_code);
19685 ELSE
19686 NULL;
19687 -- No business flow processing for business flow method of NONE.
19688 END IF;
19689
19690 --
19691 -- call analytical criteria
19692 --
19693
19694 --
19695 -- call description
19696 --
19697 -- No description or it is inherited.
19698 --
19699 -- call ADRs
19700 -- Bug 4922099
19701 --
19702 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19703 (NVL(l_actual_upg_option, 'N') = 'O') OR
19704 (NVL(l_enc_upg_option, 'N') = 'O')
19705 )
19706 THEN
19707 NULL;
19708 --
19709 --
19710
19711 l_ccid := AcctDerRule_18(
19712 p_application_id => p_application_id
19713 , p_ae_header_id => l_ae_header_id
19714 , p_source_14 => p_source_14
19715 , x_transaction_coa_id => l_adr_transaction_coa_id
19716 , x_accounting_coa_id => l_adr_accounting_coa_id
19717 , x_value_type_code => l_adr_value_type_code
19718 , p_side => 'NA'
19719 );
19720
19721 xla_ae_lines_pkg.set_ccid(
19722 p_code_combination_id => l_ccid
19723 , p_value_type_code => l_adr_value_type_code
19724 , p_transaction_coa_id => l_adr_transaction_coa_id
19725 , p_accounting_coa_id => l_adr_accounting_coa_id
19726 , p_adr_code => 'TRX_DIST_CCID'
19727 , p_adr_type_code => 'S'
19728 , p_component_type => l_component_type
19729 , p_component_code => l_component_code
19730 , p_component_type_code => l_component_type_code
19731 , p_component_appl_id => l_component_appl_id
19732 , p_amb_context_code => l_amb_context_code
19733 , p_side => 'NA'
19734 );
19735
19736
19737 --
19738 --
19739 END IF;
19740 --
19741 -- Bug 4922099
19742 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
19743 (NVL(l_enc_upg_option, 'N') = 'O')
19744 ) AND
19745 (l_bflow_method_code = 'PRIOR_ENTRY')
19746 )
19747 THEN
19748 IF
19749 --
19750 1 = 2
19751 --
19752 THEN
19753 xla_accounting_err_pkg.build_message
19754 (p_appli_s_name => 'XLA'
19755 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19756 ,p_token_1 => 'LINE_NUMBER'
19757 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
19758 ,p_token_2 => 'LINE_TYPE_NAME'
19759 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
19760 l_component_type
19761 ,l_component_code
19762 ,l_component_type_code
19763 ,l_component_appl_id
19764 ,l_amb_context_code
19765 ,l_entity_code
19766 ,l_event_class_code
19767 )
19768 ,p_token_3 => 'OWNER'
19769 ,p_value_3 => xla_lookups_pkg.get_meaning(
19770 p_lookup_type => 'XLA_OWNER_TYPE'
19771 ,p_lookup_code => l_component_type_code
19772 )
19773 ,p_token_4 => 'PRODUCT_NAME'
19774 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
19775 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
19776 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
19777 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
19778 ,p_ae_header_id => NULL
19779 );
19780
19781 IF (C_LEVEL_ERROR>= g_log_level) THEN
19782 trace
19783 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19784 ,p_level => C_LEVEL_ERROR
19788 END IF;
19785 ,p_module => l_log_module);
19786 END IF;
19787 END IF;
19789 --
19790 --
19791 ------------------------------------------------------------------------------------------------
19792 -- 4219869 Business Flow
19793 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
19794 -- Prior Entry. Currently, the following code is always generated.
19795 ------------------------------------------------------------------------------------------------
19796 XLA_AE_LINES_PKG.ValidateCurrentLine;
19797
19798 ------------------------------------------------------------------------------------
19799 -- 4219869 Business Flow
19800 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
19801 ------------------------------------------------------------------------------------
19802 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19803
19804 ----------------------------------------------------------------------------------
19805 -- 4219869 Business Flow
19806 -- Update journal entry status -- Need to generate this within IF <condition>
19807 ----------------------------------------------------------------------------------
19808 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19809 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
19810 ,p_balance_type_code => l_balance_type_code
19811 );
19812
19813 -------------------------------------------------------------------------------------------
19814 -- 4262811 - Generate the Accrual Reversal lines
19815 -------------------------------------------------------------------------------------------
19816 BEGIN
19817 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
19818 (g_array_event(p_event_id).array_value_num('header_index'));
19819 IF l_acc_rev_flag IS NULL THEN
19820 l_acc_rev_flag := 'N';
19821 END IF;
19822 EXCEPTION
19823 WHEN OTHERS THEN
19824 l_acc_rev_flag := 'N';
19825 END;
19826 --
19827 IF (l_acc_rev_flag = 'Y') THEN
19828
19829 -- 4645092 ------------------------------------------------------------------------------
19830 -- To allow MPA report to determine if it should generate report process
19831 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
19832 ------------------------------------------------------------------------------------------
19833
19834 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
19835 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
19836 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
19837 -- call ADRs
19838 -- Bug 4922099
19839 --
19840 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19841 (NVL(l_actual_upg_option, 'N') = 'O') OR
19842 (NVL(l_enc_upg_option, 'N') = 'O')
19843 )
19844 THEN
19845 NULL;
19846 --
19847 --
19848
19849 l_ccid := AcctDerRule_18(
19850 p_application_id => p_application_id
19851 , p_ae_header_id => l_ae_header_id
19852 , p_source_14 => p_source_14
19853 , x_transaction_coa_id => l_adr_transaction_coa_id
19854 , x_accounting_coa_id => l_adr_accounting_coa_id
19855 , x_value_type_code => l_adr_value_type_code
19856 , p_side => 'NA'
19857 );
19858
19859 xla_ae_lines_pkg.set_ccid(
19860 p_code_combination_id => l_ccid
19861 , p_value_type_code => l_adr_value_type_code
19862 , p_transaction_coa_id => l_adr_transaction_coa_id
19863 , p_accounting_coa_id => l_adr_accounting_coa_id
19864 , p_adr_code => 'TRX_DIST_CCID'
19865 , p_adr_type_code => 'S'
19866 , p_component_type => l_component_type
19867 , p_component_code => l_component_code
19868 , p_component_type_code => l_component_type_code
19869 , p_component_appl_id => l_component_appl_id
19870 , p_amb_context_code => l_amb_context_code
19871 , p_side => 'NA'
19872 );
19873
19874
19875 --
19876 --
19877 END IF;
19878
19879 --
19880 -- Update the line information that should be overwritten
19881 --
19882 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
19883 p_header_num => 1);
19884 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
19885
19886 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
19887
19888 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
19889 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
19890 END IF;
19891
19892 --
19893 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
19894 --
19895 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
19896 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
19897 ELSE
19898 ---------------------------------------------------------------------------------------------------
19902 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19899 -- 4262811a Switch Sign
19900 ---------------------------------------------------------------------------------------------------
19901 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
19903 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19904 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19905 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19906 -- 5132302
19907 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
19908 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19909
19910 END IF;
19911
19912 -- 4955764
19913 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19914 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
19915
19916
19917 XLA_AE_LINES_PKG.ValidateCurrentLine;
19918 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19919
19920 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19921 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
19922 ,p_balance_type_code => l_balance_type_code);
19923
19924 END IF;
19925
19926 -----------------------------------------------------------------------------------------
19927 -- 4262811 Multiperiod Accounting
19928 -----------------------------------------------------------------------------------------
19929 -- No MPA option is assigned.
19930
19931
19932 END IF;
19933 END IF;
19934 --
19935
19936 --
19937 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19938 trace
19939 (p_msg => 'END of AcctLineType_49'
19940 ,p_level => C_LEVEL_PROCEDURE
19941 ,p_module => l_log_module);
19942 END IF;
19943 --
19944 EXCEPTION
19945 WHEN xla_exceptions_pkg.application_exception THEN
19946 RAISE;
19947 WHEN OTHERS THEN
19948 xla_exceptions_pkg.raise_message
19949 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_49');
19950 END AcctLineType_49;
19951 --
19952
19953 ---------------------------------------
19954 --
19955 -- PRIVATE FUNCTION
19956 -- AcctLineType_50
19957 --
19958 ---------------------------------------
19959 PROCEDURE AcctLineType_50 (
19960 p_application_id IN NUMBER
19961 ,p_event_id IN NUMBER
19962 ,p_calculate_acctd_flag IN VARCHAR2
19963 ,p_calculate_g_l_flag IN VARCHAR2
19964 ,p_actual_flag IN OUT VARCHAR2
19965 ,p_balance_type_code OUT VARCHAR2
19966 ,p_gain_or_loss_ref OUT VARCHAR2
19967
19968 --Transaction Distribution GL Account
19969 , p_source_14 IN NUMBER
19970 --Bill To Customer Account Identifier
19971 , p_source_25 IN NUMBER
19972 --Bill To Customer Site Use Identifier
19973 , p_source_26 IN NUMBER
19974 --SLA Party Type
19975 , p_source_27 IN VARCHAR2
19976 --Transaction Distribution Account Class
19977 , p_source_28 IN VARCHAR2
19978 --Transaction Distribution Identifier
19979 , p_source_29 IN NUMBER
19980 --Transaction Distribution Type
19981 , p_source_30 IN VARCHAR2
19982 --Transaction Distribution Entered Amount
19983 , p_source_31 IN NUMBER
19984 --Transaction Currency Code
19985 , p_source_32 IN VARCHAR2
19986 --Transaction Exchange Date
19987 , p_source_33 IN DATE
19988 --Transaction Exchange Rate
19989 , p_source_34 IN NUMBER
19990 --Transaction Exchange Rate Type
19991 , p_source_35 IN VARCHAR2
19992 --Transaction Accounting Amount
19993 , p_source_36 IN NUMBER
19994 --Transaction Tax Line Identifier
19995 , p_source_50 IN NUMBER
19996 )
19997 IS
19998
19999 l_component_type VARCHAR2(80);
20000 l_component_code VARCHAR2(30);
20001 l_component_type_code VARCHAR2(1);
20002 l_component_appl_id INTEGER;
20003 l_amb_context_code VARCHAR2(30);
20004 l_entity_code VARCHAR2(30);
20005 l_event_class_code VARCHAR2(30);
20006 l_ae_header_id NUMBER;
20007 l_event_type_code VARCHAR2(30);
20008 l_line_definition_code VARCHAR2(30);
20009 l_line_definition_owner_code VARCHAR2(1);
20010 --
20011 -- adr variables
20012 l_segment VARCHAR2(30);
20013 l_ccid NUMBER;
20014 l_adr_transaction_coa_id NUMBER;
20015 l_adr_accounting_coa_id NUMBER;
20016 l_adr_flexfield_segment_code VARCHAR2(30);
20017 l_adr_flex_value_set_id NUMBER;
20018 l_adr_value_type_code VARCHAR2(30);
20019 l_adr_value_combination_id NUMBER;
20020 l_adr_value_segment_code VARCHAR2(30);
20021
20022 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
20023 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
20024 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
20025 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
20026
20027 -- 4262811 Variables ------------------------------------------------------------------------------------------
20028 l_entered_amt_idx NUMBER;
20029 l_accted_amt_idx NUMBER;
20033 l_acc_rev_natural_side_code VARCHAR2(1);
20030 l_acc_rev_flag VARCHAR2(1);
20031 l_accrual_line_num NUMBER;
20032 l_tmp_amt NUMBER;
20034
20035 l_num_entries NUMBER;
20036 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
20037 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
20038 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
20039 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
20040 l_recog_line_1 NUMBER;
20041 l_recog_line_2 NUMBER;
20042
20043 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
20044 l_bflow_applied_to_amt NUMBER; -- 5132302
20045 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
20046
20047 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
20048
20049 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
20050 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
20051
20052 ---------------------------------------------------------------------------------------------------------------
20053
20054
20055 --
20056 -- bulk performance
20057 --
20058 l_balance_type_code VARCHAR2(1);
20059 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
20060 l_log_module VARCHAR2(240);
20061
20062 --
20063 -- Upgrade strategy
20064 --
20065 l_actual_upg_option VARCHAR2(1);
20066 l_enc_upg_option VARCHAR2(1);
20067
20068 --
20069 BEGIN
20070 --
20071 IF g_log_enabled THEN
20072 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_50';
20073 END IF;
20074 --
20075 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20076
20077 trace
20078 (p_msg => 'BEGIN of AcctLineType_50'
20079 ,p_level => C_LEVEL_PROCEDURE
20080 ,p_module => l_log_module);
20081
20082 END IF;
20083 --
20084 l_component_type := 'AMB_JLT';
20085 l_component_code := 'INV_TAX';
20086 l_component_type_code := 'S';
20087 l_component_appl_id := 222;
20088 l_amb_context_code := 'DEFAULT';
20089 l_entity_code := 'TRANSACTIONS';
20090 l_event_class_code := 'INVOICE';
20091 l_event_type_code := 'INVOICE_ALL';
20092 l_line_definition_owner_code := 'S';
20093 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
20094 --
20095 l_balance_type_code := 'A';
20096 l_segment := NULL;
20097 l_ccid := NULL;
20098 l_adr_transaction_coa_id := NULL;
20099 l_adr_accounting_coa_id := NULL;
20100 l_adr_flexfield_segment_code := NULL;
20101 l_adr_flex_value_set_id := NULL;
20102 l_adr_value_type_code := NULL;
20103 l_adr_value_combination_id := NULL;
20104 l_adr_value_segment_code := NULL;
20105
20106 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
20107 l_bflow_class_code := 'TAX'; -- 4219869 Business Flow
20108 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
20109 l_budgetary_control_flag := 'N';
20110
20111 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20112 l_bflow_applied_to_amt := NULL; -- 5132302
20113 l_entered_amt_idx := NULL; -- 4262811
20114 l_accted_amt_idx := NULL; -- 4262811
20115 l_acc_rev_flag := NULL; -- 4262811
20116 l_accrual_line_num := NULL; -- 4262811
20117 l_tmp_amt := NULL; -- 4262811
20118 --
20119
20120 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
20121 l_balance_type_code <> 'B' THEN
20122 IF NVL(p_source_28,'
20123 ') = 'TAX'
20124 THEN
20125
20126 --
20127 XLA_AE_LINES_PKG.SetNewLine;
20128
20129 p_balance_type_code := l_balance_type_code;
20130 -- set the flag so later we will know whether the gain loss line needs to be created
20131
20132 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
20133 p_actual_flag :='A';
20134 END IF;
20135
20136 --
20137 -- bulk performance
20138 --
20139 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
20140 p_header_num => 0); -- 4262811
20141 --
20142 -- set accounting line options
20143 --
20144 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
20145 p_natural_side_code => 'C'
20146 , p_gain_or_loss_flag => 'N'
20147 , p_gl_transfer_mode_code => 'S'
20148 , p_acct_entry_type_code => 'A'
20149 , p_switch_side_flag => 'Y'
20150 , p_merge_duplicate_code => 'A'
20151 );
20152 --
20153 l_acc_rev_natural_side_code := 'D'; -- 4262811
20154 --
20155 --
20156 -- set accounting line type info
20157 --
20158 xla_ae_lines_pkg.SetAcctLineType
20159 (p_component_type => l_component_type
20160 ,p_event_type_code => l_event_type_code
20161 ,p_line_definition_owner_code => l_line_definition_owner_code
20162 ,p_line_definition_code => l_line_definition_code
20163 ,p_accounting_line_code => l_component_code
20167 ,p_entity_code => l_entity_code
20164 ,p_accounting_line_type_code => l_component_type_code
20165 ,p_accounting_line_appl_id => l_component_appl_id
20166 ,p_amb_context_code => l_amb_context_code
20168 ,p_event_class_code => l_event_class_code);
20169 --
20170 -- set accounting class
20171 --
20172 xla_ae_lines_pkg.SetAcctClass(
20173 p_accounting_class_code => 'TAX'
20174 , p_ae_header_id => l_ae_header_id
20175 );
20176
20177 --
20178 -- set rounding class
20179 --
20180 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
20181 'RECEIVABLE';
20182
20183 --
20184 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
20185 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
20186 --
20187 -- bulk performance
20188 --
20189 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
20190
20191 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
20192 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
20193
20194 -- 4955764
20195 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20196 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
20197
20198 -- 4458381 Public Sector Enh
20199
20200 --
20201 -- set accounting attributes for the line type
20202 --
20203 l_entered_amt_idx := 3;
20204 l_accted_amt_idx := 8;
20205 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20206 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
20207 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
20208 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
20209 l_rec_acct_attrs.array_char_value(2) := p_source_30;
20210 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
20211 l_rec_acct_attrs.array_num_value(3) := p_source_31;
20212 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
20213 l_rec_acct_attrs.array_char_value(4) := p_source_32;
20214 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
20215 l_rec_acct_attrs.array_date_value(5) := p_source_33;
20216 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
20217 l_rec_acct_attrs.array_num_value(6) := p_source_34;
20218 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
20219 l_rec_acct_attrs.array_char_value(7) := p_source_35;
20220 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
20221 l_rec_acct_attrs.array_num_value(8) := p_source_36;
20222 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
20223 l_rec_acct_attrs.array_num_value(9) := p_source_25;
20224 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
20225 l_rec_acct_attrs.array_num_value(10) := p_source_26;
20226 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
20227 l_rec_acct_attrs.array_char_value(11) := p_source_27;
20228 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
20229 l_rec_acct_attrs.array_num_value(12) := p_source_50;
20230
20231 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
20232 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
20233
20234 ---------------------------------------------------------------------------------------------------------------
20235 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
20236 ---------------------------------------------------------------------------------------------------------------
20237 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
20238
20239 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20240 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20241
20242 IF xla_accounting_cache_pkg.GetValueChar
20243 (p_source_code => 'LEDGER_CATEGORY_CODE'
20244 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
20245 AND l_bflow_method_code = 'PRIOR_ENTRY'
20246 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
20247 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
20248 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
20249 )
20250 THEN
20251 xla_ae_lines_pkg.BflowUpgEntry
20252 (p_business_method_code => l_bflow_method_code
20253 ,p_business_class_code => l_bflow_class_code
20254 ,p_balance_type => l_balance_type_code);
20255 ELSE
20256 NULL;
20257 -- No business flow processing for business flow method of NONE.
20258 END IF;
20259
20260 --
20261 -- call analytical criteria
20262 --
20263
20264 --
20265 -- call description
20266 --
20267 -- No description or it is inherited.
20268 --
20269 -- call ADRs
20270 -- Bug 4922099
20271 --
20272 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20273 (NVL(l_actual_upg_option, 'N') = 'O') OR
20274 (NVL(l_enc_upg_option, 'N') = 'O')
20275 )
20276 THEN
20277 NULL;
20278 --
20279 --
20280
20284 , p_source_14 => p_source_14
20281 l_ccid := AcctDerRule_18(
20282 p_application_id => p_application_id
20283 , p_ae_header_id => l_ae_header_id
20285 , x_transaction_coa_id => l_adr_transaction_coa_id
20286 , x_accounting_coa_id => l_adr_accounting_coa_id
20287 , x_value_type_code => l_adr_value_type_code
20288 , p_side => 'NA'
20289 );
20290
20291 xla_ae_lines_pkg.set_ccid(
20292 p_code_combination_id => l_ccid
20293 , p_value_type_code => l_adr_value_type_code
20294 , p_transaction_coa_id => l_adr_transaction_coa_id
20295 , p_accounting_coa_id => l_adr_accounting_coa_id
20296 , p_adr_code => 'TRX_DIST_CCID'
20297 , p_adr_type_code => 'S'
20298 , p_component_type => l_component_type
20299 , p_component_code => l_component_code
20300 , p_component_type_code => l_component_type_code
20301 , p_component_appl_id => l_component_appl_id
20302 , p_amb_context_code => l_amb_context_code
20303 , p_side => 'NA'
20304 );
20305
20306
20307 --
20308 --
20309 END IF;
20310 --
20311 -- Bug 4922099
20312 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
20313 (NVL(l_enc_upg_option, 'N') = 'O')
20314 ) AND
20315 (l_bflow_method_code = 'PRIOR_ENTRY')
20316 )
20317 THEN
20318 IF
20319 --
20320 1 = 2
20321 --
20322 THEN
20323 xla_accounting_err_pkg.build_message
20324 (p_appli_s_name => 'XLA'
20325 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20326 ,p_token_1 => 'LINE_NUMBER'
20327 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
20328 ,p_token_2 => 'LINE_TYPE_NAME'
20329 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
20330 l_component_type
20331 ,l_component_code
20332 ,l_component_type_code
20333 ,l_component_appl_id
20334 ,l_amb_context_code
20335 ,l_entity_code
20336 ,l_event_class_code
20337 )
20338 ,p_token_3 => 'OWNER'
20339 ,p_value_3 => xla_lookups_pkg.get_meaning(
20340 p_lookup_type => 'XLA_OWNER_TYPE'
20341 ,p_lookup_code => l_component_type_code
20342 )
20343 ,p_token_4 => 'PRODUCT_NAME'
20344 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
20345 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
20346 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
20347 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
20348 ,p_ae_header_id => NULL
20349 );
20350
20351 IF (C_LEVEL_ERROR>= g_log_level) THEN
20352 trace
20353 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20354 ,p_level => C_LEVEL_ERROR
20355 ,p_module => l_log_module);
20356 END IF;
20357 END IF;
20358 END IF;
20359 --
20360 --
20361 ------------------------------------------------------------------------------------------------
20362 -- 4219869 Business Flow
20363 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
20364 -- Prior Entry. Currently, the following code is always generated.
20365 ------------------------------------------------------------------------------------------------
20366 XLA_AE_LINES_PKG.ValidateCurrentLine;
20367
20368 ------------------------------------------------------------------------------------
20369 -- 4219869 Business Flow
20370 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
20371 ------------------------------------------------------------------------------------
20372 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20373
20374 ----------------------------------------------------------------------------------
20375 -- 4219869 Business Flow
20376 -- Update journal entry status -- Need to generate this within IF <condition>
20377 ----------------------------------------------------------------------------------
20378 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20379 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
20383 -------------------------------------------------------------------------------------------
20380 ,p_balance_type_code => l_balance_type_code
20381 );
20382
20384 -- 4262811 - Generate the Accrual Reversal lines
20385 -------------------------------------------------------------------------------------------
20386 BEGIN
20387 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
20388 (g_array_event(p_event_id).array_value_num('header_index'));
20389 IF l_acc_rev_flag IS NULL THEN
20390 l_acc_rev_flag := 'N';
20391 END IF;
20392 EXCEPTION
20393 WHEN OTHERS THEN
20394 l_acc_rev_flag := 'N';
20395 END;
20396 --
20397 IF (l_acc_rev_flag = 'Y') THEN
20398
20399 -- 4645092 ------------------------------------------------------------------------------
20400 -- To allow MPA report to determine if it should generate report process
20401 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
20402 ------------------------------------------------------------------------------------------
20403
20404 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
20405 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
20406 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
20407 -- call ADRs
20408 -- Bug 4922099
20409 --
20410 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20411 (NVL(l_actual_upg_option, 'N') = 'O') OR
20412 (NVL(l_enc_upg_option, 'N') = 'O')
20413 )
20414 THEN
20415 NULL;
20416 --
20417 --
20418
20419 l_ccid := AcctDerRule_18(
20420 p_application_id => p_application_id
20421 , p_ae_header_id => l_ae_header_id
20422 , p_source_14 => p_source_14
20423 , x_transaction_coa_id => l_adr_transaction_coa_id
20424 , x_accounting_coa_id => l_adr_accounting_coa_id
20425 , x_value_type_code => l_adr_value_type_code
20426 , p_side => 'NA'
20427 );
20428
20429 xla_ae_lines_pkg.set_ccid(
20430 p_code_combination_id => l_ccid
20431 , p_value_type_code => l_adr_value_type_code
20432 , p_transaction_coa_id => l_adr_transaction_coa_id
20433 , p_accounting_coa_id => l_adr_accounting_coa_id
20434 , p_adr_code => 'TRX_DIST_CCID'
20435 , p_adr_type_code => 'S'
20436 , p_component_type => l_component_type
20437 , p_component_code => l_component_code
20438 , p_component_type_code => l_component_type_code
20439 , p_component_appl_id => l_component_appl_id
20440 , p_amb_context_code => l_amb_context_code
20441 , p_side => 'NA'
20442 );
20443
20444
20445 --
20446 --
20447 END IF;
20448
20449 --
20450 -- Update the line information that should be overwritten
20451 --
20452 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
20453 p_header_num => 1);
20454 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
20455
20456 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
20457
20458 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
20459 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
20460 END IF;
20461
20462 --
20463 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
20464 --
20465 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
20466 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
20467 ELSE
20468 ---------------------------------------------------------------------------------------------------
20469 -- 4262811a Switch Sign
20470 ---------------------------------------------------------------------------------------------------
20471 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
20472 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20473 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20474 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20475 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20476 -- 5132302
20477 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
20478 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20479
20480 END IF;
20481
20482 -- 4955764
20483 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20484 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
20485
20486
20487 XLA_AE_LINES_PKG.ValidateCurrentLine;
20488 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20489
20490 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20494 END IF;
20491 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
20492 ,p_balance_type_code => l_balance_type_code);
20493
20495
20496 -----------------------------------------------------------------------------------------
20497 -- 4262811 Multiperiod Accounting
20498 -----------------------------------------------------------------------------------------
20499 -- No MPA option is assigned.
20500
20501
20502 END IF;
20503 END IF;
20504 --
20505
20506 --
20507 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20508 trace
20509 (p_msg => 'END of AcctLineType_50'
20510 ,p_level => C_LEVEL_PROCEDURE
20511 ,p_module => l_log_module);
20512 END IF;
20513 --
20514 EXCEPTION
20515 WHEN xla_exceptions_pkg.application_exception THEN
20516 RAISE;
20517 WHEN OTHERS THEN
20518 xla_exceptions_pkg.raise_message
20519 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_50');
20520 END AcctLineType_50;
20521 --
20522
20523 ---------------------------------------
20524 --
20525 -- PRIVATE FUNCTION
20526 -- AcctLineType_51
20527 --
20528 ---------------------------------------
20529 PROCEDURE AcctLineType_51 (
20530 p_application_id IN NUMBER
20531 ,p_event_id IN NUMBER
20532 ,p_calculate_acctd_flag IN VARCHAR2
20533 ,p_calculate_g_l_flag IN VARCHAR2
20534 ,p_actual_flag IN OUT VARCHAR2
20535 ,p_balance_type_code OUT VARCHAR2
20536 ,p_gain_or_loss_ref OUT VARCHAR2
20537
20538 --Transaction Distribution GL Account
20539 , p_source_14 IN NUMBER
20540 --Bill To Customer Account Identifier
20541 , p_source_25 IN NUMBER
20542 --Bill To Customer Site Use Identifier
20543 , p_source_26 IN NUMBER
20544 --SLA Party Type
20545 , p_source_27 IN VARCHAR2
20546 --Transaction Distribution Account Class
20547 , p_source_28 IN VARCHAR2
20548 --Transaction Distribution Identifier
20549 , p_source_29 IN NUMBER
20550 --Transaction Distribution Type
20551 , p_source_30 IN VARCHAR2
20552 --Transaction Distribution Entered Amount
20553 , p_source_31 IN NUMBER
20554 --Transaction Currency Code
20555 , p_source_32 IN VARCHAR2
20556 --Transaction Exchange Date
20557 , p_source_33 IN DATE
20558 --Transaction Exchange Rate
20559 , p_source_34 IN NUMBER
20560 --Transaction Exchange Rate Type
20561 , p_source_35 IN VARCHAR2
20562 --Transaction Accounting Amount
20563 , p_source_36 IN NUMBER
20564 --Transaction Tax Line Identifier
20565 , p_source_50 IN NUMBER
20566 --Rounding Correction Flag
20567 , p_source_51 IN VARCHAR2
20568 )
20569 IS
20570
20571 l_component_type VARCHAR2(80);
20572 l_component_code VARCHAR2(30);
20573 l_component_type_code VARCHAR2(1);
20574 l_component_appl_id INTEGER;
20575 l_amb_context_code VARCHAR2(30);
20576 l_entity_code VARCHAR2(30);
20577 l_event_class_code VARCHAR2(30);
20578 l_ae_header_id NUMBER;
20579 l_event_type_code VARCHAR2(30);
20580 l_line_definition_code VARCHAR2(30);
20581 l_line_definition_owner_code VARCHAR2(1);
20582 --
20583 -- adr variables
20584 l_segment VARCHAR2(30);
20585 l_ccid NUMBER;
20586 l_adr_transaction_coa_id NUMBER;
20587 l_adr_accounting_coa_id NUMBER;
20588 l_adr_flexfield_segment_code VARCHAR2(30);
20589 l_adr_flex_value_set_id NUMBER;
20590 l_adr_value_type_code VARCHAR2(30);
20591 l_adr_value_combination_id NUMBER;
20592 l_adr_value_segment_code VARCHAR2(30);
20593
20594 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
20595 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
20596 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
20597 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
20598
20599 -- 4262811 Variables ------------------------------------------------------------------------------------------
20600 l_entered_amt_idx NUMBER;
20601 l_accted_amt_idx NUMBER;
20602 l_acc_rev_flag VARCHAR2(1);
20603 l_accrual_line_num NUMBER;
20604 l_tmp_amt NUMBER;
20605 l_acc_rev_natural_side_code VARCHAR2(1);
20606
20607 l_num_entries NUMBER;
20608 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
20609 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
20610 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
20611 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
20612 l_recog_line_1 NUMBER;
20613 l_recog_line_2 NUMBER;
20614
20615 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
20616 l_bflow_applied_to_amt NUMBER; -- 5132302
20617 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
20618
20619 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
20620
20621 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
20622 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
20623
20624 ---------------------------------------------------------------------------------------------------------------
20625
20626
20627 --
20628 -- bulk performance
20629 --
20633
20630 l_balance_type_code VARCHAR2(1);
20631 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
20632 l_log_module VARCHAR2(240);
20634 --
20635 -- Upgrade strategy
20636 --
20637 l_actual_upg_option VARCHAR2(1);
20638 l_enc_upg_option VARCHAR2(1);
20639
20640 --
20641 BEGIN
20642 --
20643 IF g_log_enabled THEN
20644 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_51';
20645 END IF;
20646 --
20647 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20648
20649 trace
20650 (p_msg => 'BEGIN of AcctLineType_51'
20651 ,p_level => C_LEVEL_PROCEDURE
20652 ,p_module => l_log_module);
20653
20654 END IF;
20655 --
20656 l_component_type := 'AMB_JLT';
20657 l_component_code := 'INV_UNBILL';
20658 l_component_type_code := 'S';
20659 l_component_appl_id := 222;
20660 l_amb_context_code := 'DEFAULT';
20661 l_entity_code := 'TRANSACTIONS';
20662 l_event_class_code := 'INVOICE';
20663 l_event_type_code := 'INVOICE_ALL';
20664 l_line_definition_owner_code := 'S';
20665 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
20666 --
20667 l_balance_type_code := 'A';
20668 l_segment := NULL;
20669 l_ccid := NULL;
20670 l_adr_transaction_coa_id := NULL;
20671 l_adr_accounting_coa_id := NULL;
20672 l_adr_flexfield_segment_code := NULL;
20673 l_adr_flex_value_set_id := NULL;
20674 l_adr_value_type_code := NULL;
20675 l_adr_value_combination_id := NULL;
20676 l_adr_value_segment_code := NULL;
20677
20678 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
20679 l_bflow_class_code := ''; -- 4219869 Business Flow
20680 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
20681 l_budgetary_control_flag := 'N';
20682
20683 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20684 l_bflow_applied_to_amt := NULL; -- 5132302
20685 l_entered_amt_idx := NULL; -- 4262811
20686 l_accted_amt_idx := NULL; -- 4262811
20687 l_acc_rev_flag := NULL; -- 4262811
20688 l_accrual_line_num := NULL; -- 4262811
20689 l_tmp_amt := NULL; -- 4262811
20690 --
20691
20692 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
20693 l_balance_type_code <> 'B' THEN
20694 IF NVL(p_source_28,'
20695 ') = 'UNBILL' AND
20696 p_source_51 IS NULL
20697 THEN
20698
20699 --
20700 XLA_AE_LINES_PKG.SetNewLine;
20701
20702 p_balance_type_code := l_balance_type_code;
20703 -- set the flag so later we will know whether the gain loss line needs to be created
20704
20705 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
20706 p_actual_flag :='A';
20707 END IF;
20708
20709 --
20710 -- bulk performance
20711 --
20712 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
20713 p_header_num => 0); -- 4262811
20714 --
20715 -- set accounting line options
20716 --
20717 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
20718 p_natural_side_code => 'C'
20719 , p_gain_or_loss_flag => 'N'
20720 , p_gl_transfer_mode_code => 'S'
20721 , p_acct_entry_type_code => 'A'
20722 , p_switch_side_flag => 'Y'
20723 , p_merge_duplicate_code => 'A'
20724 );
20725 --
20726 l_acc_rev_natural_side_code := 'D'; -- 4262811
20727 --
20728 --
20729 -- set accounting line type info
20730 --
20731 xla_ae_lines_pkg.SetAcctLineType
20732 (p_component_type => l_component_type
20733 ,p_event_type_code => l_event_type_code
20734 ,p_line_definition_owner_code => l_line_definition_owner_code
20735 ,p_line_definition_code => l_line_definition_code
20736 ,p_accounting_line_code => l_component_code
20737 ,p_accounting_line_type_code => l_component_type_code
20738 ,p_accounting_line_appl_id => l_component_appl_id
20739 ,p_amb_context_code => l_amb_context_code
20740 ,p_entity_code => l_entity_code
20741 ,p_event_class_code => l_event_class_code);
20742 --
20743 -- set accounting class
20744 --
20745 xla_ae_lines_pkg.SetAcctClass(
20746 p_accounting_class_code => 'UNBILL'
20747 , p_ae_header_id => l_ae_header_id
20748 );
20749
20750 --
20751 -- set rounding class
20752 --
20753 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
20754 'UNBILL';
20755
20756 --
20757 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
20758 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
20759 --
20760 -- bulk performance
20761 --
20762 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
20763
20764 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
20765 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
20766
20767 -- 4955764
20768 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20772
20769 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
20770
20771 -- 4458381 Public Sector Enh
20773 --
20774 -- set accounting attributes for the line type
20775 --
20776 l_entered_amt_idx := 3;
20777 l_accted_amt_idx := 8;
20778 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20779 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
20780 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
20781 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
20782 l_rec_acct_attrs.array_char_value(2) := p_source_30;
20783 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
20784 l_rec_acct_attrs.array_num_value(3) := p_source_31;
20785 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
20786 l_rec_acct_attrs.array_char_value(4) := p_source_32;
20787 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
20788 l_rec_acct_attrs.array_date_value(5) := p_source_33;
20789 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
20790 l_rec_acct_attrs.array_num_value(6) := p_source_34;
20791 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
20792 l_rec_acct_attrs.array_char_value(7) := p_source_35;
20793 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
20794 l_rec_acct_attrs.array_num_value(8) := p_source_36;
20795 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
20796 l_rec_acct_attrs.array_num_value(9) := p_source_25;
20797 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
20798 l_rec_acct_attrs.array_num_value(10) := p_source_26;
20799 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
20800 l_rec_acct_attrs.array_char_value(11) := p_source_27;
20801 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
20802 l_rec_acct_attrs.array_num_value(12) := p_source_50;
20803
20804 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
20805 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
20806
20807 ---------------------------------------------------------------------------------------------------------------
20808 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
20809 ---------------------------------------------------------------------------------------------------------------
20810 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
20811
20812 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20813 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20814
20815 IF xla_accounting_cache_pkg.GetValueChar
20816 (p_source_code => 'LEDGER_CATEGORY_CODE'
20817 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
20818 AND l_bflow_method_code = 'PRIOR_ENTRY'
20819 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
20820 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
20821 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
20822 )
20823 THEN
20824 xla_ae_lines_pkg.BflowUpgEntry
20825 (p_business_method_code => l_bflow_method_code
20826 ,p_business_class_code => l_bflow_class_code
20827 ,p_balance_type => l_balance_type_code);
20828 ELSE
20829 NULL;
20830 -- No business flow processing for business flow method of NONE.
20831 END IF;
20832
20833 --
20834 -- call analytical criteria
20835 --
20836
20837 --
20838 -- call description
20839 --
20840 -- No description or it is inherited.
20841 --
20842 -- call ADRs
20843 -- Bug 4922099
20844 --
20845 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20846 (NVL(l_actual_upg_option, 'N') = 'O') OR
20847 (NVL(l_enc_upg_option, 'N') = 'O')
20848 )
20849 THEN
20850 NULL;
20851 --
20852 --
20853
20854 l_ccid := AcctDerRule_18(
20855 p_application_id => p_application_id
20856 , p_ae_header_id => l_ae_header_id
20857 , p_source_14 => p_source_14
20858 , x_transaction_coa_id => l_adr_transaction_coa_id
20859 , x_accounting_coa_id => l_adr_accounting_coa_id
20860 , x_value_type_code => l_adr_value_type_code
20861 , p_side => 'NA'
20862 );
20863
20864 xla_ae_lines_pkg.set_ccid(
20865 p_code_combination_id => l_ccid
20866 , p_value_type_code => l_adr_value_type_code
20867 , p_transaction_coa_id => l_adr_transaction_coa_id
20868 , p_accounting_coa_id => l_adr_accounting_coa_id
20869 , p_adr_code => 'TRX_DIST_CCID'
20870 , p_adr_type_code => 'S'
20871 , p_component_type => l_component_type
20872 , p_component_code => l_component_code
20873 , p_component_type_code => l_component_type_code
20874 , p_component_appl_id => l_component_appl_id
20875 , p_amb_context_code => l_amb_context_code
20876 , p_side => 'NA'
20877 );
20878
20879
20880 --
20881 --
20882 END IF;
20883 --
20884 -- Bug 4922099
20885 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
20886 (NVL(l_enc_upg_option, 'N') = 'O')
20887 ) AND
20888 (l_bflow_method_code = 'PRIOR_ENTRY')
20892 --
20889 )
20890 THEN
20891 IF
20893 1 = 2
20894 --
20895 THEN
20896 xla_accounting_err_pkg.build_message
20897 (p_appli_s_name => 'XLA'
20898 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20899 ,p_token_1 => 'LINE_NUMBER'
20900 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
20901 ,p_token_2 => 'LINE_TYPE_NAME'
20902 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
20903 l_component_type
20904 ,l_component_code
20905 ,l_component_type_code
20906 ,l_component_appl_id
20907 ,l_amb_context_code
20908 ,l_entity_code
20909 ,l_event_class_code
20910 )
20911 ,p_token_3 => 'OWNER'
20912 ,p_value_3 => xla_lookups_pkg.get_meaning(
20913 p_lookup_type => 'XLA_OWNER_TYPE'
20914 ,p_lookup_code => l_component_type_code
20915 )
20916 ,p_token_4 => 'PRODUCT_NAME'
20917 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
20918 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
20919 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
20920 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
20921 ,p_ae_header_id => NULL
20922 );
20923
20924 IF (C_LEVEL_ERROR>= g_log_level) THEN
20925 trace
20926 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20927 ,p_level => C_LEVEL_ERROR
20928 ,p_module => l_log_module);
20929 END IF;
20930 END IF;
20931 END IF;
20932 --
20933 --
20934 ------------------------------------------------------------------------------------------------
20935 -- 4219869 Business Flow
20936 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
20937 -- Prior Entry. Currently, the following code is always generated.
20938 ------------------------------------------------------------------------------------------------
20939 XLA_AE_LINES_PKG.ValidateCurrentLine;
20940
20941 ------------------------------------------------------------------------------------
20942 -- 4219869 Business Flow
20943 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
20944 ------------------------------------------------------------------------------------
20945 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20946
20947 ----------------------------------------------------------------------------------
20948 -- 4219869 Business Flow
20949 -- Update journal entry status -- Need to generate this within IF <condition>
20950 ----------------------------------------------------------------------------------
20951 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20952 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
20953 ,p_balance_type_code => l_balance_type_code
20954 );
20955
20956 -------------------------------------------------------------------------------------------
20957 -- 4262811 - Generate the Accrual Reversal lines
20958 -------------------------------------------------------------------------------------------
20959 BEGIN
20960 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
20961 (g_array_event(p_event_id).array_value_num('header_index'));
20962 IF l_acc_rev_flag IS NULL THEN
20963 l_acc_rev_flag := 'N';
20964 END IF;
20965 EXCEPTION
20966 WHEN OTHERS THEN
20967 l_acc_rev_flag := 'N';
20968 END;
20969 --
20970 IF (l_acc_rev_flag = 'Y') THEN
20971
20972 -- 4645092 ------------------------------------------------------------------------------
20973 -- To allow MPA report to determine if it should generate report process
20974 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
20975 ------------------------------------------------------------------------------------------
20976
20977 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
20978 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
20979 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
20980 -- call ADRs
20981 -- Bug 4922099
20982 --
20983 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20984 (NVL(l_actual_upg_option, 'N') = 'O') OR
20988 NULL;
20985 (NVL(l_enc_upg_option, 'N') = 'O')
20986 )
20987 THEN
20989 --
20990 --
20991
20992 l_ccid := AcctDerRule_18(
20993 p_application_id => p_application_id
20994 , p_ae_header_id => l_ae_header_id
20995 , p_source_14 => p_source_14
20996 , x_transaction_coa_id => l_adr_transaction_coa_id
20997 , x_accounting_coa_id => l_adr_accounting_coa_id
20998 , x_value_type_code => l_adr_value_type_code
20999 , p_side => 'NA'
21000 );
21001
21002 xla_ae_lines_pkg.set_ccid(
21003 p_code_combination_id => l_ccid
21004 , p_value_type_code => l_adr_value_type_code
21005 , p_transaction_coa_id => l_adr_transaction_coa_id
21006 , p_accounting_coa_id => l_adr_accounting_coa_id
21007 , p_adr_code => 'TRX_DIST_CCID'
21008 , p_adr_type_code => 'S'
21009 , p_component_type => l_component_type
21010 , p_component_code => l_component_code
21011 , p_component_type_code => l_component_type_code
21012 , p_component_appl_id => l_component_appl_id
21013 , p_amb_context_code => l_amb_context_code
21014 , p_side => 'NA'
21015 );
21016
21017
21018 --
21019 --
21020 END IF;
21021
21022 --
21023 -- Update the line information that should be overwritten
21024 --
21025 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
21026 p_header_num => 1);
21027 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
21028
21029 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
21030
21031 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
21032 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
21033 END IF;
21034
21035 --
21036 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
21037 --
21038 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
21039 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
21040 ELSE
21041 ---------------------------------------------------------------------------------------------------
21042 -- 4262811a Switch Sign
21043 ---------------------------------------------------------------------------------------------------
21044 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
21045 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21046 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21047 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21048 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21049 -- 5132302
21050 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
21051 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21052
21053 END IF;
21054
21055 -- 4955764
21056 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21057 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
21058
21059
21060 XLA_AE_LINES_PKG.ValidateCurrentLine;
21061 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21062
21063 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21064 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
21065 ,p_balance_type_code => l_balance_type_code);
21066
21067 END IF;
21068
21069 -----------------------------------------------------------------------------------------
21070 -- 4262811 Multiperiod Accounting
21071 -----------------------------------------------------------------------------------------
21072 -- No MPA option is assigned.
21073
21074
21075 END IF;
21076 END IF;
21077 --
21078
21079 --
21080 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21081 trace
21082 (p_msg => 'END of AcctLineType_51'
21083 ,p_level => C_LEVEL_PROCEDURE
21084 ,p_module => l_log_module);
21085 END IF;
21086 --
21087 EXCEPTION
21088 WHEN xla_exceptions_pkg.application_exception THEN
21089 RAISE;
21090 WHEN OTHERS THEN
21091 xla_exceptions_pkg.raise_message
21092 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_51');
21093 END AcctLineType_51;
21094 --
21095
21096 ---------------------------------------
21097 --
21098 -- PRIVATE FUNCTION
21099 -- AcctLineType_52
21100 --
21101 ---------------------------------------
21102 PROCEDURE AcctLineType_52 (
21103 p_application_id IN NUMBER
21104 ,p_event_id IN NUMBER
21105 ,p_calculate_acctd_flag IN VARCHAR2
21106 ,p_calculate_g_l_flag IN VARCHAR2
21107 ,p_actual_flag IN OUT VARCHAR2
21108 ,p_balance_type_code OUT VARCHAR2
21109 ,p_gain_or_loss_ref OUT VARCHAR2
21110
21114 , p_source_25 IN NUMBER
21111 --Transaction Distribution GL Account
21112 , p_source_14 IN NUMBER
21113 --Bill To Customer Account Identifier
21115 --Bill To Customer Site Use Identifier
21116 , p_source_26 IN NUMBER
21117 --SLA Party Type
21118 , p_source_27 IN VARCHAR2
21119 --Transaction Distribution Account Class
21120 , p_source_28 IN VARCHAR2
21121 --Transaction Distribution Identifier
21122 , p_source_29 IN NUMBER
21123 --Transaction Distribution Type
21124 , p_source_30 IN VARCHAR2
21125 --Transaction Distribution Entered Amount
21126 , p_source_31 IN NUMBER
21127 --Transaction Currency Code
21128 , p_source_32 IN VARCHAR2
21129 --Transaction Exchange Date
21130 , p_source_33 IN DATE
21131 --Transaction Exchange Rate
21132 , p_source_34 IN NUMBER
21133 --Transaction Exchange Rate Type
21134 , p_source_35 IN VARCHAR2
21135 --Transaction Accounting Amount
21136 , p_source_36 IN NUMBER
21137 --Transaction Tax Line Identifier
21138 , p_source_50 IN NUMBER
21139 --Rounding Correction Flag
21140 , p_source_51 IN VARCHAR2
21141 )
21142 IS
21143
21144 l_component_type VARCHAR2(80);
21145 l_component_code VARCHAR2(30);
21146 l_component_type_code VARCHAR2(1);
21147 l_component_appl_id INTEGER;
21148 l_amb_context_code VARCHAR2(30);
21149 l_entity_code VARCHAR2(30);
21150 l_event_class_code VARCHAR2(30);
21151 l_ae_header_id NUMBER;
21152 l_event_type_code VARCHAR2(30);
21153 l_line_definition_code VARCHAR2(30);
21154 l_line_definition_owner_code VARCHAR2(1);
21155 --
21156 -- adr variables
21157 l_segment VARCHAR2(30);
21158 l_ccid NUMBER;
21159 l_adr_transaction_coa_id NUMBER;
21160 l_adr_accounting_coa_id NUMBER;
21161 l_adr_flexfield_segment_code VARCHAR2(30);
21162 l_adr_flex_value_set_id NUMBER;
21163 l_adr_value_type_code VARCHAR2(30);
21164 l_adr_value_combination_id NUMBER;
21165 l_adr_value_segment_code VARCHAR2(30);
21166
21167 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
21168 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
21169 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
21170 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
21171
21172 -- 4262811 Variables ------------------------------------------------------------------------------------------
21173 l_entered_amt_idx NUMBER;
21174 l_accted_amt_idx NUMBER;
21175 l_acc_rev_flag VARCHAR2(1);
21176 l_accrual_line_num NUMBER;
21177 l_tmp_amt NUMBER;
21178 l_acc_rev_natural_side_code VARCHAR2(1);
21179
21180 l_num_entries NUMBER;
21181 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
21182 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
21183 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
21184 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
21185 l_recog_line_1 NUMBER;
21186 l_recog_line_2 NUMBER;
21187
21188 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
21189 l_bflow_applied_to_amt NUMBER; -- 5132302
21190 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
21191
21192 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
21193
21194 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
21195 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
21196
21197 ---------------------------------------------------------------------------------------------------------------
21198
21199
21200 --
21201 -- bulk performance
21202 --
21203 l_balance_type_code VARCHAR2(1);
21204 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
21205 l_log_module VARCHAR2(240);
21206
21207 --
21208 -- Upgrade strategy
21209 --
21210 l_actual_upg_option VARCHAR2(1);
21211 l_enc_upg_option VARCHAR2(1);
21212
21213 --
21214 BEGIN
21215 --
21216 IF g_log_enabled THEN
21217 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_52';
21218 END IF;
21219 --
21220 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21221
21222 trace
21223 (p_msg => 'BEGIN of AcctLineType_52'
21224 ,p_level => C_LEVEL_PROCEDURE
21225 ,p_module => l_log_module);
21226
21227 END IF;
21228 --
21229 l_component_type := 'AMB_JLT';
21230 l_component_code := 'INV_UNEARN';
21231 l_component_type_code := 'S';
21232 l_component_appl_id := 222;
21233 l_amb_context_code := 'DEFAULT';
21234 l_entity_code := 'TRANSACTIONS';
21235 l_event_class_code := 'INVOICE';
21236 l_event_type_code := 'INVOICE_ALL';
21237 l_line_definition_owner_code := 'S';
21238 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
21239 --
21240 l_balance_type_code := 'A';
21241 l_segment := NULL;
21242 l_ccid := NULL;
21246 l_adr_flex_value_set_id := NULL;
21243 l_adr_transaction_coa_id := NULL;
21244 l_adr_accounting_coa_id := NULL;
21245 l_adr_flexfield_segment_code := NULL;
21247 l_adr_value_type_code := NULL;
21248 l_adr_value_combination_id := NULL;
21249 l_adr_value_segment_code := NULL;
21250
21251 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
21252 l_bflow_class_code := ''; -- 4219869 Business Flow
21253 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
21254 l_budgetary_control_flag := 'N';
21255
21256 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21257 l_bflow_applied_to_amt := NULL; -- 5132302
21258 l_entered_amt_idx := NULL; -- 4262811
21259 l_accted_amt_idx := NULL; -- 4262811
21260 l_acc_rev_flag := NULL; -- 4262811
21261 l_accrual_line_num := NULL; -- 4262811
21262 l_tmp_amt := NULL; -- 4262811
21263 --
21264
21265 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
21266 l_balance_type_code <> 'B' THEN
21267 IF NVL(p_source_28,'
21268 ') = 'UNEARN' AND
21269 p_source_51 IS NULL
21270 THEN
21271
21272 --
21273 XLA_AE_LINES_PKG.SetNewLine;
21274
21275 p_balance_type_code := l_balance_type_code;
21276 -- set the flag so later we will know whether the gain loss line needs to be created
21277
21278 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
21279 p_actual_flag :='A';
21280 END IF;
21281
21282 --
21283 -- bulk performance
21284 --
21285 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
21286 p_header_num => 0); -- 4262811
21287 --
21288 -- set accounting line options
21289 --
21290 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
21291 p_natural_side_code => 'C'
21292 , p_gain_or_loss_flag => 'N'
21293 , p_gl_transfer_mode_code => 'S'
21294 , p_acct_entry_type_code => 'A'
21295 , p_switch_side_flag => 'Y'
21296 , p_merge_duplicate_code => 'A'
21297 );
21298 --
21299 l_acc_rev_natural_side_code := 'D'; -- 4262811
21300 --
21301 --
21302 -- set accounting line type info
21303 --
21304 xla_ae_lines_pkg.SetAcctLineType
21305 (p_component_type => l_component_type
21306 ,p_event_type_code => l_event_type_code
21307 ,p_line_definition_owner_code => l_line_definition_owner_code
21308 ,p_line_definition_code => l_line_definition_code
21309 ,p_accounting_line_code => l_component_code
21310 ,p_accounting_line_type_code => l_component_type_code
21311 ,p_accounting_line_appl_id => l_component_appl_id
21312 ,p_amb_context_code => l_amb_context_code
21313 ,p_entity_code => l_entity_code
21314 ,p_event_class_code => l_event_class_code);
21315 --
21316 -- set accounting class
21317 --
21318 xla_ae_lines_pkg.SetAcctClass(
21319 p_accounting_class_code => 'UNEARNED_REVENUE'
21320 , p_ae_header_id => l_ae_header_id
21321 );
21322
21323 --
21324 -- set rounding class
21325 --
21326 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
21327 'RECEIVABLE';
21328
21329 --
21330 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
21331 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
21332 --
21333 -- bulk performance
21334 --
21335 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
21336
21337 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
21338 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
21339
21340 -- 4955764
21341 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21342 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
21343
21344 -- 4458381 Public Sector Enh
21345
21346 --
21347 -- set accounting attributes for the line type
21348 --
21349 l_entered_amt_idx := 3;
21350 l_accted_amt_idx := 8;
21351 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21352 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
21353 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
21354 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
21355 l_rec_acct_attrs.array_char_value(2) := p_source_30;
21356 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
21357 l_rec_acct_attrs.array_num_value(3) := p_source_31;
21358 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
21359 l_rec_acct_attrs.array_char_value(4) := p_source_32;
21360 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
21361 l_rec_acct_attrs.array_date_value(5) := p_source_33;
21362 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
21363 l_rec_acct_attrs.array_num_value(6) := p_source_34;
21364 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
21368 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
21365 l_rec_acct_attrs.array_char_value(7) := p_source_35;
21366 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
21367 l_rec_acct_attrs.array_num_value(8) := p_source_36;
21369 l_rec_acct_attrs.array_num_value(9) := p_source_25;
21370 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
21371 l_rec_acct_attrs.array_num_value(10) := p_source_26;
21372 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
21373 l_rec_acct_attrs.array_char_value(11) := p_source_27;
21374 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
21375 l_rec_acct_attrs.array_num_value(12) := p_source_50;
21376
21377 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
21378 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
21379
21380 ---------------------------------------------------------------------------------------------------------------
21381 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
21382 ---------------------------------------------------------------------------------------------------------------
21383 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
21384
21385 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21386 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21387
21388 IF xla_accounting_cache_pkg.GetValueChar
21389 (p_source_code => 'LEDGER_CATEGORY_CODE'
21390 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
21391 AND l_bflow_method_code = 'PRIOR_ENTRY'
21392 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
21393 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
21394 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
21395 )
21396 THEN
21397 xla_ae_lines_pkg.BflowUpgEntry
21398 (p_business_method_code => l_bflow_method_code
21399 ,p_business_class_code => l_bflow_class_code
21400 ,p_balance_type => l_balance_type_code);
21401 ELSE
21402 NULL;
21403 -- No business flow processing for business flow method of NONE.
21404 END IF;
21405
21406 --
21407 -- call analytical criteria
21408 --
21409
21410 --
21411 -- call description
21412 --
21413 -- No description or it is inherited.
21414 --
21415 -- call ADRs
21416 -- Bug 4922099
21417 --
21418 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21419 (NVL(l_actual_upg_option, 'N') = 'O') OR
21420 (NVL(l_enc_upg_option, 'N') = 'O')
21421 )
21422 THEN
21423 NULL;
21424 --
21425 --
21426
21427 l_ccid := AcctDerRule_18(
21428 p_application_id => p_application_id
21429 , p_ae_header_id => l_ae_header_id
21430 , p_source_14 => p_source_14
21431 , x_transaction_coa_id => l_adr_transaction_coa_id
21432 , x_accounting_coa_id => l_adr_accounting_coa_id
21433 , x_value_type_code => l_adr_value_type_code
21434 , p_side => 'NA'
21435 );
21436
21437 xla_ae_lines_pkg.set_ccid(
21438 p_code_combination_id => l_ccid
21439 , p_value_type_code => l_adr_value_type_code
21440 , p_transaction_coa_id => l_adr_transaction_coa_id
21441 , p_accounting_coa_id => l_adr_accounting_coa_id
21442 , p_adr_code => 'TRX_DIST_CCID'
21443 , p_adr_type_code => 'S'
21444 , p_component_type => l_component_type
21445 , p_component_code => l_component_code
21446 , p_component_type_code => l_component_type_code
21447 , p_component_appl_id => l_component_appl_id
21448 , p_amb_context_code => l_amb_context_code
21449 , p_side => 'NA'
21450 );
21451
21452
21453 --
21454 --
21455 END IF;
21456 --
21457 -- Bug 4922099
21458 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
21459 (NVL(l_enc_upg_option, 'N') = 'O')
21460 ) AND
21461 (l_bflow_method_code = 'PRIOR_ENTRY')
21462 )
21463 THEN
21464 IF
21465 --
21466 1 = 2
21467 --
21468 THEN
21469 xla_accounting_err_pkg.build_message
21470 (p_appli_s_name => 'XLA'
21471 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
21472 ,p_token_1 => 'LINE_NUMBER'
21473 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
21474 ,p_token_2 => 'LINE_TYPE_NAME'
21475 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
21476 l_component_type
21477 ,l_component_code
21478 ,l_component_type_code
21479 ,l_component_appl_id
21480 ,l_amb_context_code
21481 ,l_entity_code
21485 ,p_value_3 => xla_lookups_pkg.get_meaning(
21482 ,l_event_class_code
21483 )
21484 ,p_token_3 => 'OWNER'
21486 p_lookup_type => 'XLA_OWNER_TYPE'
21487 ,p_lookup_code => l_component_type_code
21488 )
21489 ,p_token_4 => 'PRODUCT_NAME'
21490 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
21491 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
21492 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
21493 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
21494 ,p_ae_header_id => NULL
21495 );
21496
21497 IF (C_LEVEL_ERROR>= g_log_level) THEN
21498 trace
21499 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
21500 ,p_level => C_LEVEL_ERROR
21501 ,p_module => l_log_module);
21502 END IF;
21503 END IF;
21504 END IF;
21505 --
21506 --
21507 ------------------------------------------------------------------------------------------------
21508 -- 4219869 Business Flow
21509 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
21510 -- Prior Entry. Currently, the following code is always generated.
21511 ------------------------------------------------------------------------------------------------
21512 XLA_AE_LINES_PKG.ValidateCurrentLine;
21513
21514 ------------------------------------------------------------------------------------
21515 -- 4219869 Business Flow
21516 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
21517 ------------------------------------------------------------------------------------
21518 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21519
21520 ----------------------------------------------------------------------------------
21521 -- 4219869 Business Flow
21522 -- Update journal entry status -- Need to generate this within IF <condition>
21523 ----------------------------------------------------------------------------------
21524 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21525 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
21526 ,p_balance_type_code => l_balance_type_code
21527 );
21528
21529 -------------------------------------------------------------------------------------------
21530 -- 4262811 - Generate the Accrual Reversal lines
21531 -------------------------------------------------------------------------------------------
21532 BEGIN
21533 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
21534 (g_array_event(p_event_id).array_value_num('header_index'));
21535 IF l_acc_rev_flag IS NULL THEN
21536 l_acc_rev_flag := 'N';
21537 END IF;
21538 EXCEPTION
21539 WHEN OTHERS THEN
21540 l_acc_rev_flag := 'N';
21541 END;
21542 --
21543 IF (l_acc_rev_flag = 'Y') THEN
21544
21545 -- 4645092 ------------------------------------------------------------------------------
21546 -- To allow MPA report to determine if it should generate report process
21547 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
21548 ------------------------------------------------------------------------------------------
21549
21550 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
21551 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
21552 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
21553 -- call ADRs
21554 -- Bug 4922099
21555 --
21556 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21557 (NVL(l_actual_upg_option, 'N') = 'O') OR
21558 (NVL(l_enc_upg_option, 'N') = 'O')
21559 )
21560 THEN
21561 NULL;
21562 --
21563 --
21564
21565 l_ccid := AcctDerRule_18(
21566 p_application_id => p_application_id
21567 , p_ae_header_id => l_ae_header_id
21568 , p_source_14 => p_source_14
21569 , x_transaction_coa_id => l_adr_transaction_coa_id
21570 , x_accounting_coa_id => l_adr_accounting_coa_id
21571 , x_value_type_code => l_adr_value_type_code
21572 , p_side => 'NA'
21573 );
21574
21575 xla_ae_lines_pkg.set_ccid(
21576 p_code_combination_id => l_ccid
21577 , p_value_type_code => l_adr_value_type_code
21578 , p_transaction_coa_id => l_adr_transaction_coa_id
21579 , p_accounting_coa_id => l_adr_accounting_coa_id
21580 , p_adr_code => 'TRX_DIST_CCID'
21581 , p_adr_type_code => 'S'
21582 , p_component_type => l_component_type
21583 , p_component_code => l_component_code
21584 , p_component_type_code => l_component_type_code
21585 , p_component_appl_id => l_component_appl_id
21589
21586 , p_amb_context_code => l_amb_context_code
21587 , p_side => 'NA'
21588 );
21590
21591 --
21592 --
21593 END IF;
21594
21595 --
21596 -- Update the line information that should be overwritten
21597 --
21598 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
21599 p_header_num => 1);
21600 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
21601
21602 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
21603
21604 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
21605 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
21606 END IF;
21607
21608 --
21609 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
21610 --
21611 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
21612 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
21613 ELSE
21614 ---------------------------------------------------------------------------------------------------
21615 -- 4262811a Switch Sign
21616 ---------------------------------------------------------------------------------------------------
21617 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
21618 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21619 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21620 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21621 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21622 -- 5132302
21623 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
21624 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21625
21626 END IF;
21627
21628 -- 4955764
21629 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21630 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
21631
21632
21633 XLA_AE_LINES_PKG.ValidateCurrentLine;
21634 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21635
21636 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21637 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
21638 ,p_balance_type_code => l_balance_type_code);
21639
21640 END IF;
21641
21642 -----------------------------------------------------------------------------------------
21643 -- 4262811 Multiperiod Accounting
21644 -----------------------------------------------------------------------------------------
21645 -- No MPA option is assigned.
21646
21647
21648 END IF;
21649 END IF;
21650 --
21651
21652 --
21653 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21654 trace
21655 (p_msg => 'END of AcctLineType_52'
21656 ,p_level => C_LEVEL_PROCEDURE
21657 ,p_module => l_log_module);
21658 END IF;
21659 --
21660 EXCEPTION
21661 WHEN xla_exceptions_pkg.application_exception THEN
21662 RAISE;
21663 WHEN OTHERS THEN
21664 xla_exceptions_pkg.raise_message
21665 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_52');
21666 END AcctLineType_52;
21667 --
21668
21669 ---------------------------------------
21670 --
21671 -- PRIVATE FUNCTION
21672 -- AcctLineType_53
21673 --
21674 ---------------------------------------
21675 PROCEDURE AcctLineType_53 (
21676 p_application_id IN NUMBER
21677 ,p_event_id IN NUMBER
21678 ,p_calculate_acctd_flag IN VARCHAR2
21679 ,p_calculate_g_l_flag IN VARCHAR2
21680 ,p_actual_flag IN OUT VARCHAR2
21681 ,p_balance_type_code OUT VARCHAR2
21682 ,p_gain_or_loss_ref OUT VARCHAR2
21683
21684 --Transaction Default Receivable Account
21685 , p_source_8 IN NUMBER
21686 --Distribution GL Account
21687 , p_source_10 IN NUMBER
21688 --Distribution Source Type
21689 , p_source_15 IN VARCHAR2
21690 --Receivable Activity Type
21691 , p_source_16 IN VARCHAR2
21692 --Distribution Line Identifier
21693 , p_source_17 IN NUMBER
21694 --Distribution Type
21695 , p_source_18 IN VARCHAR2
21696 --Entered Amount
21697 , p_source_19 IN NUMBER
21698 --Currency Code
21699 , p_source_20 IN VARCHAR2
21700 --Exchange Date
21701 , p_source_21 IN DATE
21702 --Exchange Rate
21703 , p_source_22 IN NUMBER
21704 --Exchange Rate Type
21705 , p_source_23 IN VARCHAR2
21706 --Applied To Document Accounting Amount
21707 , p_source_24 IN NUMBER
21708 --Bill To Customer Account Identifier
21709 , p_source_25 IN NUMBER
21710 --Bill To Customer Site Use Identifier
21711 , p_source_26 IN NUMBER
21712 --SLA Party Type
21713 , p_source_27 IN VARCHAR2
21714 )
21715 IS
21716
21717 l_component_type VARCHAR2(80);
21718 l_component_code VARCHAR2(30);
21722 l_entity_code VARCHAR2(30);
21719 l_component_type_code VARCHAR2(1);
21720 l_component_appl_id INTEGER;
21721 l_amb_context_code VARCHAR2(30);
21723 l_event_class_code VARCHAR2(30);
21724 l_ae_header_id NUMBER;
21725 l_event_type_code VARCHAR2(30);
21726 l_line_definition_code VARCHAR2(30);
21727 l_line_definition_owner_code VARCHAR2(1);
21728 --
21729 -- adr variables
21730 l_segment VARCHAR2(30);
21731 l_ccid NUMBER;
21732 l_adr_transaction_coa_id NUMBER;
21733 l_adr_accounting_coa_id NUMBER;
21734 l_adr_flexfield_segment_code VARCHAR2(30);
21735 l_adr_flex_value_set_id NUMBER;
21736 l_adr_value_type_code VARCHAR2(30);
21737 l_adr_value_combination_id NUMBER;
21738 l_adr_value_segment_code VARCHAR2(30);
21739
21740 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
21741 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
21742 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
21743 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
21744
21745 -- 4262811 Variables ------------------------------------------------------------------------------------------
21746 l_entered_amt_idx NUMBER;
21747 l_accted_amt_idx NUMBER;
21748 l_acc_rev_flag VARCHAR2(1);
21749 l_accrual_line_num NUMBER;
21750 l_tmp_amt NUMBER;
21751 l_acc_rev_natural_side_code VARCHAR2(1);
21752
21753 l_num_entries NUMBER;
21754 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
21755 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
21756 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
21757 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
21758 l_recog_line_1 NUMBER;
21759 l_recog_line_2 NUMBER;
21760
21761 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
21762 l_bflow_applied_to_amt NUMBER; -- 5132302
21763 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
21764
21765 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
21766
21767 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
21768 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
21769
21770 ---------------------------------------------------------------------------------------------------------------
21771
21772
21773 --
21774 -- bulk performance
21775 --
21776 l_balance_type_code VARCHAR2(1);
21777 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
21778 l_log_module VARCHAR2(240);
21779
21780 --
21781 -- Upgrade strategy
21782 --
21783 l_actual_upg_option VARCHAR2(1);
21784 l_enc_upg_option VARCHAR2(1);
21785
21786 --
21787 BEGIN
21788 --
21789 IF g_log_enabled THEN
21790 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_53';
21791 END IF;
21792 --
21793 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21794
21795 trace
21796 (p_msg => 'BEGIN of AcctLineType_53'
21797 ,p_level => C_LEVEL_PROCEDURE
21798 ,p_module => l_log_module);
21799
21800 END IF;
21801 --
21802 l_component_type := 'AMB_JLT';
21803 l_component_code := 'MFAR_ADJ_REC';
21804 l_component_type_code := 'S';
21805 l_component_appl_id := 222;
21806 l_amb_context_code := 'DEFAULT';
21807 l_entity_code := 'ADJUSTMENTS';
21808 l_event_class_code := 'ADJUSTMENT';
21809 l_event_type_code := 'ADJUSTMENT_ALL';
21810 l_line_definition_owner_code := 'S';
21811 l_line_definition_code := 'MFAR_ADJ_ACCRUAL_ACCOUNT';
21812 --
21813 l_balance_type_code := 'A';
21814 l_segment := NULL;
21815 l_ccid := NULL;
21816 l_adr_transaction_coa_id := NULL;
21817 l_adr_accounting_coa_id := NULL;
21818 l_adr_flexfield_segment_code := NULL;
21819 l_adr_flex_value_set_id := NULL;
21820 l_adr_value_type_code := NULL;
21821 l_adr_value_combination_id := NULL;
21822 l_adr_value_segment_code := NULL;
21823
21824 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
21825 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
21826 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
21827 l_budgetary_control_flag := 'N';
21828
21829 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21830 l_bflow_applied_to_amt := NULL; -- 5132302
21831 l_entered_amt_idx := NULL; -- 4262811
21832 l_accted_amt_idx := NULL; -- 4262811
21833 l_acc_rev_flag := NULL; -- 4262811
21834 l_accrual_line_num := NULL; -- 4262811
21835 l_tmp_amt := NULL; -- 4262811
21836 --
21837
21838 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
21839 l_balance_type_code <> 'B' THEN
21840 IF NVL(p_source_15,'
21841 ') = 'TAX' OR
21842 NVL(p_source_15,'
21843 ') = 'DEFERRED_TAX' OR
21844 NVL(p_source_15,'
21845 ') = 'FINCHRG' OR
21846 (NVL(p_source_15,'
21847 ') = 'ADJ' AND
21848 NVL(p_source_16,'
21852 NVL(p_source_16,'
21849 ') = 'ENDORSEMENT') OR
21850 (NVL(p_source_15,'
21851 ') = 'ADJ' AND
21853 ') <> 'ENDORSEMENT')
21854 THEN
21855
21856 --
21857 XLA_AE_LINES_PKG.SetNewLine;
21858
21859 p_balance_type_code := l_balance_type_code;
21860 -- set the flag so later we will know whether the gain loss line needs to be created
21861
21862 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
21863 p_actual_flag :='A';
21864 END IF;
21865
21866 --
21867 -- bulk performance
21868 --
21869 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
21870 p_header_num => 0); -- 4262811
21871 --
21872 -- set accounting line options
21873 --
21874 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
21875 p_natural_side_code => 'D'
21876 , p_gain_or_loss_flag => 'N'
21877 , p_gl_transfer_mode_code => 'S'
21878 , p_acct_entry_type_code => 'A'
21879 , p_switch_side_flag => 'Y'
21880 , p_merge_duplicate_code => 'A'
21881 );
21882 --
21883 l_acc_rev_natural_side_code := 'C'; -- 4262811
21884 --
21885 --
21886 -- set accounting line type info
21887 --
21888 xla_ae_lines_pkg.SetAcctLineType
21889 (p_component_type => l_component_type
21890 ,p_event_type_code => l_event_type_code
21891 ,p_line_definition_owner_code => l_line_definition_owner_code
21892 ,p_line_definition_code => l_line_definition_code
21893 ,p_accounting_line_code => l_component_code
21894 ,p_accounting_line_type_code => l_component_type_code
21895 ,p_accounting_line_appl_id => l_component_appl_id
21896 ,p_amb_context_code => l_amb_context_code
21897 ,p_entity_code => l_entity_code
21898 ,p_event_class_code => l_event_class_code);
21899 --
21900 -- set accounting class
21901 --
21902 xla_ae_lines_pkg.SetAcctClass(
21903 p_accounting_class_code => 'RECEIVABLE'
21904 , p_ae_header_id => l_ae_header_id
21905 );
21906
21907 --
21908 -- set rounding class
21909 --
21910 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
21911 'RECEIVABLE';
21912
21913 --
21914 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
21915 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
21916 --
21917 -- bulk performance
21918 --
21919 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
21920
21921 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
21922 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
21923
21924 -- 4955764
21925 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21926 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
21927
21928 -- 4458381 Public Sector Enh
21929
21930 --
21931 -- set accounting attributes for the line type
21932 --
21933 l_entered_amt_idx := 3;
21934 l_accted_amt_idx := 8;
21935 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21936 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
21937 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
21938 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
21939 l_rec_acct_attrs.array_char_value(2) := p_source_18;
21940 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
21941 l_rec_acct_attrs.array_num_value(3) := p_source_19;
21942 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
21943 l_rec_acct_attrs.array_char_value(4) := p_source_20;
21944 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
21945 l_rec_acct_attrs.array_date_value(5) := p_source_21;
21946 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
21947 l_rec_acct_attrs.array_num_value(6) := p_source_22;
21948 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
21949 l_rec_acct_attrs.array_char_value(7) := p_source_23;
21950 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
21951 l_rec_acct_attrs.array_num_value(8) := p_source_24;
21952 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
21953 l_rec_acct_attrs.array_num_value(9) := p_source_25;
21954 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
21955 l_rec_acct_attrs.array_num_value(10) := p_source_26;
21956 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
21957 l_rec_acct_attrs.array_char_value(11) := p_source_27;
21958
21959 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
21960 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
21961
21962 ---------------------------------------------------------------------------------------------------------------
21963 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
21964 ---------------------------------------------------------------------------------------------------------------
21965 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
21969
21966
21967 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21968 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21970 IF xla_accounting_cache_pkg.GetValueChar
21971 (p_source_code => 'LEDGER_CATEGORY_CODE'
21972 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
21973 AND l_bflow_method_code = 'PRIOR_ENTRY'
21974 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
21975 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
21976 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
21977 )
21978 THEN
21979 xla_ae_lines_pkg.BflowUpgEntry
21980 (p_business_method_code => l_bflow_method_code
21981 ,p_business_class_code => l_bflow_class_code
21982 ,p_balance_type => l_balance_type_code);
21983 ELSE
21984 NULL;
21985 -- No business flow processing for business flow method of NONE.
21986 END IF;
21987
21988 --
21989 -- call analytical criteria
21990 --
21991
21992 --
21993 -- call description
21994 --
21995
21996 xla_ae_lines_pkg.SetLineDescription(
21997 p_ae_header_id => l_ae_header_id
21998 ,p_description => Description_1 (
21999 p_application_id => p_application_id
22000 , p_ae_header_id => l_ae_header_id
22001 )
22002 );
22003
22004
22005 --
22006 -- call ADRs
22007 -- Bug 4922099
22008 --
22009 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22010 (NVL(l_actual_upg_option, 'N') = 'O') OR
22011 (NVL(l_enc_upg_option, 'N') = 'O')
22012 )
22013 THEN
22014 NULL;
22015 --
22016 --
22017
22018 l_ccid := AcctDerRule_11(
22019 p_application_id => p_application_id
22020 , p_ae_header_id => l_ae_header_id
22021 , p_source_10 => p_source_10
22022 , x_transaction_coa_id => l_adr_transaction_coa_id
22023 , x_accounting_coa_id => l_adr_accounting_coa_id
22024 , x_value_type_code => l_adr_value_type_code
22025 , p_side => 'NA'
22026 );
22027
22028 xla_ae_lines_pkg.set_ccid(
22029 p_code_combination_id => l_ccid
22030 , p_value_type_code => l_adr_value_type_code
22031 , p_transaction_coa_id => l_adr_transaction_coa_id
22032 , p_accounting_coa_id => l_adr_accounting_coa_id
22033 , p_adr_code => 'DIST_CCID'
22034 , p_adr_type_code => 'S'
22035 , p_component_type => l_component_type
22036 , p_component_code => l_component_code
22037 , p_component_type_code => l_component_type_code
22038 , p_component_appl_id => l_component_appl_id
22039 , p_amb_context_code => l_amb_context_code
22040 , p_side => 'NA'
22041 );
22042
22043
22044 l_segment := AcctDerRule_9(
22045 p_application_id => p_application_id
22046 , p_ae_header_id => l_ae_header_id
22047 , p_source_8 => p_source_8
22048 , x_transaction_coa_id => l_adr_transaction_coa_id
22049 , x_accounting_coa_id => l_adr_accounting_coa_id
22050 , x_flexfield_segment_code => l_adr_flexfield_segment_code
22051 , x_flex_value_set_id => l_adr_flex_value_set_id
22052 , x_value_type_code => l_adr_value_type_code
22053 , x_value_combination_id => l_adr_value_combination_id
22054 , x_value_segment_code => l_adr_value_segment_code
22055 , p_side => 'NA'
22056 , p_override_seg_flag => 'Y'
22057 );
22058
22059 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
22060
22061 xla_ae_lines_pkg.set_segment(
22062 p_to_segment_code => 'GL_ACCOUNT'
22063 , p_segment_value => l_segment
22064 , p_from_segment_code => l_adr_value_segment_code
22065 , p_from_combination_id => l_adr_value_combination_id
22066 , p_value_type_code => l_adr_value_type_code
22067 , p_transaction_coa_id => l_adr_transaction_coa_id
22068 , p_accounting_coa_id => l_adr_accounting_coa_id
22069 , p_flexfield_segment_code => l_adr_flexfield_segment_code
22070 , p_flex_value_set_id => l_adr_flex_value_set_id
22071 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
22072 , p_adr_type_code => 'S'
22073 , p_component_type => l_component_type
22074 , p_component_code => l_component_code
22075 , p_component_type_code => l_component_type_code
22076 , p_component_appl_id => l_component_appl_id
22077 , p_amb_context_code => l_amb_context_code
22078 , p_entity_code => 'ADJUSTMENTS'
22079 , p_event_class_code => 'ADJUSTMENT'
22080 , p_side => 'NA'
22081 );
22082
22083 END IF;
22084
22085 --
22086 --
22087 END IF;
22088 --
22089 -- Bug 4922099
22090 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
22091 (NVL(l_enc_upg_option, 'N') = 'O')
22092 ) AND
22093 (l_bflow_method_code = 'PRIOR_ENTRY')
22097 --
22094 )
22095 THEN
22096 IF
22098 1 = 2
22099 --
22100 THEN
22101 xla_accounting_err_pkg.build_message
22102 (p_appli_s_name => 'XLA'
22103 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22104 ,p_token_1 => 'LINE_NUMBER'
22105 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
22106 ,p_token_2 => 'LINE_TYPE_NAME'
22107 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
22108 l_component_type
22109 ,l_component_code
22110 ,l_component_type_code
22111 ,l_component_appl_id
22112 ,l_amb_context_code
22113 ,l_entity_code
22114 ,l_event_class_code
22115 )
22116 ,p_token_3 => 'OWNER'
22117 ,p_value_3 => xla_lookups_pkg.get_meaning(
22118 p_lookup_type => 'XLA_OWNER_TYPE'
22119 ,p_lookup_code => l_component_type_code
22120 )
22121 ,p_token_4 => 'PRODUCT_NAME'
22122 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
22123 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
22124 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
22125 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
22126 ,p_ae_header_id => NULL
22127 );
22128
22129 IF (C_LEVEL_ERROR>= g_log_level) THEN
22130 trace
22131 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22132 ,p_level => C_LEVEL_ERROR
22133 ,p_module => l_log_module);
22134 END IF;
22135 END IF;
22136 END IF;
22137 --
22138 --
22139 ------------------------------------------------------------------------------------------------
22140 -- 4219869 Business Flow
22141 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
22142 -- Prior Entry. Currently, the following code is always generated.
22143 ------------------------------------------------------------------------------------------------
22144 XLA_AE_LINES_PKG.ValidateCurrentLine;
22145
22146 ------------------------------------------------------------------------------------
22147 -- 4219869 Business Flow
22148 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
22149 ------------------------------------------------------------------------------------
22150 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22151
22152 ----------------------------------------------------------------------------------
22153 -- 4219869 Business Flow
22154 -- Update journal entry status -- Need to generate this within IF <condition>
22155 ----------------------------------------------------------------------------------
22156 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22157 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
22158 ,p_balance_type_code => l_balance_type_code
22159 );
22160
22161 -------------------------------------------------------------------------------------------
22162 -- 4262811 - Generate the Accrual Reversal lines
22163 -------------------------------------------------------------------------------------------
22164 BEGIN
22165 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
22166 (g_array_event(p_event_id).array_value_num('header_index'));
22167 IF l_acc_rev_flag IS NULL THEN
22168 l_acc_rev_flag := 'N';
22169 END IF;
22170 EXCEPTION
22171 WHEN OTHERS THEN
22172 l_acc_rev_flag := 'N';
22173 END;
22174 --
22175 IF (l_acc_rev_flag = 'Y') THEN
22176
22177 -- 4645092 ------------------------------------------------------------------------------
22178 -- To allow MPA report to determine if it should generate report process
22179 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
22180 ------------------------------------------------------------------------------------------
22181
22182 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
22183 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
22184 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
22185 -- call ADRs
22186 -- Bug 4922099
22187 --
22188 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22189 (NVL(l_actual_upg_option, 'N') = 'O') OR
22190 (NVL(l_enc_upg_option, 'N') = 'O')
22194 --
22191 )
22192 THEN
22193 NULL;
22195 --
22196
22197 l_ccid := AcctDerRule_11(
22198 p_application_id => p_application_id
22199 , p_ae_header_id => l_ae_header_id
22200 , p_source_10 => p_source_10
22201 , x_transaction_coa_id => l_adr_transaction_coa_id
22202 , x_accounting_coa_id => l_adr_accounting_coa_id
22203 , x_value_type_code => l_adr_value_type_code
22204 , p_side => 'NA'
22205 );
22206
22207 xla_ae_lines_pkg.set_ccid(
22208 p_code_combination_id => l_ccid
22209 , p_value_type_code => l_adr_value_type_code
22210 , p_transaction_coa_id => l_adr_transaction_coa_id
22211 , p_accounting_coa_id => l_adr_accounting_coa_id
22212 , p_adr_code => 'DIST_CCID'
22213 , p_adr_type_code => 'S'
22214 , p_component_type => l_component_type
22215 , p_component_code => l_component_code
22216 , p_component_type_code => l_component_type_code
22217 , p_component_appl_id => l_component_appl_id
22218 , p_amb_context_code => l_amb_context_code
22219 , p_side => 'NA'
22220 );
22221
22222
22223 l_segment := AcctDerRule_9(
22224 p_application_id => p_application_id
22225 , p_ae_header_id => l_ae_header_id
22226 , p_source_8 => p_source_8
22227 , x_transaction_coa_id => l_adr_transaction_coa_id
22228 , x_accounting_coa_id => l_adr_accounting_coa_id
22229 , x_flexfield_segment_code => l_adr_flexfield_segment_code
22230 , x_flex_value_set_id => l_adr_flex_value_set_id
22231 , x_value_type_code => l_adr_value_type_code
22232 , x_value_combination_id => l_adr_value_combination_id
22233 , x_value_segment_code => l_adr_value_segment_code
22234 , p_side => 'NA'
22235 , p_override_seg_flag => 'Y'
22236 );
22237
22238 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
22239
22240 xla_ae_lines_pkg.set_segment(
22241 p_to_segment_code => 'GL_ACCOUNT'
22242 , p_segment_value => l_segment
22243 , p_from_segment_code => l_adr_value_segment_code
22244 , p_from_combination_id => l_adr_value_combination_id
22245 , p_value_type_code => l_adr_value_type_code
22246 , p_transaction_coa_id => l_adr_transaction_coa_id
22247 , p_accounting_coa_id => l_adr_accounting_coa_id
22248 , p_flexfield_segment_code => l_adr_flexfield_segment_code
22249 , p_flex_value_set_id => l_adr_flex_value_set_id
22250 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
22251 , p_adr_type_code => 'S'
22252 , p_component_type => l_component_type
22253 , p_component_code => l_component_code
22254 , p_component_type_code => l_component_type_code
22255 , p_component_appl_id => l_component_appl_id
22256 , p_amb_context_code => l_amb_context_code
22257 , p_entity_code => 'ADJUSTMENTS'
22258 , p_event_class_code => 'ADJUSTMENT'
22259 , p_side => 'NA'
22260 );
22261
22262 END IF;
22263
22264 --
22265 --
22266 END IF;
22267
22268 --
22269 -- Update the line information that should be overwritten
22270 --
22271 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
22272 p_header_num => 1);
22273 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
22274
22275 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
22276
22277 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
22278 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
22279 END IF;
22280
22281 --
22282 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
22283 --
22284 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
22285 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
22286 ELSE
22287 ---------------------------------------------------------------------------------------------------
22288 -- 4262811a Switch Sign
22289 ---------------------------------------------------------------------------------------------------
22290 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
22291 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22292 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22293 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22294 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22295 -- 5132302
22296 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
22297 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22298
22299 END IF;
22300
22301 -- 4955764
22302 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22303 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
22304
22305
22306 XLA_AE_LINES_PKG.ValidateCurrentLine;
22307 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22308
22309 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22310 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
22311 ,p_balance_type_code => l_balance_type_code);
22312
22313 END IF;
22314
22315 -----------------------------------------------------------------------------------------
22316 -- 4262811 Multiperiod Accounting
22317 -----------------------------------------------------------------------------------------
22318 -- No MPA option is assigned.
22319
22320
22321 END IF;
22322 END IF;
22323 --
22324
22325 --
22326 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22327 trace
22328 (p_msg => 'END of AcctLineType_53'
22329 ,p_level => C_LEVEL_PROCEDURE
22330 ,p_module => l_log_module);
22331 END IF;
22332 --
22333 EXCEPTION
22334 WHEN xla_exceptions_pkg.application_exception THEN
22335 RAISE;
22336 WHEN OTHERS THEN
22337 xla_exceptions_pkg.raise_message
22338 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_53');
22339 END AcctLineType_53;
22340 --
22341
22342 ---------------------------------------
22343 --
22344 -- PRIVATE FUNCTION
22345 -- AcctLineType_54
22346 --
22347 ---------------------------------------
22348 PROCEDURE AcctLineType_54 (
22349 p_application_id IN NUMBER
22350 ,p_event_id IN NUMBER
22351 ,p_calculate_acctd_flag IN VARCHAR2
22352 ,p_calculate_g_l_flag IN VARCHAR2
22353 ,p_actual_flag IN OUT VARCHAR2
22354 ,p_balance_type_code OUT VARCHAR2
22355 ,p_gain_or_loss_ref OUT VARCHAR2
22356
22357 --Credit Memo Default Receivable Account
22358 , p_source_2 IN NUMBER
22359 --Credit Memo Distribution GL Account
22360 , p_source_9 IN NUMBER
22361 --SLA Party Type
22362 , p_source_27 IN VARCHAR2
22363 --Credit Memo Distribution Identifier
22364 , p_source_37 IN NUMBER
22365 --Credit memo distributions type
22366 , p_source_38 IN VARCHAR2
22367 --Credit Memo Currency Code
22368 , p_source_39 IN VARCHAR2
22369 --Credit Memo Exchange Date
22370 , p_source_40 IN DATE
22371 --Credit Memo Exchange Rate
22372 , p_source_41 IN NUMBER
22373 --Credit Memo Exchange Rate Type
22374 , p_source_42 IN VARCHAR2
22375 --Gain Loss Reference
22376 , p_source_43 IN VARCHAR2
22377 --Credit Memo Accounting Amount
22378 , p_source_44 IN NUMBER
22379 --Credit Memo Bill To Customer Account Identifier
22380 , p_source_45 IN NUMBER
22381 --Credit Memo Bill To Customer Site Use Identifier
22382 , p_source_46 IN NUMBER
22383 --Credit Memo Tax Line Identifier
22384 , p_source_47 IN NUMBER
22385 --Credit Memo Distribution Account Class
22386 , p_source_48 IN VARCHAR2
22387 --Credit Memo Distribution Entered Amount
22388 , p_source_49 IN NUMBER
22389 --Credit Memo Invoicing Rule
22390 , p_source_52 IN NUMBER
22391 )
22392 IS
22393
22394 l_component_type VARCHAR2(80);
22395 l_component_code VARCHAR2(30);
22396 l_component_type_code VARCHAR2(1);
22397 l_component_appl_id INTEGER;
22398 l_amb_context_code VARCHAR2(30);
22399 l_entity_code VARCHAR2(30);
22400 l_event_class_code VARCHAR2(30);
22401 l_ae_header_id NUMBER;
22402 l_event_type_code VARCHAR2(30);
22403 l_line_definition_code VARCHAR2(30);
22404 l_line_definition_owner_code VARCHAR2(1);
22405 --
22406 -- adr variables
22407 l_segment VARCHAR2(30);
22408 l_ccid NUMBER;
22409 l_adr_transaction_coa_id NUMBER;
22410 l_adr_accounting_coa_id NUMBER;
22411 l_adr_flexfield_segment_code VARCHAR2(30);
22412 l_adr_flex_value_set_id NUMBER;
22413 l_adr_value_type_code VARCHAR2(30);
22414 l_adr_value_combination_id NUMBER;
22415 l_adr_value_segment_code VARCHAR2(30);
22416
22417 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
22418 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
22419 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
22420 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
22421
22422 -- 4262811 Variables ------------------------------------------------------------------------------------------
22423 l_entered_amt_idx NUMBER;
22424 l_accted_amt_idx NUMBER;
22425 l_acc_rev_flag VARCHAR2(1);
22426 l_accrual_line_num NUMBER;
22427 l_tmp_amt NUMBER;
22428 l_acc_rev_natural_side_code VARCHAR2(1);
22429
22430 l_num_entries NUMBER;
22431 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
22432 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
22433 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
22434 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
22435 l_recog_line_1 NUMBER;
22436 l_recog_line_2 NUMBER;
22437
22438 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
22439 l_bflow_applied_to_amt NUMBER; -- 5132302
22440 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
22441
22442 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
22443
22444 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
22445 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
22446
22447 ---------------------------------------------------------------------------------------------------------------
22448
22449
22450 --
22451 -- bulk performance
22452 --
22453 l_balance_type_code VARCHAR2(1);
22454 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
22455 l_log_module VARCHAR2(240);
22456
22457 --
22458 -- Upgrade strategy
22459 --
22460 l_actual_upg_option VARCHAR2(1);
22461 l_enc_upg_option VARCHAR2(1);
22462
22463 --
22464 BEGIN
22465 --
22466 IF g_log_enabled THEN
22467 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_54';
22468 END IF;
22469 --
22470 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22471
22472 trace
22473 (p_msg => 'BEGIN of AcctLineType_54'
22474 ,p_level => C_LEVEL_PROCEDURE
22475 ,p_module => l_log_module);
22476
22477 END IF;
22478 --
22479 l_component_type := 'AMB_JLT';
22480 l_component_code := 'MFAR_CM_REC';
22481 l_component_type_code := 'S';
22482 l_component_appl_id := 222;
22483 l_amb_context_code := 'DEFAULT';
22484 l_entity_code := 'TRANSACTIONS';
22485 l_event_class_code := 'CREDIT_MEMO';
22486 l_event_type_code := 'CREDIT_MEMO_ALL';
22487 l_line_definition_owner_code := 'S';
22488 l_line_definition_code := 'MFAR_CM_ACCRUAL_ACCOUNT';
22489 --
22490 l_balance_type_code := 'A';
22491 l_segment := NULL;
22492 l_ccid := NULL;
22493 l_adr_transaction_coa_id := NULL;
22494 l_adr_accounting_coa_id := NULL;
22495 l_adr_flexfield_segment_code := NULL;
22496 l_adr_flex_value_set_id := NULL;
22497 l_adr_value_type_code := NULL;
22498 l_adr_value_combination_id := NULL;
22499 l_adr_value_segment_code := NULL;
22500
22501 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
22502 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
22503 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
22504 l_budgetary_control_flag := 'N';
22505
22506 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22507 l_bflow_applied_to_amt := NULL; -- 5132302
22508 l_entered_amt_idx := NULL; -- 4262811
22509 l_accted_amt_idx := NULL; -- 4262811
22510 l_acc_rev_flag := NULL; -- 4262811
22511 l_accrual_line_num := NULL; -- 4262811
22512 l_tmp_amt := NULL; -- 4262811
22513 --
22514
22515 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
22516 l_balance_type_code <> 'B' THEN
22517 IF (p_source_52 IS NULL ) AND
22518 (NVL(p_source_48,'
22519 ') = 'REV' OR
22520 NVL(p_source_48,'
22521 ') = 'TAX' OR
22522 NVL(p_source_48,'
22523 ') = 'FREIGHT' OR
22524 NVL(p_source_48,'
22525 ') = 'ROUND' OR
22526 NVL(p_source_48,'
22527 ') = 'CHARGES')
22528 THEN
22529
22530 --
22531 XLA_AE_LINES_PKG.SetNewLine;
22532
22533 p_balance_type_code := l_balance_type_code;
22534 -- set the flag so later we will know whether the gain loss line needs to be created
22535
22536 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
22537 p_actual_flag :='A';
22538 END IF;
22539
22540 --
22541 -- bulk performance
22542 --
22543 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
22544 p_header_num => 0); -- 4262811
22545 --
22546 -- set accounting line options
22547 --
22548 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
22549 p_natural_side_code => 'D'
22550 , p_gain_or_loss_flag => 'N'
22551 , p_gl_transfer_mode_code => 'S'
22552 , p_acct_entry_type_code => 'A'
22553 , p_switch_side_flag => 'Y'
22554 , p_merge_duplicate_code => 'A'
22555 );
22556 --
22557 l_acc_rev_natural_side_code := 'C'; -- 4262811
22558 --
22559 --
22560 -- set accounting line type info
22561 --
22562 xla_ae_lines_pkg.SetAcctLineType
22563 (p_component_type => l_component_type
22564 ,p_event_type_code => l_event_type_code
22565 ,p_line_definition_owner_code => l_line_definition_owner_code
22566 ,p_line_definition_code => l_line_definition_code
22567 ,p_accounting_line_code => l_component_code
22568 ,p_accounting_line_type_code => l_component_type_code
22569 ,p_accounting_line_appl_id => l_component_appl_id
22570 ,p_amb_context_code => l_amb_context_code
22571 ,p_entity_code => l_entity_code
22572 ,p_event_class_code => l_event_class_code);
22573 --
22574 -- set accounting class
22575 --
22576 xla_ae_lines_pkg.SetAcctClass(
22577 p_accounting_class_code => 'RECEIVABLE'
22578 , p_ae_header_id => l_ae_header_id
22579 );
22580
22581 --
22582 -- set rounding class
22583 --
22584 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
22585 'RECEIVABLE';
22586
22587 --
22588 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
22589 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
22590 --
22591 -- bulk performance
22592 --
22593 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
22594
22595 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
22596 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
22597
22598 -- 4955764
22599 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22600 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
22601
22602 -- 4458381 Public Sector Enh
22603
22604 --
22605 -- set accounting attributes for the line type
22606 --
22607 l_entered_amt_idx := 3;
22608 l_accted_amt_idx := 9;
22609 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22610 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
22611 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_37);
22612 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
22613 l_rec_acct_attrs.array_char_value(2) := p_source_38;
22614 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
22615 l_rec_acct_attrs.array_num_value(3) := p_source_49;
22616 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
22617 l_rec_acct_attrs.array_char_value(4) := p_source_39;
22618 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
22619 l_rec_acct_attrs.array_date_value(5) := p_source_40;
22620 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
22621 l_rec_acct_attrs.array_num_value(6) := p_source_41;
22622 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
22623 l_rec_acct_attrs.array_char_value(7) := p_source_42;
22624 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
22625 l_rec_acct_attrs.array_char_value(8) := p_source_43;
22626 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
22627 l_rec_acct_attrs.array_num_value(9) := p_source_44;
22628 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
22629 l_rec_acct_attrs.array_num_value(10) := p_source_45;
22630 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
22631 l_rec_acct_attrs.array_num_value(11) := p_source_46;
22632 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
22633 l_rec_acct_attrs.array_char_value(12) := p_source_27;
22634 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
22635 l_rec_acct_attrs.array_num_value(13) := p_source_47;
22636
22637 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
22638 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
22639
22640 ---------------------------------------------------------------------------------------------------------------
22641 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
22642 ---------------------------------------------------------------------------------------------------------------
22643 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
22644
22645 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22646 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22647
22648 IF xla_accounting_cache_pkg.GetValueChar
22649 (p_source_code => 'LEDGER_CATEGORY_CODE'
22650 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
22651 AND l_bflow_method_code = 'PRIOR_ENTRY'
22652 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
22653 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
22654 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
22655 )
22656 THEN
22657 xla_ae_lines_pkg.BflowUpgEntry
22658 (p_business_method_code => l_bflow_method_code
22659 ,p_business_class_code => l_bflow_class_code
22660 ,p_balance_type => l_balance_type_code);
22661 ELSE
22662 NULL;
22663 -- No business flow processing for business flow method of NONE.
22664 END IF;
22665
22666 --
22667 -- call analytical criteria
22668 --
22669
22670 --
22671 -- call description
22672 --
22673
22674 xla_ae_lines_pkg.SetLineDescription(
22675 p_ae_header_id => l_ae_header_id
22676 ,p_description => Description_1 (
22677 p_application_id => p_application_id
22678 , p_ae_header_id => l_ae_header_id
22679 )
22680 );
22681
22682
22683 --
22684 -- call ADRs
22685 -- Bug 4922099
22686 --
22687 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22688 (NVL(l_actual_upg_option, 'N') = 'O') OR
22689 (NVL(l_enc_upg_option, 'N') = 'O')
22690 )
22691 THEN
22692 NULL;
22693 --
22694 --
22695
22696 l_ccid := AcctDerRule_10(
22697 p_application_id => p_application_id
22698 , p_ae_header_id => l_ae_header_id
22699 , p_source_9 => p_source_9
22700 , x_transaction_coa_id => l_adr_transaction_coa_id
22701 , x_accounting_coa_id => l_adr_accounting_coa_id
22702 , x_value_type_code => l_adr_value_type_code
22703 , p_side => 'NA'
22704 );
22705
22706 xla_ae_lines_pkg.set_ccid(
22707 p_code_combination_id => l_ccid
22708 , p_value_type_code => l_adr_value_type_code
22709 , p_transaction_coa_id => l_adr_transaction_coa_id
22710 , p_accounting_coa_id => l_adr_accounting_coa_id
22711 , p_adr_code => 'CM_DIST_CCID'
22712 , p_adr_type_code => 'S'
22713 , p_component_type => l_component_type
22714 , p_component_code => l_component_code
22715 , p_component_type_code => l_component_type_code
22716 , p_component_appl_id => l_component_appl_id
22717 , p_amb_context_code => l_amb_context_code
22718 , p_side => 'NA'
22719 );
22720
22721
22722 l_segment := AcctDerRule_3(
22723 p_application_id => p_application_id
22724 , p_ae_header_id => l_ae_header_id
22725 , p_source_2 => p_source_2
22726 , x_transaction_coa_id => l_adr_transaction_coa_id
22727 , x_accounting_coa_id => l_adr_accounting_coa_id
22728 , x_flexfield_segment_code => l_adr_flexfield_segment_code
22729 , x_flex_value_set_id => l_adr_flex_value_set_id
22730 , x_value_type_code => l_adr_value_type_code
22731 , x_value_combination_id => l_adr_value_combination_id
22732 , x_value_segment_code => l_adr_value_segment_code
22733 , p_side => 'NA'
22734 , p_override_seg_flag => 'Y'
22735 );
22736
22737 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
22738
22739 xla_ae_lines_pkg.set_segment(
22740 p_to_segment_code => 'GL_ACCOUNT'
22741 , p_segment_value => l_segment
22742 , p_from_segment_code => l_adr_value_segment_code
22743 , p_from_combination_id => l_adr_value_combination_id
22744 , p_value_type_code => l_adr_value_type_code
22745 , p_transaction_coa_id => l_adr_transaction_coa_id
22746 , p_accounting_coa_id => l_adr_accounting_coa_id
22747 , p_flexfield_segment_code => l_adr_flexfield_segment_code
22748 , p_flex_value_set_id => l_adr_flex_value_set_id
22752 , p_component_code => l_component_code
22749 , p_adr_code => 'MFAR_CM_NATURAL_SEGMENT'
22750 , p_adr_type_code => 'S'
22751 , p_component_type => l_component_type
22753 , p_component_type_code => l_component_type_code
22754 , p_component_appl_id => l_component_appl_id
22755 , p_amb_context_code => l_amb_context_code
22756 , p_entity_code => 'TRANSACTIONS'
22757 , p_event_class_code => 'CREDIT_MEMO'
22758 , p_side => 'NA'
22759 );
22760
22761 END IF;
22762
22763 --
22764 --
22765 END IF;
22766 --
22767 -- Bug 4922099
22768 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
22769 (NVL(l_enc_upg_option, 'N') = 'O')
22770 ) AND
22771 (l_bflow_method_code = 'PRIOR_ENTRY')
22772 )
22773 THEN
22774 IF
22775 --
22776 1 = 2
22777 --
22778 THEN
22779 xla_accounting_err_pkg.build_message
22780 (p_appli_s_name => 'XLA'
22781 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22782 ,p_token_1 => 'LINE_NUMBER'
22783 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
22784 ,p_token_2 => 'LINE_TYPE_NAME'
22785 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
22786 l_component_type
22787 ,l_component_code
22788 ,l_component_type_code
22789 ,l_component_appl_id
22790 ,l_amb_context_code
22791 ,l_entity_code
22792 ,l_event_class_code
22793 )
22794 ,p_token_3 => 'OWNER'
22795 ,p_value_3 => xla_lookups_pkg.get_meaning(
22796 p_lookup_type => 'XLA_OWNER_TYPE'
22797 ,p_lookup_code => l_component_type_code
22798 )
22799 ,p_token_4 => 'PRODUCT_NAME'
22800 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
22801 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
22802 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
22803 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
22804 ,p_ae_header_id => NULL
22805 );
22806
22807 IF (C_LEVEL_ERROR>= g_log_level) THEN
22808 trace
22809 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22810 ,p_level => C_LEVEL_ERROR
22811 ,p_module => l_log_module);
22812 END IF;
22813 END IF;
22814 END IF;
22815 --
22816 --
22817 ------------------------------------------------------------------------------------------------
22818 -- 4219869 Business Flow
22819 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
22820 -- Prior Entry. Currently, the following code is always generated.
22821 ------------------------------------------------------------------------------------------------
22822 XLA_AE_LINES_PKG.ValidateCurrentLine;
22823
22824 ------------------------------------------------------------------------------------
22825 -- 4219869 Business Flow
22826 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
22827 ------------------------------------------------------------------------------------
22828 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22829
22830 ----------------------------------------------------------------------------------
22831 -- 4219869 Business Flow
22832 -- Update journal entry status -- Need to generate this within IF <condition>
22833 ----------------------------------------------------------------------------------
22834 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22835 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
22836 ,p_balance_type_code => l_balance_type_code
22837 );
22838
22839 -------------------------------------------------------------------------------------------
22840 -- 4262811 - Generate the Accrual Reversal lines
22841 -------------------------------------------------------------------------------------------
22842 BEGIN
22843 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
22844 (g_array_event(p_event_id).array_value_num('header_index'));
22845 IF l_acc_rev_flag IS NULL THEN
22846 l_acc_rev_flag := 'N';
22847 END IF;
22848 EXCEPTION
22849 WHEN OTHERS THEN
22850 l_acc_rev_flag := 'N';
22851 END;
22852 --
22853 IF (l_acc_rev_flag = 'Y') THEN
22854
22855 -- 4645092 ------------------------------------------------------------------------------
22856 -- To allow MPA report to determine if it should generate report process
22857 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
22858 ------------------------------------------------------------------------------------------
22859
22860 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
22861 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
22862 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
22863 -- call ADRs
22864 -- Bug 4922099
22865 --
22866 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22867 (NVL(l_actual_upg_option, 'N') = 'O') OR
22868 (NVL(l_enc_upg_option, 'N') = 'O')
22869 )
22870 THEN
22871 NULL;
22872 --
22873 --
22874
22875 l_ccid := AcctDerRule_10(
22876 p_application_id => p_application_id
22877 , p_ae_header_id => l_ae_header_id
22878 , p_source_9 => p_source_9
22879 , x_transaction_coa_id => l_adr_transaction_coa_id
22880 , x_accounting_coa_id => l_adr_accounting_coa_id
22881 , x_value_type_code => l_adr_value_type_code
22882 , p_side => 'NA'
22883 );
22884
22885 xla_ae_lines_pkg.set_ccid(
22886 p_code_combination_id => l_ccid
22887 , p_value_type_code => l_adr_value_type_code
22888 , p_transaction_coa_id => l_adr_transaction_coa_id
22889 , p_accounting_coa_id => l_adr_accounting_coa_id
22890 , p_adr_code => 'CM_DIST_CCID'
22891 , p_adr_type_code => 'S'
22892 , p_component_type => l_component_type
22893 , p_component_code => l_component_code
22894 , p_component_type_code => l_component_type_code
22895 , p_component_appl_id => l_component_appl_id
22896 , p_amb_context_code => l_amb_context_code
22897 , p_side => 'NA'
22898 );
22899
22900
22901 l_segment := AcctDerRule_3(
22902 p_application_id => p_application_id
22903 , p_ae_header_id => l_ae_header_id
22904 , p_source_2 => p_source_2
22905 , x_transaction_coa_id => l_adr_transaction_coa_id
22906 , x_accounting_coa_id => l_adr_accounting_coa_id
22907 , x_flexfield_segment_code => l_adr_flexfield_segment_code
22908 , x_flex_value_set_id => l_adr_flex_value_set_id
22909 , x_value_type_code => l_adr_value_type_code
22910 , x_value_combination_id => l_adr_value_combination_id
22911 , x_value_segment_code => l_adr_value_segment_code
22912 , p_side => 'NA'
22913 , p_override_seg_flag => 'Y'
22914 );
22915
22916 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
22917
22918 xla_ae_lines_pkg.set_segment(
22919 p_to_segment_code => 'GL_ACCOUNT'
22920 , p_segment_value => l_segment
22921 , p_from_segment_code => l_adr_value_segment_code
22922 , p_from_combination_id => l_adr_value_combination_id
22923 , p_value_type_code => l_adr_value_type_code
22924 , p_transaction_coa_id => l_adr_transaction_coa_id
22925 , p_accounting_coa_id => l_adr_accounting_coa_id
22926 , p_flexfield_segment_code => l_adr_flexfield_segment_code
22927 , p_flex_value_set_id => l_adr_flex_value_set_id
22928 , p_adr_code => 'MFAR_CM_NATURAL_SEGMENT'
22929 , p_adr_type_code => 'S'
22930 , p_component_type => l_component_type
22931 , p_component_code => l_component_code
22932 , p_component_type_code => l_component_type_code
22933 , p_component_appl_id => l_component_appl_id
22934 , p_amb_context_code => l_amb_context_code
22935 , p_entity_code => 'TRANSACTIONS'
22936 , p_event_class_code => 'CREDIT_MEMO'
22937 , p_side => 'NA'
22938 );
22939
22940 END IF;
22941
22942 --
22943 --
22944 END IF;
22945
22949 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
22946 --
22947 -- Update the line information that should be overwritten
22948 --
22950 p_header_num => 1);
22951 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
22952
22953 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
22954
22955 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
22956 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
22957 END IF;
22958
22959 --
22960 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
22961 --
22962 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
22963 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
22964 ELSE
22965 ---------------------------------------------------------------------------------------------------
22966 -- 4262811a Switch Sign
22967 ---------------------------------------------------------------------------------------------------
22968 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
22969 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22970 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22971 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22972 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22973 -- 5132302
22974 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
22975 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22976
22977 END IF;
22978
22979 -- 4955764
22980 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22981 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
22982
22983
22984 XLA_AE_LINES_PKG.ValidateCurrentLine;
22985 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22986
22987 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22988 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
22989 ,p_balance_type_code => l_balance_type_code);
22990
22991 END IF;
22992
22993 -----------------------------------------------------------------------------------------
22994 -- 4262811 Multiperiod Accounting
22995 -----------------------------------------------------------------------------------------
22996 -- No MPA option is assigned.
22997
22998
22999 END IF;
23000 END IF;
23001 --
23002
23003 --
23004 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23005 trace
23006 (p_msg => 'END of AcctLineType_54'
23007 ,p_level => C_LEVEL_PROCEDURE
23008 ,p_module => l_log_module);
23009 END IF;
23010 --
23011 EXCEPTION
23012 WHEN xla_exceptions_pkg.application_exception THEN
23013 RAISE;
23014 WHEN OTHERS THEN
23015 xla_exceptions_pkg.raise_message
23016 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_54');
23017 END AcctLineType_54;
23018 --
23019
23020 ---------------------------------------
23021 --
23022 -- PRIVATE FUNCTION
23023 -- AcctLineType_55
23024 --
23025 ---------------------------------------
23026 PROCEDURE AcctLineType_55 (
23027 p_application_id IN NUMBER
23028 ,p_event_id IN NUMBER
23029 ,p_calculate_acctd_flag IN VARCHAR2
23030 ,p_calculate_g_l_flag IN VARCHAR2
23031 ,p_actual_flag IN OUT VARCHAR2
23032 ,p_balance_type_code OUT VARCHAR2
23033 ,p_gain_or_loss_ref OUT VARCHAR2
23034
23035 --Transaction Default Receivable Account
23036 , p_source_8 IN NUMBER
23037 --Transaction Distribution GL Account
23038 , p_source_14 IN NUMBER
23039 --Bill To Customer Account Identifier
23040 , p_source_25 IN NUMBER
23041 --Bill To Customer Site Use Identifier
23042 , p_source_26 IN NUMBER
23043 --SLA Party Type
23044 , p_source_27 IN VARCHAR2
23045 --Transaction Distribution Account Class
23046 , p_source_28 IN VARCHAR2
23047 --Transaction Distribution Identifier
23048 , p_source_29 IN NUMBER
23049 --Transaction Distribution Type
23050 , p_source_30 IN VARCHAR2
23051 --Transaction Distribution Entered Amount
23052 , p_source_31 IN NUMBER
23053 --Transaction Currency Code
23054 , p_source_32 IN VARCHAR2
23055 --Transaction Exchange Date
23056 , p_source_33 IN DATE
23057 --Transaction Exchange Rate
23058 , p_source_34 IN NUMBER
23059 --Transaction Exchange Rate Type
23060 , p_source_35 IN VARCHAR2
23061 --Transaction Accounting Amount
23062 , p_source_36 IN NUMBER
23063 --Transaction Tax Line Identifier
23064 , p_source_50 IN NUMBER
23065 --Transaction Invoicing Rule
23066 , p_source_53 IN NUMBER
23067 )
23068 IS
23069
23070 l_component_type VARCHAR2(80);
23074 l_amb_context_code VARCHAR2(30);
23071 l_component_code VARCHAR2(30);
23072 l_component_type_code VARCHAR2(1);
23073 l_component_appl_id INTEGER;
23075 l_entity_code VARCHAR2(30);
23076 l_event_class_code VARCHAR2(30);
23077 l_ae_header_id NUMBER;
23078 l_event_type_code VARCHAR2(30);
23079 l_line_definition_code VARCHAR2(30);
23080 l_line_definition_owner_code VARCHAR2(1);
23081 --
23082 -- adr variables
23083 l_segment VARCHAR2(30);
23084 l_ccid NUMBER;
23085 l_adr_transaction_coa_id NUMBER;
23086 l_adr_accounting_coa_id NUMBER;
23087 l_adr_flexfield_segment_code VARCHAR2(30);
23088 l_adr_flex_value_set_id NUMBER;
23089 l_adr_value_type_code VARCHAR2(30);
23090 l_adr_value_combination_id NUMBER;
23091 l_adr_value_segment_code VARCHAR2(30);
23092
23093 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
23094 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
23095 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
23096 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
23097
23098 -- 4262811 Variables ------------------------------------------------------------------------------------------
23099 l_entered_amt_idx NUMBER;
23100 l_accted_amt_idx NUMBER;
23101 l_acc_rev_flag VARCHAR2(1);
23102 l_accrual_line_num NUMBER;
23103 l_tmp_amt NUMBER;
23104 l_acc_rev_natural_side_code VARCHAR2(1);
23105
23106 l_num_entries NUMBER;
23107 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
23108 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
23109 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
23110 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
23111 l_recog_line_1 NUMBER;
23112 l_recog_line_2 NUMBER;
23113
23114 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
23115 l_bflow_applied_to_amt NUMBER; -- 5132302
23116 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
23117
23118 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
23119
23120 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
23121 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
23122
23123 ---------------------------------------------------------------------------------------------------------------
23124
23125
23126 --
23127 -- bulk performance
23128 --
23129 l_balance_type_code VARCHAR2(1);
23130 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
23131 l_log_module VARCHAR2(240);
23132
23133 --
23134 -- Upgrade strategy
23135 --
23136 l_actual_upg_option VARCHAR2(1);
23137 l_enc_upg_option VARCHAR2(1);
23138
23139 --
23140 BEGIN
23141 --
23142 IF g_log_enabled THEN
23143 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_55';
23144 END IF;
23145 --
23146 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23147
23148 trace
23149 (p_msg => 'BEGIN of AcctLineType_55'
23150 ,p_level => C_LEVEL_PROCEDURE
23151 ,p_module => l_log_module);
23152
23153 END IF;
23154 --
23155 l_component_type := 'AMB_JLT';
23156 l_component_code := 'MFAR_DM_REC';
23157 l_component_type_code := 'S';
23158 l_component_appl_id := 222;
23159 l_amb_context_code := 'DEFAULT';
23160 l_entity_code := 'TRANSACTIONS';
23161 l_event_class_code := 'DEBIT_MEMO';
23162 l_event_type_code := 'DEBIT_MEMO_ALL';
23163 l_line_definition_owner_code := 'S';
23164 l_line_definition_code := 'MFAR_DM_ACCRUAL_ACCOUNT';
23165 --
23166 l_balance_type_code := 'A';
23167 l_segment := NULL;
23168 l_ccid := NULL;
23169 l_adr_transaction_coa_id := NULL;
23170 l_adr_accounting_coa_id := NULL;
23171 l_adr_flexfield_segment_code := NULL;
23172 l_adr_flex_value_set_id := NULL;
23173 l_adr_value_type_code := NULL;
23174 l_adr_value_combination_id := NULL;
23175 l_adr_value_segment_code := NULL;
23176
23177 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
23178 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
23179 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
23180 l_budgetary_control_flag := 'N';
23181
23182 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23183 l_bflow_applied_to_amt := NULL; -- 5132302
23184 l_entered_amt_idx := NULL; -- 4262811
23185 l_accted_amt_idx := NULL; -- 4262811
23186 l_acc_rev_flag := NULL; -- 4262811
23187 l_accrual_line_num := NULL; -- 4262811
23188 l_tmp_amt := NULL; -- 4262811
23189 --
23190
23191 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
23192 l_balance_type_code <> 'B' THEN
23193 IF (p_source_53 IS NULL ) AND
23194 (NVL(p_source_28,'
23195 ') = 'REV' OR
23196 NVL(p_source_28,'
23197 ') = 'TAX' OR
23198 NVL(p_source_28,'
23199 ') = 'FREIGHT' OR
23200 NVL(p_source_28,'
23201 ') = 'ROUND' OR
23202 NVL(p_source_28,'
23203 ') = 'CHARGES')
23204 THEN
23205
23206 --
23207 XLA_AE_LINES_PKG.SetNewLine;
23208
23209 p_balance_type_code := l_balance_type_code;
23210 -- set the flag so later we will know whether the gain loss line needs to be created
23211
23212 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
23213 p_actual_flag :='A';
23214 END IF;
23215
23216 --
23217 -- bulk performance
23218 --
23219 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
23220 p_header_num => 0); -- 4262811
23221 --
23222 -- set accounting line options
23223 --
23224 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
23225 p_natural_side_code => 'D'
23226 , p_gain_or_loss_flag => 'N'
23227 , p_gl_transfer_mode_code => 'S'
23228 , p_acct_entry_type_code => 'A'
23229 , p_switch_side_flag => 'Y'
23230 , p_merge_duplicate_code => 'A'
23231 );
23232 --
23233 l_acc_rev_natural_side_code := 'C'; -- 4262811
23234 --
23235 --
23236 -- set accounting line type info
23237 --
23238 xla_ae_lines_pkg.SetAcctLineType
23239 (p_component_type => l_component_type
23240 ,p_event_type_code => l_event_type_code
23241 ,p_line_definition_owner_code => l_line_definition_owner_code
23242 ,p_line_definition_code => l_line_definition_code
23243 ,p_accounting_line_code => l_component_code
23244 ,p_accounting_line_type_code => l_component_type_code
23245 ,p_accounting_line_appl_id => l_component_appl_id
23246 ,p_amb_context_code => l_amb_context_code
23247 ,p_entity_code => l_entity_code
23248 ,p_event_class_code => l_event_class_code);
23249 --
23250 -- set accounting class
23251 --
23252 xla_ae_lines_pkg.SetAcctClass(
23253 p_accounting_class_code => 'RECEIVABLE'
23254 , p_ae_header_id => l_ae_header_id
23255 );
23256
23257 --
23258 -- set rounding class
23259 --
23260 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
23261 'RECEIVABLE';
23262
23263 --
23264 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
23268 --
23265 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
23266 --
23267 -- bulk performance
23269 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
23270
23271 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
23272 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
23273
23274 -- 4955764
23275 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23276 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
23277
23278 -- 4458381 Public Sector Enh
23279
23280 --
23281 -- set accounting attributes for the line type
23282 --
23283 l_entered_amt_idx := 3;
23284 l_accted_amt_idx := 8;
23285 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23286 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
23287 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
23288 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
23289 l_rec_acct_attrs.array_char_value(2) := p_source_30;
23290 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
23291 l_rec_acct_attrs.array_num_value(3) := p_source_31;
23292 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
23293 l_rec_acct_attrs.array_char_value(4) := p_source_32;
23294 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
23295 l_rec_acct_attrs.array_date_value(5) := p_source_33;
23296 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
23297 l_rec_acct_attrs.array_num_value(6) := p_source_34;
23298 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
23299 l_rec_acct_attrs.array_char_value(7) := p_source_35;
23300 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
23301 l_rec_acct_attrs.array_num_value(8) := p_source_36;
23302 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
23303 l_rec_acct_attrs.array_num_value(9) := p_source_25;
23304 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
23305 l_rec_acct_attrs.array_num_value(10) := p_source_26;
23306 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
23307 l_rec_acct_attrs.array_char_value(11) := p_source_27;
23308 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
23309 l_rec_acct_attrs.array_num_value(12) := p_source_50;
23310
23311 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
23312 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
23313
23314 ---------------------------------------------------------------------------------------------------------------
23315 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
23316 ---------------------------------------------------------------------------------------------------------------
23317 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
23318
23319 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23320 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23321
23322 IF xla_accounting_cache_pkg.GetValueChar
23323 (p_source_code => 'LEDGER_CATEGORY_CODE'
23324 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
23325 AND l_bflow_method_code = 'PRIOR_ENTRY'
23326 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
23327 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
23328 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
23329 )
23330 THEN
23331 xla_ae_lines_pkg.BflowUpgEntry
23332 (p_business_method_code => l_bflow_method_code
23333 ,p_business_class_code => l_bflow_class_code
23334 ,p_balance_type => l_balance_type_code);
23335 ELSE
23336 NULL;
23337 -- No business flow processing for business flow method of NONE.
23338 END IF;
23339
23340 --
23341 -- call analytical criteria
23342 --
23343
23344 --
23345 -- call description
23346 --
23347
23348 xla_ae_lines_pkg.SetLineDescription(
23349 p_ae_header_id => l_ae_header_id
23350 ,p_description => Description_1 (
23351 p_application_id => p_application_id
23352 , p_ae_header_id => l_ae_header_id
23353 )
23354 );
23355
23356
23357 --
23358 -- call ADRs
23359 -- Bug 4922099
23360 --
23361 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23362 (NVL(l_actual_upg_option, 'N') = 'O') OR
23363 (NVL(l_enc_upg_option, 'N') = 'O')
23364 )
23365 THEN
23366 NULL;
23367 --
23368 --
23369
23370 l_ccid := AcctDerRule_18(
23371 p_application_id => p_application_id
23372 , p_ae_header_id => l_ae_header_id
23373 , p_source_14 => p_source_14
23374 , x_transaction_coa_id => l_adr_transaction_coa_id
23375 , x_accounting_coa_id => l_adr_accounting_coa_id
23376 , x_value_type_code => l_adr_value_type_code
23377 , p_side => 'NA'
23378 );
23379
23380 xla_ae_lines_pkg.set_ccid(
23381 p_code_combination_id => l_ccid
23382 , p_value_type_code => l_adr_value_type_code
23383 , p_transaction_coa_id => l_adr_transaction_coa_id
23384 , p_accounting_coa_id => l_adr_accounting_coa_id
23385 , p_adr_code => 'TRX_DIST_CCID'
23386 , p_adr_type_code => 'S'
23387 , p_component_type => l_component_type
23388 , p_component_code => l_component_code
23389 , p_component_type_code => l_component_type_code
23390 , p_component_appl_id => l_component_appl_id
23391 , p_amb_context_code => l_amb_context_code
23392 , p_side => 'NA'
23393 );
23394
23395
23396 l_segment := AcctDerRule_9(
23397 p_application_id => p_application_id
23398 , p_ae_header_id => l_ae_header_id
23399 , p_source_8 => p_source_8
23400 , x_transaction_coa_id => l_adr_transaction_coa_id
23401 , x_accounting_coa_id => l_adr_accounting_coa_id
23402 , x_flexfield_segment_code => l_adr_flexfield_segment_code
23403 , x_flex_value_set_id => l_adr_flex_value_set_id
23404 , x_value_type_code => l_adr_value_type_code
23405 , x_value_combination_id => l_adr_value_combination_id
23406 , x_value_segment_code => l_adr_value_segment_code
23407 , p_side => 'NA'
23408 , p_override_seg_flag => 'Y'
23409 );
23410
23411 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
23412
23413 xla_ae_lines_pkg.set_segment(
23414 p_to_segment_code => 'GL_ACCOUNT'
23415 , p_segment_value => l_segment
23416 , p_from_segment_code => l_adr_value_segment_code
23417 , p_from_combination_id => l_adr_value_combination_id
23418 , p_value_type_code => l_adr_value_type_code
23419 , p_transaction_coa_id => l_adr_transaction_coa_id
23420 , p_accounting_coa_id => l_adr_accounting_coa_id
23421 , p_flexfield_segment_code => l_adr_flexfield_segment_code
23422 , p_flex_value_set_id => l_adr_flex_value_set_id
23423 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
23424 , p_adr_type_code => 'S'
23425 , p_component_type => l_component_type
23426 , p_component_code => l_component_code
23427 , p_component_type_code => l_component_type_code
23428 , p_component_appl_id => l_component_appl_id
23429 , p_amb_context_code => l_amb_context_code
23430 , p_entity_code => 'TRANSACTIONS'
23431 , p_event_class_code => 'DEBIT_MEMO'
23432 , p_side => 'NA'
23433 );
23434
23435 END IF;
23436
23437 --
23438 --
23439 END IF;
23440 --
23441 -- Bug 4922099
23442 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
23443 (NVL(l_enc_upg_option, 'N') = 'O')
23444 ) AND
23445 (l_bflow_method_code = 'PRIOR_ENTRY')
23446 )
23447 THEN
23448 IF
23449 --
23450 1 = 2
23451 --
23452 THEN
23453 xla_accounting_err_pkg.build_message
23454 (p_appli_s_name => 'XLA'
23455 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23456 ,p_token_1 => 'LINE_NUMBER'
23457 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
23458 ,p_token_2 => 'LINE_TYPE_NAME'
23459 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
23460 l_component_type
23461 ,l_component_code
23462 ,l_component_type_code
23463 ,l_component_appl_id
23464 ,l_amb_context_code
23465 ,l_entity_code
23466 ,l_event_class_code
23467 )
23468 ,p_token_3 => 'OWNER'
23469 ,p_value_3 => xla_lookups_pkg.get_meaning(
23470 p_lookup_type => 'XLA_OWNER_TYPE'
23471 ,p_lookup_code => l_component_type_code
23472 )
23473 ,p_token_4 => 'PRODUCT_NAME'
23474 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
23475 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
23476 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
23477 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
23478 ,p_ae_header_id => NULL
23479 );
23480
23481 IF (C_LEVEL_ERROR>= g_log_level) THEN
23482 trace
23483 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23484 ,p_level => C_LEVEL_ERROR
23485 ,p_module => l_log_module);
23486 END IF;
23487 END IF;
23488 END IF;
23489 --
23490 --
23491 ------------------------------------------------------------------------------------------------
23492 -- 4219869 Business Flow
23493 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
23494 -- Prior Entry. Currently, the following code is always generated.
23495 ------------------------------------------------------------------------------------------------
23496 XLA_AE_LINES_PKG.ValidateCurrentLine;
23497
23498 ------------------------------------------------------------------------------------
23499 -- 4219869 Business Flow
23500 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
23501 ------------------------------------------------------------------------------------
23502 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23503
23504 ----------------------------------------------------------------------------------
23505 -- 4219869 Business Flow
23506 -- Update journal entry status -- Need to generate this within IF <condition>
23507 ----------------------------------------------------------------------------------
23508 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23509 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
23510 ,p_balance_type_code => l_balance_type_code
23511 );
23512
23513 -------------------------------------------------------------------------------------------
23514 -- 4262811 - Generate the Accrual Reversal lines
23515 -------------------------------------------------------------------------------------------
23516 BEGIN
23517 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
23518 (g_array_event(p_event_id).array_value_num('header_index'));
23519 IF l_acc_rev_flag IS NULL THEN
23520 l_acc_rev_flag := 'N';
23521 END IF;
23522 EXCEPTION
23523 WHEN OTHERS THEN
23524 l_acc_rev_flag := 'N';
23525 END;
23526 --
23527 IF (l_acc_rev_flag = 'Y') THEN
23528
23529 -- 4645092 ------------------------------------------------------------------------------
23530 -- To allow MPA report to determine if it should generate report process
23531 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
23532 ------------------------------------------------------------------------------------------
23533
23534 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
23535 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
23536 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
23537 -- call ADRs
23538 -- Bug 4922099
23539 --
23540 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23541 (NVL(l_actual_upg_option, 'N') = 'O') OR
23542 (NVL(l_enc_upg_option, 'N') = 'O')
23543 )
23544 THEN
23545 NULL;
23546 --
23547 --
23548
23549 l_ccid := AcctDerRule_18(
23550 p_application_id => p_application_id
23551 , p_ae_header_id => l_ae_header_id
23552 , p_source_14 => p_source_14
23553 , x_transaction_coa_id => l_adr_transaction_coa_id
23554 , x_accounting_coa_id => l_adr_accounting_coa_id
23555 , x_value_type_code => l_adr_value_type_code
23556 , p_side => 'NA'
23557 );
23558
23559 xla_ae_lines_pkg.set_ccid(
23560 p_code_combination_id => l_ccid
23561 , p_value_type_code => l_adr_value_type_code
23562 , p_transaction_coa_id => l_adr_transaction_coa_id
23563 , p_accounting_coa_id => l_adr_accounting_coa_id
23564 , p_adr_code => 'TRX_DIST_CCID'
23565 , p_adr_type_code => 'S'
23566 , p_component_type => l_component_type
23567 , p_component_code => l_component_code
23568 , p_component_type_code => l_component_type_code
23569 , p_component_appl_id => l_component_appl_id
23570 , p_amb_context_code => l_amb_context_code
23571 , p_side => 'NA'
23572 );
23573
23574
23575 l_segment := AcctDerRule_9(
23576 p_application_id => p_application_id
23577 , p_ae_header_id => l_ae_header_id
23578 , p_source_8 => p_source_8
23579 , x_transaction_coa_id => l_adr_transaction_coa_id
23580 , x_accounting_coa_id => l_adr_accounting_coa_id
23581 , x_flexfield_segment_code => l_adr_flexfield_segment_code
23582 , x_flex_value_set_id => l_adr_flex_value_set_id
23583 , x_value_type_code => l_adr_value_type_code
23584 , x_value_combination_id => l_adr_value_combination_id
23585 , x_value_segment_code => l_adr_value_segment_code
23586 , p_side => 'NA'
23587 , p_override_seg_flag => 'Y'
23588 );
23589
23590 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
23591
23592 xla_ae_lines_pkg.set_segment(
23593 p_to_segment_code => 'GL_ACCOUNT'
23594 , p_segment_value => l_segment
23595 , p_from_segment_code => l_adr_value_segment_code
23596 , p_from_combination_id => l_adr_value_combination_id
23597 , p_value_type_code => l_adr_value_type_code
23598 , p_transaction_coa_id => l_adr_transaction_coa_id
23599 , p_accounting_coa_id => l_adr_accounting_coa_id
23600 , p_flexfield_segment_code => l_adr_flexfield_segment_code
23601 , p_flex_value_set_id => l_adr_flex_value_set_id
23602 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
23603 , p_adr_type_code => 'S'
23604 , p_component_type => l_component_type
23605 , p_component_code => l_component_code
23606 , p_component_type_code => l_component_type_code
23607 , p_component_appl_id => l_component_appl_id
23608 , p_amb_context_code => l_amb_context_code
23609 , p_entity_code => 'TRANSACTIONS'
23610 , p_event_class_code => 'DEBIT_MEMO'
23611 , p_side => 'NA'
23612 );
23613
23614 END IF;
23615
23616 --
23617 --
23618 END IF;
23619
23620 --
23621 -- Update the line information that should be overwritten
23622 --
23623 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
23624 p_header_num => 1);
23625 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
23626
23627 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
23628
23629 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
23630 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
23631 END IF;
23632
23633 --
23634 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
23635 --
23636 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
23637 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
23638 ELSE
23639 ---------------------------------------------------------------------------------------------------
23640 -- 4262811a Switch Sign
23641 ---------------------------------------------------------------------------------------------------
23642 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
23643 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23644 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23645 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23646 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23647 -- 5132302
23648 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
23649 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23650
23651 END IF;
23652
23653 -- 4955764
23654 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23655 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
23656
23657
23658 XLA_AE_LINES_PKG.ValidateCurrentLine;
23659 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23660
23661 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23662 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
23663 ,p_balance_type_code => l_balance_type_code);
23664
23665 END IF;
23666
23667 -----------------------------------------------------------------------------------------
23668 -- 4262811 Multiperiod Accounting
23669 -----------------------------------------------------------------------------------------
23670 -- No MPA option is assigned.
23671
23672
23673 END IF;
23674 END IF;
23675 --
23676
23677 --
23678 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23679 trace
23680 (p_msg => 'END of AcctLineType_55'
23681 ,p_level => C_LEVEL_PROCEDURE
23682 ,p_module => l_log_module);
23683 END IF;
23684 --
23685 EXCEPTION
23686 WHEN xla_exceptions_pkg.application_exception THEN
23687 RAISE;
23688 WHEN OTHERS THEN
23689 xla_exceptions_pkg.raise_message
23690 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_55');
23691 END AcctLineType_55;
23692 --
23693
23694 ---------------------------------------
23695 --
23696 -- PRIVATE FUNCTION
23697 -- AcctLineType_56
23698 --
23699 ---------------------------------------
23700 PROCEDURE AcctLineType_56 (
23701 p_application_id IN NUMBER
23702 ,p_event_id IN NUMBER
23703 ,p_calculate_acctd_flag IN VARCHAR2
23704 ,p_calculate_g_l_flag IN VARCHAR2
23705 ,p_actual_flag IN OUT VARCHAR2
23706 ,p_balance_type_code OUT VARCHAR2
23707 ,p_gain_or_loss_ref OUT VARCHAR2
23708
23709 --Transaction Default Receivable Account
23710 , p_source_8 IN NUMBER
23711 --Transaction Distribution GL Account
23712 , p_source_14 IN NUMBER
23713 --Bill To Customer Account Identifier
23714 , p_source_25 IN NUMBER
23715 --Bill To Customer Site Use Identifier
23716 , p_source_26 IN NUMBER
23717 --SLA Party Type
23718 , p_source_27 IN VARCHAR2
23719 --Transaction Distribution Account Class
23720 , p_source_28 IN VARCHAR2
23721 --Transaction Distribution Identifier
23722 , p_source_29 IN NUMBER
23723 --Transaction Distribution Type
23724 , p_source_30 IN VARCHAR2
23725 --Transaction Distribution Entered Amount
23726 , p_source_31 IN NUMBER
23727 --Transaction Currency Code
23728 , p_source_32 IN VARCHAR2
23729 --Transaction Exchange Date
23730 , p_source_33 IN DATE
23731 --Transaction Exchange Rate
23732 , p_source_34 IN NUMBER
23733 --Transaction Exchange Rate Type
23734 , p_source_35 IN VARCHAR2
23735 --Transaction Accounting Amount
23736 , p_source_36 IN NUMBER
23737 --Transaction Tax Line Identifier
23738 , p_source_50 IN NUMBER
23739 --Transaction Invoicing Rule
23740 , p_source_53 IN NUMBER
23741 )
23742 IS
23743
23744 l_component_type VARCHAR2(80);
23745 l_component_code VARCHAR2(30);
23746 l_component_type_code VARCHAR2(1);
23747 l_component_appl_id INTEGER;
23748 l_amb_context_code VARCHAR2(30);
23749 l_entity_code VARCHAR2(30);
23750 l_event_class_code VARCHAR2(30);
23751 l_ae_header_id NUMBER;
23752 l_event_type_code VARCHAR2(30);
23753 l_line_definition_code VARCHAR2(30);
23754 l_line_definition_owner_code VARCHAR2(1);
23755 --
23756 -- adr variables
23757 l_segment VARCHAR2(30);
23758 l_ccid NUMBER;
23759 l_adr_transaction_coa_id NUMBER;
23760 l_adr_accounting_coa_id NUMBER;
23761 l_adr_flexfield_segment_code VARCHAR2(30);
23762 l_adr_flex_value_set_id NUMBER;
23763 l_adr_value_type_code VARCHAR2(30);
23764 l_adr_value_combination_id NUMBER;
23765 l_adr_value_segment_code VARCHAR2(30);
23766
23767 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
23768 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
23769 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
23770 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
23771
23772 -- 4262811 Variables ------------------------------------------------------------------------------------------
23773 l_entered_amt_idx NUMBER;
23774 l_accted_amt_idx NUMBER;
23775 l_acc_rev_flag VARCHAR2(1);
23776 l_accrual_line_num NUMBER;
23777 l_tmp_amt NUMBER;
23778 l_acc_rev_natural_side_code VARCHAR2(1);
23779
23780 l_num_entries NUMBER;
23781 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
23782 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
23783 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
23784 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
23785 l_recog_line_1 NUMBER;
23786 l_recog_line_2 NUMBER;
23787
23788 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
23789 l_bflow_applied_to_amt NUMBER; -- 5132302
23790 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
23791
23792 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
23793
23794 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
23795 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
23796
23797 ---------------------------------------------------------------------------------------------------------------
23798
23799
23800 --
23801 -- bulk performance
23802 --
23803 l_balance_type_code VARCHAR2(1);
23804 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
23805 l_log_module VARCHAR2(240);
23806
23807 --
23808 -- Upgrade strategy
23809 --
23810 l_actual_upg_option VARCHAR2(1);
23811 l_enc_upg_option VARCHAR2(1);
23812
23813 --
23814 BEGIN
23815 --
23816 IF g_log_enabled THEN
23817 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_56';
23818 END IF;
23819 --
23820 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23821
23822 trace
23823 (p_msg => 'BEGIN of AcctLineType_56'
23824 ,p_level => C_LEVEL_PROCEDURE
23825 ,p_module => l_log_module);
23826
23827 END IF;
23828 --
23829 l_component_type := 'AMB_JLT';
23830 l_component_code := 'MFAR_INV_REC';
23831 l_component_type_code := 'S';
23832 l_component_appl_id := 222;
23836 l_event_type_code := 'INVOICE_ALL';
23833 l_amb_context_code := 'DEFAULT';
23834 l_entity_code := 'TRANSACTIONS';
23835 l_event_class_code := 'INVOICE';
23837 l_line_definition_owner_code := 'S';
23838 l_line_definition_code := 'MFAR_INV_ACCRUAL_ACCOUNT';
23839 --
23840 l_balance_type_code := 'A';
23841 l_segment := NULL;
23842 l_ccid := NULL;
23843 l_adr_transaction_coa_id := NULL;
23844 l_adr_accounting_coa_id := NULL;
23845 l_adr_flexfield_segment_code := NULL;
23846 l_adr_flex_value_set_id := NULL;
23847 l_adr_value_type_code := NULL;
23848 l_adr_value_combination_id := NULL;
23849 l_adr_value_segment_code := NULL;
23850
23851 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
23852 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
23853 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
23854 l_budgetary_control_flag := 'N';
23855
23856 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23857 l_bflow_applied_to_amt := NULL; -- 5132302
23858 l_entered_amt_idx := NULL; -- 4262811
23859 l_accted_amt_idx := NULL; -- 4262811
23860 l_acc_rev_flag := NULL; -- 4262811
23861 l_accrual_line_num := NULL; -- 4262811
23862 l_tmp_amt := NULL; -- 4262811
23863 --
23864
23865 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
23866 l_balance_type_code <> 'B' THEN
23867 IF (p_source_53 IS NULL ) AND
23868 (NVL(p_source_28,'
23869 ') = 'REV' OR
23870 NVL(p_source_28,'
23871 ') = 'TAX' OR
23872 NVL(p_source_28,'
23873 ') = 'FREIGHT' OR
23874 NVL(p_source_28,'
23875 ') = 'ROUND' OR
23876 NVL(p_source_28,'
23877 ') = 'CHARGES')
23878 THEN
23879
23880 --
23881 XLA_AE_LINES_PKG.SetNewLine;
23882
23883 p_balance_type_code := l_balance_type_code;
23884 -- set the flag so later we will know whether the gain loss line needs to be created
23885
23886 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
23887 p_actual_flag :='A';
23888 END IF;
23889
23890 --
23891 -- bulk performance
23892 --
23893 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
23894 p_header_num => 0); -- 4262811
23895 --
23896 -- set accounting line options
23897 --
23898 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
23899 p_natural_side_code => 'D'
23900 , p_gain_or_loss_flag => 'N'
23901 , p_gl_transfer_mode_code => 'S'
23902 , p_acct_entry_type_code => 'A'
23903 , p_switch_side_flag => 'Y'
23904 , p_merge_duplicate_code => 'A'
23905 );
23906 --
23907 l_acc_rev_natural_side_code := 'C'; -- 4262811
23908 --
23909 --
23910 -- set accounting line type info
23911 --
23912 xla_ae_lines_pkg.SetAcctLineType
23913 (p_component_type => l_component_type
23914 ,p_event_type_code => l_event_type_code
23915 ,p_line_definition_owner_code => l_line_definition_owner_code
23916 ,p_line_definition_code => l_line_definition_code
23917 ,p_accounting_line_code => l_component_code
23918 ,p_accounting_line_type_code => l_component_type_code
23919 ,p_accounting_line_appl_id => l_component_appl_id
23920 ,p_amb_context_code => l_amb_context_code
23921 ,p_entity_code => l_entity_code
23922 ,p_event_class_code => l_event_class_code);
23923 --
23924 -- set accounting class
23925 --
23926 xla_ae_lines_pkg.SetAcctClass(
23927 p_accounting_class_code => 'RECEIVABLE'
23928 , p_ae_header_id => l_ae_header_id
23929 );
23930
23931 --
23932 -- set rounding class
23933 --
23934 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
23935 'RECEIVABLE';
23936
23937 --
23938 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
23939 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
23940 --
23941 -- bulk performance
23942 --
23943 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
23944
23945 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
23946 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
23947
23948 -- 4955764
23949 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23950 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
23951
23952 -- 4458381 Public Sector Enh
23953
23954 --
23955 -- set accounting attributes for the line type
23956 --
23957 l_entered_amt_idx := 3;
23958 l_accted_amt_idx := 8;
23959 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23960 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
23961 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_29);
23962 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
23963 l_rec_acct_attrs.array_char_value(2) := p_source_30;
23964 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
23965 l_rec_acct_attrs.array_num_value(3) := p_source_31;
23966 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
23967 l_rec_acct_attrs.array_char_value(4) := p_source_32;
23968 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
23969 l_rec_acct_attrs.array_date_value(5) := p_source_33;
23970 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
23971 l_rec_acct_attrs.array_num_value(6) := p_source_34;
23972 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
23973 l_rec_acct_attrs.array_char_value(7) := p_source_35;
23974 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
23975 l_rec_acct_attrs.array_num_value(8) := p_source_36;
23976 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
23977 l_rec_acct_attrs.array_num_value(9) := p_source_25;
23978 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
23979 l_rec_acct_attrs.array_num_value(10) := p_source_26;
23980 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
23981 l_rec_acct_attrs.array_char_value(11) := p_source_27;
23982 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
23983 l_rec_acct_attrs.array_num_value(12) := p_source_50;
23984
23985 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
23986 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
23987
23988 ---------------------------------------------------------------------------------------------------------------
23989 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
23990 ---------------------------------------------------------------------------------------------------------------
23991 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
23992
23993 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23994 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23995
23996 IF xla_accounting_cache_pkg.GetValueChar
23997 (p_source_code => 'LEDGER_CATEGORY_CODE'
23998 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
23999 AND l_bflow_method_code = 'PRIOR_ENTRY'
24000 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
24001 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
24002 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
24003 )
24004 THEN
24005 xla_ae_lines_pkg.BflowUpgEntry
24006 (p_business_method_code => l_bflow_method_code
24007 ,p_business_class_code => l_bflow_class_code
24008 ,p_balance_type => l_balance_type_code);
24009 ELSE
24010 NULL;
24011 -- No business flow processing for business flow method of NONE.
24012 END IF;
24013
24014 --
24015 -- call analytical criteria
24016 --
24017
24018 --
24019 -- call description
24020 --
24021
24022 xla_ae_lines_pkg.SetLineDescription(
24023 p_ae_header_id => l_ae_header_id
24024 ,p_description => Description_1 (
24025 p_application_id => p_application_id
24026 , p_ae_header_id => l_ae_header_id
24027 )
24028 );
24029
24030
24031 --
24032 -- call ADRs
24033 -- Bug 4922099
24034 --
24035 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24036 (NVL(l_actual_upg_option, 'N') = 'O') OR
24037 (NVL(l_enc_upg_option, 'N') = 'O')
24038 )
24039 THEN
24040 NULL;
24041 --
24042 --
24043
24044 l_ccid := AcctDerRule_18(
24045 p_application_id => p_application_id
24046 , p_ae_header_id => l_ae_header_id
24047 , p_source_14 => p_source_14
24048 , x_transaction_coa_id => l_adr_transaction_coa_id
24049 , x_accounting_coa_id => l_adr_accounting_coa_id
24050 , x_value_type_code => l_adr_value_type_code
24051 , p_side => 'NA'
24052 );
24053
24054 xla_ae_lines_pkg.set_ccid(
24055 p_code_combination_id => l_ccid
24056 , p_value_type_code => l_adr_value_type_code
24057 , p_transaction_coa_id => l_adr_transaction_coa_id
24058 , p_accounting_coa_id => l_adr_accounting_coa_id
24059 , p_adr_code => 'TRX_DIST_CCID'
24060 , p_adr_type_code => 'S'
24061 , p_component_type => l_component_type
24062 , p_component_code => l_component_code
24063 , p_component_type_code => l_component_type_code
24064 , p_component_appl_id => l_component_appl_id
24065 , p_amb_context_code => l_amb_context_code
24066 , p_side => 'NA'
24067 );
24068
24069
24070 l_segment := AcctDerRule_9(
24071 p_application_id => p_application_id
24072 , p_ae_header_id => l_ae_header_id
24073 , p_source_8 => p_source_8
24074 , x_transaction_coa_id => l_adr_transaction_coa_id
24075 , x_accounting_coa_id => l_adr_accounting_coa_id
24076 , x_flexfield_segment_code => l_adr_flexfield_segment_code
24077 , x_flex_value_set_id => l_adr_flex_value_set_id
24078 , x_value_type_code => l_adr_value_type_code
24079 , x_value_combination_id => l_adr_value_combination_id
24080 , x_value_segment_code => l_adr_value_segment_code
24081 , p_side => 'NA'
24082 , p_override_seg_flag => 'Y'
24083 );
24084
24085 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
24086
24087 xla_ae_lines_pkg.set_segment(
24088 p_to_segment_code => 'GL_ACCOUNT'
24089 , p_segment_value => l_segment
24090 , p_from_segment_code => l_adr_value_segment_code
24091 , p_from_combination_id => l_adr_value_combination_id
24092 , p_value_type_code => l_adr_value_type_code
24093 , p_transaction_coa_id => l_adr_transaction_coa_id
24094 , p_accounting_coa_id => l_adr_accounting_coa_id
24095 , p_flexfield_segment_code => l_adr_flexfield_segment_code
24096 , p_flex_value_set_id => l_adr_flex_value_set_id
24097 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
24098 , p_adr_type_code => 'S'
24099 , p_component_type => l_component_type
24100 , p_component_code => l_component_code
24101 , p_component_type_code => l_component_type_code
24102 , p_component_appl_id => l_component_appl_id
24103 , p_amb_context_code => l_amb_context_code
24104 , p_entity_code => 'TRANSACTIONS'
24105 , p_event_class_code => 'INVOICE'
24106 , p_side => 'NA'
24107 );
24108
24109 END IF;
24110
24111 --
24112 --
24113 END IF;
24114 --
24115 -- Bug 4922099
24116 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
24117 (NVL(l_enc_upg_option, 'N') = 'O')
24118 ) AND
24119 (l_bflow_method_code = 'PRIOR_ENTRY')
24120 )
24121 THEN
24122 IF
24123 --
24124 1 = 2
24125 --
24126 THEN
24127 xla_accounting_err_pkg.build_message
24128 (p_appli_s_name => 'XLA'
24129 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24130 ,p_token_1 => 'LINE_NUMBER'
24131 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
24132 ,p_token_2 => 'LINE_TYPE_NAME'
24133 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
24134 l_component_type
24135 ,l_component_code
24136 ,l_component_type_code
24137 ,l_component_appl_id
24138 ,l_amb_context_code
24139 ,l_entity_code
24140 ,l_event_class_code
24141 )
24142 ,p_token_3 => 'OWNER'
24143 ,p_value_3 => xla_lookups_pkg.get_meaning(
24144 p_lookup_type => 'XLA_OWNER_TYPE'
24145 ,p_lookup_code => l_component_type_code
24146 )
24147 ,p_token_4 => 'PRODUCT_NAME'
24148 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
24149 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
24150 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
24151 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
24152 ,p_ae_header_id => NULL
24153 );
24154
24155 IF (C_LEVEL_ERROR>= g_log_level) THEN
24156 trace
24157 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24158 ,p_level => C_LEVEL_ERROR
24159 ,p_module => l_log_module);
24160 END IF;
24161 END IF;
24162 END IF;
24163 --
24164 --
24165 ------------------------------------------------------------------------------------------------
24166 -- 4219869 Business Flow
24167 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
24168 -- Prior Entry. Currently, the following code is always generated.
24169 ------------------------------------------------------------------------------------------------
24170 XLA_AE_LINES_PKG.ValidateCurrentLine;
24171
24172 ------------------------------------------------------------------------------------
24173 -- 4219869 Business Flow
24174 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
24175 ------------------------------------------------------------------------------------
24176 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24177
24178 ----------------------------------------------------------------------------------
24179 -- 4219869 Business Flow
24180 -- Update journal entry status -- Need to generate this within IF <condition>
24181 ----------------------------------------------------------------------------------
24182 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24183 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
24184 ,p_balance_type_code => l_balance_type_code
24185 );
24186
24187 -------------------------------------------------------------------------------------------
24188 -- 4262811 - Generate the Accrual Reversal lines
24189 -------------------------------------------------------------------------------------------
24190 BEGIN
24191 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
24192 (g_array_event(p_event_id).array_value_num('header_index'));
24193 IF l_acc_rev_flag IS NULL THEN
24194 l_acc_rev_flag := 'N';
24195 END IF;
24196 EXCEPTION
24197 WHEN OTHERS THEN
24198 l_acc_rev_flag := 'N';
24199 END;
24200 --
24201 IF (l_acc_rev_flag = 'Y') THEN
24202
24203 -- 4645092 ------------------------------------------------------------------------------
24204 -- To allow MPA report to determine if it should generate report process
24205 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
24206 ------------------------------------------------------------------------------------------
24207
24208 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
24209 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
24210 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
24211 -- call ADRs
24212 -- Bug 4922099
24213 --
24214 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24215 (NVL(l_actual_upg_option, 'N') = 'O') OR
24216 (NVL(l_enc_upg_option, 'N') = 'O')
24217 )
24218 THEN
24219 NULL;
24220 --
24221 --
24222
24223 l_ccid := AcctDerRule_18(
24224 p_application_id => p_application_id
24225 , p_ae_header_id => l_ae_header_id
24226 , p_source_14 => p_source_14
24227 , x_transaction_coa_id => l_adr_transaction_coa_id
24228 , x_accounting_coa_id => l_adr_accounting_coa_id
24229 , x_value_type_code => l_adr_value_type_code
24230 , p_side => 'NA'
24231 );
24232
24233 xla_ae_lines_pkg.set_ccid(
24234 p_code_combination_id => l_ccid
24235 , p_value_type_code => l_adr_value_type_code
24236 , p_transaction_coa_id => l_adr_transaction_coa_id
24237 , p_accounting_coa_id => l_adr_accounting_coa_id
24238 , p_adr_code => 'TRX_DIST_CCID'
24239 , p_adr_type_code => 'S'
24240 , p_component_type => l_component_type
24241 , p_component_code => l_component_code
24245 , p_side => 'NA'
24242 , p_component_type_code => l_component_type_code
24243 , p_component_appl_id => l_component_appl_id
24244 , p_amb_context_code => l_amb_context_code
24246 );
24247
24248
24249 l_segment := AcctDerRule_9(
24250 p_application_id => p_application_id
24251 , p_ae_header_id => l_ae_header_id
24252 , p_source_8 => p_source_8
24253 , x_transaction_coa_id => l_adr_transaction_coa_id
24254 , x_accounting_coa_id => l_adr_accounting_coa_id
24255 , x_flexfield_segment_code => l_adr_flexfield_segment_code
24256 , x_flex_value_set_id => l_adr_flex_value_set_id
24257 , x_value_type_code => l_adr_value_type_code
24258 , x_value_combination_id => l_adr_value_combination_id
24259 , x_value_segment_code => l_adr_value_segment_code
24260 , p_side => 'NA'
24261 , p_override_seg_flag => 'Y'
24262 );
24263
24264 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
24265
24266 xla_ae_lines_pkg.set_segment(
24267 p_to_segment_code => 'GL_ACCOUNT'
24268 , p_segment_value => l_segment
24269 , p_from_segment_code => l_adr_value_segment_code
24270 , p_from_combination_id => l_adr_value_combination_id
24271 , p_value_type_code => l_adr_value_type_code
24272 , p_transaction_coa_id => l_adr_transaction_coa_id
24273 , p_accounting_coa_id => l_adr_accounting_coa_id
24274 , p_flexfield_segment_code => l_adr_flexfield_segment_code
24275 , p_flex_value_set_id => l_adr_flex_value_set_id
24276 , p_adr_code => 'MFAR_TRX_NATURAL_SEGMENT'
24277 , p_adr_type_code => 'S'
24278 , p_component_type => l_component_type
24279 , p_component_code => l_component_code
24280 , p_component_type_code => l_component_type_code
24281 , p_component_appl_id => l_component_appl_id
24282 , p_amb_context_code => l_amb_context_code
24283 , p_entity_code => 'TRANSACTIONS'
24284 , p_event_class_code => 'INVOICE'
24285 , p_side => 'NA'
24286 );
24287
24288 END IF;
24289
24290 --
24291 --
24292 END IF;
24293
24294 --
24295 -- Update the line information that should be overwritten
24296 --
24297 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
24298 p_header_num => 1);
24299 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
24300
24301 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
24302
24303 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
24304 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
24305 END IF;
24306
24307 --
24308 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
24309 --
24310 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
24311 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
24312 ELSE
24313 ---------------------------------------------------------------------------------------------------
24314 -- 4262811a Switch Sign
24315 ---------------------------------------------------------------------------------------------------
24316 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
24317 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24318 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24319 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24320 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24321 -- 5132302
24322 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
24323 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24324
24325 END IF;
24326
24327 -- 4955764
24328 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24329 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
24330
24331
24332 XLA_AE_LINES_PKG.ValidateCurrentLine;
24333 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24334
24335 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24336 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
24337 ,p_balance_type_code => l_balance_type_code);
24338
24339 END IF;
24340
24341 -----------------------------------------------------------------------------------------
24342 -- 4262811 Multiperiod Accounting
24343 -----------------------------------------------------------------------------------------
24344 -- No MPA option is assigned.
24345
24346
24347 END IF;
24348 END IF;
24349 --
24350
24351 --
24352 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24353 trace
24354 (p_msg => 'END of AcctLineType_56'
24358 --
24355 ,p_level => C_LEVEL_PROCEDURE
24356 ,p_module => l_log_module);
24357 END IF;
24359 EXCEPTION
24360 WHEN xla_exceptions_pkg.application_exception THEN
24361 RAISE;
24362 WHEN OTHERS THEN
24363 xla_exceptions_pkg.raise_message
24364 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_56');
24365 END AcctLineType_56;
24366 --
24367
24368 ---------------------------------------
24369 --
24370 -- PRIVATE FUNCTION
24371 -- AcctLineType_57
24372 --
24373 ---------------------------------------
24374 PROCEDURE AcctLineType_57 (
24375 p_application_id IN NUMBER
24376 ,p_event_id IN NUMBER
24377 ,p_calculate_acctd_flag IN VARCHAR2
24378 ,p_calculate_g_l_flag IN VARCHAR2
24379 ,p_actual_flag IN OUT VARCHAR2
24380 ,p_balance_type_code OUT VARCHAR2
24381 ,p_gain_or_loss_ref OUT VARCHAR2
24382
24383 --Remittance Bank Account Bank Charges Acount
24384 , p_source_1 IN NUMBER
24385 --Remittance Bank Account Cash Account
24386 , p_source_5 IN NUMBER
24387 --Distribution Source Type
24388 , p_source_15 IN VARCHAR2
24389 --Distribution Line Identifier
24390 , p_source_17 IN NUMBER
24391 --Distribution Type
24392 , p_source_18 IN VARCHAR2
24393 --Entered Amount
24394 , p_source_19 IN NUMBER
24395 --Currency Code
24396 , p_source_20 IN VARCHAR2
24397 --Exchange Rate
24398 , p_source_22 IN NUMBER
24399 --Exchange Rate Type
24400 , p_source_23 IN VARCHAR2
24401 --Applied To Document Accounting Amount
24402 , p_source_24 IN NUMBER
24403 --Distribution Multi Fund Additional Entry
24404 , p_source_54 IN VARCHAR2
24405 --Applied To Document Exchange Date
24406 , p_source_55 IN DATE
24407 )
24408 IS
24409
24410 l_component_type VARCHAR2(80);
24411 l_component_code VARCHAR2(30);
24412 l_component_type_code VARCHAR2(1);
24413 l_component_appl_id INTEGER;
24414 l_amb_context_code VARCHAR2(30);
24415 l_entity_code VARCHAR2(30);
24416 l_event_class_code VARCHAR2(30);
24417 l_ae_header_id NUMBER;
24418 l_event_type_code VARCHAR2(30);
24419 l_line_definition_code VARCHAR2(30);
24420 l_line_definition_owner_code VARCHAR2(1);
24421 --
24422 -- adr variables
24423 l_segment VARCHAR2(30);
24424 l_ccid NUMBER;
24425 l_adr_transaction_coa_id NUMBER;
24426 l_adr_accounting_coa_id NUMBER;
24427 l_adr_flexfield_segment_code VARCHAR2(30);
24428 l_adr_flex_value_set_id NUMBER;
24429 l_adr_value_type_code VARCHAR2(30);
24430 l_adr_value_combination_id NUMBER;
24431 l_adr_value_segment_code VARCHAR2(30);
24432
24433 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
24434 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
24435 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
24436 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
24437
24438 -- 4262811 Variables ------------------------------------------------------------------------------------------
24439 l_entered_amt_idx NUMBER;
24440 l_accted_amt_idx NUMBER;
24441 l_acc_rev_flag VARCHAR2(1);
24442 l_accrual_line_num NUMBER;
24443 l_tmp_amt NUMBER;
24444 l_acc_rev_natural_side_code VARCHAR2(1);
24445
24446 l_num_entries NUMBER;
24447 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
24448 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
24449 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
24450 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
24451 l_recog_line_1 NUMBER;
24452 l_recog_line_2 NUMBER;
24453
24454 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
24455 l_bflow_applied_to_amt NUMBER; -- 5132302
24456 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
24457
24458 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
24459
24460 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
24461 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
24462
24463 ---------------------------------------------------------------------------------------------------------------
24464
24465
24466 --
24467 -- bulk performance
24468 --
24469 l_balance_type_code VARCHAR2(1);
24470 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
24471 l_log_module VARCHAR2(240);
24472
24473 --
24474 -- Upgrade strategy
24475 --
24476 l_actual_upg_option VARCHAR2(1);
24477 l_enc_upg_option VARCHAR2(1);
24478
24479 --
24480 BEGIN
24481 --
24482 IF g_log_enabled THEN
24483 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_57';
24484 END IF;
24485 --
24486 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24487
24488 trace
24489 (p_msg => 'BEGIN of AcctLineType_57'
24490 ,p_level => C_LEVEL_PROCEDURE
24491 ,p_module => l_log_module);
24492
24493 END IF;
24494 --
24495 l_component_type := 'AMB_JLT';
24496 l_component_code := 'MFAR_MISC_RCT_BNK_CHG_CASH';
24497 l_component_type_code := 'S';
24498 l_component_appl_id := 222;
24499 l_amb_context_code := 'DEFAULT';
24500 l_entity_code := 'RECEIPTS';
24501 l_event_class_code := 'MISC_RECEIPT';
24502 l_event_type_code := 'MISC_RECEIPT_ALL';
24503 l_line_definition_owner_code := 'S';
24504 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
24505 --
24506 l_balance_type_code := 'A';
24507 l_segment := NULL;
24508 l_ccid := NULL;
24509 l_adr_transaction_coa_id := NULL;
24510 l_adr_accounting_coa_id := NULL;
24511 l_adr_flexfield_segment_code := NULL;
24512 l_adr_flex_value_set_id := NULL;
24513 l_adr_value_type_code := NULL;
24514 l_adr_value_combination_id := NULL;
24515 l_adr_value_segment_code := NULL;
24516
24517 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
24518 l_bflow_class_code := ''; -- 4219869 Business Flow
24519 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
24520 l_budgetary_control_flag := 'N';
24521
24522 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24523 l_bflow_applied_to_amt := NULL; -- 5132302
24524 l_entered_amt_idx := NULL; -- 4262811
24525 l_accted_amt_idx := NULL; -- 4262811
24526 l_acc_rev_flag := NULL; -- 4262811
24527 l_accrual_line_num := NULL; -- 4262811
24528 l_tmp_amt := NULL; -- 4262811
24529 --
24530
24531 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
24532 l_balance_type_code <> 'B' THEN
24533 IF NVL(p_source_15,'
24534 ') = 'BANK_CHARGES' AND
24535 NVL(p_source_54,'
24536 ') = 'N'
24537 THEN
24538
24539 --
24540 XLA_AE_LINES_PKG.SetNewLine;
24541
24542 p_balance_type_code := l_balance_type_code;
24543 -- set the flag so later we will know whether the gain loss line needs to be created
24544
24545 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
24546 p_actual_flag :='A';
24547 END IF;
24548
24549 --
24550 -- bulk performance
24551 --
24552 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
24553 p_header_num => 0); -- 4262811
24554 --
24555 -- set accounting line options
24556 --
24557 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
24558 p_natural_side_code => 'D'
24559 , p_gain_or_loss_flag => 'N'
24560 , p_gl_transfer_mode_code => 'S'
24561 , p_acct_entry_type_code => 'A'
24562 , p_switch_side_flag => 'Y'
24563 , p_merge_duplicate_code => 'A'
24564 );
24565 --
24566 l_acc_rev_natural_side_code := 'C'; -- 4262811
24567 --
24568 --
24569 -- set accounting line type info
24570 --
24571 xla_ae_lines_pkg.SetAcctLineType
24572 (p_component_type => l_component_type
24573 ,p_event_type_code => l_event_type_code
24574 ,p_line_definition_owner_code => l_line_definition_owner_code
24575 ,p_line_definition_code => l_line_definition_code
24576 ,p_accounting_line_code => l_component_code
24577 ,p_accounting_line_type_code => l_component_type_code
24578 ,p_accounting_line_appl_id => l_component_appl_id
24579 ,p_amb_context_code => l_amb_context_code
24580 ,p_entity_code => l_entity_code
24581 ,p_event_class_code => l_event_class_code);
24582 --
24583 -- set accounting class
24584 --
24585 xla_ae_lines_pkg.SetAcctClass(
24586 p_accounting_class_code => 'BANK_CHG'
24587 , p_ae_header_id => l_ae_header_id
24588 );
24589
24590 --
24591 -- set rounding class
24592 --
24593 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
24594 'RECEIVABLE';
24595
24596 --
24597 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
24598 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
24599 --
24600 -- bulk performance
24601 --
24602 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
24603
24604 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
24605 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
24606
24607 -- 4955764
24608 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24609 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
24610
24611 -- 4458381 Public Sector Enh
24612
24613 --
24614 -- set accounting attributes for the line type
24615 --
24616 l_entered_amt_idx := 3;
24617 l_accted_amt_idx := 8;
24618 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24619 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
24620 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
24621 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
24622 l_rec_acct_attrs.array_char_value(2) := p_source_18;
24623 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
24624 l_rec_acct_attrs.array_num_value(3) := p_source_19;
24625 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
24626 l_rec_acct_attrs.array_char_value(4) := p_source_20;
24627 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
24628 l_rec_acct_attrs.array_date_value(5) := p_source_55;
24629 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
24630 l_rec_acct_attrs.array_num_value(6) := p_source_22;
24631 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
24632 l_rec_acct_attrs.array_char_value(7) := p_source_23;
24633 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
24634 l_rec_acct_attrs.array_num_value(8) := p_source_24;
24635
24636 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
24637 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
24638
24639 ---------------------------------------------------------------------------------------------------------------
24640 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
24641 ---------------------------------------------------------------------------------------------------------------
24642 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
24643
24644 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24645 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24646
24647 IF xla_accounting_cache_pkg.GetValueChar
24648 (p_source_code => 'LEDGER_CATEGORY_CODE'
24649 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
24650 AND l_bflow_method_code = 'PRIOR_ENTRY'
24651 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
24652 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
24653 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
24654 )
24655 THEN
24656 xla_ae_lines_pkg.BflowUpgEntry
24657 (p_business_method_code => l_bflow_method_code
24658 ,p_business_class_code => l_bflow_class_code
24659 ,p_balance_type => l_balance_type_code);
24660 ELSE
24661 NULL;
24662 -- No business flow processing for business flow method of NONE.
24663 END IF;
24664
24665 --
24666 -- call analytical criteria
24667 --
24668
24669 --
24670 -- call description
24671 --
24672
24673 xla_ae_lines_pkg.SetLineDescription(
24674 p_ae_header_id => l_ae_header_id
24675 ,p_description => Description_1 (
24676 p_application_id => p_application_id
24677 , p_ae_header_id => l_ae_header_id
24678 )
24679 );
24680
24681
24682 --
24683 -- call ADRs
24684 -- Bug 4922099
24685 --
24686 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24687 (NVL(l_actual_upg_option, 'N') = 'O') OR
24688 (NVL(l_enc_upg_option, 'N') = 'O')
24689 )
24690 THEN
24691 NULL;
24692 --
24693 --
24694
24695 l_ccid := AcctDerRule_12(
24696 p_application_id => p_application_id
24697 , p_ae_header_id => l_ae_header_id
24698 , p_source_5 => p_source_5
24699 , x_transaction_coa_id => l_adr_transaction_coa_id
24700 , x_accounting_coa_id => l_adr_accounting_coa_id
24701 , x_value_type_code => l_adr_value_type_code
24702 , p_side => 'NA'
24703 );
24704
24705 xla_ae_lines_pkg.set_ccid(
24706 p_code_combination_id => l_ccid
24707 , p_value_type_code => l_adr_value_type_code
24708 , p_transaction_coa_id => l_adr_transaction_coa_id
24709 , p_accounting_coa_id => l_adr_accounting_coa_id
24710 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
24711 , p_adr_type_code => 'S'
24712 , p_component_type => l_component_type
24713 , p_component_code => l_component_code
24714 , p_component_type_code => l_component_type_code
24715 , p_component_appl_id => l_component_appl_id
24716 , p_amb_context_code => l_amb_context_code
24717 , p_side => 'NA'
24718 );
24719
24720
24721 l_segment := AcctDerRule_2(
24722 p_application_id => p_application_id
24723 , p_ae_header_id => l_ae_header_id
24724 , p_source_1 => p_source_1
24725 , x_transaction_coa_id => l_adr_transaction_coa_id
24726 , x_accounting_coa_id => l_adr_accounting_coa_id
24727 , x_flexfield_segment_code => l_adr_flexfield_segment_code
24728 , x_flex_value_set_id => l_adr_flex_value_set_id
24729 , x_value_type_code => l_adr_value_type_code
24730 , x_value_combination_id => l_adr_value_combination_id
24731 , x_value_segment_code => l_adr_value_segment_code
24732 , p_side => 'NA'
24733 , p_override_seg_flag => 'Y'
24734 );
24735
24736 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
24737
24738 xla_ae_lines_pkg.set_segment(
24739 p_to_segment_code => 'GL_ACCOUNT'
24740 , p_segment_value => l_segment
24741 , p_from_segment_code => l_adr_value_segment_code
24742 , p_from_combination_id => l_adr_value_combination_id
24743 , p_value_type_code => l_adr_value_type_code
24744 , p_transaction_coa_id => l_adr_transaction_coa_id
24745 , p_accounting_coa_id => l_adr_accounting_coa_id
24746 , p_flexfield_segment_code => l_adr_flexfield_segment_code
24747 , p_flex_value_set_id => l_adr_flex_value_set_id
24748 , p_adr_code => 'MFAR_BNK_CHARGES_NATURAL_SEG'
24749 , p_adr_type_code => 'S'
24750 , p_component_type => l_component_type
24751 , p_component_code => l_component_code
24752 , p_component_type_code => l_component_type_code
24753 , p_component_appl_id => l_component_appl_id
24754 , p_amb_context_code => l_amb_context_code
24755 , p_entity_code => 'RECEIPTS'
24756 , p_event_class_code => 'MISC_RECEIPT'
24757 , p_side => 'NA'
24758 );
24759
24760 END IF;
24761
24762 --
24763 --
24764 END IF;
24765 --
24766 -- Bug 4922099
24767 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
24768 (NVL(l_enc_upg_option, 'N') = 'O')
24769 ) AND
24770 (l_bflow_method_code = 'PRIOR_ENTRY')
24771 )
24772 THEN
24773 IF
24774 --
24775 1 = 2
24776 --
24777 THEN
24778 xla_accounting_err_pkg.build_message
24779 (p_appli_s_name => 'XLA'
24780 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24781 ,p_token_1 => 'LINE_NUMBER'
24782 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
24783 ,p_token_2 => 'LINE_TYPE_NAME'
24784 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
24785 l_component_type
24786 ,l_component_code
24787 ,l_component_type_code
24788 ,l_component_appl_id
24789 ,l_amb_context_code
24790 ,l_entity_code
24791 ,l_event_class_code
24792 )
24793 ,p_token_3 => 'OWNER'
24794 ,p_value_3 => xla_lookups_pkg.get_meaning(
24795 p_lookup_type => 'XLA_OWNER_TYPE'
24796 ,p_lookup_code => l_component_type_code
24797 )
24798 ,p_token_4 => 'PRODUCT_NAME'
24799 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
24800 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
24801 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
24802 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
24803 ,p_ae_header_id => NULL
24804 );
24805
24806 IF (C_LEVEL_ERROR>= g_log_level) THEN
24807 trace
24808 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24809 ,p_level => C_LEVEL_ERROR
24810 ,p_module => l_log_module);
24811 END IF;
24812 END IF;
24813 END IF;
24814 --
24815 --
24816 ------------------------------------------------------------------------------------------------
24817 -- 4219869 Business Flow
24818 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
24819 -- Prior Entry. Currently, the following code is always generated.
24820 ------------------------------------------------------------------------------------------------
24821 XLA_AE_LINES_PKG.ValidateCurrentLine;
24822
24823 ------------------------------------------------------------------------------------
24824 -- 4219869 Business Flow
24825 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
24826 ------------------------------------------------------------------------------------
24827 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24828
24829 ----------------------------------------------------------------------------------
24830 -- 4219869 Business Flow
24831 -- Update journal entry status -- Need to generate this within IF <condition>
24832 ----------------------------------------------------------------------------------
24833 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24834 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
24835 ,p_balance_type_code => l_balance_type_code
24836 );
24837
24838 -------------------------------------------------------------------------------------------
24839 -- 4262811 - Generate the Accrual Reversal lines
24840 -------------------------------------------------------------------------------------------
24841 BEGIN
24842 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
24843 (g_array_event(p_event_id).array_value_num('header_index'));
24844 IF l_acc_rev_flag IS NULL THEN
24845 l_acc_rev_flag := 'N';
24846 END IF;
24847 EXCEPTION
24848 WHEN OTHERS THEN
24849 l_acc_rev_flag := 'N';
24850 END;
24851 --
24852 IF (l_acc_rev_flag = 'Y') THEN
24853
24854 -- 4645092 ------------------------------------------------------------------------------
24855 -- To allow MPA report to determine if it should generate report process
24856 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
24857 ------------------------------------------------------------------------------------------
24858
24859 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
24860 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
24861 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
24862 -- call ADRs
24863 -- Bug 4922099
24864 --
24865 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24866 (NVL(l_actual_upg_option, 'N') = 'O') OR
24867 (NVL(l_enc_upg_option, 'N') = 'O')
24868 )
24869 THEN
24870 NULL;
24871 --
24872 --
24873
24874 l_ccid := AcctDerRule_12(
24875 p_application_id => p_application_id
24876 , p_ae_header_id => l_ae_header_id
24877 , p_source_5 => p_source_5
24878 , x_transaction_coa_id => l_adr_transaction_coa_id
24879 , x_accounting_coa_id => l_adr_accounting_coa_id
24880 , x_value_type_code => l_adr_value_type_code
24881 , p_side => 'NA'
24882 );
24883
24884 xla_ae_lines_pkg.set_ccid(
24885 p_code_combination_id => l_ccid
24886 , p_value_type_code => l_adr_value_type_code
24887 , p_transaction_coa_id => l_adr_transaction_coa_id
24888 , p_accounting_coa_id => l_adr_accounting_coa_id
24889 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
24890 , p_adr_type_code => 'S'
24891 , p_component_type => l_component_type
24892 , p_component_code => l_component_code
24893 , p_component_type_code => l_component_type_code
24894 , p_component_appl_id => l_component_appl_id
24895 , p_amb_context_code => l_amb_context_code
24896 , p_side => 'NA'
24897 );
24898
24899
24900 l_segment := AcctDerRule_2(
24901 p_application_id => p_application_id
24902 , p_ae_header_id => l_ae_header_id
24903 , p_source_1 => p_source_1
24904 , x_transaction_coa_id => l_adr_transaction_coa_id
24905 , x_accounting_coa_id => l_adr_accounting_coa_id
24906 , x_flexfield_segment_code => l_adr_flexfield_segment_code
24907 , x_flex_value_set_id => l_adr_flex_value_set_id
24908 , x_value_type_code => l_adr_value_type_code
24909 , x_value_combination_id => l_adr_value_combination_id
24910 , x_value_segment_code => l_adr_value_segment_code
24911 , p_side => 'NA'
24912 , p_override_seg_flag => 'Y'
24913 );
24914
24915 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
24916
24917 xla_ae_lines_pkg.set_segment(
24918 p_to_segment_code => 'GL_ACCOUNT'
24919 , p_segment_value => l_segment
24920 , p_from_segment_code => l_adr_value_segment_code
24921 , p_from_combination_id => l_adr_value_combination_id
24922 , p_value_type_code => l_adr_value_type_code
24923 , p_transaction_coa_id => l_adr_transaction_coa_id
24924 , p_accounting_coa_id => l_adr_accounting_coa_id
24925 , p_flexfield_segment_code => l_adr_flexfield_segment_code
24926 , p_flex_value_set_id => l_adr_flex_value_set_id
24927 , p_adr_code => 'MFAR_BNK_CHARGES_NATURAL_SEG'
24928 , p_adr_type_code => 'S'
24929 , p_component_type => l_component_type
24930 , p_component_code => l_component_code
24931 , p_component_type_code => l_component_type_code
24932 , p_component_appl_id => l_component_appl_id
24933 , p_amb_context_code => l_amb_context_code
24934 , p_entity_code => 'RECEIPTS'
24935 , p_event_class_code => 'MISC_RECEIPT'
24936 , p_side => 'NA'
24937 );
24938
24939 END IF;
24940
24941 --
24942 --
24943 END IF;
24944
24945 --
24946 -- Update the line information that should be overwritten
24947 --
24948 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
24949 p_header_num => 1);
24950 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
24951
24952 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
24953
24954 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
24955 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
24956 END IF;
24957
24958 --
24959 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
24960 --
24961 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
24962 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
24963 ELSE
24964 ---------------------------------------------------------------------------------------------------
24965 -- 4262811a Switch Sign
24966 ---------------------------------------------------------------------------------------------------
24967 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
24968 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24969 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24970 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24971 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24972 -- 5132302
24973 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
24974 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24975
24976 END IF;
24977
24978 -- 4955764
24979 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24980 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
24981
24982
24983 XLA_AE_LINES_PKG.ValidateCurrentLine;
24984 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24985
24986 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24987 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
24988 ,p_balance_type_code => l_balance_type_code);
24989
24990 END IF;
24991
24992 -----------------------------------------------------------------------------------------
24993 -- 4262811 Multiperiod Accounting
24994 -----------------------------------------------------------------------------------------
24995 -- No MPA option is assigned.
24996
24997
24998 END IF;
24999 END IF;
25000 --
25001
25002 --
25003 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25004 trace
25005 (p_msg => 'END of AcctLineType_57'
25006 ,p_level => C_LEVEL_PROCEDURE
25007 ,p_module => l_log_module);
25008 END IF;
25009 --
25010 EXCEPTION
25011 WHEN xla_exceptions_pkg.application_exception THEN
25012 RAISE;
25013 WHEN OTHERS THEN
25014 xla_exceptions_pkg.raise_message
25015 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_57');
25016 END AcctLineType_57;
25017 --
25018
25019 ---------------------------------------
25020 --
25021 -- PRIVATE FUNCTION
25022 -- AcctLineType_58
25023 --
25024 ---------------------------------------
25025 PROCEDURE AcctLineType_58 (
25026 p_application_id IN NUMBER
25027 ,p_event_id IN NUMBER
25028 ,p_calculate_acctd_flag IN VARCHAR2
25029 ,p_calculate_g_l_flag IN VARCHAR2
25030 ,p_actual_flag IN OUT VARCHAR2
25031 ,p_balance_type_code OUT VARCHAR2
25032 ,p_gain_or_loss_ref OUT VARCHAR2
25033
25034 --Remittance Bank Account Cash Account
25035 , p_source_5 IN NUMBER
25036 --Distribution GL Account
25037 , p_source_10 IN NUMBER
25038 --Distribution Source Type
25039 , p_source_15 IN VARCHAR2
25040 --Distribution Line Identifier
25041 , p_source_17 IN NUMBER
25042 --Distribution Type
25043 , p_source_18 IN VARCHAR2
25044 --Entered Amount
25045 , p_source_19 IN NUMBER
25046 --Currency Code
25047 , p_source_20 IN VARCHAR2
25048 --Exchange Rate
25049 , p_source_22 IN NUMBER
25050 --Exchange Rate Type
25051 , p_source_23 IN VARCHAR2
25052 --Applied To Document Accounting Amount
25053 , p_source_24 IN NUMBER
25054 --Distribution Multi Fund Additional Entry
25055 , p_source_54 IN VARCHAR2
25056 --Applied To Document Exchange Date
25057 , p_source_55 IN DATE
25058 --Receipt Class Require Remittance Flag
25059 , p_source_56 IN VARCHAR2
25060 --Receipt Class Confirm Flag
25061 , p_source_57 IN VARCHAR2
25062 )
25063 IS
25064
25065 l_component_type VARCHAR2(80);
25066 l_component_code VARCHAR2(30);
25067 l_component_type_code VARCHAR2(1);
25068 l_component_appl_id INTEGER;
25069 l_amb_context_code VARCHAR2(30);
25070 l_entity_code VARCHAR2(30);
25071 l_event_class_code VARCHAR2(30);
25072 l_ae_header_id NUMBER;
25073 l_event_type_code VARCHAR2(30);
25074 l_line_definition_code VARCHAR2(30);
25075 l_line_definition_owner_code VARCHAR2(1);
25076 --
25077 -- adr variables
25078 l_segment VARCHAR2(30);
25079 l_ccid NUMBER;
25080 l_adr_transaction_coa_id NUMBER;
25081 l_adr_accounting_coa_id NUMBER;
25082 l_adr_flexfield_segment_code VARCHAR2(30);
25083 l_adr_flex_value_set_id NUMBER;
25084 l_adr_value_type_code VARCHAR2(30);
25085 l_adr_value_combination_id NUMBER;
25086 l_adr_value_segment_code VARCHAR2(30);
25087
25088 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
25089 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
25090 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
25091 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
25092
25093 -- 4262811 Variables ------------------------------------------------------------------------------------------
25094 l_entered_amt_idx NUMBER;
25095 l_accted_amt_idx NUMBER;
25096 l_acc_rev_flag VARCHAR2(1);
25097 l_accrual_line_num NUMBER;
25098 l_tmp_amt NUMBER;
25099 l_acc_rev_natural_side_code VARCHAR2(1);
25100
25101 l_num_entries NUMBER;
25102 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
25103 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
25104 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
25105 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
25106 l_recog_line_1 NUMBER;
25107 l_recog_line_2 NUMBER;
25108
25112
25109 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
25110 l_bflow_applied_to_amt NUMBER; -- 5132302
25111 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
25113 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
25114
25115 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
25116 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
25117
25118 ---------------------------------------------------------------------------------------------------------------
25119
25120
25121 --
25122 -- bulk performance
25123 --
25124 l_balance_type_code VARCHAR2(1);
25125 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
25126 l_log_module VARCHAR2(240);
25127
25128 --
25129 -- Upgrade strategy
25130 --
25131 l_actual_upg_option VARCHAR2(1);
25132 l_enc_upg_option VARCHAR2(1);
25133
25134 --
25135 BEGIN
25136 --
25137 IF g_log_enabled THEN
25138 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_58';
25139 END IF;
25140 --
25141 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25142
25143 trace
25144 (p_msg => 'BEGIN of AcctLineType_58'
25145 ,p_level => C_LEVEL_PROCEDURE
25146 ,p_module => l_log_module);
25147
25148 END IF;
25149 --
25150 l_component_type := 'AMB_JLT';
25151 l_component_code := 'MFAR_MISC_RCT_CASH';
25152 l_component_type_code := 'S';
25153 l_component_appl_id := 222;
25154 l_amb_context_code := 'DEFAULT';
25155 l_entity_code := 'RECEIPTS';
25156 l_event_class_code := 'MISC_RECEIPT';
25157 l_event_type_code := 'MISC_RECEIPT_ALL';
25158 l_line_definition_owner_code := 'S';
25159 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
25160 --
25161 l_balance_type_code := 'A';
25162 l_segment := NULL;
25163 l_ccid := NULL;
25164 l_adr_transaction_coa_id := NULL;
25165 l_adr_accounting_coa_id := NULL;
25166 l_adr_flexfield_segment_code := NULL;
25167 l_adr_flex_value_set_id := NULL;
25168 l_adr_value_type_code := NULL;
25169 l_adr_value_combination_id := NULL;
25170 l_adr_value_segment_code := NULL;
25171
25172 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
25173 l_bflow_class_code := ''; -- 4219869 Business Flow
25174 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
25175 l_budgetary_control_flag := 'N';
25176
25177 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25178 l_bflow_applied_to_amt := NULL; -- 5132302
25179 l_entered_amt_idx := NULL; -- 4262811
25180 l_accted_amt_idx := NULL; -- 4262811
25181 l_acc_rev_flag := NULL; -- 4262811
25182 l_accrual_line_num := NULL; -- 4262811
25183 l_tmp_amt := NULL; -- 4262811
25184 --
25185
25186 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
25187 l_balance_type_code <> 'B' THEN
25188 IF (NVL(p_source_15,'
25189 ') = 'CASH' OR
25190 NVL(p_source_15,'
25191 ') = 'TAX') AND
25192 NVL(p_source_54,'
25193 ') = 'N' AND
25194 NVL(p_source_56,'
25195 ') = 'N' AND
25196 NVL(p_source_57,'
25197 ') = 'N'
25198 THEN
25199
25200 --
25201 XLA_AE_LINES_PKG.SetNewLine;
25202
25203 p_balance_type_code := l_balance_type_code;
25204 -- set the flag so later we will know whether the gain loss line needs to be created
25205
25206 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
25207 p_actual_flag :='A';
25208 END IF;
25209
25210 --
25211 -- bulk performance
25212 --
25213 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
25214 p_header_num => 0); -- 4262811
25215 --
25216 -- set accounting line options
25217 --
25218 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
25219 p_natural_side_code => 'C'
25220 , p_gain_or_loss_flag => 'N'
25221 , p_gl_transfer_mode_code => 'S'
25222 , p_acct_entry_type_code => 'A'
25223 , p_switch_side_flag => 'Y'
25224 , p_merge_duplicate_code => 'A'
25225 );
25226 --
25227 l_acc_rev_natural_side_code := 'D'; -- 4262811
25228 --
25229 --
25230 -- set accounting line type info
25231 --
25232 xla_ae_lines_pkg.SetAcctLineType
25233 (p_component_type => l_component_type
25234 ,p_event_type_code => l_event_type_code
25235 ,p_line_definition_owner_code => l_line_definition_owner_code
25236 ,p_line_definition_code => l_line_definition_code
25237 ,p_accounting_line_code => l_component_code
25238 ,p_accounting_line_type_code => l_component_type_code
25239 ,p_accounting_line_appl_id => l_component_appl_id
25240 ,p_amb_context_code => l_amb_context_code
25241 ,p_entity_code => l_entity_code
25242 ,p_event_class_code => l_event_class_code);
25243 --
25244 -- set accounting class
25245 --
25246 xla_ae_lines_pkg.SetAcctClass(
25247 p_accounting_class_code => 'CASH'
25248 , p_ae_header_id => l_ae_header_id
25249 );
25250
25251 --
25252 -- set rounding class
25253 --
25254 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
25255 'RECEIVABLE';
25256
25257 --
25258 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
25259 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
25260 --
25261 -- bulk performance
25262 --
25263 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
25264
25265 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
25266 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
25267
25268 -- 4955764
25269 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25270 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
25271
25272 -- 4458381 Public Sector Enh
25273
25274 --
25275 -- set accounting attributes for the line type
25276 --
25277 l_entered_amt_idx := 3;
25278 l_accted_amt_idx := 8;
25279 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25280 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
25281 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
25282 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
25283 l_rec_acct_attrs.array_char_value(2) := p_source_18;
25284 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
25285 l_rec_acct_attrs.array_num_value(3) := p_source_19;
25286 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
25287 l_rec_acct_attrs.array_char_value(4) := p_source_20;
25288 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
25289 l_rec_acct_attrs.array_date_value(5) := p_source_55;
25290 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
25291 l_rec_acct_attrs.array_num_value(6) := p_source_22;
25292 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
25293 l_rec_acct_attrs.array_char_value(7) := p_source_23;
25294 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
25295 l_rec_acct_attrs.array_num_value(8) := p_source_24;
25296
25297 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
25298 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
25299
25300 ---------------------------------------------------------------------------------------------------------------
25301 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
25302 ---------------------------------------------------------------------------------------------------------------
25303 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
25304
25305 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25306 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25307
25308 IF xla_accounting_cache_pkg.GetValueChar
25309 (p_source_code => 'LEDGER_CATEGORY_CODE'
25310 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
25311 AND l_bflow_method_code = 'PRIOR_ENTRY'
25312 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
25313 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
25314 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
25315 )
25316 THEN
25317 xla_ae_lines_pkg.BflowUpgEntry
25318 (p_business_method_code => l_bflow_method_code
25319 ,p_business_class_code => l_bflow_class_code
25320 ,p_balance_type => l_balance_type_code);
25321 ELSE
25322 NULL;
25323 -- No business flow processing for business flow method of NONE.
25324 END IF;
25325
25326 --
25327 -- call analytical criteria
25328 --
25329
25330 --
25331 -- call description
25332 --
25333
25334 xla_ae_lines_pkg.SetLineDescription(
25335 p_ae_header_id => l_ae_header_id
25336 ,p_description => Description_1 (
25337 p_application_id => p_application_id
25338 , p_ae_header_id => l_ae_header_id
25339 )
25340 );
25341
25342
25343 --
25344 -- call ADRs
25345 -- Bug 4922099
25346 --
25347 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25348 (NVL(l_actual_upg_option, 'N') = 'O') OR
25349 (NVL(l_enc_upg_option, 'N') = 'O')
25350 )
25351 THEN
25352 NULL;
25353 --
25354 --
25355
25356 l_ccid := AcctDerRule_11(
25357 p_application_id => p_application_id
25358 , p_ae_header_id => l_ae_header_id
25359 , p_source_10 => p_source_10
25360 , x_transaction_coa_id => l_adr_transaction_coa_id
25361 , x_accounting_coa_id => l_adr_accounting_coa_id
25362 , x_value_type_code => l_adr_value_type_code
25363 , p_side => 'NA'
25364 );
25365
25366 xla_ae_lines_pkg.set_ccid(
25367 p_code_combination_id => l_ccid
25368 , p_value_type_code => l_adr_value_type_code
25369 , p_transaction_coa_id => l_adr_transaction_coa_id
25370 , p_accounting_coa_id => l_adr_accounting_coa_id
25371 , p_adr_code => 'DIST_CCID'
25372 , p_adr_type_code => 'S'
25373 , p_component_type => l_component_type
25374 , p_component_code => l_component_code
25375 , p_component_type_code => l_component_type_code
25376 , p_component_appl_id => l_component_appl_id
25377 , p_amb_context_code => l_amb_context_code
25378 , p_side => 'NA'
25379 );
25380
25381
25382 l_segment := AcctDerRule_6(
25383 p_application_id => p_application_id
25384 , p_ae_header_id => l_ae_header_id
25385 , p_source_5 => p_source_5
25386 , x_transaction_coa_id => l_adr_transaction_coa_id
25387 , x_accounting_coa_id => l_adr_accounting_coa_id
25388 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25389 , x_flex_value_set_id => l_adr_flex_value_set_id
25390 , x_value_type_code => l_adr_value_type_code
25391 , x_value_combination_id => l_adr_value_combination_id
25392 , x_value_segment_code => l_adr_value_segment_code
25393 , p_side => 'NA'
25394 , p_override_seg_flag => 'Y'
25395 );
25396
25397 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25398
25399 xla_ae_lines_pkg.set_segment(
25400 p_to_segment_code => 'GL_ACCOUNT'
25401 , p_segment_value => l_segment
25402 , p_from_segment_code => l_adr_value_segment_code
25403 , p_from_combination_id => l_adr_value_combination_id
25404 , p_value_type_code => l_adr_value_type_code
25405 , p_transaction_coa_id => l_adr_transaction_coa_id
25406 , p_accounting_coa_id => l_adr_accounting_coa_id
25407 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25408 , p_flex_value_set_id => l_adr_flex_value_set_id
25409 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
25410 , p_adr_type_code => 'S'
25411 , p_component_type => l_component_type
25412 , p_component_code => l_component_code
25413 , p_component_type_code => l_component_type_code
25414 , p_component_appl_id => l_component_appl_id
25415 , p_amb_context_code => l_amb_context_code
25416 , p_entity_code => 'RECEIPTS'
25417 , p_event_class_code => 'MISC_RECEIPT'
25418 , p_side => 'NA'
25419 );
25420
25421 END IF;
25422
25423 --
25424 --
25425 END IF;
25426 --
25427 -- Bug 4922099
25428 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
25429 (NVL(l_enc_upg_option, 'N') = 'O')
25430 ) AND
25431 (l_bflow_method_code = 'PRIOR_ENTRY')
25432 )
25433 THEN
25434 IF
25435 --
25436 1 = 2
25437 --
25438 THEN
25439 xla_accounting_err_pkg.build_message
25440 (p_appli_s_name => 'XLA'
25441 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25442 ,p_token_1 => 'LINE_NUMBER'
25443 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
25444 ,p_token_2 => 'LINE_TYPE_NAME'
25448 ,l_component_type_code
25445 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
25446 l_component_type
25447 ,l_component_code
25449 ,l_component_appl_id
25450 ,l_amb_context_code
25451 ,l_entity_code
25452 ,l_event_class_code
25453 )
25454 ,p_token_3 => 'OWNER'
25455 ,p_value_3 => xla_lookups_pkg.get_meaning(
25456 p_lookup_type => 'XLA_OWNER_TYPE'
25457 ,p_lookup_code => l_component_type_code
25458 )
25459 ,p_token_4 => 'PRODUCT_NAME'
25460 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
25461 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
25462 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
25463 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
25464 ,p_ae_header_id => NULL
25465 );
25466
25467 IF (C_LEVEL_ERROR>= g_log_level) THEN
25468 trace
25469 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25470 ,p_level => C_LEVEL_ERROR
25471 ,p_module => l_log_module);
25472 END IF;
25473 END IF;
25474 END IF;
25475 --
25476 --
25477 ------------------------------------------------------------------------------------------------
25478 -- 4219869 Business Flow
25479 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
25480 -- Prior Entry. Currently, the following code is always generated.
25481 ------------------------------------------------------------------------------------------------
25482 XLA_AE_LINES_PKG.ValidateCurrentLine;
25483
25484 ------------------------------------------------------------------------------------
25485 -- 4219869 Business Flow
25486 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
25487 ------------------------------------------------------------------------------------
25488 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25489
25490 ----------------------------------------------------------------------------------
25491 -- 4219869 Business Flow
25492 -- Update journal entry status -- Need to generate this within IF <condition>
25493 ----------------------------------------------------------------------------------
25494 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25495 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
25496 ,p_balance_type_code => l_balance_type_code
25497 );
25498
25499 -------------------------------------------------------------------------------------------
25500 -- 4262811 - Generate the Accrual Reversal lines
25501 -------------------------------------------------------------------------------------------
25502 BEGIN
25503 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
25504 (g_array_event(p_event_id).array_value_num('header_index'));
25505 IF l_acc_rev_flag IS NULL THEN
25506 l_acc_rev_flag := 'N';
25507 END IF;
25508 EXCEPTION
25509 WHEN OTHERS THEN
25510 l_acc_rev_flag := 'N';
25511 END;
25512 --
25513 IF (l_acc_rev_flag = 'Y') THEN
25514
25515 -- 4645092 ------------------------------------------------------------------------------
25516 -- To allow MPA report to determine if it should generate report process
25517 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
25518 ------------------------------------------------------------------------------------------
25519
25520 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
25521 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
25522 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
25523 -- call ADRs
25524 -- Bug 4922099
25525 --
25526 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25527 (NVL(l_actual_upg_option, 'N') = 'O') OR
25528 (NVL(l_enc_upg_option, 'N') = 'O')
25529 )
25530 THEN
25531 NULL;
25532 --
25533 --
25534
25535 l_ccid := AcctDerRule_11(
25536 p_application_id => p_application_id
25537 , p_ae_header_id => l_ae_header_id
25538 , p_source_10 => p_source_10
25539 , x_transaction_coa_id => l_adr_transaction_coa_id
25540 , x_accounting_coa_id => l_adr_accounting_coa_id
25541 , x_value_type_code => l_adr_value_type_code
25542 , p_side => 'NA'
25543 );
25544
25545 xla_ae_lines_pkg.set_ccid(
25546 p_code_combination_id => l_ccid
25547 , p_value_type_code => l_adr_value_type_code
25548 , p_transaction_coa_id => l_adr_transaction_coa_id
25549 , p_accounting_coa_id => l_adr_accounting_coa_id
25550 , p_adr_code => 'DIST_CCID'
25551 , p_adr_type_code => 'S'
25552 , p_component_type => l_component_type
25553 , p_component_code => l_component_code
25554 , p_component_type_code => l_component_type_code
25555 , p_component_appl_id => l_component_appl_id
25556 , p_amb_context_code => l_amb_context_code
25557 , p_side => 'NA'
25558 );
25559
25560
25561 l_segment := AcctDerRule_6(
25562 p_application_id => p_application_id
25563 , p_ae_header_id => l_ae_header_id
25564 , p_source_5 => p_source_5
25565 , x_transaction_coa_id => l_adr_transaction_coa_id
25566 , x_accounting_coa_id => l_adr_accounting_coa_id
25567 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25568 , x_flex_value_set_id => l_adr_flex_value_set_id
25569 , x_value_type_code => l_adr_value_type_code
25570 , x_value_combination_id => l_adr_value_combination_id
25571 , x_value_segment_code => l_adr_value_segment_code
25572 , p_side => 'NA'
25573 , p_override_seg_flag => 'Y'
25574 );
25575
25576 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25577
25578 xla_ae_lines_pkg.set_segment(
25579 p_to_segment_code => 'GL_ACCOUNT'
25580 , p_segment_value => l_segment
25581 , p_from_segment_code => l_adr_value_segment_code
25582 , p_from_combination_id => l_adr_value_combination_id
25583 , p_value_type_code => l_adr_value_type_code
25584 , p_transaction_coa_id => l_adr_transaction_coa_id
25585 , p_accounting_coa_id => l_adr_accounting_coa_id
25586 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25587 , p_flex_value_set_id => l_adr_flex_value_set_id
25588 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
25589 , p_adr_type_code => 'S'
25590 , p_component_type => l_component_type
25591 , p_component_code => l_component_code
25592 , p_component_type_code => l_component_type_code
25593 , p_component_appl_id => l_component_appl_id
25594 , p_amb_context_code => l_amb_context_code
25595 , p_entity_code => 'RECEIPTS'
25596 , p_event_class_code => 'MISC_RECEIPT'
25597 , p_side => 'NA'
25598 );
25599
25600 END IF;
25601
25602 --
25603 --
25604 END IF;
25605
25606 --
25607 -- Update the line information that should be overwritten
25608 --
25609 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
25610 p_header_num => 1);
25611 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
25612
25613 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
25614
25615 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
25616 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
25617 END IF;
25618
25619 --
25620 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
25621 --
25622 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
25623 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
25624 ELSE
25625 ---------------------------------------------------------------------------------------------------
25626 -- 4262811a Switch Sign
25627 ---------------------------------------------------------------------------------------------------
25628 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
25629 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25630 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25631 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25632 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25633 -- 5132302
25634 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
25635 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25636
25637 END IF;
25638
25639 -- 4955764
25640 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25641 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
25642
25643
25644 XLA_AE_LINES_PKG.ValidateCurrentLine;
25645 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25646
25647 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25648 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
25649 ,p_balance_type_code => l_balance_type_code);
25650
25651 END IF;
25652
25653 -----------------------------------------------------------------------------------------
25654 -- 4262811 Multiperiod Accounting
25655 -----------------------------------------------------------------------------------------
25656 -- No MPA option is assigned.
25657
25658
25659 END IF;
25660 END IF;
25661 --
25662
25663 --
25664 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25665 trace
25666 (p_msg => 'END of AcctLineType_58'
25667 ,p_level => C_LEVEL_PROCEDURE
25668 ,p_module => l_log_module);
25669 END IF;
25670 --
25671 EXCEPTION
25672 WHEN xla_exceptions_pkg.application_exception THEN
25673 RAISE;
25674 WHEN OTHERS THEN
25675 xla_exceptions_pkg.raise_message
25676 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_58');
25677 END AcctLineType_58;
25678 --
25679
25680 ---------------------------------------
25681 --
25682 -- PRIVATE FUNCTION
25683 -- AcctLineType_59
25684 --
25685 ---------------------------------------
25686 PROCEDURE AcctLineType_59 (
25687 p_application_id IN NUMBER
25688 ,p_event_id IN NUMBER
25689 ,p_calculate_acctd_flag IN VARCHAR2
25690 ,p_calculate_g_l_flag IN VARCHAR2
25691 ,p_actual_flag IN OUT VARCHAR2
25692 ,p_balance_type_code OUT VARCHAR2
25693 ,p_gain_or_loss_ref OUT VARCHAR2
25694
25695 --Remittance Bank Account Cash Account
25696 , p_source_5 IN NUMBER
25697 --Distribution GL Account
25698 , p_source_10 IN NUMBER
25699 --Distribution Source Type
25700 , p_source_15 IN VARCHAR2
25701 --Distribution Line Identifier
25702 , p_source_17 IN NUMBER
25703 --Distribution Type
25704 , p_source_18 IN VARCHAR2
25705 --Entered Amount
25706 , p_source_19 IN NUMBER
25707 --Currency Code
25708 , p_source_20 IN VARCHAR2
25709 --Exchange Rate
25710 , p_source_22 IN NUMBER
25711 --Exchange Rate Type
25712 , p_source_23 IN VARCHAR2
25713 --Applied To Document Accounting Amount
25714 , p_source_24 IN NUMBER
25715 --Distribution Multi Fund Additional Entry
25716 , p_source_54 IN VARCHAR2
25717 --Applied To Document Exchange Date
25718 , p_source_55 IN DATE
25719 --Receipt Class Require Remittance Flag
25720 , p_source_56 IN VARCHAR2
25721 )
25722 IS
25723
25724 l_component_type VARCHAR2(80);
25725 l_component_code VARCHAR2(30);
25726 l_component_type_code VARCHAR2(1);
25727 l_component_appl_id INTEGER;
25728 l_amb_context_code VARCHAR2(30);
25729 l_entity_code VARCHAR2(30);
25730 l_event_class_code VARCHAR2(30);
25731 l_ae_header_id NUMBER;
25732 l_event_type_code VARCHAR2(30);
25733 l_line_definition_code VARCHAR2(30);
25734 l_line_definition_owner_code VARCHAR2(1);
25735 --
25736 -- adr variables
25737 l_segment VARCHAR2(30);
25738 l_ccid NUMBER;
25739 l_adr_transaction_coa_id NUMBER;
25740 l_adr_accounting_coa_id NUMBER;
25741 l_adr_flexfield_segment_code VARCHAR2(30);
25742 l_adr_flex_value_set_id NUMBER;
25743 l_adr_value_type_code VARCHAR2(30);
25744 l_adr_value_combination_id NUMBER;
25745 l_adr_value_segment_code VARCHAR2(30);
25746
25747 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
25748 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
25749 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
25750 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
25751
25752 -- 4262811 Variables ------------------------------------------------------------------------------------------
25753 l_entered_amt_idx NUMBER;
25754 l_accted_amt_idx NUMBER;
25755 l_acc_rev_flag VARCHAR2(1);
25756 l_accrual_line_num NUMBER;
25757 l_tmp_amt NUMBER;
25758 l_acc_rev_natural_side_code VARCHAR2(1);
25759
25760 l_num_entries NUMBER;
25761 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
25762 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
25763 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
25764 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
25765 l_recog_line_1 NUMBER;
25766 l_recog_line_2 NUMBER;
25767
25768 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
25769 l_bflow_applied_to_amt NUMBER; -- 5132302
25770 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
25771
25772 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
25773
25774 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
25775 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
25776
25777 ---------------------------------------------------------------------------------------------------------------
25778
25779
25780 --
25781 -- bulk performance
25782 --
25783 l_balance_type_code VARCHAR2(1);
25784 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
25785 l_log_module VARCHAR2(240);
25786
25787 --
25788 -- Upgrade strategy
25789 --
25790 l_actual_upg_option VARCHAR2(1);
25791 l_enc_upg_option VARCHAR2(1);
25792
25793 --
25794 BEGIN
25795 --
25796 IF g_log_enabled THEN
25797 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_59';
25798 END IF;
25799 --
25800 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25801
25802 trace
25803 (p_msg => 'BEGIN of AcctLineType_59'
25804 ,p_level => C_LEVEL_PROCEDURE
25805 ,p_module => l_log_module);
25806
25807 END IF;
25808 --
25809 l_component_type := 'AMB_JLT';
25810 l_component_code := 'MFAR_MISC_RCT_CM_CASH';
25811 l_component_type_code := 'S';
25812 l_component_appl_id := 222;
25813 l_amb_context_code := 'DEFAULT';
25814 l_entity_code := 'RECEIPTS';
25815 l_event_class_code := 'MISC_RECEIPT';
25816 l_event_type_code := 'MISC_RECEIPT_ALL';
25817 l_line_definition_owner_code := 'S';
25818 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
25819 --
25820 l_balance_type_code := 'A';
25821 l_segment := NULL;
25822 l_ccid := NULL;
25823 l_adr_transaction_coa_id := NULL;
25824 l_adr_accounting_coa_id := NULL;
25825 l_adr_flexfield_segment_code := NULL;
25826 l_adr_flex_value_set_id := NULL;
25827 l_adr_value_type_code := NULL;
25828 l_adr_value_combination_id := NULL;
25829 l_adr_value_segment_code := NULL;
25830
25831 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
25832 l_bflow_class_code := ''; -- 4219869 Business Flow
25833 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
25834 l_budgetary_control_flag := 'N';
25835
25836 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25837 l_bflow_applied_to_amt := NULL; -- 5132302
25838 l_entered_amt_idx := NULL; -- 4262811
25839 l_accted_amt_idx := NULL; -- 4262811
25840 l_acc_rev_flag := NULL; -- 4262811
25841 l_accrual_line_num := NULL; -- 4262811
25842 l_tmp_amt := NULL; -- 4262811
25843 --
25844
25845 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
25846 l_balance_type_code <> 'B' THEN
25847 IF NVL(p_source_15,'
25848 ') = 'MISCCASH' AND
25849 NVL(p_source_54,'
25850 ') = 'Y' AND
25851 NVL(p_source_56,'
25852 ') = 'Y'
25853 THEN
25854
25855 --
25856 XLA_AE_LINES_PKG.SetNewLine;
25857
25858 p_balance_type_code := l_balance_type_code;
25859 -- set the flag so later we will know whether the gain loss line needs to be created
25860
25861 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
25862 p_actual_flag :='A';
25863 END IF;
25864
25865 --
25866 -- bulk performance
25867 --
25868 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
25869 p_header_num => 0); -- 4262811
25870 --
25871 -- set accounting line options
25872 --
25873 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
25874 p_natural_side_code => 'C'
25875 , p_gain_or_loss_flag => 'N'
25876 , p_gl_transfer_mode_code => 'S'
25877 , p_acct_entry_type_code => 'A'
25878 , p_switch_side_flag => 'Y'
25879 , p_merge_duplicate_code => 'A'
25880 );
25881 --
25882 l_acc_rev_natural_side_code := 'D'; -- 4262811
25883 --
25884 --
25885 -- set accounting line type info
25886 --
25887 xla_ae_lines_pkg.SetAcctLineType
25888 (p_component_type => l_component_type
25889 ,p_event_type_code => l_event_type_code
25890 ,p_line_definition_owner_code => l_line_definition_owner_code
25891 ,p_line_definition_code => l_line_definition_code
25892 ,p_accounting_line_code => l_component_code
25893 ,p_accounting_line_type_code => l_component_type_code
25894 ,p_accounting_line_appl_id => l_component_appl_id
25895 ,p_amb_context_code => l_amb_context_code
25896 ,p_entity_code => l_entity_code
25897 ,p_event_class_code => l_event_class_code);
25898 --
25899 -- set accounting class
25900 --
25901 xla_ae_lines_pkg.SetAcctClass(
25902 p_accounting_class_code => 'CASH'
25903 , p_ae_header_id => l_ae_header_id
25904 );
25905
25906 --
25907 -- set rounding class
25908 --
25909 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
25910 'RECEIVABLE';
25911
25912 --
25913 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
25914 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
25915 --
25916 -- bulk performance
25917 --
25918 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
25919
25920 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
25921 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
25922
25923 -- 4955764
25924 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25925 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
25926
25927 -- 4458381 Public Sector Enh
25928
25929 --
25930 -- set accounting attributes for the line type
25931 --
25932 l_entered_amt_idx := 3;
25933 l_accted_amt_idx := 8;
25934 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25935 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
25936 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
25937 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
25938 l_rec_acct_attrs.array_char_value(2) := p_source_18;
25939 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
25940 l_rec_acct_attrs.array_num_value(3) := p_source_19;
25941 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
25942 l_rec_acct_attrs.array_char_value(4) := p_source_20;
25943 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
25944 l_rec_acct_attrs.array_date_value(5) := p_source_55;
25945 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
25946 l_rec_acct_attrs.array_num_value(6) := p_source_22;
25947 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
25948 l_rec_acct_attrs.array_char_value(7) := p_source_23;
25949 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
25950 l_rec_acct_attrs.array_num_value(8) := p_source_24;
25951
25952 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
25953 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
25954
25955 ---------------------------------------------------------------------------------------------------------------
25956 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
25957 ---------------------------------------------------------------------------------------------------------------
25958 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
25959
25960 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25961 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25962
25963 IF xla_accounting_cache_pkg.GetValueChar
25964 (p_source_code => 'LEDGER_CATEGORY_CODE'
25965 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
25966 AND l_bflow_method_code = 'PRIOR_ENTRY'
25967 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
25968 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
25969 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
25970 )
25971 THEN
25972 xla_ae_lines_pkg.BflowUpgEntry
25973 (p_business_method_code => l_bflow_method_code
25974 ,p_business_class_code => l_bflow_class_code
25975 ,p_balance_type => l_balance_type_code);
25976 ELSE
25977 NULL;
25978 -- No business flow processing for business flow method of NONE.
25979 END IF;
25980
25981 --
25982 -- call analytical criteria
25983 --
25984
25985 --
25986 -- call description
25987 --
25988
25989 xla_ae_lines_pkg.SetLineDescription(
25990 p_ae_header_id => l_ae_header_id
25991 ,p_description => Description_1 (
25992 p_application_id => p_application_id
25993 , p_ae_header_id => l_ae_header_id
25994 )
25995 );
25996
25997
25998 --
25999 -- call ADRs
26000 -- Bug 4922099
26001 --
26002 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26003 (NVL(l_actual_upg_option, 'N') = 'O') OR
26004 (NVL(l_enc_upg_option, 'N') = 'O')
26005 )
26006 THEN
26007 NULL;
26008 --
26009 --
26010
26011 l_ccid := AcctDerRule_11(
26012 p_application_id => p_application_id
26013 , p_ae_header_id => l_ae_header_id
26014 , p_source_10 => p_source_10
26015 , x_transaction_coa_id => l_adr_transaction_coa_id
26016 , x_accounting_coa_id => l_adr_accounting_coa_id
26017 , x_value_type_code => l_adr_value_type_code
26018 , p_side => 'NA'
26019 );
26020
26021 xla_ae_lines_pkg.set_ccid(
26022 p_code_combination_id => l_ccid
26023 , p_value_type_code => l_adr_value_type_code
26024 , p_transaction_coa_id => l_adr_transaction_coa_id
26025 , p_accounting_coa_id => l_adr_accounting_coa_id
26026 , p_adr_code => 'DIST_CCID'
26027 , p_adr_type_code => 'S'
26028 , p_component_type => l_component_type
26029 , p_component_code => l_component_code
26030 , p_component_type_code => l_component_type_code
26031 , p_component_appl_id => l_component_appl_id
26032 , p_amb_context_code => l_amb_context_code
26033 , p_side => 'NA'
26034 );
26035
26036
26037 l_segment := AcctDerRule_6(
26038 p_application_id => p_application_id
26039 , p_ae_header_id => l_ae_header_id
26040 , p_source_5 => p_source_5
26041 , x_transaction_coa_id => l_adr_transaction_coa_id
26042 , x_accounting_coa_id => l_adr_accounting_coa_id
26043 , x_flexfield_segment_code => l_adr_flexfield_segment_code
26044 , x_flex_value_set_id => l_adr_flex_value_set_id
26045 , x_value_type_code => l_adr_value_type_code
26046 , x_value_combination_id => l_adr_value_combination_id
26047 , x_value_segment_code => l_adr_value_segment_code
26048 , p_side => 'NA'
26049 , p_override_seg_flag => 'Y'
26050 );
26051
26052 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
26053
26054 xla_ae_lines_pkg.set_segment(
26055 p_to_segment_code => 'GL_ACCOUNT'
26056 , p_segment_value => l_segment
26057 , p_from_segment_code => l_adr_value_segment_code
26058 , p_from_combination_id => l_adr_value_combination_id
26059 , p_value_type_code => l_adr_value_type_code
26060 , p_transaction_coa_id => l_adr_transaction_coa_id
26061 , p_accounting_coa_id => l_adr_accounting_coa_id
26062 , p_flexfield_segment_code => l_adr_flexfield_segment_code
26063 , p_flex_value_set_id => l_adr_flex_value_set_id
26064 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
26065 , p_adr_type_code => 'S'
26066 , p_component_type => l_component_type
26067 , p_component_code => l_component_code
26068 , p_component_type_code => l_component_type_code
26069 , p_component_appl_id => l_component_appl_id
26070 , p_amb_context_code => l_amb_context_code
26071 , p_entity_code => 'RECEIPTS'
26072 , p_event_class_code => 'MISC_RECEIPT'
26073 , p_side => 'NA'
26074 );
26075
26076 END IF;
26077
26078 --
26079 --
26080 END IF;
26081 --
26082 -- Bug 4922099
26083 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
26084 (NVL(l_enc_upg_option, 'N') = 'O')
26085 ) AND
26086 (l_bflow_method_code = 'PRIOR_ENTRY')
26087 )
26088 THEN
26089 IF
26090 --
26091 1 = 2
26092 --
26093 THEN
26094 xla_accounting_err_pkg.build_message
26095 (p_appli_s_name => 'XLA'
26096 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26097 ,p_token_1 => 'LINE_NUMBER'
26098 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
26099 ,p_token_2 => 'LINE_TYPE_NAME'
26100 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
26101 l_component_type
26102 ,l_component_code
26103 ,l_component_type_code
26104 ,l_component_appl_id
26105 ,l_amb_context_code
26106 ,l_entity_code
26107 ,l_event_class_code
26108 )
26109 ,p_token_3 => 'OWNER'
26110 ,p_value_3 => xla_lookups_pkg.get_meaning(
26111 p_lookup_type => 'XLA_OWNER_TYPE'
26112 ,p_lookup_code => l_component_type_code
26113 )
26114 ,p_token_4 => 'PRODUCT_NAME'
26115 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
26116 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
26117 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
26118 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
26119 ,p_ae_header_id => NULL
26120 );
26121
26122 IF (C_LEVEL_ERROR>= g_log_level) THEN
26123 trace
26124 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26125 ,p_level => C_LEVEL_ERROR
26126 ,p_module => l_log_module);
26127 END IF;
26128 END IF;
26129 END IF;
26130 --
26131 --
26132 ------------------------------------------------------------------------------------------------
26133 -- 4219869 Business Flow
26134 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
26135 -- Prior Entry. Currently, the following code is always generated.
26136 ------------------------------------------------------------------------------------------------
26137 XLA_AE_LINES_PKG.ValidateCurrentLine;
26138
26139 ------------------------------------------------------------------------------------
26140 -- 4219869 Business Flow
26141 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
26142 ------------------------------------------------------------------------------------
26143 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26144
26145 ----------------------------------------------------------------------------------
26146 -- 4219869 Business Flow
26147 -- Update journal entry status -- Need to generate this within IF <condition>
26148 ----------------------------------------------------------------------------------
26149 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26150 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
26151 ,p_balance_type_code => l_balance_type_code
26152 );
26153
26154 -------------------------------------------------------------------------------------------
26155 -- 4262811 - Generate the Accrual Reversal lines
26156 -------------------------------------------------------------------------------------------
26157 BEGIN
26158 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
26159 (g_array_event(p_event_id).array_value_num('header_index'));
26160 IF l_acc_rev_flag IS NULL THEN
26161 l_acc_rev_flag := 'N';
26162 END IF;
26163 EXCEPTION
26164 WHEN OTHERS THEN
26165 l_acc_rev_flag := 'N';
26166 END;
26167 --
26168 IF (l_acc_rev_flag = 'Y') THEN
26169
26170 -- 4645092 ------------------------------------------------------------------------------
26171 -- To allow MPA report to determine if it should generate report process
26172 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
26173 ------------------------------------------------------------------------------------------
26174
26175 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
26176 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
26177 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
26178 -- call ADRs
26179 -- Bug 4922099
26180 --
26181 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26182 (NVL(l_actual_upg_option, 'N') = 'O') OR
26183 (NVL(l_enc_upg_option, 'N') = 'O')
26184 )
26185 THEN
26186 NULL;
26187 --
26188 --
26189
26190 l_ccid := AcctDerRule_11(
26191 p_application_id => p_application_id
26192 , p_ae_header_id => l_ae_header_id
26193 , p_source_10 => p_source_10
26194 , x_transaction_coa_id => l_adr_transaction_coa_id
26195 , x_accounting_coa_id => l_adr_accounting_coa_id
26196 , x_value_type_code => l_adr_value_type_code
26197 , p_side => 'NA'
26198 );
26199
26200 xla_ae_lines_pkg.set_ccid(
26201 p_code_combination_id => l_ccid
26202 , p_value_type_code => l_adr_value_type_code
26203 , p_transaction_coa_id => l_adr_transaction_coa_id
26204 , p_accounting_coa_id => l_adr_accounting_coa_id
26205 , p_adr_code => 'DIST_CCID'
26206 , p_adr_type_code => 'S'
26207 , p_component_type => l_component_type
26208 , p_component_code => l_component_code
26209 , p_component_type_code => l_component_type_code
26210 , p_component_appl_id => l_component_appl_id
26211 , p_amb_context_code => l_amb_context_code
26212 , p_side => 'NA'
26213 );
26214
26215
26216 l_segment := AcctDerRule_6(
26217 p_application_id => p_application_id
26218 , p_ae_header_id => l_ae_header_id
26219 , p_source_5 => p_source_5
26220 , x_transaction_coa_id => l_adr_transaction_coa_id
26221 , x_accounting_coa_id => l_adr_accounting_coa_id
26222 , x_flexfield_segment_code => l_adr_flexfield_segment_code
26223 , x_flex_value_set_id => l_adr_flex_value_set_id
26224 , x_value_type_code => l_adr_value_type_code
26225 , x_value_combination_id => l_adr_value_combination_id
26226 , x_value_segment_code => l_adr_value_segment_code
26227 , p_side => 'NA'
26228 , p_override_seg_flag => 'Y'
26229 );
26230
26231 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
26232
26233 xla_ae_lines_pkg.set_segment(
26234 p_to_segment_code => 'GL_ACCOUNT'
26235 , p_segment_value => l_segment
26236 , p_from_segment_code => l_adr_value_segment_code
26237 , p_from_combination_id => l_adr_value_combination_id
26238 , p_value_type_code => l_adr_value_type_code
26239 , p_transaction_coa_id => l_adr_transaction_coa_id
26240 , p_accounting_coa_id => l_adr_accounting_coa_id
26241 , p_flexfield_segment_code => l_adr_flexfield_segment_code
26242 , p_flex_value_set_id => l_adr_flex_value_set_id
26243 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
26244 , p_adr_type_code => 'S'
26245 , p_component_type => l_component_type
26246 , p_component_code => l_component_code
26247 , p_component_type_code => l_component_type_code
26248 , p_component_appl_id => l_component_appl_id
26249 , p_amb_context_code => l_amb_context_code
26250 , p_entity_code => 'RECEIPTS'
26251 , p_event_class_code => 'MISC_RECEIPT'
26252 , p_side => 'NA'
26253 );
26254
26255 END IF;
26256
26257 --
26258 --
26259 END IF;
26260
26261 --
26262 -- Update the line information that should be overwritten
26263 --
26264 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
26265 p_header_num => 1);
26266 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
26267
26268 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
26269
26270 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
26271 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
26272 END IF;
26273
26274 --
26275 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
26276 --
26277 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
26278 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
26279 ELSE
26280 ---------------------------------------------------------------------------------------------------
26281 -- 4262811a Switch Sign
26282 ---------------------------------------------------------------------------------------------------
26283 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
26284 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26285 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26286 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26287 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26288 -- 5132302
26289 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
26290 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26291
26292 END IF;
26293
26294 -- 4955764
26295 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26296 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
26297
26298
26299 XLA_AE_LINES_PKG.ValidateCurrentLine;
26300 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26301
26302 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26303 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
26304 ,p_balance_type_code => l_balance_type_code);
26305
26306 END IF;
26307
26308 -----------------------------------------------------------------------------------------
26309 -- 4262811 Multiperiod Accounting
26310 -----------------------------------------------------------------------------------------
26311 -- No MPA option is assigned.
26312
26313
26314 END IF;
26315 END IF;
26316 --
26317
26318 --
26319 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26320 trace
26321 (p_msg => 'END of AcctLineType_59'
26322 ,p_level => C_LEVEL_PROCEDURE
26323 ,p_module => l_log_module);
26324 END IF;
26325 --
26326 EXCEPTION
26327 WHEN xla_exceptions_pkg.application_exception THEN
26328 RAISE;
26329 WHEN OTHERS THEN
26330 xla_exceptions_pkg.raise_message
26331 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_59');
26332 END AcctLineType_59;
26333 --
26334
26335 ---------------------------------------
26336 --
26337 -- PRIVATE FUNCTION
26338 -- AcctLineType_60
26339 --
26340 ---------------------------------------
26341 PROCEDURE AcctLineType_60 (
26342 p_application_id IN NUMBER
26343 ,p_event_id IN NUMBER
26344 ,p_calculate_acctd_flag IN VARCHAR2
26345 ,p_calculate_g_l_flag IN VARCHAR2
26346 ,p_actual_flag IN OUT VARCHAR2
26347 ,p_balance_type_code OUT VARCHAR2
26348 ,p_gain_or_loss_ref OUT VARCHAR2
26349
26350 --Remittance Bank Account Confirmation Account
26351 , p_source_3 IN NUMBER
26352 --Distribution GL Account
26353 , p_source_10 IN NUMBER
26354 --Distribution Source Type
26355 , p_source_15 IN VARCHAR2
26356 --Distribution Line Identifier
26357 , p_source_17 IN NUMBER
26358 --Distribution Type
26359 , p_source_18 IN VARCHAR2
26360 --Entered Amount
26361 , p_source_19 IN NUMBER
26362 --Currency Code
26363 , p_source_20 IN VARCHAR2
26364 --Exchange Rate
26365 , p_source_22 IN NUMBER
26366 --Exchange Rate Type
26367 , p_source_23 IN VARCHAR2
26368 --Applied To Document Accounting Amount
26369 , p_source_24 IN NUMBER
26370 --Distribution Multi Fund Additional Entry
26371 , p_source_54 IN VARCHAR2
26372 --Applied To Document Exchange Date
26373 , p_source_55 IN DATE
26374 )
26375 IS
26376
26377 l_component_type VARCHAR2(80);
26378 l_component_code VARCHAR2(30);
26379 l_component_type_code VARCHAR2(1);
26380 l_component_appl_id INTEGER;
26381 l_amb_context_code VARCHAR2(30);
26382 l_entity_code VARCHAR2(30);
26383 l_event_class_code VARCHAR2(30);
26384 l_ae_header_id NUMBER;
26385 l_event_type_code VARCHAR2(30);
26386 l_line_definition_code VARCHAR2(30);
26387 l_line_definition_owner_code VARCHAR2(1);
26388 --
26389 -- adr variables
26390 l_segment VARCHAR2(30);
26391 l_ccid NUMBER;
26392 l_adr_transaction_coa_id NUMBER;
26393 l_adr_accounting_coa_id NUMBER;
26394 l_adr_flexfield_segment_code VARCHAR2(30);
26395 l_adr_flex_value_set_id NUMBER;
26396 l_adr_value_type_code VARCHAR2(30);
26397 l_adr_value_combination_id NUMBER;
26398 l_adr_value_segment_code VARCHAR2(30);
26399
26400 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
26401 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
26402 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
26403 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
26404
26405 -- 4262811 Variables ------------------------------------------------------------------------------------------
26406 l_entered_amt_idx NUMBER;
26407 l_accted_amt_idx NUMBER;
26408 l_acc_rev_flag VARCHAR2(1);
26409 l_accrual_line_num NUMBER;
26410 l_tmp_amt NUMBER;
26411 l_acc_rev_natural_side_code VARCHAR2(1);
26412
26413 l_num_entries NUMBER;
26414 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
26415 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
26416 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
26417 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
26418 l_recog_line_1 NUMBER;
26419 l_recog_line_2 NUMBER;
26420
26421 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
26422 l_bflow_applied_to_amt NUMBER; -- 5132302
26423 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
26424
26425 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
26426
26427 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
26428 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
26429
26430 ---------------------------------------------------------------------------------------------------------------
26431
26432
26433 --
26434 -- bulk performance
26435 --
26436 l_balance_type_code VARCHAR2(1);
26437 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
26438 l_log_module VARCHAR2(240);
26439
26440 --
26441 -- Upgrade strategy
26442 --
26443 l_actual_upg_option VARCHAR2(1);
26444 l_enc_upg_option VARCHAR2(1);
26445
26446 --
26447 BEGIN
26448 --
26449 IF g_log_enabled THEN
26450 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_60';
26451 END IF;
26452 --
26453 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26454
26455 trace
26456 (p_msg => 'BEGIN of AcctLineType_60'
26457 ,p_level => C_LEVEL_PROCEDURE
26458 ,p_module => l_log_module);
26459
26460 END IF;
26461 --
26462 l_component_type := 'AMB_JLT';
26463 l_component_code := 'MFAR_MISC_RCT_CONFIRMATION';
26464 l_component_type_code := 'S';
26465 l_component_appl_id := 222;
26466 l_amb_context_code := 'DEFAULT';
26467 l_entity_code := 'RECEIPTS';
26468 l_event_class_code := 'MISC_RECEIPT';
26469 l_event_type_code := 'MISC_RECEIPT_ALL';
26470 l_line_definition_owner_code := 'S';
26471 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
26472 --
26473 l_balance_type_code := 'A';
26474 l_segment := NULL;
26475 l_ccid := NULL;
26476 l_adr_transaction_coa_id := NULL;
26477 l_adr_accounting_coa_id := NULL;
26478 l_adr_flexfield_segment_code := NULL;
26479 l_adr_flex_value_set_id := NULL;
26480 l_adr_value_type_code := NULL;
26481 l_adr_value_combination_id := NULL;
26482 l_adr_value_segment_code := NULL;
26483
26484 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
26485 l_bflow_class_code := ''; -- 4219869 Business Flow
26486 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
26487 l_budgetary_control_flag := 'N';
26488
26489 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26490 l_bflow_applied_to_amt := NULL; -- 5132302
26491 l_entered_amt_idx := NULL; -- 4262811
26492 l_accted_amt_idx := NULL; -- 4262811
26493 l_acc_rev_flag := NULL; -- 4262811
26494 l_accrual_line_num := NULL; -- 4262811
26495 l_tmp_amt := NULL; -- 4262811
26496 --
26497
26498 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
26499 l_balance_type_code <> 'B' THEN
26500 IF NVL(p_source_15,'
26501 ') = 'CONFIRMATION' AND
26502 NVL(p_source_54,'
26503 ') = 'Y'
26504 THEN
26505
26506 --
26507 XLA_AE_LINES_PKG.SetNewLine;
26508
26509 p_balance_type_code := l_balance_type_code;
26510 -- set the flag so later we will know whether the gain loss line needs to be created
26511
26512 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
26513 p_actual_flag :='A';
26514 END IF;
26515
26516 --
26517 -- bulk performance
26518 --
26519 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
26520 p_header_num => 0); -- 4262811
26521 --
26522 -- set accounting line options
26523 --
26524 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
26525 p_natural_side_code => 'C'
26526 , p_gain_or_loss_flag => 'N'
26527 , p_gl_transfer_mode_code => 'S'
26528 , p_acct_entry_type_code => 'A'
26529 , p_switch_side_flag => 'Y'
26530 , p_merge_duplicate_code => 'A'
26531 );
26532 --
26533 l_acc_rev_natural_side_code := 'D'; -- 4262811
26534 --
26535 --
26536 -- set accounting line type info
26537 --
26538 xla_ae_lines_pkg.SetAcctLineType
26539 (p_component_type => l_component_type
26540 ,p_event_type_code => l_event_type_code
26541 ,p_line_definition_owner_code => l_line_definition_owner_code
26542 ,p_line_definition_code => l_line_definition_code
26543 ,p_accounting_line_code => l_component_code
26544 ,p_accounting_line_type_code => l_component_type_code
26545 ,p_accounting_line_appl_id => l_component_appl_id
26546 ,p_amb_context_code => l_amb_context_code
26547 ,p_entity_code => l_entity_code
26548 ,p_event_class_code => l_event_class_code);
26549 --
26550 -- set accounting class
26551 --
26552 xla_ae_lines_pkg.SetAcctClass(
26553 p_accounting_class_code => 'CONFIRMATION'
26554 , p_ae_header_id => l_ae_header_id
26555 );
26556
26557 --
26558 -- set rounding class
26559 --
26560 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
26561 'RECEIVABLE';
26562
26563 --
26564 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
26565 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
26566 --
26567 -- bulk performance
26568 --
26569 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
26570
26571 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
26572 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
26573
26574 -- 4955764
26575 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26576 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
26577
26578 -- 4458381 Public Sector Enh
26579
26580 --
26581 -- set accounting attributes for the line type
26582 --
26583 l_entered_amt_idx := 3;
26584 l_accted_amt_idx := 8;
26585 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26586 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
26587 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
26588 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
26589 l_rec_acct_attrs.array_char_value(2) := p_source_18;
26590 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
26591 l_rec_acct_attrs.array_num_value(3) := p_source_19;
26592 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
26593 l_rec_acct_attrs.array_char_value(4) := p_source_20;
26594 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
26595 l_rec_acct_attrs.array_date_value(5) := p_source_55;
26596 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
26597 l_rec_acct_attrs.array_num_value(6) := p_source_22;
26598 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
26599 l_rec_acct_attrs.array_char_value(7) := p_source_23;
26600 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
26601 l_rec_acct_attrs.array_num_value(8) := p_source_24;
26602
26603 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
26604 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
26605
26606 ---------------------------------------------------------------------------------------------------------------
26607 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
26608 ---------------------------------------------------------------------------------------------------------------
26609 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
26610
26611 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26612 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26613
26614 IF xla_accounting_cache_pkg.GetValueChar
26615 (p_source_code => 'LEDGER_CATEGORY_CODE'
26616 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
26617 AND l_bflow_method_code = 'PRIOR_ENTRY'
26618 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
26619 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
26620 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
26621 )
26622 THEN
26623 xla_ae_lines_pkg.BflowUpgEntry
26624 (p_business_method_code => l_bflow_method_code
26625 ,p_business_class_code => l_bflow_class_code
26626 ,p_balance_type => l_balance_type_code);
26627 ELSE
26628 NULL;
26629 -- No business flow processing for business flow method of NONE.
26630 END IF;
26631
26632 --
26633 -- call analytical criteria
26634 --
26635
26636 --
26637 -- call description
26638 --
26639
26640 xla_ae_lines_pkg.SetLineDescription(
26641 p_ae_header_id => l_ae_header_id
26642 ,p_description => Description_1 (
26643 p_application_id => p_application_id
26644 , p_ae_header_id => l_ae_header_id
26645 )
26646 );
26647
26648
26649 --
26650 -- call ADRs
26651 -- Bug 4922099
26652 --
26653 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26654 (NVL(l_actual_upg_option, 'N') = 'O') OR
26655 (NVL(l_enc_upg_option, 'N') = 'O')
26656 )
26657 THEN
26658 NULL;
26659 --
26660 --
26661
26662 l_ccid := AcctDerRule_11(
26663 p_application_id => p_application_id
26664 , p_ae_header_id => l_ae_header_id
26665 , p_source_10 => p_source_10
26666 , x_transaction_coa_id => l_adr_transaction_coa_id
26667 , x_accounting_coa_id => l_adr_accounting_coa_id
26668 , x_value_type_code => l_adr_value_type_code
26669 , p_side => 'NA'
26670 );
26671
26672 xla_ae_lines_pkg.set_ccid(
26673 p_code_combination_id => l_ccid
26674 , p_value_type_code => l_adr_value_type_code
26675 , p_transaction_coa_id => l_adr_transaction_coa_id
26676 , p_accounting_coa_id => l_adr_accounting_coa_id
26677 , p_adr_code => 'DIST_CCID'
26678 , p_adr_type_code => 'S'
26679 , p_component_type => l_component_type
26680 , p_component_code => l_component_code
26681 , p_component_type_code => l_component_type_code
26682 , p_component_appl_id => l_component_appl_id
26683 , p_amb_context_code => l_amb_context_code
26684 , p_side => 'NA'
26685 );
26686
26687
26688 l_segment := AcctDerRule_4(
26689 p_application_id => p_application_id
26690 , p_ae_header_id => l_ae_header_id
26691 , p_source_3 => p_source_3
26692 , x_transaction_coa_id => l_adr_transaction_coa_id
26693 , x_accounting_coa_id => l_adr_accounting_coa_id
26694 , x_flexfield_segment_code => l_adr_flexfield_segment_code
26695 , x_flex_value_set_id => l_adr_flex_value_set_id
26696 , x_value_type_code => l_adr_value_type_code
26697 , x_value_combination_id => l_adr_value_combination_id
26698 , x_value_segment_code => l_adr_value_segment_code
26699 , p_side => 'NA'
26700 , p_override_seg_flag => 'Y'
26704
26701 );
26702
26703 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
26705 xla_ae_lines_pkg.set_segment(
26706 p_to_segment_code => 'GL_ACCOUNT'
26707 , p_segment_value => l_segment
26708 , p_from_segment_code => l_adr_value_segment_code
26709 , p_from_combination_id => l_adr_value_combination_id
26710 , p_value_type_code => l_adr_value_type_code
26711 , p_transaction_coa_id => l_adr_transaction_coa_id
26712 , p_accounting_coa_id => l_adr_accounting_coa_id
26713 , p_flexfield_segment_code => l_adr_flexfield_segment_code
26714 , p_flex_value_set_id => l_adr_flex_value_set_id
26715 , p_adr_code => 'MFAR_RCT_CONFIRMATION_NATSEG'
26716 , p_adr_type_code => 'S'
26717 , p_component_type => l_component_type
26718 , p_component_code => l_component_code
26719 , p_component_type_code => l_component_type_code
26720 , p_component_appl_id => l_component_appl_id
26721 , p_amb_context_code => l_amb_context_code
26722 , p_entity_code => 'RECEIPTS'
26723 , p_event_class_code => 'MISC_RECEIPT'
26724 , p_side => 'NA'
26725 );
26726
26727 END IF;
26728
26729 --
26730 --
26731 END IF;
26732 --
26733 -- Bug 4922099
26734 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
26735 (NVL(l_enc_upg_option, 'N') = 'O')
26736 ) AND
26737 (l_bflow_method_code = 'PRIOR_ENTRY')
26738 )
26739 THEN
26740 IF
26741 --
26742 1 = 2
26743 --
26744 THEN
26745 xla_accounting_err_pkg.build_message
26746 (p_appli_s_name => 'XLA'
26747 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26748 ,p_token_1 => 'LINE_NUMBER'
26749 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
26750 ,p_token_2 => 'LINE_TYPE_NAME'
26751 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
26752 l_component_type
26753 ,l_component_code
26754 ,l_component_type_code
26755 ,l_component_appl_id
26756 ,l_amb_context_code
26757 ,l_entity_code
26758 ,l_event_class_code
26759 )
26760 ,p_token_3 => 'OWNER'
26761 ,p_value_3 => xla_lookups_pkg.get_meaning(
26762 p_lookup_type => 'XLA_OWNER_TYPE'
26763 ,p_lookup_code => l_component_type_code
26764 )
26765 ,p_token_4 => 'PRODUCT_NAME'
26766 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
26767 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
26768 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
26769 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
26770 ,p_ae_header_id => NULL
26771 );
26772
26773 IF (C_LEVEL_ERROR>= g_log_level) THEN
26774 trace
26775 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26776 ,p_level => C_LEVEL_ERROR
26777 ,p_module => l_log_module);
26778 END IF;
26779 END IF;
26780 END IF;
26781 --
26782 --
26783 ------------------------------------------------------------------------------------------------
26784 -- 4219869 Business Flow
26785 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
26786 -- Prior Entry. Currently, the following code is always generated.
26787 ------------------------------------------------------------------------------------------------
26788 XLA_AE_LINES_PKG.ValidateCurrentLine;
26789
26790 ------------------------------------------------------------------------------------
26791 -- 4219869 Business Flow
26792 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
26793 ------------------------------------------------------------------------------------
26794 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26795
26796 ----------------------------------------------------------------------------------
26797 -- 4219869 Business Flow
26798 -- Update journal entry status -- Need to generate this within IF <condition>
26799 ----------------------------------------------------------------------------------
26800 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26801 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
26802 ,p_balance_type_code => l_balance_type_code
26803 );
26804
26805 -------------------------------------------------------------------------------------------
26806 -- 4262811 - Generate the Accrual Reversal lines
26807 -------------------------------------------------------------------------------------------
26808 BEGIN
26809 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
26810 (g_array_event(p_event_id).array_value_num('header_index'));
26811 IF l_acc_rev_flag IS NULL THEN
26812 l_acc_rev_flag := 'N';
26813 END IF;
26814 EXCEPTION
26815 WHEN OTHERS THEN
26816 l_acc_rev_flag := 'N';
26817 END;
26818 --
26819 IF (l_acc_rev_flag = 'Y') THEN
26820
26821 -- 4645092 ------------------------------------------------------------------------------
26822 -- To allow MPA report to determine if it should generate report process
26823 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
26824 ------------------------------------------------------------------------------------------
26825
26826 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
26827 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
26828 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
26829 -- call ADRs
26830 -- Bug 4922099
26831 --
26832 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26833 (NVL(l_actual_upg_option, 'N') = 'O') OR
26834 (NVL(l_enc_upg_option, 'N') = 'O')
26835 )
26836 THEN
26837 NULL;
26838 --
26839 --
26840
26841 l_ccid := AcctDerRule_11(
26842 p_application_id => p_application_id
26843 , p_ae_header_id => l_ae_header_id
26844 , p_source_10 => p_source_10
26845 , x_transaction_coa_id => l_adr_transaction_coa_id
26846 , x_accounting_coa_id => l_adr_accounting_coa_id
26847 , x_value_type_code => l_adr_value_type_code
26848 , p_side => 'NA'
26849 );
26850
26851 xla_ae_lines_pkg.set_ccid(
26852 p_code_combination_id => l_ccid
26853 , p_value_type_code => l_adr_value_type_code
26854 , p_transaction_coa_id => l_adr_transaction_coa_id
26855 , p_accounting_coa_id => l_adr_accounting_coa_id
26856 , p_adr_code => 'DIST_CCID'
26857 , p_adr_type_code => 'S'
26858 , p_component_type => l_component_type
26859 , p_component_code => l_component_code
26860 , p_component_type_code => l_component_type_code
26861 , p_component_appl_id => l_component_appl_id
26862 , p_amb_context_code => l_amb_context_code
26863 , p_side => 'NA'
26864 );
26865
26866
26867 l_segment := AcctDerRule_4(
26868 p_application_id => p_application_id
26869 , p_ae_header_id => l_ae_header_id
26870 , p_source_3 => p_source_3
26871 , x_transaction_coa_id => l_adr_transaction_coa_id
26872 , x_accounting_coa_id => l_adr_accounting_coa_id
26873 , x_flexfield_segment_code => l_adr_flexfield_segment_code
26874 , x_flex_value_set_id => l_adr_flex_value_set_id
26875 , x_value_type_code => l_adr_value_type_code
26876 , x_value_combination_id => l_adr_value_combination_id
26877 , x_value_segment_code => l_adr_value_segment_code
26878 , p_side => 'NA'
26882 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
26879 , p_override_seg_flag => 'Y'
26880 );
26881
26883
26884 xla_ae_lines_pkg.set_segment(
26885 p_to_segment_code => 'GL_ACCOUNT'
26886 , p_segment_value => l_segment
26887 , p_from_segment_code => l_adr_value_segment_code
26888 , p_from_combination_id => l_adr_value_combination_id
26889 , p_value_type_code => l_adr_value_type_code
26890 , p_transaction_coa_id => l_adr_transaction_coa_id
26891 , p_accounting_coa_id => l_adr_accounting_coa_id
26892 , p_flexfield_segment_code => l_adr_flexfield_segment_code
26893 , p_flex_value_set_id => l_adr_flex_value_set_id
26894 , p_adr_code => 'MFAR_RCT_CONFIRMATION_NATSEG'
26895 , p_adr_type_code => 'S'
26896 , p_component_type => l_component_type
26897 , p_component_code => l_component_code
26898 , p_component_type_code => l_component_type_code
26899 , p_component_appl_id => l_component_appl_id
26900 , p_amb_context_code => l_amb_context_code
26901 , p_entity_code => 'RECEIPTS'
26902 , p_event_class_code => 'MISC_RECEIPT'
26903 , p_side => 'NA'
26904 );
26905
26906 END IF;
26907
26908 --
26909 --
26910 END IF;
26911
26912 --
26913 -- Update the line information that should be overwritten
26914 --
26915 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
26916 p_header_num => 1);
26917 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
26918
26919 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
26920
26921 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
26922 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
26923 END IF;
26924
26925 --
26926 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
26927 --
26928 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
26929 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
26930 ELSE
26931 ---------------------------------------------------------------------------------------------------
26932 -- 4262811a Switch Sign
26933 ---------------------------------------------------------------------------------------------------
26934 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
26935 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26936 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26937 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26938 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26939 -- 5132302
26940 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
26941 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26942
26943 END IF;
26944
26945 -- 4955764
26946 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26947 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
26948
26949
26950 XLA_AE_LINES_PKG.ValidateCurrentLine;
26951 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26952
26953 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26954 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
26955 ,p_balance_type_code => l_balance_type_code);
26956
26957 END IF;
26958
26959 -----------------------------------------------------------------------------------------
26960 -- 4262811 Multiperiod Accounting
26961 -----------------------------------------------------------------------------------------
26962 -- No MPA option is assigned.
26963
26964
26965 END IF;
26966 END IF;
26967 --
26968
26969 --
26970 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26971 trace
26972 (p_msg => 'END of AcctLineType_60'
26973 ,p_level => C_LEVEL_PROCEDURE
26974 ,p_module => l_log_module);
26975 END IF;
26976 --
26977 EXCEPTION
26978 WHEN xla_exceptions_pkg.application_exception THEN
26979 RAISE;
26980 WHEN OTHERS THEN
26981 xla_exceptions_pkg.raise_message
26982 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_60');
26983 END AcctLineType_60;
26984 --
26985
26986 ---------------------------------------
26987 --
26988 -- PRIVATE FUNCTION
26989 -- AcctLineType_61
26990 --
26991 ---------------------------------------
26992 PROCEDURE AcctLineType_61 (
26993 p_application_id IN NUMBER
26994 ,p_event_id IN NUMBER
26995 ,p_calculate_acctd_flag IN VARCHAR2
26996 ,p_calculate_g_l_flag IN VARCHAR2
26997 ,p_actual_flag IN OUT VARCHAR2
26998 ,p_balance_type_code OUT VARCHAR2
26999 ,p_gain_or_loss_ref OUT VARCHAR2
27000
27001 --Remittance Bank Account Remittance Account
27002 , p_source_6 IN NUMBER
27003 --Distribution GL Account
27004 , p_source_10 IN NUMBER
27005 --Distribution Source Type
27006 , p_source_15 IN VARCHAR2
27007 --Distribution Line Identifier
27008 , p_source_17 IN NUMBER
27009 --Distribution Type
27010 , p_source_18 IN VARCHAR2
27011 --Entered Amount
27012 , p_source_19 IN NUMBER
27013 --Currency Code
27014 , p_source_20 IN VARCHAR2
27015 --Exchange Rate
27016 , p_source_22 IN NUMBER
27017 --Exchange Rate Type
27018 , p_source_23 IN VARCHAR2
27019 --Applied To Document Accounting Amount
27020 , p_source_24 IN NUMBER
27021 --Distribution Multi Fund Additional Entry
27022 , p_source_54 IN VARCHAR2
27023 --Applied To Document Exchange Date
27024 , p_source_55 IN DATE
27025 )
27026 IS
27027
27028 l_component_type VARCHAR2(80);
27029 l_component_code VARCHAR2(30);
27030 l_component_type_code VARCHAR2(1);
27031 l_component_appl_id INTEGER;
27032 l_amb_context_code VARCHAR2(30);
27033 l_entity_code VARCHAR2(30);
27034 l_event_class_code VARCHAR2(30);
27035 l_ae_header_id NUMBER;
27036 l_event_type_code VARCHAR2(30);
27037 l_line_definition_code VARCHAR2(30);
27038 l_line_definition_owner_code VARCHAR2(1);
27039 --
27040 -- adr variables
27041 l_segment VARCHAR2(30);
27042 l_ccid NUMBER;
27043 l_adr_transaction_coa_id NUMBER;
27044 l_adr_accounting_coa_id NUMBER;
27045 l_adr_flexfield_segment_code VARCHAR2(30);
27046 l_adr_flex_value_set_id NUMBER;
27047 l_adr_value_type_code VARCHAR2(30);
27048 l_adr_value_combination_id NUMBER;
27049 l_adr_value_segment_code VARCHAR2(30);
27050
27051 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
27052 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
27053 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
27054 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
27055
27056 -- 4262811 Variables ------------------------------------------------------------------------------------------
27057 l_entered_amt_idx NUMBER;
27058 l_accted_amt_idx NUMBER;
27059 l_acc_rev_flag VARCHAR2(1);
27060 l_accrual_line_num NUMBER;
27061 l_tmp_amt NUMBER;
27062 l_acc_rev_natural_side_code VARCHAR2(1);
27063
27064 l_num_entries NUMBER;
27065 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
27066 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
27067 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
27068 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
27069 l_recog_line_1 NUMBER;
27070 l_recog_line_2 NUMBER;
27071
27072 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
27073 l_bflow_applied_to_amt NUMBER; -- 5132302
27074 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
27075
27076 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
27077
27078 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
27079 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
27080
27081 ---------------------------------------------------------------------------------------------------------------
27082
27083
27084 --
27085 -- bulk performance
27086 --
27087 l_balance_type_code VARCHAR2(1);
27088 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
27089 l_log_module VARCHAR2(240);
27090
27091 --
27092 -- Upgrade strategy
27093 --
27094 l_actual_upg_option VARCHAR2(1);
27095 l_enc_upg_option VARCHAR2(1);
27096
27097 --
27098 BEGIN
27099 --
27100 IF g_log_enabled THEN
27101 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_61';
27102 END IF;
27103 --
27104 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27105
27106 trace
27107 (p_msg => 'BEGIN of AcctLineType_61'
27108 ,p_level => C_LEVEL_PROCEDURE
27109 ,p_module => l_log_module);
27110
27111 END IF;
27112 --
27113 l_component_type := 'AMB_JLT';
27114 l_component_code := 'MFAR_MISC_RCT_REMITTANCE';
27115 l_component_type_code := 'S';
27116 l_component_appl_id := 222;
27117 l_amb_context_code := 'DEFAULT';
27118 l_entity_code := 'RECEIPTS';
27119 l_event_class_code := 'MISC_RECEIPT';
27120 l_event_type_code := 'MISC_RECEIPT_ALL';
27121 l_line_definition_owner_code := 'S';
27122 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
27123 --
27124 l_balance_type_code := 'A';
27125 l_segment := NULL;
27126 l_ccid := NULL;
27127 l_adr_transaction_coa_id := NULL;
27128 l_adr_accounting_coa_id := NULL;
27129 l_adr_flexfield_segment_code := NULL;
27130 l_adr_flex_value_set_id := NULL;
27131 l_adr_value_type_code := NULL;
27132 l_adr_value_combination_id := NULL;
27133 l_adr_value_segment_code := NULL;
27134
27135 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
27136 l_bflow_class_code := ''; -- 4219869 Business Flow
27137 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
27138 l_budgetary_control_flag := 'N';
27139
27140 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27141 l_bflow_applied_to_amt := NULL; -- 5132302
27142 l_entered_amt_idx := NULL; -- 4262811
27143 l_accted_amt_idx := NULL; -- 4262811
27144 l_acc_rev_flag := NULL; -- 4262811
27145 l_accrual_line_num := NULL; -- 4262811
27146 l_tmp_amt := NULL; -- 4262811
27147 --
27148
27149 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
27150 l_balance_type_code <> 'B' THEN
27151 IF NVL(p_source_15,'
27152 ') = 'REMITTANCE' AND
27153 NVL(p_source_54,'
27154 ') = 'Y'
27155 THEN
27156
27157 --
27158 XLA_AE_LINES_PKG.SetNewLine;
27159
27160 p_balance_type_code := l_balance_type_code;
27161 -- set the flag so later we will know whether the gain loss line needs to be created
27162
27163 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
27164 p_actual_flag :='A';
27165 END IF;
27166
27167 --
27168 -- bulk performance
27169 --
27170 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
27171 p_header_num => 0); -- 4262811
27172 --
27173 -- set accounting line options
27174 --
27175 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
27176 p_natural_side_code => 'C'
27177 , p_gain_or_loss_flag => 'N'
27178 , p_gl_transfer_mode_code => 'S'
27179 , p_acct_entry_type_code => 'A'
27180 , p_switch_side_flag => 'Y'
27181 , p_merge_duplicate_code => 'A'
27182 );
27183 --
27184 l_acc_rev_natural_side_code := 'D'; -- 4262811
27185 --
27186 --
27187 -- set accounting line type info
27188 --
27189 xla_ae_lines_pkg.SetAcctLineType
27190 (p_component_type => l_component_type
27191 ,p_event_type_code => l_event_type_code
27192 ,p_line_definition_owner_code => l_line_definition_owner_code
27193 ,p_line_definition_code => l_line_definition_code
27194 ,p_accounting_line_code => l_component_code
27195 ,p_accounting_line_type_code => l_component_type_code
27196 ,p_accounting_line_appl_id => l_component_appl_id
27197 ,p_amb_context_code => l_amb_context_code
27198 ,p_entity_code => l_entity_code
27199 ,p_event_class_code => l_event_class_code);
27200 --
27201 -- set accounting class
27202 --
27203 xla_ae_lines_pkg.SetAcctClass(
27204 p_accounting_class_code => 'REMITTANCE'
27205 , p_ae_header_id => l_ae_header_id
27206 );
27207
27208 --
27209 -- set rounding class
27210 --
27211 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
27212 'RECEIVABLE';
27213
27214 --
27215 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
27216 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
27217 --
27218 -- bulk performance
27219 --
27220 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
27221
27222 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
27223 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
27224
27225 -- 4955764
27226 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27227 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
27228
27229 -- 4458381 Public Sector Enh
27230
27231 --
27232 -- set accounting attributes for the line type
27233 --
27234 l_entered_amt_idx := 3;
27235 l_accted_amt_idx := 8;
27236 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27237 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
27238 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
27239 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
27240 l_rec_acct_attrs.array_char_value(2) := p_source_18;
27241 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
27242 l_rec_acct_attrs.array_num_value(3) := p_source_19;
27243 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
27244 l_rec_acct_attrs.array_char_value(4) := p_source_20;
27245 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
27246 l_rec_acct_attrs.array_date_value(5) := p_source_55;
27247 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
27248 l_rec_acct_attrs.array_num_value(6) := p_source_22;
27249 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
27250 l_rec_acct_attrs.array_char_value(7) := p_source_23;
27251 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
27252 l_rec_acct_attrs.array_num_value(8) := p_source_24;
27253
27254 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
27255 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
27256
27257 ---------------------------------------------------------------------------------------------------------------
27258 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
27259 ---------------------------------------------------------------------------------------------------------------
27260 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
27261
27262 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27263 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27264
27265 IF xla_accounting_cache_pkg.GetValueChar
27266 (p_source_code => 'LEDGER_CATEGORY_CODE'
27267 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
27268 AND l_bflow_method_code = 'PRIOR_ENTRY'
27269 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
27270 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
27271 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
27272 )
27273 THEN
27274 xla_ae_lines_pkg.BflowUpgEntry
27275 (p_business_method_code => l_bflow_method_code
27276 ,p_business_class_code => l_bflow_class_code
27277 ,p_balance_type => l_balance_type_code);
27278 ELSE
27279 NULL;
27280 -- No business flow processing for business flow method of NONE.
27281 END IF;
27282
27283 --
27284 -- call analytical criteria
27285 --
27286
27287 --
27288 -- call description
27289 --
27290
27291 xla_ae_lines_pkg.SetLineDescription(
27292 p_ae_header_id => l_ae_header_id
27293 ,p_description => Description_1 (
27294 p_application_id => p_application_id
27295 , p_ae_header_id => l_ae_header_id
27296 )
27297 );
27298
27299
27300 --
27301 -- call ADRs
27302 -- Bug 4922099
27303 --
27304 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27305 (NVL(l_actual_upg_option, 'N') = 'O') OR
27306 (NVL(l_enc_upg_option, 'N') = 'O')
27307 )
27308 THEN
27309 NULL;
27310 --
27311 --
27312
27313 l_ccid := AcctDerRule_11(
27314 p_application_id => p_application_id
27315 , p_ae_header_id => l_ae_header_id
27316 , p_source_10 => p_source_10
27317 , x_transaction_coa_id => l_adr_transaction_coa_id
27318 , x_accounting_coa_id => l_adr_accounting_coa_id
27319 , x_value_type_code => l_adr_value_type_code
27320 , p_side => 'NA'
27321 );
27322
27323 xla_ae_lines_pkg.set_ccid(
27324 p_code_combination_id => l_ccid
27325 , p_value_type_code => l_adr_value_type_code
27326 , p_transaction_coa_id => l_adr_transaction_coa_id
27327 , p_accounting_coa_id => l_adr_accounting_coa_id
27328 , p_adr_code => 'DIST_CCID'
27329 , p_adr_type_code => 'S'
27330 , p_component_type => l_component_type
27331 , p_component_code => l_component_code
27332 , p_component_type_code => l_component_type_code
27333 , p_component_appl_id => l_component_appl_id
27334 , p_amb_context_code => l_amb_context_code
27335 , p_side => 'NA'
27336 );
27337
27338
27339 l_segment := AcctDerRule_7(
27340 p_application_id => p_application_id
27341 , p_ae_header_id => l_ae_header_id
27342 , p_source_6 => p_source_6
27343 , x_transaction_coa_id => l_adr_transaction_coa_id
27344 , x_accounting_coa_id => l_adr_accounting_coa_id
27345 , x_flexfield_segment_code => l_adr_flexfield_segment_code
27346 , x_flex_value_set_id => l_adr_flex_value_set_id
27347 , x_value_type_code => l_adr_value_type_code
27348 , x_value_combination_id => l_adr_value_combination_id
27349 , x_value_segment_code => l_adr_value_segment_code
27350 , p_side => 'NA'
27351 , p_override_seg_flag => 'Y'
27352 );
27353
27354 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
27355
27356 xla_ae_lines_pkg.set_segment(
27357 p_to_segment_code => 'GL_ACCOUNT'
27358 , p_segment_value => l_segment
27359 , p_from_segment_code => l_adr_value_segment_code
27360 , p_from_combination_id => l_adr_value_combination_id
27361 , p_value_type_code => l_adr_value_type_code
27362 , p_transaction_coa_id => l_adr_transaction_coa_id
27363 , p_accounting_coa_id => l_adr_accounting_coa_id
27364 , p_flexfield_segment_code => l_adr_flexfield_segment_code
27365 , p_flex_value_set_id => l_adr_flex_value_set_id
27366 , p_adr_code => 'MFAR_RCT_REMITTANCE_NATSEG'
27367 , p_adr_type_code => 'S'
27368 , p_component_type => l_component_type
27369 , p_component_code => l_component_code
27370 , p_component_type_code => l_component_type_code
27371 , p_component_appl_id => l_component_appl_id
27372 , p_amb_context_code => l_amb_context_code
27373 , p_entity_code => 'RECEIPTS'
27374 , p_event_class_code => 'MISC_RECEIPT'
27375 , p_side => 'NA'
27376 );
27377
27378 END IF;
27379
27380 --
27381 --
27382 END IF;
27383 --
27384 -- Bug 4922099
27385 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
27386 (NVL(l_enc_upg_option, 'N') = 'O')
27387 ) AND
27388 (l_bflow_method_code = 'PRIOR_ENTRY')
27389 )
27390 THEN
27391 IF
27392 --
27393 1 = 2
27394 --
27395 THEN
27396 xla_accounting_err_pkg.build_message
27397 (p_appli_s_name => 'XLA'
27398 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27399 ,p_token_1 => 'LINE_NUMBER'
27400 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
27401 ,p_token_2 => 'LINE_TYPE_NAME'
27402 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
27403 l_component_type
27404 ,l_component_code
27405 ,l_component_type_code
27406 ,l_component_appl_id
27407 ,l_amb_context_code
27408 ,l_entity_code
27409 ,l_event_class_code
27410 )
27411 ,p_token_3 => 'OWNER'
27412 ,p_value_3 => xla_lookups_pkg.get_meaning(
27413 p_lookup_type => 'XLA_OWNER_TYPE'
27414 ,p_lookup_code => l_component_type_code
27415 )
27416 ,p_token_4 => 'PRODUCT_NAME'
27417 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
27418 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
27419 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
27420 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
27421 ,p_ae_header_id => NULL
27422 );
27423
27424 IF (C_LEVEL_ERROR>= g_log_level) THEN
27425 trace
27426 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27427 ,p_level => C_LEVEL_ERROR
27428 ,p_module => l_log_module);
27429 END IF;
27430 END IF;
27431 END IF;
27432 --
27433 --
27434 ------------------------------------------------------------------------------------------------
27435 -- 4219869 Business Flow
27436 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
27437 -- Prior Entry. Currently, the following code is always generated.
27438 ------------------------------------------------------------------------------------------------
27439 XLA_AE_LINES_PKG.ValidateCurrentLine;
27440
27441 ------------------------------------------------------------------------------------
27442 -- 4219869 Business Flow
27443 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
27444 ------------------------------------------------------------------------------------
27445 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27446
27447 ----------------------------------------------------------------------------------
27448 -- 4219869 Business Flow
27449 -- Update journal entry status -- Need to generate this within IF <condition>
27450 ----------------------------------------------------------------------------------
27451 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27452 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
27453 ,p_balance_type_code => l_balance_type_code
27454 );
27455
27456 -------------------------------------------------------------------------------------------
27457 -- 4262811 - Generate the Accrual Reversal lines
27458 -------------------------------------------------------------------------------------------
27459 BEGIN
27460 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
27461 (g_array_event(p_event_id).array_value_num('header_index'));
27462 IF l_acc_rev_flag IS NULL THEN
27463 l_acc_rev_flag := 'N';
27464 END IF;
27465 EXCEPTION
27466 WHEN OTHERS THEN
27467 l_acc_rev_flag := 'N';
27468 END;
27469 --
27470 IF (l_acc_rev_flag = 'Y') THEN
27471
27472 -- 4645092 ------------------------------------------------------------------------------
27473 -- To allow MPA report to determine if it should generate report process
27474 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
27475 ------------------------------------------------------------------------------------------
27476
27477 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
27478 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
27479 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
27480 -- call ADRs
27481 -- Bug 4922099
27482 --
27483 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27484 (NVL(l_actual_upg_option, 'N') = 'O') OR
27485 (NVL(l_enc_upg_option, 'N') = 'O')
27486 )
27487 THEN
27488 NULL;
27489 --
27490 --
27491
27492 l_ccid := AcctDerRule_11(
27493 p_application_id => p_application_id
27494 , p_ae_header_id => l_ae_header_id
27495 , p_source_10 => p_source_10
27496 , x_transaction_coa_id => l_adr_transaction_coa_id
27497 , x_accounting_coa_id => l_adr_accounting_coa_id
27498 , x_value_type_code => l_adr_value_type_code
27499 , p_side => 'NA'
27500 );
27501
27502 xla_ae_lines_pkg.set_ccid(
27503 p_code_combination_id => l_ccid
27504 , p_value_type_code => l_adr_value_type_code
27505 , p_transaction_coa_id => l_adr_transaction_coa_id
27506 , p_accounting_coa_id => l_adr_accounting_coa_id
27507 , p_adr_code => 'DIST_CCID'
27508 , p_adr_type_code => 'S'
27509 , p_component_type => l_component_type
27510 , p_component_code => l_component_code
27511 , p_component_type_code => l_component_type_code
27512 , p_component_appl_id => l_component_appl_id
27513 , p_amb_context_code => l_amb_context_code
27514 , p_side => 'NA'
27515 );
27516
27517
27518 l_segment := AcctDerRule_7(
27519 p_application_id => p_application_id
27520 , p_ae_header_id => l_ae_header_id
27521 , p_source_6 => p_source_6
27522 , x_transaction_coa_id => l_adr_transaction_coa_id
27523 , x_accounting_coa_id => l_adr_accounting_coa_id
27524 , x_flexfield_segment_code => l_adr_flexfield_segment_code
27525 , x_flex_value_set_id => l_adr_flex_value_set_id
27526 , x_value_type_code => l_adr_value_type_code
27527 , x_value_combination_id => l_adr_value_combination_id
27528 , x_value_segment_code => l_adr_value_segment_code
27529 , p_side => 'NA'
27530 , p_override_seg_flag => 'Y'
27531 );
27532
27533 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
27534
27535 xla_ae_lines_pkg.set_segment(
27536 p_to_segment_code => 'GL_ACCOUNT'
27537 , p_segment_value => l_segment
27538 , p_from_segment_code => l_adr_value_segment_code
27539 , p_from_combination_id => l_adr_value_combination_id
27540 , p_value_type_code => l_adr_value_type_code
27541 , p_transaction_coa_id => l_adr_transaction_coa_id
27542 , p_accounting_coa_id => l_adr_accounting_coa_id
27543 , p_flexfield_segment_code => l_adr_flexfield_segment_code
27544 , p_flex_value_set_id => l_adr_flex_value_set_id
27545 , p_adr_code => 'MFAR_RCT_REMITTANCE_NATSEG'
27546 , p_adr_type_code => 'S'
27547 , p_component_type => l_component_type
27548 , p_component_code => l_component_code
27549 , p_component_type_code => l_component_type_code
27550 , p_component_appl_id => l_component_appl_id
27551 , p_amb_context_code => l_amb_context_code
27552 , p_entity_code => 'RECEIPTS'
27553 , p_event_class_code => 'MISC_RECEIPT'
27554 , p_side => 'NA'
27555 );
27556
27557 END IF;
27558
27559 --
27560 --
27561 END IF;
27562
27563 --
27564 -- Update the line information that should be overwritten
27565 --
27566 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
27567 p_header_num => 1);
27568 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
27569
27570 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
27571
27572 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
27573 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
27574 END IF;
27575
27576 --
27577 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
27578 --
27579 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
27580 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
27581 ELSE
27582 ---------------------------------------------------------------------------------------------------
27583 -- 4262811a Switch Sign
27584 ---------------------------------------------------------------------------------------------------
27585 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
27586 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27587 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27588 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27589 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27590 -- 5132302
27591 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
27592 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27593
27594 END IF;
27595
27596 -- 4955764
27597 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27598 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
27599
27600
27601 XLA_AE_LINES_PKG.ValidateCurrentLine;
27602 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27603
27604 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27605 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
27606 ,p_balance_type_code => l_balance_type_code);
27607
27608 END IF;
27609
27610 -----------------------------------------------------------------------------------------
27611 -- 4262811 Multiperiod Accounting
27612 -----------------------------------------------------------------------------------------
27613 -- No MPA option is assigned.
27614
27615
27616 END IF;
27617 END IF;
27618 --
27619
27620 --
27621 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27622 trace
27623 (p_msg => 'END of AcctLineType_61'
27624 ,p_level => C_LEVEL_PROCEDURE
27625 ,p_module => l_log_module);
27626 END IF;
27627 --
27628 EXCEPTION
27629 WHEN xla_exceptions_pkg.application_exception THEN
27630 RAISE;
27631 WHEN OTHERS THEN
27632 xla_exceptions_pkg.raise_message
27633 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_61');
27634 END AcctLineType_61;
27635 --
27636
27637 ---------------------------------------
27638 --
27639 -- PRIVATE FUNCTION
27640 -- AcctLineType_62
27641 --
27642 ---------------------------------------
27643 PROCEDURE AcctLineType_62 (
27644 p_application_id IN NUMBER
27645 ,p_event_id IN NUMBER
27646 ,p_calculate_acctd_flag IN VARCHAR2
27647 ,p_calculate_g_l_flag IN VARCHAR2
27648 ,p_actual_flag IN OUT VARCHAR2
27649 ,p_balance_type_code OUT VARCHAR2
27650 ,p_gain_or_loss_ref OUT VARCHAR2
27651
27652 --Remittance Bank Account Bank Charges Acount
27653 , p_source_1 IN NUMBER
27654 --Remittance Bank Account Cash Account
27655 , p_source_5 IN NUMBER
27656 --Distribution Source Type
27657 , p_source_15 IN VARCHAR2
27658 --Distribution Line Identifier
27659 , p_source_17 IN NUMBER
27660 --Distribution Type
27661 , p_source_18 IN VARCHAR2
27662 --Exchange Date
27663 , p_source_21 IN DATE
27664 --Exchange Rate
27665 , p_source_22 IN NUMBER
27666 --Exchange Rate Type
27667 , p_source_23 IN VARCHAR2
27668 --Transaction Distribution Identifier
27669 , p_source_29 IN NUMBER
27670 --Transaction Distribution Type
27671 , p_source_30 IN VARCHAR2
27672 --Distribution Multi Fund Additional Entry
27673 , p_source_54 IN VARCHAR2
27674 --Receipt Applied To Application Identifier
27675 , p_source_58 IN NUMBER
27676 --Transaction Entity Code
27677 , p_source_59 IN VARCHAR2
27678 --Transaction Identifier
27679 , p_source_60 IN NUMBER
27680 --DIST_ENT_AMT_FROM
27681 , p_source_61 IN NUMBER
27682 --Applying Document Currency Code
27683 , p_source_62 IN VARCHAR2
27684 --Accounting Amount
27685 , p_source_63 IN NUMBER
27686 --Distribution Party Identifier
27687 , p_source_64 IN NUMBER
27688 --Distribution Party Site Id
27689 , p_source_65 IN NUMBER
27690 --Distribution Party Type
27691 , p_source_66 IN VARCHAR2
27692 )
27693 IS
27694
27695 l_component_type VARCHAR2(80);
27696 l_component_code VARCHAR2(30);
27697 l_component_type_code VARCHAR2(1);
27698 l_component_appl_id INTEGER;
27699 l_amb_context_code VARCHAR2(30);
27700 l_entity_code VARCHAR2(30);
27701 l_event_class_code VARCHAR2(30);
27702 l_ae_header_id NUMBER;
27703 l_event_type_code VARCHAR2(30);
27704 l_line_definition_code VARCHAR2(30);
27705 l_line_definition_owner_code VARCHAR2(1);
27706 --
27707 -- adr variables
27708 l_segment VARCHAR2(30);
27709 l_ccid NUMBER;
27710 l_adr_transaction_coa_id NUMBER;
27711 l_adr_accounting_coa_id NUMBER;
27712 l_adr_flexfield_segment_code VARCHAR2(30);
27713 l_adr_flex_value_set_id NUMBER;
27714 l_adr_value_type_code VARCHAR2(30);
27715 l_adr_value_combination_id NUMBER;
27716 l_adr_value_segment_code VARCHAR2(30);
27717
27718 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
27719 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
27720 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
27721 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
27722
27723 -- 4262811 Variables ------------------------------------------------------------------------------------------
27724 l_entered_amt_idx NUMBER;
27725 l_accted_amt_idx NUMBER;
27726 l_acc_rev_flag VARCHAR2(1);
27727 l_accrual_line_num NUMBER;
27728 l_tmp_amt NUMBER;
27729 l_acc_rev_natural_side_code VARCHAR2(1);
27730
27731 l_num_entries NUMBER;
27732 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
27733 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
27734 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
27735 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
27736 l_recog_line_1 NUMBER;
27737 l_recog_line_2 NUMBER;
27738
27739 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
27740 l_bflow_applied_to_amt NUMBER; -- 5132302
27741 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
27742
27743 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
27744
27745 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
27746 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
27747
27748 ---------------------------------------------------------------------------------------------------------------
27749
27750
27751 --
27752 -- bulk performance
27753 --
27754 l_balance_type_code VARCHAR2(1);
27755 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
27756 l_log_module VARCHAR2(240);
27757
27758 --
27759 -- Upgrade strategy
27760 --
27761 l_actual_upg_option VARCHAR2(1);
27762 l_enc_upg_option VARCHAR2(1);
27763
27764 --
27765 BEGIN
27766 --
27767 IF g_log_enabled THEN
27768 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_62';
27769 END IF;
27770 --
27771 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27772
27773 trace
27774 (p_msg => 'BEGIN of AcctLineType_62'
27775 ,p_level => C_LEVEL_PROCEDURE
27776 ,p_module => l_log_module);
27777
27778 END IF;
27779 --
27780 l_component_type := 'AMB_JLT';
27781 l_component_code := 'MFAR_RCT_BNK_CHG_CASH';
27782 l_component_type_code := 'S';
27783 l_component_appl_id := 222;
27784 l_amb_context_code := 'DEFAULT';
27785 l_entity_code := 'RECEIPTS';
27786 l_event_class_code := 'RECEIPT';
27787 l_event_type_code := 'RECEIPT_ALL';
27788 l_line_definition_owner_code := 'S';
27789 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
27790 --
27791 l_balance_type_code := 'A';
27792 l_segment := NULL;
27793 l_ccid := NULL;
27794 l_adr_transaction_coa_id := NULL;
27795 l_adr_accounting_coa_id := NULL;
27796 l_adr_flexfield_segment_code := NULL;
27797 l_adr_flex_value_set_id := NULL;
27798 l_adr_value_type_code := NULL;
27799 l_adr_value_combination_id := NULL;
27800 l_adr_value_segment_code := NULL;
27801
27802 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
27803 l_bflow_class_code := ''; -- 4219869 Business Flow
27804 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
27805 l_budgetary_control_flag := 'N';
27806
27807 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27808 l_bflow_applied_to_amt := NULL; -- 5132302
27809 l_entered_amt_idx := NULL; -- 4262811
27810 l_accted_amt_idx := NULL; -- 4262811
27811 l_acc_rev_flag := NULL; -- 4262811
27812 l_accrual_line_num := NULL; -- 4262811
27813 l_tmp_amt := NULL; -- 4262811
27814 --
27815
27816 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
27817 l_balance_type_code <> 'B' THEN
27818 IF NVL(p_source_15,'
27819 ') = 'BANK_CHARGES' AND
27820 NVL(p_source_54,'
27821 ') = 'N'
27822 THEN
27823
27824 --
27825 XLA_AE_LINES_PKG.SetNewLine;
27826
27827 p_balance_type_code := l_balance_type_code;
27828 -- set the flag so later we will know whether the gain loss line needs to be created
27829
27830 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
27831 p_actual_flag :='A';
27832 END IF;
27833
27834 --
27835 -- bulk performance
27836 --
27837 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
27838 p_header_num => 0); -- 4262811
27839 --
27840 -- set accounting line options
27841 --
27842 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
27843 p_natural_side_code => 'D'
27844 , p_gain_or_loss_flag => 'N'
27845 , p_gl_transfer_mode_code => 'S'
27846 , p_acct_entry_type_code => 'A'
27847 , p_switch_side_flag => 'Y'
27851 l_acc_rev_natural_side_code := 'C'; -- 4262811
27848 , p_merge_duplicate_code => 'A'
27849 );
27850 --
27852 --
27853 --
27854 -- set accounting line type info
27855 --
27856 xla_ae_lines_pkg.SetAcctLineType
27857 (p_component_type => l_component_type
27858 ,p_event_type_code => l_event_type_code
27859 ,p_line_definition_owner_code => l_line_definition_owner_code
27860 ,p_line_definition_code => l_line_definition_code
27861 ,p_accounting_line_code => l_component_code
27862 ,p_accounting_line_type_code => l_component_type_code
27863 ,p_accounting_line_appl_id => l_component_appl_id
27864 ,p_amb_context_code => l_amb_context_code
27865 ,p_entity_code => l_entity_code
27866 ,p_event_class_code => l_event_class_code);
27867 --
27868 -- set accounting class
27869 --
27870 xla_ae_lines_pkg.SetAcctClass(
27871 p_accounting_class_code => 'CASH'
27872 , p_ae_header_id => l_ae_header_id
27873 );
27874
27875 --
27876 -- set rounding class
27877 --
27878 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
27879 'RECEIVABLE';
27880
27881 --
27882 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
27883 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
27884 --
27885 -- bulk performance
27886 --
27887 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
27888
27889 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
27890 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
27891
27892 -- 4955764
27893 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27894 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
27895
27896 -- 4458381 Public Sector Enh
27897
27898 --
27899 -- set accounting attributes for the line type
27900 --
27901 l_entered_amt_idx := 8;
27902 l_accted_amt_idx := 13;
27903 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27904 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
27905 l_rec_acct_attrs.array_num_value(1) := p_source_58;
27906 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
27907 l_rec_acct_attrs.array_char_value(2) := p_source_30;
27908 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
27909 l_rec_acct_attrs.array_char_value(3) := p_source_59;
27910 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
27911 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
27912 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
27913 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
27914 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
27915 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
27916 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
27917 l_rec_acct_attrs.array_char_value(7) := p_source_18;
27918 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
27919 l_rec_acct_attrs.array_num_value(8) := p_source_61;
27920 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
27921 l_rec_acct_attrs.array_char_value(9) := p_source_62;
27922 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
27923 l_rec_acct_attrs.array_date_value(10) := p_source_21;
27924 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
27925 l_rec_acct_attrs.array_num_value(11) := p_source_22;
27926 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
27927 l_rec_acct_attrs.array_char_value(12) := p_source_23;
27928 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
27929 l_rec_acct_attrs.array_num_value(13) := p_source_63;
27930 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
27931 l_rec_acct_attrs.array_num_value(14) := p_source_64;
27932 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
27933 l_rec_acct_attrs.array_num_value(15) := p_source_65;
27934 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
27935 l_rec_acct_attrs.array_char_value(16) := p_source_66;
27936
27937 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
27938 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
27939
27940 ---------------------------------------------------------------------------------------------------------------
27941 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
27942 ---------------------------------------------------------------------------------------------------------------
27943 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
27944
27945 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27946 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27947
27948 IF xla_accounting_cache_pkg.GetValueChar
27949 (p_source_code => 'LEDGER_CATEGORY_CODE'
27950 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
27951 AND l_bflow_method_code = 'PRIOR_ENTRY'
27952 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
27953 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
27954 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
27955 )
27956 THEN
27957 xla_ae_lines_pkg.BflowUpgEntry
27958 (p_business_method_code => l_bflow_method_code
27959 ,p_business_class_code => l_bflow_class_code
27960 ,p_balance_type => l_balance_type_code);
27961 ELSE
27962 NULL;
27963 -- No business flow processing for business flow method of NONE.
27964 END IF;
27965
27966 --
27967 -- call analytical criteria
27968 --
27969
27970 --
27971 -- call description
27972 --
27973
27974 xla_ae_lines_pkg.SetLineDescription(
27975 p_ae_header_id => l_ae_header_id
27976 ,p_description => Description_1 (
27977 p_application_id => p_application_id
27978 , p_ae_header_id => l_ae_header_id
27979 )
27980 );
27981
27982
27983 --
27984 -- call ADRs
27985 -- Bug 4922099
27986 --
27987 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27988 (NVL(l_actual_upg_option, 'N') = 'O') OR
27989 (NVL(l_enc_upg_option, 'N') = 'O')
27990 )
27991 THEN
27992 NULL;
27993 --
27994 --
27995
27996 l_ccid := AcctDerRule_12(
27997 p_application_id => p_application_id
27998 , p_ae_header_id => l_ae_header_id
27999 , p_source_5 => p_source_5
28000 , x_transaction_coa_id => l_adr_transaction_coa_id
28001 , x_accounting_coa_id => l_adr_accounting_coa_id
28002 , x_value_type_code => l_adr_value_type_code
28003 , p_side => 'NA'
28004 );
28005
28006 xla_ae_lines_pkg.set_ccid(
28007 p_code_combination_id => l_ccid
28008 , p_value_type_code => l_adr_value_type_code
28009 , p_transaction_coa_id => l_adr_transaction_coa_id
28010 , p_accounting_coa_id => l_adr_accounting_coa_id
28011 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
28012 , p_adr_type_code => 'S'
28013 , p_component_type => l_component_type
28014 , p_component_code => l_component_code
28015 , p_component_type_code => l_component_type_code
28016 , p_component_appl_id => l_component_appl_id
28017 , p_amb_context_code => l_amb_context_code
28018 , p_side => 'NA'
28019 );
28020
28021
28022 l_segment := AcctDerRule_2(
28023 p_application_id => p_application_id
28024 , p_ae_header_id => l_ae_header_id
28025 , p_source_1 => p_source_1
28026 , x_transaction_coa_id => l_adr_transaction_coa_id
28027 , x_accounting_coa_id => l_adr_accounting_coa_id
28028 , x_flexfield_segment_code => l_adr_flexfield_segment_code
28029 , x_flex_value_set_id => l_adr_flex_value_set_id
28030 , x_value_type_code => l_adr_value_type_code
28031 , x_value_combination_id => l_adr_value_combination_id
28032 , x_value_segment_code => l_adr_value_segment_code
28033 , p_side => 'NA'
28034 , p_override_seg_flag => 'Y'
28035 );
28036
28037 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
28038
28039 xla_ae_lines_pkg.set_segment(
28040 p_to_segment_code => 'GL_ACCOUNT'
28041 , p_segment_value => l_segment
28042 , p_from_segment_code => l_adr_value_segment_code
28043 , p_from_combination_id => l_adr_value_combination_id
28044 , p_value_type_code => l_adr_value_type_code
28045 , p_transaction_coa_id => l_adr_transaction_coa_id
28046 , p_accounting_coa_id => l_adr_accounting_coa_id
28047 , p_flexfield_segment_code => l_adr_flexfield_segment_code
28048 , p_flex_value_set_id => l_adr_flex_value_set_id
28049 , p_adr_code => 'MFAR_BNK_CHARGES_NATURAL_SEG'
28050 , p_adr_type_code => 'S'
28051 , p_component_type => l_component_type
28052 , p_component_code => l_component_code
28053 , p_component_type_code => l_component_type_code
28054 , p_component_appl_id => l_component_appl_id
28055 , p_amb_context_code => l_amb_context_code
28056 , p_entity_code => 'RECEIPTS'
28057 , p_event_class_code => 'RECEIPT'
28058 , p_side => 'NA'
28059 );
28060
28061 END IF;
28062
28063 --
28064 --
28065 END IF;
28066 --
28067 -- Bug 4922099
28071 (l_bflow_method_code = 'PRIOR_ENTRY')
28068 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
28069 (NVL(l_enc_upg_option, 'N') = 'O')
28070 ) AND
28072 )
28073 THEN
28074 IF
28075 --
28076 1 = 2
28077 --
28078 THEN
28079 xla_accounting_err_pkg.build_message
28080 (p_appli_s_name => 'XLA'
28081 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28082 ,p_token_1 => 'LINE_NUMBER'
28083 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
28084 ,p_token_2 => 'LINE_TYPE_NAME'
28085 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
28086 l_component_type
28087 ,l_component_code
28088 ,l_component_type_code
28089 ,l_component_appl_id
28090 ,l_amb_context_code
28091 ,l_entity_code
28092 ,l_event_class_code
28093 )
28094 ,p_token_3 => 'OWNER'
28095 ,p_value_3 => xla_lookups_pkg.get_meaning(
28096 p_lookup_type => 'XLA_OWNER_TYPE'
28097 ,p_lookup_code => l_component_type_code
28098 )
28099 ,p_token_4 => 'PRODUCT_NAME'
28100 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
28101 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
28102 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
28103 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
28104 ,p_ae_header_id => NULL
28105 );
28106
28107 IF (C_LEVEL_ERROR>= g_log_level) THEN
28108 trace
28109 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28110 ,p_level => C_LEVEL_ERROR
28111 ,p_module => l_log_module);
28112 END IF;
28113 END IF;
28114 END IF;
28115 --
28116 --
28117 ------------------------------------------------------------------------------------------------
28118 -- 4219869 Business Flow
28119 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
28120 -- Prior Entry. Currently, the following code is always generated.
28121 ------------------------------------------------------------------------------------------------
28122 XLA_AE_LINES_PKG.ValidateCurrentLine;
28123
28124 ------------------------------------------------------------------------------------
28125 -- 4219869 Business Flow
28126 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
28127 ------------------------------------------------------------------------------------
28128 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28129
28130 ----------------------------------------------------------------------------------
28131 -- 4219869 Business Flow
28132 -- Update journal entry status -- Need to generate this within IF <condition>
28133 ----------------------------------------------------------------------------------
28134 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28135 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
28136 ,p_balance_type_code => l_balance_type_code
28137 );
28138
28139 -------------------------------------------------------------------------------------------
28140 -- 4262811 - Generate the Accrual Reversal lines
28141 -------------------------------------------------------------------------------------------
28142 BEGIN
28143 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
28144 (g_array_event(p_event_id).array_value_num('header_index'));
28145 IF l_acc_rev_flag IS NULL THEN
28146 l_acc_rev_flag := 'N';
28147 END IF;
28148 EXCEPTION
28149 WHEN OTHERS THEN
28150 l_acc_rev_flag := 'N';
28151 END;
28152 --
28153 IF (l_acc_rev_flag = 'Y') THEN
28154
28155 -- 4645092 ------------------------------------------------------------------------------
28156 -- To allow MPA report to determine if it should generate report process
28157 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
28158 ------------------------------------------------------------------------------------------
28159
28160 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
28161 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
28162 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
28163 -- call ADRs
28164 -- Bug 4922099
28165 --
28166 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28167 (NVL(l_actual_upg_option, 'N') = 'O') OR
28168 (NVL(l_enc_upg_option, 'N') = 'O')
28169 )
28170 THEN
28171 NULL;
28172 --
28173 --
28174
28175 l_ccid := AcctDerRule_12(
28176 p_application_id => p_application_id
28177 , p_ae_header_id => l_ae_header_id
28178 , p_source_5 => p_source_5
28179 , x_transaction_coa_id => l_adr_transaction_coa_id
28180 , x_accounting_coa_id => l_adr_accounting_coa_id
28181 , x_value_type_code => l_adr_value_type_code
28182 , p_side => 'NA'
28183 );
28184
28185 xla_ae_lines_pkg.set_ccid(
28186 p_code_combination_id => l_ccid
28187 , p_value_type_code => l_adr_value_type_code
28188 , p_transaction_coa_id => l_adr_transaction_coa_id
28189 , p_accounting_coa_id => l_adr_accounting_coa_id
28190 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
28191 , p_adr_type_code => 'S'
28192 , p_component_type => l_component_type
28193 , p_component_code => l_component_code
28194 , p_component_type_code => l_component_type_code
28195 , p_component_appl_id => l_component_appl_id
28196 , p_amb_context_code => l_amb_context_code
28197 , p_side => 'NA'
28198 );
28199
28200
28201 l_segment := AcctDerRule_2(
28202 p_application_id => p_application_id
28203 , p_ae_header_id => l_ae_header_id
28204 , p_source_1 => p_source_1
28205 , x_transaction_coa_id => l_adr_transaction_coa_id
28206 , x_accounting_coa_id => l_adr_accounting_coa_id
28207 , x_flexfield_segment_code => l_adr_flexfield_segment_code
28208 , x_flex_value_set_id => l_adr_flex_value_set_id
28209 , x_value_type_code => l_adr_value_type_code
28210 , x_value_combination_id => l_adr_value_combination_id
28211 , x_value_segment_code => l_adr_value_segment_code
28212 , p_side => 'NA'
28213 , p_override_seg_flag => 'Y'
28214 );
28215
28216 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
28217
28218 xla_ae_lines_pkg.set_segment(
28219 p_to_segment_code => 'GL_ACCOUNT'
28220 , p_segment_value => l_segment
28221 , p_from_segment_code => l_adr_value_segment_code
28222 , p_from_combination_id => l_adr_value_combination_id
28223 , p_value_type_code => l_adr_value_type_code
28224 , p_transaction_coa_id => l_adr_transaction_coa_id
28225 , p_accounting_coa_id => l_adr_accounting_coa_id
28226 , p_flexfield_segment_code => l_adr_flexfield_segment_code
28227 , p_flex_value_set_id => l_adr_flex_value_set_id
28228 , p_adr_code => 'MFAR_BNK_CHARGES_NATURAL_SEG'
28229 , p_adr_type_code => 'S'
28230 , p_component_type => l_component_type
28231 , p_component_code => l_component_code
28232 , p_component_type_code => l_component_type_code
28233 , p_component_appl_id => l_component_appl_id
28234 , p_amb_context_code => l_amb_context_code
28235 , p_entity_code => 'RECEIPTS'
28236 , p_event_class_code => 'RECEIPT'
28237 , p_side => 'NA'
28238 );
28239
28240 END IF;
28241
28242 --
28243 --
28244 END IF;
28245
28246 --
28247 -- Update the line information that should be overwritten
28248 --
28249 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
28250 p_header_num => 1);
28251 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
28252
28253 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
28254
28255 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
28256 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
28257 END IF;
28258
28259 --
28260 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
28261 --
28262 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
28263 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
28264 ELSE
28265 ---------------------------------------------------------------------------------------------------
28266 -- 4262811a Switch Sign
28267 ---------------------------------------------------------------------------------------------------
28268 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
28269 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28270 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28271 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28272 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28273 -- 5132302
28274 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
28275 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28276
28277 END IF;
28278
28279 -- 4955764
28280 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28281 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
28282
28283
28284 XLA_AE_LINES_PKG.ValidateCurrentLine;
28285 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28286
28287 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28288 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
28289 ,p_balance_type_code => l_balance_type_code);
28290
28291 END IF;
28292
28293 -----------------------------------------------------------------------------------------
28294 -- 4262811 Multiperiod Accounting
28295 -----------------------------------------------------------------------------------------
28296 -- No MPA option is assigned.
28297
28298
28299 END IF;
28300 END IF;
28301 --
28302
28303 --
28304 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28305 trace
28306 (p_msg => 'END of AcctLineType_62'
28307 ,p_level => C_LEVEL_PROCEDURE
28308 ,p_module => l_log_module);
28309 END IF;
28310 --
28311 EXCEPTION
28312 WHEN xla_exceptions_pkg.application_exception THEN
28313 RAISE;
28314 WHEN OTHERS THEN
28315 xla_exceptions_pkg.raise_message
28316 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_62');
28317 END AcctLineType_62;
28318 --
28319
28320 ---------------------------------------
28321 --
28322 -- PRIVATE FUNCTION
28323 -- AcctLineType_63
28324 --
28325 ---------------------------------------
28326 PROCEDURE AcctLineType_63 (
28327 p_application_id IN NUMBER
28328 ,p_event_id IN NUMBER
28329 ,p_calculate_acctd_flag IN VARCHAR2
28330 ,p_calculate_g_l_flag IN VARCHAR2
28331 ,p_actual_flag IN OUT VARCHAR2
28332 ,p_balance_type_code OUT VARCHAR2
28333 ,p_gain_or_loss_ref OUT VARCHAR2
28334
28335 --Remittance Bank Account Cash Account
28336 , p_source_5 IN NUMBER
28337 --Distribution Source Type
28338 , p_source_15 IN VARCHAR2
28339 --Distribution Line Identifier
28340 , p_source_17 IN NUMBER
28341 --Distribution Type
28342 , p_source_18 IN VARCHAR2
28343 --Exchange Date
28344 , p_source_21 IN DATE
28345 --Exchange Rate
28346 , p_source_22 IN NUMBER
28347 --Exchange Rate Type
28348 , p_source_23 IN VARCHAR2
28349 --Transaction Distribution Account Class
28350 , p_source_28 IN VARCHAR2
28351 --Transaction Distribution Identifier
28352 , p_source_29 IN NUMBER
28353 --Transaction Distribution Type
28354 , p_source_30 IN VARCHAR2
28355 --Distribution Multi Fund Additional Entry
28356 , p_source_54 IN VARCHAR2
28357 --Receipt Class Require Remittance Flag
28358 , p_source_56 IN VARCHAR2
28362 , p_source_58 IN NUMBER
28359 --Receipt Class Confirm Flag
28360 , p_source_57 IN VARCHAR2
28361 --Receipt Applied To Application Identifier
28363 --Transaction Entity Code
28364 , p_source_59 IN VARCHAR2
28365 --Transaction Identifier
28366 , p_source_60 IN NUMBER
28367 --DIST_ENT_AMT_FROM
28368 , p_source_61 IN NUMBER
28369 --Applying Document Currency Code
28370 , p_source_62 IN VARCHAR2
28371 --Accounting Amount
28372 , p_source_63 IN NUMBER
28373 --Distribution Party Identifier
28374 , p_source_64 IN NUMBER
28375 --Distribution Party Site Id
28376 , p_source_65 IN NUMBER
28377 --Distribution Party Type
28378 , p_source_66 IN VARCHAR2
28379 )
28380 IS
28381
28382 l_component_type VARCHAR2(80);
28383 l_component_code VARCHAR2(30);
28384 l_component_type_code VARCHAR2(1);
28385 l_component_appl_id INTEGER;
28386 l_amb_context_code VARCHAR2(30);
28387 l_entity_code VARCHAR2(30);
28388 l_event_class_code VARCHAR2(30);
28389 l_ae_header_id NUMBER;
28390 l_event_type_code VARCHAR2(30);
28391 l_line_definition_code VARCHAR2(30);
28392 l_line_definition_owner_code VARCHAR2(1);
28393 --
28394 -- adr variables
28395 l_segment VARCHAR2(30);
28396 l_ccid NUMBER;
28397 l_adr_transaction_coa_id NUMBER;
28398 l_adr_accounting_coa_id NUMBER;
28399 l_adr_flexfield_segment_code VARCHAR2(30);
28400 l_adr_flex_value_set_id NUMBER;
28401 l_adr_value_type_code VARCHAR2(30);
28402 l_adr_value_combination_id NUMBER;
28403 l_adr_value_segment_code VARCHAR2(30);
28404
28405 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
28406 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
28407 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
28408 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
28409
28410 -- 4262811 Variables ------------------------------------------------------------------------------------------
28411 l_entered_amt_idx NUMBER;
28412 l_accted_amt_idx NUMBER;
28413 l_acc_rev_flag VARCHAR2(1);
28414 l_accrual_line_num NUMBER;
28415 l_tmp_amt NUMBER;
28416 l_acc_rev_natural_side_code VARCHAR2(1);
28417
28418 l_num_entries NUMBER;
28419 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
28420 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
28421 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
28422 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
28423 l_recog_line_1 NUMBER;
28424 l_recog_line_2 NUMBER;
28425
28426 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
28427 l_bflow_applied_to_amt NUMBER; -- 5132302
28428 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
28429
28430 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
28431
28432 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
28433 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
28434
28435 ---------------------------------------------------------------------------------------------------------------
28436
28437
28438 --
28439 -- bulk performance
28440 --
28441 l_balance_type_code VARCHAR2(1);
28442 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
28443 l_log_module VARCHAR2(240);
28444
28445 --
28446 -- Upgrade strategy
28447 --
28448 l_actual_upg_option VARCHAR2(1);
28449 l_enc_upg_option VARCHAR2(1);
28450
28451 --
28452 BEGIN
28453 --
28454 IF g_log_enabled THEN
28455 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_63';
28456 END IF;
28457 --
28458 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28459
28460 trace
28461 (p_msg => 'BEGIN of AcctLineType_63'
28462 ,p_level => C_LEVEL_PROCEDURE
28463 ,p_module => l_log_module);
28464
28465 END IF;
28466 --
28467 l_component_type := 'AMB_JLT';
28468 l_component_code := 'MFAR_RCT_CASH_REVERSE';
28469 l_component_type_code := 'S';
28470 l_component_appl_id := 222;
28471 l_amb_context_code := 'DEFAULT';
28472 l_entity_code := 'RECEIPTS';
28473 l_event_class_code := 'RECEIPT';
28474 l_event_type_code := 'RECEIPT_ALL';
28475 l_line_definition_owner_code := 'S';
28476 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
28477 --
28478 l_balance_type_code := 'A';
28479 l_segment := NULL;
28480 l_ccid := NULL;
28481 l_adr_transaction_coa_id := NULL;
28482 l_adr_accounting_coa_id := NULL;
28483 l_adr_flexfield_segment_code := NULL;
28484 l_adr_flex_value_set_id := NULL;
28485 l_adr_value_type_code := NULL;
28486 l_adr_value_combination_id := NULL;
28487 l_adr_value_segment_code := NULL;
28488
28489 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
28490 l_bflow_class_code := ''; -- 4219869 Business Flow
28491 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
28492 l_budgetary_control_flag := 'N';
28493
28494 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28495 l_bflow_applied_to_amt := NULL; -- 5132302
28496 l_entered_amt_idx := NULL; -- 4262811
28497 l_accted_amt_idx := NULL; -- 4262811
28498 l_acc_rev_flag := NULL; -- 4262811
28499 l_accrual_line_num := NULL; -- 4262811
28500 l_tmp_amt := NULL; -- 4262811
28501 --
28502
28503 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
28504 l_balance_type_code <> 'B' THEN
28505 IF (NVL(p_source_28,'
28506 ') = 'REV' OR
28507 NVL(p_source_28,'
28508 ') = 'TAX' OR
28509 NVL(p_source_28,'
28510 ') = 'FREIGHT' OR
28511 NVL(p_source_28,'
28512 ') = 'CHARGES' OR
28513 NVL(p_source_28,'
28514 ') = 'ROUND') AND
28515 NVL(p_source_15,'
28516 ') = 'REC' AND
28517 NVL(p_source_54,'
28518 ') = 'N' AND
28519 NVL(p_source_56,'
28520 ') = 'N' AND
28521 NVL(p_source_57,'
28522 ') = 'N'
28523 THEN
28524
28525 --
28526 XLA_AE_LINES_PKG.SetNewLine;
28527
28528 p_balance_type_code := l_balance_type_code;
28529 -- set the flag so later we will know whether the gain loss line needs to be created
28530
28531 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
28532 p_actual_flag :='A';
28533 END IF;
28534
28535 --
28536 -- bulk performance
28537 --
28538 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
28539 p_header_num => 0); -- 4262811
28540 --
28541 -- set accounting line options
28542 --
28543 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
28544 p_natural_side_code => 'C'
28545 , p_gain_or_loss_flag => 'N'
28546 , p_gl_transfer_mode_code => 'S'
28547 , p_acct_entry_type_code => 'A'
28548 , p_switch_side_flag => 'Y'
28549 , p_merge_duplicate_code => 'A'
28550 );
28551 --
28552 l_acc_rev_natural_side_code := 'D'; -- 4262811
28553 --
28554 --
28555 -- set accounting line type info
28556 --
28557 xla_ae_lines_pkg.SetAcctLineType
28558 (p_component_type => l_component_type
28559 ,p_event_type_code => l_event_type_code
28560 ,p_line_definition_owner_code => l_line_definition_owner_code
28561 ,p_line_definition_code => l_line_definition_code
28562 ,p_accounting_line_code => l_component_code
28563 ,p_accounting_line_type_code => l_component_type_code
28564 ,p_accounting_line_appl_id => l_component_appl_id
28565 ,p_amb_context_code => l_amb_context_code
28566 ,p_entity_code => l_entity_code
28567 ,p_event_class_code => l_event_class_code);
28568 --
28569 -- set accounting class
28570 --
28571 xla_ae_lines_pkg.SetAcctClass(
28572 p_accounting_class_code => 'CASH'
28573 , p_ae_header_id => l_ae_header_id
28574 );
28575
28576 --
28577 -- set rounding class
28578 --
28579 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
28580 'RECEIVABLE';
28581
28582 --
28583 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
28584 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
28585 --
28586 -- bulk performance
28587 --
28588 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
28589
28590 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
28591 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
28592
28593 -- 4955764
28594 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28595 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
28596
28597 -- 4458381 Public Sector Enh
28598
28599 --
28600 -- set accounting attributes for the line type
28601 --
28602 l_entered_amt_idx := 8;
28603 l_accted_amt_idx := 13;
28604 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28605 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
28606 l_rec_acct_attrs.array_num_value(1) := p_source_58;
28607 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
28608 l_rec_acct_attrs.array_char_value(2) := p_source_30;
28609 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
28610 l_rec_acct_attrs.array_char_value(3) := p_source_59;
28611 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
28612 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
28613 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
28614 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
28615 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
28616 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
28617 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
28618 l_rec_acct_attrs.array_char_value(7) := p_source_18;
28619 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
28620 l_rec_acct_attrs.array_num_value(8) := p_source_61;
28621 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
28622 l_rec_acct_attrs.array_char_value(9) := p_source_62;
28623 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
28624 l_rec_acct_attrs.array_date_value(10) := p_source_21;
28625 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
28626 l_rec_acct_attrs.array_num_value(11) := p_source_22;
28627 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
28628 l_rec_acct_attrs.array_char_value(12) := p_source_23;
28629 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
28630 l_rec_acct_attrs.array_num_value(13) := p_source_63;
28631 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
28632 l_rec_acct_attrs.array_num_value(14) := p_source_64;
28633 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
28634 l_rec_acct_attrs.array_num_value(15) := p_source_65;
28635 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
28636 l_rec_acct_attrs.array_char_value(16) := p_source_66;
28637
28638 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
28639 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
28640
28641 ---------------------------------------------------------------------------------------------------------------
28642 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
28643 ---------------------------------------------------------------------------------------------------------------
28644 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
28645
28646 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28647 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28648
28649 IF xla_accounting_cache_pkg.GetValueChar
28650 (p_source_code => 'LEDGER_CATEGORY_CODE'
28651 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
28652 AND l_bflow_method_code = 'PRIOR_ENTRY'
28653 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
28654 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
28655 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
28656 )
28657 THEN
28658 xla_ae_lines_pkg.BflowUpgEntry
28659 (p_business_method_code => l_bflow_method_code
28660 ,p_business_class_code => l_bflow_class_code
28661 ,p_balance_type => l_balance_type_code);
28662 ELSE
28663 NULL;
28664 -- No business flow processing for business flow method of NONE.
28665 END IF;
28666
28667 --
28668 -- call analytical criteria
28669 --
28670
28671 --
28672 -- call description
28673 --
28674
28675 xla_ae_lines_pkg.SetLineDescription(
28676 p_ae_header_id => l_ae_header_id
28677 ,p_description => Description_1 (
28678 p_application_id => p_application_id
28679 , p_ae_header_id => l_ae_header_id
28680 )
28681 );
28682
28683
28684 --
28685 -- call ADRs
28686 -- Bug 4922099
28687 --
28688 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28689 (NVL(l_actual_upg_option, 'N') = 'O') OR
28690 (NVL(l_enc_upg_option, 'N') = 'O')
28691 )
28692 THEN
28693 NULL;
28694 --
28695 --
28696
28697 l_ccid := AcctDerRule_12(
28698 p_application_id => p_application_id
28699 , p_ae_header_id => l_ae_header_id
28700 , p_source_5 => p_source_5
28701 , x_transaction_coa_id => l_adr_transaction_coa_id
28702 , x_accounting_coa_id => l_adr_accounting_coa_id
28703 , x_value_type_code => l_adr_value_type_code
28704 , p_side => 'NA'
28705 );
28706
28710 , p_transaction_coa_id => l_adr_transaction_coa_id
28707 xla_ae_lines_pkg.set_ccid(
28708 p_code_combination_id => l_ccid
28709 , p_value_type_code => l_adr_value_type_code
28711 , p_accounting_coa_id => l_adr_accounting_coa_id
28712 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
28713 , p_adr_type_code => 'S'
28714 , p_component_type => l_component_type
28715 , p_component_code => l_component_code
28716 , p_component_type_code => l_component_type_code
28717 , p_component_appl_id => l_component_appl_id
28718 , p_amb_context_code => l_amb_context_code
28719 , p_side => 'NA'
28720 );
28721
28722
28723 --
28724 --
28725 END IF;
28726 --
28727 -- Bug 4922099
28728 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
28729 (NVL(l_enc_upg_option, 'N') = 'O')
28730 ) AND
28731 (l_bflow_method_code = 'PRIOR_ENTRY')
28732 )
28733 THEN
28734 IF
28735 --
28736 1 = 2
28737 --
28738 THEN
28739 xla_accounting_err_pkg.build_message
28740 (p_appli_s_name => 'XLA'
28741 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28742 ,p_token_1 => 'LINE_NUMBER'
28743 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
28744 ,p_token_2 => 'LINE_TYPE_NAME'
28745 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
28746 l_component_type
28747 ,l_component_code
28748 ,l_component_type_code
28749 ,l_component_appl_id
28750 ,l_amb_context_code
28751 ,l_entity_code
28752 ,l_event_class_code
28753 )
28754 ,p_token_3 => 'OWNER'
28755 ,p_value_3 => xla_lookups_pkg.get_meaning(
28756 p_lookup_type => 'XLA_OWNER_TYPE'
28757 ,p_lookup_code => l_component_type_code
28758 )
28759 ,p_token_4 => 'PRODUCT_NAME'
28760 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
28761 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
28762 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
28763 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
28764 ,p_ae_header_id => NULL
28765 );
28766
28767 IF (C_LEVEL_ERROR>= g_log_level) THEN
28768 trace
28769 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28770 ,p_level => C_LEVEL_ERROR
28771 ,p_module => l_log_module);
28772 END IF;
28773 END IF;
28774 END IF;
28775 --
28776 --
28777 ------------------------------------------------------------------------------------------------
28778 -- 4219869 Business Flow
28779 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
28780 -- Prior Entry. Currently, the following code is always generated.
28781 ------------------------------------------------------------------------------------------------
28782 XLA_AE_LINES_PKG.ValidateCurrentLine;
28783
28784 ------------------------------------------------------------------------------------
28785 -- 4219869 Business Flow
28786 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
28787 ------------------------------------------------------------------------------------
28788 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28789
28790 ----------------------------------------------------------------------------------
28791 -- 4219869 Business Flow
28792 -- Update journal entry status -- Need to generate this within IF <condition>
28793 ----------------------------------------------------------------------------------
28794 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28795 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
28796 ,p_balance_type_code => l_balance_type_code
28797 );
28798
28799 -------------------------------------------------------------------------------------------
28800 -- 4262811 - Generate the Accrual Reversal lines
28801 -------------------------------------------------------------------------------------------
28802 BEGIN
28803 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
28804 (g_array_event(p_event_id).array_value_num('header_index'));
28805 IF l_acc_rev_flag IS NULL THEN
28806 l_acc_rev_flag := 'N';
28807 END IF;
28808 EXCEPTION
28809 WHEN OTHERS THEN
28810 l_acc_rev_flag := 'N';
28811 END;
28812 --
28813 IF (l_acc_rev_flag = 'Y') THEN
28814
28815 -- 4645092 ------------------------------------------------------------------------------
28816 -- To allow MPA report to determine if it should generate report process
28817 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
28818 ------------------------------------------------------------------------------------------
28819
28820 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
28821 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
28822 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
28823 -- call ADRs
28824 -- Bug 4922099
28825 --
28826 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28830 THEN
28827 (NVL(l_actual_upg_option, 'N') = 'O') OR
28828 (NVL(l_enc_upg_option, 'N') = 'O')
28829 )
28831 NULL;
28832 --
28833 --
28834
28835 l_ccid := AcctDerRule_12(
28836 p_application_id => p_application_id
28837 , p_ae_header_id => l_ae_header_id
28838 , p_source_5 => p_source_5
28839 , x_transaction_coa_id => l_adr_transaction_coa_id
28840 , x_accounting_coa_id => l_adr_accounting_coa_id
28841 , x_value_type_code => l_adr_value_type_code
28842 , p_side => 'NA'
28843 );
28844
28845 xla_ae_lines_pkg.set_ccid(
28846 p_code_combination_id => l_ccid
28847 , p_value_type_code => l_adr_value_type_code
28848 , p_transaction_coa_id => l_adr_transaction_coa_id
28849 , p_accounting_coa_id => l_adr_accounting_coa_id
28850 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
28851 , p_adr_type_code => 'S'
28852 , p_component_type => l_component_type
28853 , p_component_code => l_component_code
28854 , p_component_type_code => l_component_type_code
28855 , p_component_appl_id => l_component_appl_id
28856 , p_amb_context_code => l_amb_context_code
28857 , p_side => 'NA'
28858 );
28859
28860
28861 --
28862 --
28863 END IF;
28864
28865 --
28866 -- Update the line information that should be overwritten
28867 --
28868 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
28869 p_header_num => 1);
28870 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
28871
28872 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
28873
28874 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
28875 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
28876 END IF;
28877
28878 --
28879 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
28880 --
28881 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
28882 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
28883 ELSE
28884 ---------------------------------------------------------------------------------------------------
28885 -- 4262811a Switch Sign
28886 ---------------------------------------------------------------------------------------------------
28887 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
28888 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28889 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28890 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28891 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28892 -- 5132302
28893 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
28894 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28895
28896 END IF;
28897
28898 -- 4955764
28899 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28900 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
28901
28902
28903 XLA_AE_LINES_PKG.ValidateCurrentLine;
28904 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28905
28906 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28907 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
28908 ,p_balance_type_code => l_balance_type_code);
28909
28910 END IF;
28911
28912 -----------------------------------------------------------------------------------------
28913 -- 4262811 Multiperiod Accounting
28914 -----------------------------------------------------------------------------------------
28915 -- No MPA option is assigned.
28916
28917
28918 END IF;
28919 END IF;
28920 --
28921
28922 --
28923 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28924 trace
28925 (p_msg => 'END of AcctLineType_63'
28926 ,p_level => C_LEVEL_PROCEDURE
28927 ,p_module => l_log_module);
28928 END IF;
28929 --
28930 EXCEPTION
28931 WHEN xla_exceptions_pkg.application_exception THEN
28932 RAISE;
28933 WHEN OTHERS THEN
28934 xla_exceptions_pkg.raise_message
28935 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_63');
28936 END AcctLineType_63;
28937 --
28938
28939 ---------------------------------------
28940 --
28941 -- PRIVATE FUNCTION
28942 -- AcctLineType_64
28943 --
28944 ---------------------------------------
28945 PROCEDURE AcctLineType_64 (
28946 p_application_id IN NUMBER
28947 ,p_event_id IN NUMBER
28948 ,p_calculate_acctd_flag IN VARCHAR2
28949 ,p_calculate_g_l_flag IN VARCHAR2
28950 ,p_actual_flag IN OUT VARCHAR2
28951 ,p_balance_type_code OUT VARCHAR2
28955 , p_source_5 IN NUMBER
28952 ,p_gain_or_loss_ref OUT VARCHAR2
28953
28954 --Remittance Bank Account Cash Account
28956 --Distribution Source Type
28957 , p_source_15 IN VARCHAR2
28958 --Distribution Line Identifier
28959 , p_source_17 IN NUMBER
28960 --Distribution Type
28961 , p_source_18 IN VARCHAR2
28962 --Exchange Date
28963 , p_source_21 IN DATE
28964 --Exchange Rate
28965 , p_source_22 IN NUMBER
28966 --Exchange Rate Type
28967 , p_source_23 IN VARCHAR2
28968 --Transaction Distribution Identifier
28969 , p_source_29 IN NUMBER
28970 --Transaction Distribution Type
28971 , p_source_30 IN VARCHAR2
28972 --Distribution Multi Fund Additional Entry
28973 , p_source_54 IN VARCHAR2
28974 --Receipt Class Require Remittance Flag
28975 , p_source_56 IN VARCHAR2
28976 --Receipt Applied To Application Identifier
28977 , p_source_58 IN NUMBER
28978 --Transaction Entity Code
28979 , p_source_59 IN VARCHAR2
28980 --Transaction Identifier
28981 , p_source_60 IN NUMBER
28982 --DIST_ENT_AMT_FROM
28983 , p_source_61 IN NUMBER
28984 --Applying Document Currency Code
28985 , p_source_62 IN VARCHAR2
28986 --Accounting Amount
28987 , p_source_63 IN NUMBER
28988 --Distribution Party Identifier
28989 , p_source_64 IN NUMBER
28990 --Distribution Party Site Id
28991 , p_source_65 IN NUMBER
28992 --Distribution Party Type
28993 , p_source_66 IN VARCHAR2
28994 )
28995 IS
28996
28997 l_component_type VARCHAR2(80);
28998 l_component_code VARCHAR2(30);
28999 l_component_type_code VARCHAR2(1);
29000 l_component_appl_id INTEGER;
29001 l_amb_context_code VARCHAR2(30);
29002 l_entity_code VARCHAR2(30);
29003 l_event_class_code VARCHAR2(30);
29004 l_ae_header_id NUMBER;
29005 l_event_type_code VARCHAR2(30);
29006 l_line_definition_code VARCHAR2(30);
29007 l_line_definition_owner_code VARCHAR2(1);
29008 --
29009 -- adr variables
29010 l_segment VARCHAR2(30);
29011 l_ccid NUMBER;
29012 l_adr_transaction_coa_id NUMBER;
29013 l_adr_accounting_coa_id NUMBER;
29014 l_adr_flexfield_segment_code VARCHAR2(30);
29015 l_adr_flex_value_set_id NUMBER;
29016 l_adr_value_type_code VARCHAR2(30);
29017 l_adr_value_combination_id NUMBER;
29018 l_adr_value_segment_code VARCHAR2(30);
29019
29020 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
29021 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
29022 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
29023 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
29024
29025 -- 4262811 Variables ------------------------------------------------------------------------------------------
29026 l_entered_amt_idx NUMBER;
29027 l_accted_amt_idx NUMBER;
29028 l_acc_rev_flag VARCHAR2(1);
29029 l_accrual_line_num NUMBER;
29030 l_tmp_amt NUMBER;
29031 l_acc_rev_natural_side_code VARCHAR2(1);
29032
29033 l_num_entries NUMBER;
29034 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
29035 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
29036 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
29037 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
29038 l_recog_line_1 NUMBER;
29039 l_recog_line_2 NUMBER;
29040
29041 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
29042 l_bflow_applied_to_amt NUMBER; -- 5132302
29043 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
29044
29045 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
29046
29047 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
29048 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
29049
29050 ---------------------------------------------------------------------------------------------------------------
29051
29052
29053 --
29054 -- bulk performance
29055 --
29056 l_balance_type_code VARCHAR2(1);
29057 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
29058 l_log_module VARCHAR2(240);
29059
29060 --
29061 -- Upgrade strategy
29062 --
29063 l_actual_upg_option VARCHAR2(1);
29064 l_enc_upg_option VARCHAR2(1);
29065
29066 --
29067 BEGIN
29068 --
29069 IF g_log_enabled THEN
29070 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_64';
29071 END IF;
29072 --
29073 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29074
29075 trace
29076 (p_msg => 'BEGIN of AcctLineType_64'
29077 ,p_level => C_LEVEL_PROCEDURE
29078 ,p_module => l_log_module);
29079
29080 END IF;
29081 --
29082 l_component_type := 'AMB_JLT';
29083 l_component_code := 'MFAR_RCT_CM_CASH_REVERSAL';
29084 l_component_type_code := 'S';
29085 l_component_appl_id := 222;
29086 l_amb_context_code := 'DEFAULT';
29087 l_entity_code := 'RECEIPTS';
29088 l_event_class_code := 'RECEIPT';
29089 l_event_type_code := 'RECEIPT_ALL';
29090 l_line_definition_owner_code := 'S';
29094 l_segment := NULL;
29091 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
29092 --
29093 l_balance_type_code := 'A';
29095 l_ccid := NULL;
29096 l_adr_transaction_coa_id := NULL;
29097 l_adr_accounting_coa_id := NULL;
29098 l_adr_flexfield_segment_code := NULL;
29099 l_adr_flex_value_set_id := NULL;
29100 l_adr_value_type_code := NULL;
29101 l_adr_value_combination_id := NULL;
29102 l_adr_value_segment_code := NULL;
29103
29104 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
29105 l_bflow_class_code := ''; -- 4219869 Business Flow
29106 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
29107 l_budgetary_control_flag := 'N';
29108
29109 l_bflow_applied_to_amt_idx := NULL; -- 5132302
29110 l_bflow_applied_to_amt := NULL; -- 5132302
29111 l_entered_amt_idx := NULL; -- 4262811
29112 l_accted_amt_idx := NULL; -- 4262811
29113 l_acc_rev_flag := NULL; -- 4262811
29114 l_accrual_line_num := NULL; -- 4262811
29115 l_tmp_amt := NULL; -- 4262811
29116 --
29117
29118 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
29119 l_balance_type_code <> 'B' THEN
29120 IF NVL(p_source_15,'
29121 ') = 'CASH' AND
29122 NVL(p_source_54,'
29123 ') = 'Y' AND
29124 NVL(p_source_56,'
29125 ') = 'Y'
29126 THEN
29127
29128 --
29129 XLA_AE_LINES_PKG.SetNewLine;
29130
29131 p_balance_type_code := l_balance_type_code;
29132 -- set the flag so later we will know whether the gain loss line needs to be created
29133
29134 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
29135 p_actual_flag :='A';
29136 END IF;
29137
29138 --
29139 -- bulk performance
29140 --
29141 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
29142 p_header_num => 0); -- 4262811
29143 --
29144 -- set accounting line options
29145 --
29146 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
29147 p_natural_side_code => 'D'
29148 , p_gain_or_loss_flag => 'N'
29149 , p_gl_transfer_mode_code => 'S'
29150 , p_acct_entry_type_code => 'A'
29151 , p_switch_side_flag => 'Y'
29152 , p_merge_duplicate_code => 'A'
29153 );
29154 --
29155 l_acc_rev_natural_side_code := 'C'; -- 4262811
29156 --
29157 --
29158 -- set accounting line type info
29159 --
29160 xla_ae_lines_pkg.SetAcctLineType
29161 (p_component_type => l_component_type
29162 ,p_event_type_code => l_event_type_code
29163 ,p_line_definition_owner_code => l_line_definition_owner_code
29164 ,p_line_definition_code => l_line_definition_code
29165 ,p_accounting_line_code => l_component_code
29166 ,p_accounting_line_type_code => l_component_type_code
29167 ,p_accounting_line_appl_id => l_component_appl_id
29168 ,p_amb_context_code => l_amb_context_code
29169 ,p_entity_code => l_entity_code
29170 ,p_event_class_code => l_event_class_code);
29171 --
29172 -- set accounting class
29173 --
29174 xla_ae_lines_pkg.SetAcctClass(
29175 p_accounting_class_code => 'CASH'
29176 , p_ae_header_id => l_ae_header_id
29177 );
29178
29179 --
29180 -- set rounding class
29181 --
29182 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
29183 'RECEIVABLE';
29184
29185 --
29186 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
29187 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
29188 --
29189 -- bulk performance
29190 --
29191 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
29192
29193 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
29194 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
29195
29196 -- 4955764
29197 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29198 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
29199
29200 -- 4458381 Public Sector Enh
29201
29202 --
29203 -- set accounting attributes for the line type
29204 --
29205 l_entered_amt_idx := 8;
29206 l_accted_amt_idx := 13;
29207 l_bflow_applied_to_amt_idx := NULL; -- 5132302
29208 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
29209 l_rec_acct_attrs.array_num_value(1) := p_source_58;
29210 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
29211 l_rec_acct_attrs.array_char_value(2) := p_source_30;
29212 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
29213 l_rec_acct_attrs.array_char_value(3) := p_source_59;
29214 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
29215 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
29216 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
29217 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
29218 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
29219 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
29220 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
29221 l_rec_acct_attrs.array_char_value(7) := p_source_18;
29222 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
29223 l_rec_acct_attrs.array_num_value(8) := p_source_61;
29224 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
29225 l_rec_acct_attrs.array_char_value(9) := p_source_62;
29226 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
29227 l_rec_acct_attrs.array_date_value(10) := p_source_21;
29228 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
29229 l_rec_acct_attrs.array_num_value(11) := p_source_22;
29230 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
29231 l_rec_acct_attrs.array_char_value(12) := p_source_23;
29232 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
29233 l_rec_acct_attrs.array_num_value(13) := p_source_63;
29234 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
29235 l_rec_acct_attrs.array_num_value(14) := p_source_64;
29236 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
29237 l_rec_acct_attrs.array_num_value(15) := p_source_65;
29238 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
29239 l_rec_acct_attrs.array_char_value(16) := p_source_66;
29240
29241 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
29242 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
29243
29244 ---------------------------------------------------------------------------------------------------------------
29245 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
29246 ---------------------------------------------------------------------------------------------------------------
29247 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
29248
29249 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
29250 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
29251
29252 IF xla_accounting_cache_pkg.GetValueChar
29253 (p_source_code => 'LEDGER_CATEGORY_CODE'
29254 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
29255 AND l_bflow_method_code = 'PRIOR_ENTRY'
29256 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
29257 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
29258 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
29259 )
29260 THEN
29261 xla_ae_lines_pkg.BflowUpgEntry
29262 (p_business_method_code => l_bflow_method_code
29263 ,p_business_class_code => l_bflow_class_code
29264 ,p_balance_type => l_balance_type_code);
29265 ELSE
29266 NULL;
29267 -- No business flow processing for business flow method of NONE.
29268 END IF;
29269
29270 --
29271 -- call analytical criteria
29272 --
29273
29274 --
29275 -- call description
29276 --
29277
29278 xla_ae_lines_pkg.SetLineDescription(
29279 p_ae_header_id => l_ae_header_id
29280 ,p_description => Description_1 (
29281 p_application_id => p_application_id
29282 , p_ae_header_id => l_ae_header_id
29283 )
29284 );
29285
29286
29287 --
29288 -- call ADRs
29289 -- Bug 4922099
29290 --
29291 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29292 (NVL(l_actual_upg_option, 'N') = 'O') OR
29293 (NVL(l_enc_upg_option, 'N') = 'O')
29294 )
29295 THEN
29296 NULL;
29297 --
29298 --
29299
29300 l_ccid := AcctDerRule_12(
29301 p_application_id => p_application_id
29302 , p_ae_header_id => l_ae_header_id
29303 , p_source_5 => p_source_5
29304 , x_transaction_coa_id => l_adr_transaction_coa_id
29305 , x_accounting_coa_id => l_adr_accounting_coa_id
29306 , x_value_type_code => l_adr_value_type_code
29307 , p_side => 'NA'
29308 );
29309
29310 xla_ae_lines_pkg.set_ccid(
29311 p_code_combination_id => l_ccid
29312 , p_value_type_code => l_adr_value_type_code
29313 , p_transaction_coa_id => l_adr_transaction_coa_id
29314 , p_accounting_coa_id => l_adr_accounting_coa_id
29315 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
29316 , p_adr_type_code => 'S'
29317 , p_component_type => l_component_type
29318 , p_component_code => l_component_code
29319 , p_component_type_code => l_component_type_code
29320 , p_component_appl_id => l_component_appl_id
29321 , p_amb_context_code => l_amb_context_code
29322 , p_side => 'NA'
29323 );
29324
29325
29326 --
29327 --
29328 END IF;
29329 --
29330 -- Bug 4922099
29331 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
29332 (NVL(l_enc_upg_option, 'N') = 'O')
29333 ) AND
29334 (l_bflow_method_code = 'PRIOR_ENTRY')
29335 )
29336 THEN
29337 IF
29338 --
29339 1 = 2
29340 --
29341 THEN
29342 xla_accounting_err_pkg.build_message
29343 (p_appli_s_name => 'XLA'
29344 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29345 ,p_token_1 => 'LINE_NUMBER'
29346 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
29347 ,p_token_2 => 'LINE_TYPE_NAME'
29348 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
29349 l_component_type
29350 ,l_component_code
29351 ,l_component_type_code
29352 ,l_component_appl_id
29353 ,l_amb_context_code
29354 ,l_entity_code
29355 ,l_event_class_code
29356 )
29357 ,p_token_3 => 'OWNER'
29358 ,p_value_3 => xla_lookups_pkg.get_meaning(
29359 p_lookup_type => 'XLA_OWNER_TYPE'
29360 ,p_lookup_code => l_component_type_code
29361 )
29362 ,p_token_4 => 'PRODUCT_NAME'
29363 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
29364 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
29365 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
29366 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
29367 ,p_ae_header_id => NULL
29368 );
29369
29370 IF (C_LEVEL_ERROR>= g_log_level) THEN
29371 trace
29372 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29373 ,p_level => C_LEVEL_ERROR
29374 ,p_module => l_log_module);
29375 END IF;
29376 END IF;
29377 END IF;
29378 --
29379 --
29380 ------------------------------------------------------------------------------------------------
29381 -- 4219869 Business Flow
29382 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
29383 -- Prior Entry. Currently, the following code is always generated.
29384 ------------------------------------------------------------------------------------------------
29385 XLA_AE_LINES_PKG.ValidateCurrentLine;
29386
29387 ------------------------------------------------------------------------------------
29388 -- 4219869 Business Flow
29389 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
29390 ------------------------------------------------------------------------------------
29391 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29392
29393 ----------------------------------------------------------------------------------
29394 -- 4219869 Business Flow
29395 -- Update journal entry status -- Need to generate this within IF <condition>
29396 ----------------------------------------------------------------------------------
29397 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29398 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
29399 ,p_balance_type_code => l_balance_type_code
29400 );
29401
29402 -------------------------------------------------------------------------------------------
29403 -- 4262811 - Generate the Accrual Reversal lines
29407 (g_array_event(p_event_id).array_value_num('header_index'));
29404 -------------------------------------------------------------------------------------------
29405 BEGIN
29406 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
29408 IF l_acc_rev_flag IS NULL THEN
29409 l_acc_rev_flag := 'N';
29410 END IF;
29411 EXCEPTION
29412 WHEN OTHERS THEN
29413 l_acc_rev_flag := 'N';
29414 END;
29415 --
29416 IF (l_acc_rev_flag = 'Y') THEN
29417
29418 -- 4645092 ------------------------------------------------------------------------------
29419 -- To allow MPA report to determine if it should generate report process
29420 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
29421 ------------------------------------------------------------------------------------------
29422
29423 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
29424 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
29425 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
29426 -- call ADRs
29427 -- Bug 4922099
29428 --
29429 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29430 (NVL(l_actual_upg_option, 'N') = 'O') OR
29431 (NVL(l_enc_upg_option, 'N') = 'O')
29432 )
29433 THEN
29434 NULL;
29435 --
29436 --
29437
29438 l_ccid := AcctDerRule_12(
29439 p_application_id => p_application_id
29440 , p_ae_header_id => l_ae_header_id
29441 , p_source_5 => p_source_5
29442 , x_transaction_coa_id => l_adr_transaction_coa_id
29443 , x_accounting_coa_id => l_adr_accounting_coa_id
29444 , x_value_type_code => l_adr_value_type_code
29445 , p_side => 'NA'
29446 );
29447
29448 xla_ae_lines_pkg.set_ccid(
29449 p_code_combination_id => l_ccid
29450 , p_value_type_code => l_adr_value_type_code
29451 , p_transaction_coa_id => l_adr_transaction_coa_id
29452 , p_accounting_coa_id => l_adr_accounting_coa_id
29453 , p_adr_code => 'MFAR_RCT_DEF_CASH_CCID'
29454 , p_adr_type_code => 'S'
29455 , p_component_type => l_component_type
29456 , p_component_code => l_component_code
29457 , p_component_type_code => l_component_type_code
29458 , p_component_appl_id => l_component_appl_id
29459 , p_amb_context_code => l_amb_context_code
29460 , p_side => 'NA'
29461 );
29462
29463
29464 --
29465 --
29466 END IF;
29467
29468 --
29469 -- Update the line information that should be overwritten
29470 --
29471 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
29472 p_header_num => 1);
29473 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
29474
29475 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
29476
29477 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
29478 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
29479 END IF;
29480
29481 --
29482 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
29483 --
29484 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
29485 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
29486 ELSE
29487 ---------------------------------------------------------------------------------------------------
29488 -- 4262811a Switch Sign
29489 ---------------------------------------------------------------------------------------------------
29490 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
29491 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29492 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29493 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29494 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29495 -- 5132302
29496 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
29497 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29498
29499 END IF;
29500
29501 -- 4955764
29502 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29503 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
29504
29505
29506 XLA_AE_LINES_PKG.ValidateCurrentLine;
29507 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29508
29509 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29510 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
29511 ,p_balance_type_code => l_balance_type_code);
29512
29513 END IF;
29514
29515 -----------------------------------------------------------------------------------------
29516 -- 4262811 Multiperiod Accounting
29517 -----------------------------------------------------------------------------------------
29518 -- No MPA option is assigned.
29519
29520
29521 END IF;
29522 END IF;
29523 --
29524
29525 --
29526 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29527 trace
29528 (p_msg => 'END of AcctLineType_64'
29529 ,p_level => C_LEVEL_PROCEDURE
29530 ,p_module => l_log_module);
29531 END IF;
29532 --
29533 EXCEPTION
29534 WHEN xla_exceptions_pkg.application_exception THEN
29535 RAISE;
29536 WHEN OTHERS THEN
29537 xla_exceptions_pkg.raise_message
29538 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_64');
29539 END AcctLineType_64;
29540 --
29541
29542 ---------------------------------------
29543 --
29544 -- PRIVATE FUNCTION
29545 -- AcctLineType_65
29546 --
29547 ---------------------------------------
29548 PROCEDURE AcctLineType_65 (
29549 p_application_id IN NUMBER
29550 ,p_event_id IN NUMBER
29551 ,p_calculate_acctd_flag IN VARCHAR2
29552 ,p_calculate_g_l_flag IN VARCHAR2
29553 ,p_actual_flag IN OUT VARCHAR2
29554 ,p_balance_type_code OUT VARCHAR2
29555 ,p_gain_or_loss_ref OUT VARCHAR2
29556
29557 --Remittance Bank Account Confirmation Account
29558 , p_source_3 IN NUMBER
29559 --Distribution Source Type
29560 , p_source_15 IN VARCHAR2
29561 --Distribution Line Identifier
29562 , p_source_17 IN NUMBER
29563 --Distribution Type
29564 , p_source_18 IN VARCHAR2
29565 --Exchange Date
29566 , p_source_21 IN DATE
29567 --Exchange Rate
29568 , p_source_22 IN NUMBER
29569 --Exchange Rate Type
29570 , p_source_23 IN VARCHAR2
29571 --Transaction Distribution Identifier
29572 , p_source_29 IN NUMBER
29573 --Transaction Distribution Type
29574 , p_source_30 IN VARCHAR2
29575 --Distribution Multi Fund Additional Entry
29576 , p_source_54 IN VARCHAR2
29577 --Receipt Applied To Application Identifier
29578 , p_source_58 IN NUMBER
29579 --Transaction Entity Code
29580 , p_source_59 IN VARCHAR2
29581 --Transaction Identifier
29582 , p_source_60 IN NUMBER
29583 --DIST_ENT_AMT_FROM
29584 , p_source_61 IN NUMBER
29585 --Applying Document Currency Code
29586 , p_source_62 IN VARCHAR2
29587 --Accounting Amount
29588 , p_source_63 IN NUMBER
29589 --Distribution Party Identifier
29590 , p_source_64 IN NUMBER
29591 --Distribution Party Site Id
29592 , p_source_65 IN NUMBER
29593 --Distribution Party Type
29594 , p_source_66 IN VARCHAR2
29595 )
29596 IS
29597
29598 l_component_type VARCHAR2(80);
29599 l_component_code VARCHAR2(30);
29600 l_component_type_code VARCHAR2(1);
29601 l_component_appl_id INTEGER;
29602 l_amb_context_code VARCHAR2(30);
29603 l_entity_code VARCHAR2(30);
29604 l_event_class_code VARCHAR2(30);
29605 l_ae_header_id NUMBER;
29606 l_event_type_code VARCHAR2(30);
29607 l_line_definition_code VARCHAR2(30);
29608 l_line_definition_owner_code VARCHAR2(1);
29609 --
29610 -- adr variables
29611 l_segment VARCHAR2(30);
29612 l_ccid NUMBER;
29613 l_adr_transaction_coa_id NUMBER;
29614 l_adr_accounting_coa_id NUMBER;
29615 l_adr_flexfield_segment_code VARCHAR2(30);
29616 l_adr_flex_value_set_id NUMBER;
29617 l_adr_value_type_code VARCHAR2(30);
29618 l_adr_value_combination_id NUMBER;
29619 l_adr_value_segment_code VARCHAR2(30);
29620
29621 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
29622 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
29623 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
29624 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
29625
29626 -- 4262811 Variables ------------------------------------------------------------------------------------------
29627 l_entered_amt_idx NUMBER;
29628 l_accted_amt_idx NUMBER;
29629 l_acc_rev_flag VARCHAR2(1);
29630 l_accrual_line_num NUMBER;
29631 l_tmp_amt NUMBER;
29632 l_acc_rev_natural_side_code VARCHAR2(1);
29633
29634 l_num_entries NUMBER;
29635 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
29636 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
29637 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
29638 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
29639 l_recog_line_1 NUMBER;
29640 l_recog_line_2 NUMBER;
29641
29642 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
29643 l_bflow_applied_to_amt NUMBER; -- 5132302
29644 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
29645
29646 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
29647
29648 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
29649 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
29650
29651 ---------------------------------------------------------------------------------------------------------------
29652
29653
29654 --
29655 -- bulk performance
29656 --
29657 l_balance_type_code VARCHAR2(1);
29658 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
29659 l_log_module VARCHAR2(240);
29660
29661 --
29662 -- Upgrade strategy
29663 --
29664 l_actual_upg_option VARCHAR2(1);
29665 l_enc_upg_option VARCHAR2(1);
29666
29667 --
29668 BEGIN
29669 --
29670 IF g_log_enabled THEN
29671 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_65';
29672 END IF;
29673 --
29674 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29675
29676 trace
29677 (p_msg => 'BEGIN of AcctLineType_65'
29678 ,p_level => C_LEVEL_PROCEDURE
29679 ,p_module => l_log_module);
29680
29681 END IF;
29682 --
29683 l_component_type := 'AMB_JLT';
29684 l_component_code := 'MFAR_RCT_CONFIRM_REVERSAL';
29685 l_component_type_code := 'S';
29686 l_component_appl_id := 222;
29687 l_amb_context_code := 'DEFAULT';
29688 l_entity_code := 'RECEIPTS';
29689 l_event_class_code := 'RECEIPT';
29690 l_event_type_code := 'RECEIPT_ALL';
29691 l_line_definition_owner_code := 'S';
29692 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
29693 --
29694 l_balance_type_code := 'A';
29695 l_segment := NULL;
29696 l_ccid := NULL;
29697 l_adr_transaction_coa_id := NULL;
29698 l_adr_accounting_coa_id := NULL;
29699 l_adr_flexfield_segment_code := NULL;
29700 l_adr_flex_value_set_id := NULL;
29701 l_adr_value_type_code := NULL;
29702 l_adr_value_combination_id := NULL;
29703 l_adr_value_segment_code := NULL;
29704
29705 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
29706 l_bflow_class_code := ''; -- 4219869 Business Flow
29707 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
29708 l_budgetary_control_flag := 'N';
29709
29710 l_bflow_applied_to_amt_idx := NULL; -- 5132302
29711 l_bflow_applied_to_amt := NULL; -- 5132302
29712 l_entered_amt_idx := NULL; -- 4262811
29713 l_accted_amt_idx := NULL; -- 4262811
29714 l_acc_rev_flag := NULL; -- 4262811
29715 l_accrual_line_num := NULL; -- 4262811
29716 l_tmp_amt := NULL; -- 4262811
29717 --
29718
29719 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
29720 l_balance_type_code <> 'B' THEN
29721 IF NVL(p_source_15,'
29722 ') = 'CONFIRMATION' AND
29723 NVL(p_source_54,'
29724 ') = 'Y'
29725 THEN
29726
29727 --
29728 XLA_AE_LINES_PKG.SetNewLine;
29729
29730 p_balance_type_code := l_balance_type_code;
29731 -- set the flag so later we will know whether the gain loss line needs to be created
29732
29733 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
29734 p_actual_flag :='A';
29735 END IF;
29736
29737 --
29738 -- bulk performance
29739 --
29740 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
29741 p_header_num => 0); -- 4262811
29742 --
29743 -- set accounting line options
29744 --
29745 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
29746 p_natural_side_code => 'D'
29747 , p_gain_or_loss_flag => 'N'
29748 , p_gl_transfer_mode_code => 'S'
29749 , p_acct_entry_type_code => 'A'
29750 , p_switch_side_flag => 'Y'
29751 , p_merge_duplicate_code => 'A'
29752 );
29753 --
29754 l_acc_rev_natural_side_code := 'C'; -- 4262811
29755 --
29756 --
29757 -- set accounting line type info
29758 --
29759 xla_ae_lines_pkg.SetAcctLineType
29760 (p_component_type => l_component_type
29761 ,p_event_type_code => l_event_type_code
29762 ,p_line_definition_owner_code => l_line_definition_owner_code
29763 ,p_line_definition_code => l_line_definition_code
29764 ,p_accounting_line_code => l_component_code
29765 ,p_accounting_line_type_code => l_component_type_code
29766 ,p_accounting_line_appl_id => l_component_appl_id
29767 ,p_amb_context_code => l_amb_context_code
29768 ,p_entity_code => l_entity_code
29769 ,p_event_class_code => l_event_class_code);
29770 --
29771 -- set accounting class
29772 --
29773 xla_ae_lines_pkg.SetAcctClass(
29774 p_accounting_class_code => 'CONFIRMATION'
29775 , p_ae_header_id => l_ae_header_id
29776 );
29777
29778 --
29779 -- set rounding class
29780 --
29781 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
29782 'RECEIVABLE';
29783
29784 --
29785 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
29786 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
29787 --
29788 -- bulk performance
29789 --
29790 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
29791
29792 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
29793 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
29794
29795 -- 4955764
29796 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29797 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
29798
29799 -- 4458381 Public Sector Enh
29800
29801 --
29802 -- set accounting attributes for the line type
29803 --
29804 l_entered_amt_idx := 8;
29805 l_accted_amt_idx := 13;
29806 l_bflow_applied_to_amt_idx := NULL; -- 5132302
29807 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
29808 l_rec_acct_attrs.array_num_value(1) := p_source_58;
29809 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
29810 l_rec_acct_attrs.array_char_value(2) := p_source_30;
29811 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
29812 l_rec_acct_attrs.array_char_value(3) := p_source_59;
29813 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
29814 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
29815 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
29816 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
29817 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
29818 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
29819 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
29820 l_rec_acct_attrs.array_char_value(7) := p_source_18;
29821 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
29822 l_rec_acct_attrs.array_num_value(8) := p_source_61;
29823 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
29824 l_rec_acct_attrs.array_char_value(9) := p_source_62;
29825 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
29826 l_rec_acct_attrs.array_date_value(10) := p_source_21;
29827 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
29828 l_rec_acct_attrs.array_num_value(11) := p_source_22;
29829 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
29830 l_rec_acct_attrs.array_char_value(12) := p_source_23;
29831 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
29832 l_rec_acct_attrs.array_num_value(13) := p_source_63;
29833 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
29834 l_rec_acct_attrs.array_num_value(14) := p_source_64;
29835 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
29836 l_rec_acct_attrs.array_num_value(15) := p_source_65;
29837 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
29838 l_rec_acct_attrs.array_char_value(16) := p_source_66;
29839
29840 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
29841 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
29842
29843 ---------------------------------------------------------------------------------------------------------------
29844 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
29845 ---------------------------------------------------------------------------------------------------------------
29846 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
29847
29848 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
29849 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
29850
29851 IF xla_accounting_cache_pkg.GetValueChar
29855 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
29852 (p_source_code => 'LEDGER_CATEGORY_CODE'
29853 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
29854 AND l_bflow_method_code = 'PRIOR_ENTRY'
29856 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
29857 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
29858 )
29859 THEN
29860 xla_ae_lines_pkg.BflowUpgEntry
29861 (p_business_method_code => l_bflow_method_code
29862 ,p_business_class_code => l_bflow_class_code
29863 ,p_balance_type => l_balance_type_code);
29864 ELSE
29865 NULL;
29866 -- No business flow processing for business flow method of NONE.
29867 END IF;
29868
29869 --
29870 -- call analytical criteria
29871 --
29872
29873 --
29874 -- call description
29875 --
29876
29877 xla_ae_lines_pkg.SetLineDescription(
29878 p_ae_header_id => l_ae_header_id
29879 ,p_description => Description_1 (
29880 p_application_id => p_application_id
29881 , p_ae_header_id => l_ae_header_id
29882 )
29883 );
29884
29885
29886 --
29887 -- call ADRs
29888 -- Bug 4922099
29889 --
29890 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29891 (NVL(l_actual_upg_option, 'N') = 'O') OR
29892 (NVL(l_enc_upg_option, 'N') = 'O')
29893 )
29894 THEN
29895 NULL;
29896 --
29897 --
29898
29899 l_ccid := AcctDerRule_13(
29900 p_application_id => p_application_id
29901 , p_ae_header_id => l_ae_header_id
29902 , p_source_3 => p_source_3
29903 , x_transaction_coa_id => l_adr_transaction_coa_id
29904 , x_accounting_coa_id => l_adr_accounting_coa_id
29905 , x_value_type_code => l_adr_value_type_code
29906 , p_side => 'NA'
29907 );
29908
29909 xla_ae_lines_pkg.set_ccid(
29910 p_code_combination_id => l_ccid
29911 , p_value_type_code => l_adr_value_type_code
29912 , p_transaction_coa_id => l_adr_transaction_coa_id
29913 , p_accounting_coa_id => l_adr_accounting_coa_id
29914 , p_adr_code => 'MFAR_RCT_DEF_CONFIRMATION_CCID'
29915 , p_adr_type_code => 'S'
29916 , p_component_type => l_component_type
29917 , p_component_code => l_component_code
29918 , p_component_type_code => l_component_type_code
29919 , p_component_appl_id => l_component_appl_id
29920 , p_amb_context_code => l_amb_context_code
29921 , p_side => 'NA'
29922 );
29923
29924
29925 --
29926 --
29927 END IF;
29928 --
29929 -- Bug 4922099
29930 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
29931 (NVL(l_enc_upg_option, 'N') = 'O')
29932 ) AND
29933 (l_bflow_method_code = 'PRIOR_ENTRY')
29934 )
29935 THEN
29936 IF
29937 --
29938 1 = 2
29939 --
29940 THEN
29941 xla_accounting_err_pkg.build_message
29942 (p_appli_s_name => 'XLA'
29943 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29944 ,p_token_1 => 'LINE_NUMBER'
29945 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
29946 ,p_token_2 => 'LINE_TYPE_NAME'
29947 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
29948 l_component_type
29949 ,l_component_code
29950 ,l_component_type_code
29951 ,l_component_appl_id
29952 ,l_amb_context_code
29953 ,l_entity_code
29954 ,l_event_class_code
29955 )
29956 ,p_token_3 => 'OWNER'
29957 ,p_value_3 => xla_lookups_pkg.get_meaning(
29958 p_lookup_type => 'XLA_OWNER_TYPE'
29959 ,p_lookup_code => l_component_type_code
29960 )
29961 ,p_token_4 => 'PRODUCT_NAME'
29962 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
29963 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
29964 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
29965 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
29966 ,p_ae_header_id => NULL
29967 );
29968
29969 IF (C_LEVEL_ERROR>= g_log_level) THEN
29970 trace
29971 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29972 ,p_level => C_LEVEL_ERROR
29973 ,p_module => l_log_module);
29974 END IF;
29975 END IF;
29976 END IF;
29977 --
29978 --
29979 ------------------------------------------------------------------------------------------------
29980 -- 4219869 Business Flow
29981 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
29982 -- Prior Entry. Currently, the following code is always generated.
29983 ------------------------------------------------------------------------------------------------
29984 XLA_AE_LINES_PKG.ValidateCurrentLine;
29985
29986 ------------------------------------------------------------------------------------
29987 -- 4219869 Business Flow
29988 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
29989 ------------------------------------------------------------------------------------
29990 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29991
29992 ----------------------------------------------------------------------------------
29993 -- 4219869 Business Flow
29994 -- Update journal entry status -- Need to generate this within IF <condition>
29995 ----------------------------------------------------------------------------------
29996 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29997 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
29998 ,p_balance_type_code => l_balance_type_code
29999 );
30000
30001 -------------------------------------------------------------------------------------------
30002 -- 4262811 - Generate the Accrual Reversal lines
30003 -------------------------------------------------------------------------------------------
30004 BEGIN
30005 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
30006 (g_array_event(p_event_id).array_value_num('header_index'));
30007 IF l_acc_rev_flag IS NULL THEN
30008 l_acc_rev_flag := 'N';
30009 END IF;
30010 EXCEPTION
30011 WHEN OTHERS THEN
30012 l_acc_rev_flag := 'N';
30013 END;
30014 --
30015 IF (l_acc_rev_flag = 'Y') THEN
30016
30017 -- 4645092 ------------------------------------------------------------------------------
30018 -- To allow MPA report to determine if it should generate report process
30019 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
30020 ------------------------------------------------------------------------------------------
30021
30022 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
30023 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
30024 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
30025 -- call ADRs
30026 -- Bug 4922099
30027 --
30028 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30029 (NVL(l_actual_upg_option, 'N') = 'O') OR
30030 (NVL(l_enc_upg_option, 'N') = 'O')
30031 )
30032 THEN
30033 NULL;
30034 --
30035 --
30036
30037 l_ccid := AcctDerRule_13(
30038 p_application_id => p_application_id
30039 , p_ae_header_id => l_ae_header_id
30040 , p_source_3 => p_source_3
30041 , x_transaction_coa_id => l_adr_transaction_coa_id
30042 , x_accounting_coa_id => l_adr_accounting_coa_id
30043 , x_value_type_code => l_adr_value_type_code
30044 , p_side => 'NA'
30045 );
30046
30047 xla_ae_lines_pkg.set_ccid(
30048 p_code_combination_id => l_ccid
30052 , p_adr_code => 'MFAR_RCT_DEF_CONFIRMATION_CCID'
30049 , p_value_type_code => l_adr_value_type_code
30050 , p_transaction_coa_id => l_adr_transaction_coa_id
30051 , p_accounting_coa_id => l_adr_accounting_coa_id
30053 , p_adr_type_code => 'S'
30054 , p_component_type => l_component_type
30055 , p_component_code => l_component_code
30056 , p_component_type_code => l_component_type_code
30057 , p_component_appl_id => l_component_appl_id
30058 , p_amb_context_code => l_amb_context_code
30059 , p_side => 'NA'
30060 );
30061
30062
30063 --
30064 --
30065 END IF;
30066
30067 --
30068 -- Update the line information that should be overwritten
30069 --
30070 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
30071 p_header_num => 1);
30072 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
30073
30074 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
30075
30076 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
30077 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
30078 END IF;
30079
30080 --
30081 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
30082 --
30083 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
30084 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
30085 ELSE
30086 ---------------------------------------------------------------------------------------------------
30087 -- 4262811a Switch Sign
30088 ---------------------------------------------------------------------------------------------------
30089 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
30090 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30091 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30092 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30093 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30094 -- 5132302
30095 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
30096 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30097
30098 END IF;
30099
30100 -- 4955764
30101 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30102 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
30103
30104
30105 XLA_AE_LINES_PKG.ValidateCurrentLine;
30106 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
30107
30108 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
30109 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
30110 ,p_balance_type_code => l_balance_type_code);
30111
30112 END IF;
30113
30114 -----------------------------------------------------------------------------------------
30115 -- 4262811 Multiperiod Accounting
30116 -----------------------------------------------------------------------------------------
30117 -- No MPA option is assigned.
30118
30119
30120 END IF;
30121 END IF;
30122 --
30123
30124 --
30125 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30126 trace
30127 (p_msg => 'END of AcctLineType_65'
30128 ,p_level => C_LEVEL_PROCEDURE
30129 ,p_module => l_log_module);
30130 END IF;
30131 --
30132 EXCEPTION
30133 WHEN xla_exceptions_pkg.application_exception THEN
30134 RAISE;
30135 WHEN OTHERS THEN
30136 xla_exceptions_pkg.raise_message
30137 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_65');
30138 END AcctLineType_65;
30139 --
30140
30141 ---------------------------------------
30142 --
30143 -- PRIVATE FUNCTION
30144 -- AcctLineType_66
30145 --
30146 ---------------------------------------
30147 PROCEDURE AcctLineType_66 (
30148 p_application_id IN NUMBER
30149 ,p_event_id IN NUMBER
30150 ,p_calculate_acctd_flag IN VARCHAR2
30151 ,p_calculate_g_l_flag IN VARCHAR2
30152 ,p_actual_flag IN OUT VARCHAR2
30153 ,p_balance_type_code OUT VARCHAR2
30154 ,p_gain_or_loss_ref OUT VARCHAR2
30155
30156 --Distribution Source Type
30157 , p_source_15 IN VARCHAR2
30158 --Distribution Line Identifier
30159 , p_source_17 IN NUMBER
30160 --Distribution Type
30161 , p_source_18 IN VARCHAR2
30162 --Entered Amount
30163 , p_source_19 IN NUMBER
30164 --Currency Code
30165 , p_source_20 IN VARCHAR2
30166 --Applied To Document Accounting Amount
30167 , p_source_24 IN NUMBER
30168 --Transaction Distribution Identifier
30169 , p_source_29 IN NUMBER
30170 --Transaction Distribution Type
30171 , p_source_30 IN VARCHAR2
30172 --Distribution Multi Fund Additional Entry
30173 , p_source_54 IN VARCHAR2
30174 --Receipt Applied To Application Identifier
30175 , p_source_58 IN NUMBER
30176 --Transaction Entity Code
30177 , p_source_59 IN VARCHAR2
30178 --Transaction Identifier
30179 , p_source_60 IN NUMBER
30180 --Distribution Party Type
30181 , p_source_66 IN VARCHAR2
30182 )
30183 IS
30184
30185 l_component_type VARCHAR2(80);
30186 l_component_code VARCHAR2(30);
30187 l_component_type_code VARCHAR2(1);
30188 l_component_appl_id INTEGER;
30189 l_amb_context_code VARCHAR2(30);
30190 l_entity_code VARCHAR2(30);
30191 l_event_class_code VARCHAR2(30);
30192 l_ae_header_id NUMBER;
30193 l_event_type_code VARCHAR2(30);
30194 l_line_definition_code VARCHAR2(30);
30195 l_line_definition_owner_code VARCHAR2(1);
30196 --
30197 -- adr variables
30198 l_segment VARCHAR2(30);
30199 l_ccid NUMBER;
30200 l_adr_transaction_coa_id NUMBER;
30201 l_adr_accounting_coa_id NUMBER;
30202 l_adr_flexfield_segment_code VARCHAR2(30);
30203 l_adr_flex_value_set_id NUMBER;
30204 l_adr_value_type_code VARCHAR2(30);
30205 l_adr_value_combination_id NUMBER;
30206 l_adr_value_segment_code VARCHAR2(30);
30207
30208 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
30209 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
30210 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
30211 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
30212
30213 -- 4262811 Variables ------------------------------------------------------------------------------------------
30214 l_entered_amt_idx NUMBER;
30215 l_accted_amt_idx NUMBER;
30216 l_acc_rev_flag VARCHAR2(1);
30217 l_accrual_line_num NUMBER;
30218 l_tmp_amt NUMBER;
30219 l_acc_rev_natural_side_code VARCHAR2(1);
30220
30221 l_num_entries NUMBER;
30222 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
30223 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
30224 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
30225 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
30226 l_recog_line_1 NUMBER;
30227 l_recog_line_2 NUMBER;
30228
30229 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
30230 l_bflow_applied_to_amt NUMBER; -- 5132302
30231 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
30232
30233 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
30234
30235 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
30236 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
30237
30238 ---------------------------------------------------------------------------------------------------------------
30239
30240
30241 --
30242 -- bulk performance
30243 --
30244 l_balance_type_code VARCHAR2(1);
30245 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
30246 l_log_module VARCHAR2(240);
30247
30248 --
30249 -- Upgrade strategy
30250 --
30251 l_actual_upg_option VARCHAR2(1);
30252 l_enc_upg_option VARCHAR2(1);
30253
30254 --
30255 BEGIN
30256 --
30257 IF g_log_enabled THEN
30258 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_66';
30259 END IF;
30260 --
30261 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30262
30263 trace
30264 (p_msg => 'BEGIN of AcctLineType_66'
30265 ,p_level => C_LEVEL_PROCEDURE
30266 ,p_module => l_log_module);
30267
30268 END IF;
30269 --
30270 l_component_type := 'AMB_JLT';
30271 l_component_code := 'MFAR_RCT_EDISC_REC';
30272 l_component_type_code := 'S';
30273 l_component_appl_id := 222;
30274 l_amb_context_code := 'DEFAULT';
30275 l_entity_code := 'RECEIPTS';
30276 l_event_class_code := 'RECEIPT';
30277 l_event_type_code := 'RECEIPT_ALL';
30278 l_line_definition_owner_code := 'S';
30279 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
30280 --
30281 l_balance_type_code := 'A';
30282 l_segment := NULL;
30283 l_ccid := NULL;
30284 l_adr_transaction_coa_id := NULL;
30285 l_adr_accounting_coa_id := NULL;
30286 l_adr_flexfield_segment_code := NULL;
30287 l_adr_flex_value_set_id := NULL;
30288 l_adr_value_type_code := NULL;
30289 l_adr_value_combination_id := NULL;
30290 l_adr_value_segment_code := NULL;
30291
30292 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
30293 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
30294 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
30295 l_budgetary_control_flag := 'N';
30296
30297 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30298 l_bflow_applied_to_amt := NULL; -- 5132302
30299 l_entered_amt_idx := NULL; -- 4262811
30300 l_accted_amt_idx := NULL; -- 4262811
30301 l_acc_rev_flag := NULL; -- 4262811
30302 l_accrual_line_num := NULL; -- 4262811
30303 l_tmp_amt := NULL; -- 4262811
30304 --
30305
30306 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
30307 l_balance_type_code <> 'B' THEN
30308 IF NVL(p_source_15,'
30309 ') = 'EDISC' AND
30310 NVL(p_source_54,'
30311 ') = 'N'
30312 THEN
30313
30314 --
30315 XLA_AE_LINES_PKG.SetNewLine;
30316
30317 p_balance_type_code := l_balance_type_code;
30318 -- set the flag so later we will know whether the gain loss line needs to be created
30319
30320 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
30321 p_actual_flag :='A';
30322 END IF;
30323
30324 --
30325 -- bulk performance
30326 --
30327 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
30328 p_header_num => 0); -- 4262811
30329 --
30330 -- set accounting line options
30331 --
30332 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
30333 p_natural_side_code => 'D'
30334 , p_gain_or_loss_flag => 'N'
30335 , p_gl_transfer_mode_code => 'S'
30336 , p_acct_entry_type_code => 'A'
30337 , p_switch_side_flag => 'Y'
30338 , p_merge_duplicate_code => 'A'
30339 );
30340 --
30341 l_acc_rev_natural_side_code := 'C'; -- 4262811
30342 --
30343 --
30344 -- set accounting line type info
30345 --
30346 xla_ae_lines_pkg.SetAcctLineType
30347 (p_component_type => l_component_type
30348 ,p_event_type_code => l_event_type_code
30349 ,p_line_definition_owner_code => l_line_definition_owner_code
30353 ,p_accounting_line_appl_id => l_component_appl_id
30350 ,p_line_definition_code => l_line_definition_code
30351 ,p_accounting_line_code => l_component_code
30352 ,p_accounting_line_type_code => l_component_type_code
30354 ,p_amb_context_code => l_amb_context_code
30355 ,p_entity_code => l_entity_code
30356 ,p_event_class_code => l_event_class_code);
30357 --
30358 -- set accounting class
30359 --
30360 xla_ae_lines_pkg.SetAcctClass(
30361 p_accounting_class_code => 'RECEIVABLE'
30362 , p_ae_header_id => l_ae_header_id
30363 );
30364
30365 --
30366 -- set rounding class
30367 --
30368 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
30369 'RECEIVABLE';
30370
30371 --
30372 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
30373 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
30374 --
30375 -- bulk performance
30376 --
30377 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
30378
30379 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
30380 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
30381
30382 -- 4955764
30383 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30384 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
30385
30386 -- 4458381 Public Sector Enh
30387
30388 --
30389 -- set accounting attributes for the line type
30390 --
30391 l_entered_amt_idx := 8;
30392 l_accted_amt_idx := 10;
30393 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30394 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
30395 l_rec_acct_attrs.array_num_value(1) := p_source_58;
30396 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
30397 l_rec_acct_attrs.array_char_value(2) := p_source_30;
30398 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
30399 l_rec_acct_attrs.array_char_value(3) := p_source_59;
30400 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
30401 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
30402 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
30403 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
30404 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
30405 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
30406 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
30407 l_rec_acct_attrs.array_char_value(7) := p_source_18;
30408 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
30409 l_rec_acct_attrs.array_num_value(8) := p_source_19;
30410 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
30411 l_rec_acct_attrs.array_char_value(9) := p_source_20;
30412 l_rec_acct_attrs.array_acct_attr_code(10) := 'LEDGER_AMOUNT';
30413 l_rec_acct_attrs.array_num_value(10) := p_source_24;
30414 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
30415 l_rec_acct_attrs.array_char_value(11) := p_source_66;
30416
30417 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
30418 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
30419
30420 ---------------------------------------------------------------------------------------------------------------
30421 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
30422 ---------------------------------------------------------------------------------------------------------------
30423 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
30424
30425 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30426 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30427
30428 IF xla_accounting_cache_pkg.GetValueChar
30429 (p_source_code => 'LEDGER_CATEGORY_CODE'
30430 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
30431 AND l_bflow_method_code = 'PRIOR_ENTRY'
30432 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
30433 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
30434 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
30435 )
30436 THEN
30437 xla_ae_lines_pkg.BflowUpgEntry
30438 (p_business_method_code => l_bflow_method_code
30439 ,p_business_class_code => l_bflow_class_code
30440 ,p_balance_type => l_balance_type_code);
30441 ELSE
30442 NULL;
30443 XLA_AE_LINES_PKG.business_flow_validation(
30444 p_business_method_code => l_bflow_method_code
30445 ,p_business_class_code => l_bflow_class_code
30446 ,p_inherit_description_flag => l_inherit_desc_flag);
30447 END IF;
30448
30449 --
30450 -- call analytical criteria
30451 --
30452 -- Inherited Analytical Criteria for business flow method of Prior Entry.
30453 --
30454 -- call description
30455 --
30456
30457 xla_ae_lines_pkg.SetLineDescription(
30458 p_ae_header_id => l_ae_header_id
30459 ,p_description => Description_1 (
30460 p_application_id => p_application_id
30461 , p_ae_header_id => l_ae_header_id
30462 )
30463 );
30464
30465
30466 --
30467 -- call ADRs
30468 -- Bug 4922099
30469 --
30470 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30471 (NVL(l_actual_upg_option, 'N') = 'O') OR
30472 (NVL(l_enc_upg_option, 'N') = 'O')
30473 )
30474 THEN
30475 NULL;
30476 --
30477 --
30478
30479 --
30480 --
30481 END IF;
30482 --
30483 -- Bug 4922099
30484 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
30485 (NVL(l_enc_upg_option, 'N') = 'O')
30486 ) AND
30487 (l_bflow_method_code = 'PRIOR_ENTRY')
30488 )
30489 THEN
30490 IF
30491 --
30492 1 = 1
30493 --
30494 THEN
30495 xla_accounting_err_pkg.build_message
30496 (p_appli_s_name => 'XLA'
30497 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30498 ,p_token_1 => 'LINE_NUMBER'
30499 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
30500 ,p_token_2 => 'LINE_TYPE_NAME'
30501 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
30502 l_component_type
30503 ,l_component_code
30504 ,l_component_type_code
30505 ,l_component_appl_id
30506 ,l_amb_context_code
30507 ,l_entity_code
30508 ,l_event_class_code
30509 )
30510 ,p_token_3 => 'OWNER'
30511 ,p_value_3 => xla_lookups_pkg.get_meaning(
30512 p_lookup_type => 'XLA_OWNER_TYPE'
30513 ,p_lookup_code => l_component_type_code
30514 )
30515 ,p_token_4 => 'PRODUCT_NAME'
30516 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
30517 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
30518 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
30519 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
30520 ,p_ae_header_id => NULL
30521 );
30522
30523 IF (C_LEVEL_ERROR>= g_log_level) THEN
30524 trace
30525 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30526 ,p_level => C_LEVEL_ERROR
30527 ,p_module => l_log_module);
30528 END IF;
30529 END IF;
30530 END IF;
30531 --
30532 --
30533 ------------------------------------------------------------------------------------------------
30534 -- 4219869 Business Flow
30535 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
30536 -- Prior Entry. Currently, the following code is always generated.
30537 ------------------------------------------------------------------------------------------------
30538 -- No ValidateCurrentLine for business flow method of Prior Entry
30539
30540 ------------------------------------------------------------------------------------
30541 -- 4219869 Business Flow
30542 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
30543 ------------------------------------------------------------------------------------
30544 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
30545
30546 ----------------------------------------------------------------------------------
30547 -- 4219869 Business Flow
30548 -- Update journal entry status -- Need to generate this within IF <condition>
30549 ----------------------------------------------------------------------------------
30550 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
30551 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
30552 ,p_balance_type_code => l_balance_type_code
30553 );
30554
30555 -------------------------------------------------------------------------------------------
30556 -- 4262811 - Generate the Accrual Reversal lines
30557 -------------------------------------------------------------------------------------------
30558 BEGIN
30559 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
30560 (g_array_event(p_event_id).array_value_num('header_index'));
30561 IF l_acc_rev_flag IS NULL THEN
30562 l_acc_rev_flag := 'N';
30563 END IF;
30564 EXCEPTION
30565 WHEN OTHERS THEN
30566 l_acc_rev_flag := 'N';
30567 END;
30568 --
30569 IF (l_acc_rev_flag = 'Y') THEN
30570
30571 -- 4645092 ------------------------------------------------------------------------------
30572 -- To allow MPA report to determine if it should generate report process
30573 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
30574 ------------------------------------------------------------------------------------------
30575
30576 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
30577 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
30578 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
30579 -- call ADRs
30580 -- Bug 4922099
30581 --
30582 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30583 (NVL(l_actual_upg_option, 'N') = 'O') OR
30584 (NVL(l_enc_upg_option, 'N') = 'O')
30585 )
30586 THEN
30587 NULL;
30588 --
30589 --
30590
30591 --
30592 --
30593 END IF;
30594
30595 --
30596 -- Update the line information that should be overwritten
30597 --
30598 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
30599 p_header_num => 1);
30600 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
30601
30602 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
30603
30604 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
30605 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
30606 END IF;
30607
30608 --
30609 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
30610 --
30611 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
30612 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
30613 ELSE
30614 ---------------------------------------------------------------------------------------------------
30615 -- 4262811a Switch Sign
30616 ---------------------------------------------------------------------------------------------------
30617 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
30618 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30619 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30620 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30621 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30622 -- 5132302
30623 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
30624 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30625
30626 END IF;
30627
30628 -- 4955764
30629 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30630 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
30631
30632
30633 XLA_AE_LINES_PKG.ValidateCurrentLine;
30634 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
30635
30636 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
30637 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
30638 ,p_balance_type_code => l_balance_type_code);
30639
30640 END IF;
30641
30642 -----------------------------------------------------------------------------------------
30643 -- 4262811 Multiperiod Accounting
30644 -----------------------------------------------------------------------------------------
30645 -- No MPA option is assigned.
30646
30647
30648 END IF;
30649 END IF;
30650 --
30651
30652 --
30653 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30654 trace
30655 (p_msg => 'END of AcctLineType_66'
30656 ,p_level => C_LEVEL_PROCEDURE
30657 ,p_module => l_log_module);
30658 END IF;
30659 --
30660 EXCEPTION
30661 WHEN xla_exceptions_pkg.application_exception THEN
30662 RAISE;
30663 WHEN OTHERS THEN
30664 xla_exceptions_pkg.raise_message
30665 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_66');
30666 END AcctLineType_66;
30667 --
30668
30669 ---------------------------------------
30670 --
30671 -- PRIVATE FUNCTION
30672 -- AcctLineType_67
30673 --
30674 ---------------------------------------
30675 PROCEDURE AcctLineType_67 (
30676 p_application_id IN NUMBER
30677 ,p_event_id IN NUMBER
30678 ,p_calculate_acctd_flag IN VARCHAR2
30679 ,p_calculate_g_l_flag IN VARCHAR2
30680 ,p_actual_flag IN OUT VARCHAR2
30681 ,p_balance_type_code OUT VARCHAR2
30682 ,p_gain_or_loss_ref OUT VARCHAR2
30683
30684 --Remittance Bank Account Remittance Account
30685 , p_source_6 IN NUMBER
30686 --Distribution Source Type
30687 , p_source_15 IN VARCHAR2
30688 --Distribution Line Identifier
30689 , p_source_17 IN NUMBER
30690 --Distribution Type
30691 , p_source_18 IN VARCHAR2
30692 --Exchange Date
30693 , p_source_21 IN DATE
30694 --Exchange Rate
30695 , p_source_22 IN NUMBER
30696 --Exchange Rate Type
30697 , p_source_23 IN VARCHAR2
30698 --Transaction Distribution Identifier
30699 , p_source_29 IN NUMBER
30700 --Transaction Distribution Type
30701 , p_source_30 IN VARCHAR2
30702 --Distribution Multi Fund Additional Entry
30703 , p_source_54 IN VARCHAR2
30704 --Receipt Applied To Application Identifier
30705 , p_source_58 IN NUMBER
30706 --Transaction Entity Code
30707 , p_source_59 IN VARCHAR2
30708 --Transaction Identifier
30709 , p_source_60 IN NUMBER
30710 --DIST_ENT_AMT_FROM
30711 , p_source_61 IN NUMBER
30712 --Applying Document Currency Code
30713 , p_source_62 IN VARCHAR2
30714 --Accounting Amount
30715 , p_source_63 IN NUMBER
30716 --Distribution Party Identifier
30717 , p_source_64 IN NUMBER
30718 --Distribution Party Site Id
30719 , p_source_65 IN NUMBER
30720 --Distribution Party Type
30721 , p_source_66 IN VARCHAR2
30722 )
30723 IS
30724
30725 l_component_type VARCHAR2(80);
30726 l_component_code VARCHAR2(30);
30727 l_component_type_code VARCHAR2(1);
30728 l_component_appl_id INTEGER;
30729 l_amb_context_code VARCHAR2(30);
30730 l_entity_code VARCHAR2(30);
30731 l_event_class_code VARCHAR2(30);
30732 l_ae_header_id NUMBER;
30733 l_event_type_code VARCHAR2(30);
30734 l_line_definition_code VARCHAR2(30);
30735 l_line_definition_owner_code VARCHAR2(1);
30736 --
30737 -- adr variables
30738 l_segment VARCHAR2(30);
30739 l_ccid NUMBER;
30740 l_adr_transaction_coa_id NUMBER;
30741 l_adr_accounting_coa_id NUMBER;
30742 l_adr_flexfield_segment_code VARCHAR2(30);
30743 l_adr_flex_value_set_id NUMBER;
30744 l_adr_value_type_code VARCHAR2(30);
30745 l_adr_value_combination_id NUMBER;
30746 l_adr_value_segment_code VARCHAR2(30);
30747
30748 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
30749 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
30750 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
30751 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
30752
30753 -- 4262811 Variables ------------------------------------------------------------------------------------------
30754 l_entered_amt_idx NUMBER;
30755 l_accted_amt_idx NUMBER;
30756 l_acc_rev_flag VARCHAR2(1);
30757 l_accrual_line_num NUMBER;
30758 l_tmp_amt NUMBER;
30759 l_acc_rev_natural_side_code VARCHAR2(1);
30760
30761 l_num_entries NUMBER;
30762 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
30763 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
30764 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
30765 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
30766 l_recog_line_1 NUMBER;
30767 l_recog_line_2 NUMBER;
30768
30769 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
30770 l_bflow_applied_to_amt NUMBER; -- 5132302
30771 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
30772
30773 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
30774
30775 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
30776 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
30777
30778 ---------------------------------------------------------------------------------------------------------------
30779
30780
30781 --
30782 -- bulk performance
30783 --
30784 l_balance_type_code VARCHAR2(1);
30785 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
30786 l_log_module VARCHAR2(240);
30787
30788 --
30789 -- Upgrade strategy
30790 --
30791 l_actual_upg_option VARCHAR2(1);
30792 l_enc_upg_option VARCHAR2(1);
30793
30794 --
30795 BEGIN
30796 --
30797 IF g_log_enabled THEN
30798 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_67';
30799 END IF;
30800 --
30801 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30802
30803 trace
30804 (p_msg => 'BEGIN of AcctLineType_67'
30805 ,p_level => C_LEVEL_PROCEDURE
30806 ,p_module => l_log_module);
30807
30808 END IF;
30809 --
30810 l_component_type := 'AMB_JLT';
30811 l_component_code := 'MFAR_RCT_REMIT_REVERSAL';
30812 l_component_type_code := 'S';
30813 l_component_appl_id := 222;
30814 l_amb_context_code := 'DEFAULT';
30815 l_entity_code := 'RECEIPTS';
30816 l_event_class_code := 'RECEIPT';
30817 l_event_type_code := 'RECEIPT_ALL';
30818 l_line_definition_owner_code := 'S';
30819 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
30820 --
30821 l_balance_type_code := 'A';
30822 l_segment := NULL;
30823 l_ccid := NULL;
30824 l_adr_transaction_coa_id := NULL;
30825 l_adr_accounting_coa_id := NULL;
30826 l_adr_flexfield_segment_code := NULL;
30827 l_adr_flex_value_set_id := NULL;
30828 l_adr_value_type_code := NULL;
30829 l_adr_value_combination_id := NULL;
30830 l_adr_value_segment_code := NULL;
30831
30832 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
30833 l_bflow_class_code := ''; -- 4219869 Business Flow
30834 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
30835 l_budgetary_control_flag := 'N';
30836
30837 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30838 l_bflow_applied_to_amt := NULL; -- 5132302
30839 l_entered_amt_idx := NULL; -- 4262811
30840 l_accted_amt_idx := NULL; -- 4262811
30841 l_acc_rev_flag := NULL; -- 4262811
30842 l_accrual_line_num := NULL; -- 4262811
30843 l_tmp_amt := NULL; -- 4262811
30844 --
30845
30846 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
30847 l_balance_type_code <> 'B' THEN
30848 IF NVL(p_source_15,'
30849 ') = 'REMITTANCE' AND
30850 NVL(p_source_54,'
30851 ') = 'Y'
30852 THEN
30853
30854 --
30855 XLA_AE_LINES_PKG.SetNewLine;
30856
30857 p_balance_type_code := l_balance_type_code;
30858 -- set the flag so later we will know whether the gain loss line needs to be created
30859
30860 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
30861 p_actual_flag :='A';
30862 END IF;
30863
30864 --
30865 -- bulk performance
30866 --
30867 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
30868 p_header_num => 0); -- 4262811
30869 --
30870 -- set accounting line options
30871 --
30872 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
30873 p_natural_side_code => 'D'
30874 , p_gain_or_loss_flag => 'N'
30875 , p_gl_transfer_mode_code => 'S'
30876 , p_acct_entry_type_code => 'A'
30877 , p_switch_side_flag => 'Y'
30878 , p_merge_duplicate_code => 'A'
30879 );
30880 --
30881 l_acc_rev_natural_side_code := 'C'; -- 4262811
30882 --
30883 --
30884 -- set accounting line type info
30885 --
30886 xla_ae_lines_pkg.SetAcctLineType
30887 (p_component_type => l_component_type
30888 ,p_event_type_code => l_event_type_code
30889 ,p_line_definition_owner_code => l_line_definition_owner_code
30890 ,p_line_definition_code => l_line_definition_code
30891 ,p_accounting_line_code => l_component_code
30892 ,p_accounting_line_type_code => l_component_type_code
30893 ,p_accounting_line_appl_id => l_component_appl_id
30894 ,p_amb_context_code => l_amb_context_code
30895 ,p_entity_code => l_entity_code
30896 ,p_event_class_code => l_event_class_code);
30897 --
30898 -- set accounting class
30899 --
30900 xla_ae_lines_pkg.SetAcctClass(
30901 p_accounting_class_code => 'REMITTANCE'
30902 , p_ae_header_id => l_ae_header_id
30903 );
30904
30905 --
30906 -- set rounding class
30907 --
30908 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
30909 'RECEIVABLE';
30910
30911 --
30912 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
30913 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
30914 --
30915 -- bulk performance
30916 --
30917 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
30918
30919 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
30920 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
30921
30922 -- 4955764
30923 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30924 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
30925
30926 -- 4458381 Public Sector Enh
30927
30928 --
30929 -- set accounting attributes for the line type
30930 --
30931 l_entered_amt_idx := 8;
30932 l_accted_amt_idx := 13;
30933 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30934 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
30935 l_rec_acct_attrs.array_num_value(1) := p_source_58;
30936 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
30937 l_rec_acct_attrs.array_char_value(2) := p_source_30;
30938 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
30939 l_rec_acct_attrs.array_char_value(3) := p_source_59;
30940 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
30941 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
30942 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
30943 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
30944 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
30945 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
30946 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
30947 l_rec_acct_attrs.array_char_value(7) := p_source_18;
30948 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
30949 l_rec_acct_attrs.array_num_value(8) := p_source_61;
30950 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
30951 l_rec_acct_attrs.array_char_value(9) := p_source_62;
30952 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
30953 l_rec_acct_attrs.array_date_value(10) := p_source_21;
30954 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
30955 l_rec_acct_attrs.array_num_value(11) := p_source_22;
30956 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
30957 l_rec_acct_attrs.array_char_value(12) := p_source_23;
30958 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
30959 l_rec_acct_attrs.array_num_value(13) := p_source_63;
30960 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
30961 l_rec_acct_attrs.array_num_value(14) := p_source_64;
30962 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
30963 l_rec_acct_attrs.array_num_value(15) := p_source_65;
30964 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
30965 l_rec_acct_attrs.array_char_value(16) := p_source_66;
30966
30967 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
30968 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
30969
30970 ---------------------------------------------------------------------------------------------------------------
30971 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
30972 ---------------------------------------------------------------------------------------------------------------
30973 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
30974
30975 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30976 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30977
30978 IF xla_accounting_cache_pkg.GetValueChar
30979 (p_source_code => 'LEDGER_CATEGORY_CODE'
30980 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
30981 AND l_bflow_method_code = 'PRIOR_ENTRY'
30982 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
30983 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
30984 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
30985 )
30986 THEN
30987 xla_ae_lines_pkg.BflowUpgEntry
30988 (p_business_method_code => l_bflow_method_code
30989 ,p_business_class_code => l_bflow_class_code
30990 ,p_balance_type => l_balance_type_code);
30991 ELSE
30992 NULL;
30993 -- No business flow processing for business flow method of NONE.
30994 END IF;
30995
30996 --
30997 -- call analytical criteria
30998 --
30999
31000 --
31001 -- call description
31002 --
31003
31004 xla_ae_lines_pkg.SetLineDescription(
31005 p_ae_header_id => l_ae_header_id
31006 ,p_description => Description_1 (
31007 p_application_id => p_application_id
31008 , p_ae_header_id => l_ae_header_id
31009 )
31010 );
31011
31012
31013 --
31014 -- call ADRs
31015 -- Bug 4922099
31016 --
31017 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31018 (NVL(l_actual_upg_option, 'N') = 'O') OR
31019 (NVL(l_enc_upg_option, 'N') = 'O')
31020 )
31021 THEN
31022 NULL;
31023 --
31024 --
31025
31026 l_ccid := AcctDerRule_14(
31027 p_application_id => p_application_id
31028 , p_ae_header_id => l_ae_header_id
31029 , p_source_6 => p_source_6
31030 , x_transaction_coa_id => l_adr_transaction_coa_id
31031 , x_accounting_coa_id => l_adr_accounting_coa_id
31032 , x_value_type_code => l_adr_value_type_code
31033 , p_side => 'NA'
31034 );
31035
31036 xla_ae_lines_pkg.set_ccid(
31037 p_code_combination_id => l_ccid
31038 , p_value_type_code => l_adr_value_type_code
31039 , p_transaction_coa_id => l_adr_transaction_coa_id
31040 , p_accounting_coa_id => l_adr_accounting_coa_id
31041 , p_adr_code => 'MFAR_RCT_DEF_REMITTANCE_CCID'
31042 , p_adr_type_code => 'S'
31043 , p_component_type => l_component_type
31044 , p_component_code => l_component_code
31045 , p_component_type_code => l_component_type_code
31046 , p_component_appl_id => l_component_appl_id
31047 , p_amb_context_code => l_amb_context_code
31048 , p_side => 'NA'
31049 );
31050
31051
31052 --
31053 --
31054 END IF;
31055 --
31056 -- Bug 4922099
31057 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
31058 (NVL(l_enc_upg_option, 'N') = 'O')
31059 ) AND
31060 (l_bflow_method_code = 'PRIOR_ENTRY')
31061 )
31062 THEN
31063 IF
31064 --
31065 1 = 2
31066 --
31067 THEN
31068 xla_accounting_err_pkg.build_message
31069 (p_appli_s_name => 'XLA'
31070 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31071 ,p_token_1 => 'LINE_NUMBER'
31072 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
31073 ,p_token_2 => 'LINE_TYPE_NAME'
31074 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
31075 l_component_type
31076 ,l_component_code
31077 ,l_component_type_code
31078 ,l_component_appl_id
31079 ,l_amb_context_code
31080 ,l_entity_code
31081 ,l_event_class_code
31082 )
31083 ,p_token_3 => 'OWNER'
31084 ,p_value_3 => xla_lookups_pkg.get_meaning(
31085 p_lookup_type => 'XLA_OWNER_TYPE'
31086 ,p_lookup_code => l_component_type_code
31087 )
31088 ,p_token_4 => 'PRODUCT_NAME'
31089 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
31090 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
31091 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
31092 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
31093 ,p_ae_header_id => NULL
31094 );
31095
31096 IF (C_LEVEL_ERROR>= g_log_level) THEN
31097 trace
31098 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31099 ,p_level => C_LEVEL_ERROR
31100 ,p_module => l_log_module);
31101 END IF;
31102 END IF;
31103 END IF;
31104 --
31105 --
31106 ------------------------------------------------------------------------------------------------
31107 -- 4219869 Business Flow
31108 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
31109 -- Prior Entry. Currently, the following code is always generated.
31110 ------------------------------------------------------------------------------------------------
31111 XLA_AE_LINES_PKG.ValidateCurrentLine;
31112
31113 ------------------------------------------------------------------------------------
31114 -- 4219869 Business Flow
31115 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
31116 ------------------------------------------------------------------------------------
31117 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31118
31119 ----------------------------------------------------------------------------------
31120 -- 4219869 Business Flow
31121 -- Update journal entry status -- Need to generate this within IF <condition>
31122 ----------------------------------------------------------------------------------
31123 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31124 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
31125 ,p_balance_type_code => l_balance_type_code
31126 );
31127
31128 -------------------------------------------------------------------------------------------
31129 -- 4262811 - Generate the Accrual Reversal lines
31130 -------------------------------------------------------------------------------------------
31131 BEGIN
31132 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
31136 END IF;
31133 (g_array_event(p_event_id).array_value_num('header_index'));
31134 IF l_acc_rev_flag IS NULL THEN
31135 l_acc_rev_flag := 'N';
31137 EXCEPTION
31138 WHEN OTHERS THEN
31139 l_acc_rev_flag := 'N';
31140 END;
31141 --
31142 IF (l_acc_rev_flag = 'Y') THEN
31143
31144 -- 4645092 ------------------------------------------------------------------------------
31145 -- To allow MPA report to determine if it should generate report process
31146 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
31147 ------------------------------------------------------------------------------------------
31148
31149 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
31150 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
31151 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
31152 -- call ADRs
31153 -- Bug 4922099
31154 --
31155 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31156 (NVL(l_actual_upg_option, 'N') = 'O') OR
31157 (NVL(l_enc_upg_option, 'N') = 'O')
31158 )
31159 THEN
31160 NULL;
31161 --
31162 --
31163
31164 l_ccid := AcctDerRule_14(
31165 p_application_id => p_application_id
31166 , p_ae_header_id => l_ae_header_id
31167 , p_source_6 => p_source_6
31168 , x_transaction_coa_id => l_adr_transaction_coa_id
31169 , x_accounting_coa_id => l_adr_accounting_coa_id
31170 , x_value_type_code => l_adr_value_type_code
31171 , p_side => 'NA'
31172 );
31173
31174 xla_ae_lines_pkg.set_ccid(
31175 p_code_combination_id => l_ccid
31176 , p_value_type_code => l_adr_value_type_code
31177 , p_transaction_coa_id => l_adr_transaction_coa_id
31178 , p_accounting_coa_id => l_adr_accounting_coa_id
31179 , p_adr_code => 'MFAR_RCT_DEF_REMITTANCE_CCID'
31180 , p_adr_type_code => 'S'
31181 , p_component_type => l_component_type
31182 , p_component_code => l_component_code
31183 , p_component_type_code => l_component_type_code
31184 , p_component_appl_id => l_component_appl_id
31185 , p_amb_context_code => l_amb_context_code
31186 , p_side => 'NA'
31187 );
31188
31189
31190 --
31191 --
31192 END IF;
31193
31194 --
31195 -- Update the line information that should be overwritten
31196 --
31197 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
31198 p_header_num => 1);
31199 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
31200
31201 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
31202
31203 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
31204 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
31205 END IF;
31206
31207 --
31208 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
31209 --
31210 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
31211 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
31212 ELSE
31213 ---------------------------------------------------------------------------------------------------
31214 -- 4262811a Switch Sign
31215 ---------------------------------------------------------------------------------------------------
31216 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
31217 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31218 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31219 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31220 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31221 -- 5132302
31222 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
31223 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31224
31225 END IF;
31226
31227 -- 4955764
31228 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31229 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
31230
31231
31232 XLA_AE_LINES_PKG.ValidateCurrentLine;
31233 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31234
31235 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31236 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
31237 ,p_balance_type_code => l_balance_type_code);
31238
31239 END IF;
31240
31241 -----------------------------------------------------------------------------------------
31242 -- 4262811 Multiperiod Accounting
31243 -----------------------------------------------------------------------------------------
31244 -- No MPA option is assigned.
31245
31246
31247 END IF;
31248 END IF;
31249 --
31250
31251 --
31252 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31253 trace
31254 (p_msg => 'END of AcctLineType_67'
31255 ,p_level => C_LEVEL_PROCEDURE
31256 ,p_module => l_log_module);
31257 END IF;
31258 --
31259 EXCEPTION
31260 WHEN xla_exceptions_pkg.application_exception THEN
31261 RAISE;
31262 WHEN OTHERS THEN
31263 xla_exceptions_pkg.raise_message
31264 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_67');
31265 END AcctLineType_67;
31266 --
31267
31268 ---------------------------------------
31269 --
31270 -- PRIVATE FUNCTION
31271 -- AcctLineType_68
31272 --
31273 ---------------------------------------
31274 PROCEDURE AcctLineType_68 (
31275 p_application_id IN NUMBER
31276 ,p_event_id IN NUMBER
31277 ,p_calculate_acctd_flag IN VARCHAR2
31278 ,p_calculate_g_l_flag IN VARCHAR2
31279 ,p_actual_flag IN OUT VARCHAR2
31280 ,p_balance_type_code OUT VARCHAR2
31281 ,p_gain_or_loss_ref OUT VARCHAR2
31282
31283 --Distribution Source Type
31284 , p_source_15 IN VARCHAR2
31285 --Distribution Line Identifier
31286 , p_source_17 IN NUMBER
31287 --Distribution Type
31288 , p_source_18 IN VARCHAR2
31289 --Entered Amount
31290 , p_source_19 IN NUMBER
31291 --Currency Code
31292 , p_source_20 IN VARCHAR2
31293 --Applied To Document Accounting Amount
31294 , p_source_24 IN NUMBER
31295 --Transaction Distribution Identifier
31296 , p_source_29 IN NUMBER
31297 --Transaction Distribution Type
31298 , p_source_30 IN VARCHAR2
31299 --Distribution Multi Fund Additional Entry
31300 , p_source_54 IN VARCHAR2
31301 --Receipt Applied To Application Identifier
31302 , p_source_58 IN NUMBER
31303 --Transaction Entity Code
31304 , p_source_59 IN VARCHAR2
31305 --Transaction Identifier
31306 , p_source_60 IN NUMBER
31307 --Distribution Party Type
31308 , p_source_66 IN VARCHAR2
31309 )
31310 IS
31311
31312 l_component_type VARCHAR2(80);
31313 l_component_code VARCHAR2(30);
31314 l_component_type_code VARCHAR2(1);
31315 l_component_appl_id INTEGER;
31316 l_amb_context_code VARCHAR2(30);
31317 l_entity_code VARCHAR2(30);
31318 l_event_class_code VARCHAR2(30);
31319 l_ae_header_id NUMBER;
31320 l_event_type_code VARCHAR2(30);
31324 -- adr variables
31321 l_line_definition_code VARCHAR2(30);
31322 l_line_definition_owner_code VARCHAR2(1);
31323 --
31325 l_segment VARCHAR2(30);
31326 l_ccid NUMBER;
31327 l_adr_transaction_coa_id NUMBER;
31328 l_adr_accounting_coa_id NUMBER;
31329 l_adr_flexfield_segment_code VARCHAR2(30);
31330 l_adr_flex_value_set_id NUMBER;
31331 l_adr_value_type_code VARCHAR2(30);
31332 l_adr_value_combination_id NUMBER;
31333 l_adr_value_segment_code VARCHAR2(30);
31334
31335 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
31336 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
31337 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
31338 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
31339
31340 -- 4262811 Variables ------------------------------------------------------------------------------------------
31341 l_entered_amt_idx NUMBER;
31342 l_accted_amt_idx NUMBER;
31343 l_acc_rev_flag VARCHAR2(1);
31344 l_accrual_line_num NUMBER;
31345 l_tmp_amt NUMBER;
31346 l_acc_rev_natural_side_code VARCHAR2(1);
31347
31348 l_num_entries NUMBER;
31349 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
31350 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
31351 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
31352 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
31353 l_recog_line_1 NUMBER;
31354 l_recog_line_2 NUMBER;
31355
31356 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
31357 l_bflow_applied_to_amt NUMBER; -- 5132302
31358 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
31359
31360 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
31361
31362 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
31363 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
31364
31365 ---------------------------------------------------------------------------------------------------------------
31366
31367
31368 --
31369 -- bulk performance
31370 --
31371 l_balance_type_code VARCHAR2(1);
31372 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
31373 l_log_module VARCHAR2(240);
31374
31375 --
31376 -- Upgrade strategy
31377 --
31378 l_actual_upg_option VARCHAR2(1);
31379 l_enc_upg_option VARCHAR2(1);
31380
31381 --
31382 BEGIN
31383 --
31384 IF g_log_enabled THEN
31385 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_68';
31386 END IF;
31387 --
31388 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31389
31390 trace
31391 (p_msg => 'BEGIN of AcctLineType_68'
31392 ,p_level => C_LEVEL_PROCEDURE
31393 ,p_module => l_log_module);
31394
31395 END IF;
31396 --
31397 l_component_type := 'AMB_JLT';
31398 l_component_code := 'MFAR_RCT_UNDISC_REC';
31399 l_component_type_code := 'S';
31400 l_component_appl_id := 222;
31401 l_amb_context_code := 'DEFAULT';
31402 l_entity_code := 'RECEIPTS';
31403 l_event_class_code := 'RECEIPT';
31404 l_event_type_code := 'RECEIPT_ALL';
31405 l_line_definition_owner_code := 'S';
31406 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
31407 --
31408 l_balance_type_code := 'A';
31409 l_segment := NULL;
31410 l_ccid := NULL;
31411 l_adr_transaction_coa_id := NULL;
31412 l_adr_accounting_coa_id := NULL;
31413 l_adr_flexfield_segment_code := NULL;
31414 l_adr_flex_value_set_id := NULL;
31415 l_adr_value_type_code := NULL;
31416 l_adr_value_combination_id := NULL;
31417 l_adr_value_segment_code := NULL;
31418
31419 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
31420 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
31421 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
31422 l_budgetary_control_flag := 'N';
31423
31424 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31425 l_bflow_applied_to_amt := NULL; -- 5132302
31426 l_entered_amt_idx := NULL; -- 4262811
31427 l_accted_amt_idx := NULL; -- 4262811
31428 l_acc_rev_flag := NULL; -- 4262811
31429 l_accrual_line_num := NULL; -- 4262811
31430 l_tmp_amt := NULL; -- 4262811
31431 --
31432
31433 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
31434 l_balance_type_code <> 'B' THEN
31435 IF NVL(p_source_15,'
31436 ') = 'UNEDISC' AND
31437 NVL(p_source_54,'
31438 ') = 'N'
31439 THEN
31440
31441 --
31442 XLA_AE_LINES_PKG.SetNewLine;
31443
31444 p_balance_type_code := l_balance_type_code;
31445 -- set the flag so later we will know whether the gain loss line needs to be created
31446
31447 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
31448 p_actual_flag :='A';
31449 END IF;
31450
31451 --
31452 -- bulk performance
31453 --
31454 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
31458 --
31455 p_header_num => 0); -- 4262811
31456 --
31457 -- set accounting line options
31459 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
31460 p_natural_side_code => 'D'
31461 , p_gain_or_loss_flag => 'N'
31462 , p_gl_transfer_mode_code => 'S'
31463 , p_acct_entry_type_code => 'A'
31464 , p_switch_side_flag => 'Y'
31465 , p_merge_duplicate_code => 'A'
31466 );
31467 --
31468 l_acc_rev_natural_side_code := 'C'; -- 4262811
31469 --
31470 --
31471 -- set accounting line type info
31472 --
31473 xla_ae_lines_pkg.SetAcctLineType
31474 (p_component_type => l_component_type
31475 ,p_event_type_code => l_event_type_code
31476 ,p_line_definition_owner_code => l_line_definition_owner_code
31477 ,p_line_definition_code => l_line_definition_code
31478 ,p_accounting_line_code => l_component_code
31479 ,p_accounting_line_type_code => l_component_type_code
31480 ,p_accounting_line_appl_id => l_component_appl_id
31481 ,p_amb_context_code => l_amb_context_code
31482 ,p_entity_code => l_entity_code
31483 ,p_event_class_code => l_event_class_code);
31484 --
31485 -- set accounting class
31486 --
31487 xla_ae_lines_pkg.SetAcctClass(
31488 p_accounting_class_code => 'RECEIVABLE'
31489 , p_ae_header_id => l_ae_header_id
31490 );
31491
31492 --
31493 -- set rounding class
31494 --
31495 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
31496 'RECEIVABLE';
31497
31498 --
31499 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
31500 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
31501 --
31502 -- bulk performance
31503 --
31504 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
31505
31506 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
31507 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
31508
31509 -- 4955764
31510 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31511 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
31512
31513 -- 4458381 Public Sector Enh
31514
31515 --
31516 -- set accounting attributes for the line type
31517 --
31518 l_entered_amt_idx := 8;
31519 l_accted_amt_idx := 10;
31520 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31521 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
31522 l_rec_acct_attrs.array_num_value(1) := p_source_58;
31523 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
31524 l_rec_acct_attrs.array_char_value(2) := p_source_30;
31525 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
31526 l_rec_acct_attrs.array_char_value(3) := p_source_59;
31527 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
31528 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
31529 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
31530 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
31531 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
31532 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
31533 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
31534 l_rec_acct_attrs.array_char_value(7) := p_source_18;
31535 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
31536 l_rec_acct_attrs.array_num_value(8) := p_source_19;
31537 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
31538 l_rec_acct_attrs.array_char_value(9) := p_source_20;
31539 l_rec_acct_attrs.array_acct_attr_code(10) := 'LEDGER_AMOUNT';
31540 l_rec_acct_attrs.array_num_value(10) := p_source_24;
31541 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
31542 l_rec_acct_attrs.array_char_value(11) := p_source_66;
31543
31544 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
31545 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
31546
31547 ---------------------------------------------------------------------------------------------------------------
31548 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
31549 ---------------------------------------------------------------------------------------------------------------
31550 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
31551
31552 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
31553 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
31554
31555 IF xla_accounting_cache_pkg.GetValueChar
31556 (p_source_code => 'LEDGER_CATEGORY_CODE'
31557 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
31558 AND l_bflow_method_code = 'PRIOR_ENTRY'
31559 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
31560 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
31561 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
31562 )
31563 THEN
31564 xla_ae_lines_pkg.BflowUpgEntry
31565 (p_business_method_code => l_bflow_method_code
31566 ,p_business_class_code => l_bflow_class_code
31567 ,p_balance_type => l_balance_type_code);
31568 ELSE
31569 NULL;
31570 XLA_AE_LINES_PKG.business_flow_validation(
31571 p_business_method_code => l_bflow_method_code
31572 ,p_business_class_code => l_bflow_class_code
31573 ,p_inherit_description_flag => l_inherit_desc_flag);
31574 END IF;
31575
31576 --
31577 -- call analytical criteria
31578 --
31579 -- Inherited Analytical Criteria for business flow method of Prior Entry.
31580 --
31581 -- call description
31582 --
31583
31584 xla_ae_lines_pkg.SetLineDescription(
31585 p_ae_header_id => l_ae_header_id
31586 ,p_description => Description_1 (
31587 p_application_id => p_application_id
31588 , p_ae_header_id => l_ae_header_id
31589 )
31590 );
31591
31592
31593 --
31594 -- call ADRs
31595 -- Bug 4922099
31596 --
31597 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31598 (NVL(l_actual_upg_option, 'N') = 'O') OR
31599 (NVL(l_enc_upg_option, 'N') = 'O')
31600 )
31601 THEN
31602 NULL;
31603 --
31604 --
31605
31606 --
31607 --
31608 END IF;
31609 --
31610 -- Bug 4922099
31611 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
31612 (NVL(l_enc_upg_option, 'N') = 'O')
31613 ) AND
31614 (l_bflow_method_code = 'PRIOR_ENTRY')
31615 )
31616 THEN
31617 IF
31618 --
31619 1 = 1
31620 --
31621 THEN
31622 xla_accounting_err_pkg.build_message
31623 (p_appli_s_name => 'XLA'
31624 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31625 ,p_token_1 => 'LINE_NUMBER'
31626 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
31627 ,p_token_2 => 'LINE_TYPE_NAME'
31628 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
31629 l_component_type
31630 ,l_component_code
31631 ,l_component_type_code
31632 ,l_component_appl_id
31633 ,l_amb_context_code
31634 ,l_entity_code
31635 ,l_event_class_code
31636 )
31637 ,p_token_3 => 'OWNER'
31638 ,p_value_3 => xla_lookups_pkg.get_meaning(
31639 p_lookup_type => 'XLA_OWNER_TYPE'
31640 ,p_lookup_code => l_component_type_code
31641 )
31642 ,p_token_4 => 'PRODUCT_NAME'
31643 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
31644 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
31645 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
31646 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
31647 ,p_ae_header_id => NULL
31648 );
31649
31650 IF (C_LEVEL_ERROR>= g_log_level) THEN
31651 trace
31652 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31653 ,p_level => C_LEVEL_ERROR
31654 ,p_module => l_log_module);
31655 END IF;
31656 END IF;
31657 END IF;
31658 --
31659 --
31660 ------------------------------------------------------------------------------------------------
31661 -- 4219869 Business Flow
31665 -- No ValidateCurrentLine for business flow method of Prior Entry
31662 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
31663 -- Prior Entry. Currently, the following code is always generated.
31664 ------------------------------------------------------------------------------------------------
31666
31667 ------------------------------------------------------------------------------------
31668 -- 4219869 Business Flow
31669 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
31670 ------------------------------------------------------------------------------------
31671 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31672
31673 ----------------------------------------------------------------------------------
31674 -- 4219869 Business Flow
31675 -- Update journal entry status -- Need to generate this within IF <condition>
31676 ----------------------------------------------------------------------------------
31677 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31678 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
31679 ,p_balance_type_code => l_balance_type_code
31680 );
31681
31682 -------------------------------------------------------------------------------------------
31683 -- 4262811 - Generate the Accrual Reversal lines
31684 -------------------------------------------------------------------------------------------
31685 BEGIN
31686 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
31687 (g_array_event(p_event_id).array_value_num('header_index'));
31688 IF l_acc_rev_flag IS NULL THEN
31689 l_acc_rev_flag := 'N';
31690 END IF;
31691 EXCEPTION
31692 WHEN OTHERS THEN
31693 l_acc_rev_flag := 'N';
31694 END;
31695 --
31696 IF (l_acc_rev_flag = 'Y') THEN
31697
31698 -- 4645092 ------------------------------------------------------------------------------
31699 -- To allow MPA report to determine if it should generate report process
31700 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
31701 ------------------------------------------------------------------------------------------
31702
31703 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
31704 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
31705 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
31706 -- call ADRs
31707 -- Bug 4922099
31708 --
31709 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31710 (NVL(l_actual_upg_option, 'N') = 'O') OR
31711 (NVL(l_enc_upg_option, 'N') = 'O')
31712 )
31713 THEN
31714 NULL;
31715 --
31716 --
31717
31718 --
31719 --
31720 END IF;
31721
31722 --
31723 -- Update the line information that should be overwritten
31724 --
31725 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
31726 p_header_num => 1);
31727 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
31728
31729 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
31730
31731 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
31732 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
31733 END IF;
31734
31735 --
31736 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
31737 --
31738 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
31739 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
31740 ELSE
31741 ---------------------------------------------------------------------------------------------------
31742 -- 4262811a Switch Sign
31743 ---------------------------------------------------------------------------------------------------
31744 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
31745 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31746 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31747 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31748 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31749 -- 5132302
31750 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
31751 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31752
31753 END IF;
31754
31755 -- 4955764
31756 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31757 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
31758
31759
31760 XLA_AE_LINES_PKG.ValidateCurrentLine;
31761 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31762
31763 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31764 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
31765 ,p_balance_type_code => l_balance_type_code);
31766
31767 END IF;
31768
31769 -----------------------------------------------------------------------------------------
31770 -- 4262811 Multiperiod Accounting
31771 -----------------------------------------------------------------------------------------
31775 END IF;
31772 -- No MPA option is assigned.
31773
31774
31776 END IF;
31777 --
31778
31779 --
31780 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31781 trace
31782 (p_msg => 'END of AcctLineType_68'
31783 ,p_level => C_LEVEL_PROCEDURE
31784 ,p_module => l_log_module);
31785 END IF;
31786 --
31787 EXCEPTION
31788 WHEN xla_exceptions_pkg.application_exception THEN
31789 RAISE;
31790 WHEN OTHERS THEN
31791 xla_exceptions_pkg.raise_message
31792 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_68');
31793 END AcctLineType_68;
31794 --
31795
31796 ---------------------------------------
31797 --
31798 -- PRIVATE FUNCTION
31799 -- AcctLineType_69
31800 --
31801 ---------------------------------------
31802 PROCEDURE AcctLineType_69 (
31803 p_application_id IN NUMBER
31804 ,p_event_id IN NUMBER
31805 ,p_calculate_acctd_flag IN VARCHAR2
31806 ,p_calculate_g_l_flag IN VARCHAR2
31807 ,p_actual_flag IN OUT VARCHAR2
31808 ,p_balance_type_code OUT VARCHAR2
31809 ,p_gain_or_loss_ref OUT VARCHAR2
31810
31811 --Distribution GL Account
31812 , p_source_10 IN NUMBER
31813 --Distribution Source Type
31814 , p_source_15 IN VARCHAR2
31815 --Distribution Line Identifier
31816 , p_source_17 IN NUMBER
31817 --Distribution Type
31818 , p_source_18 IN VARCHAR2
31819 --Entered Amount
31820 , p_source_19 IN NUMBER
31821 --Currency Code
31822 , p_source_20 IN VARCHAR2
31823 --Exchange Rate
31824 , p_source_22 IN NUMBER
31825 --Exchange Rate Type
31826 , p_source_23 IN VARCHAR2
31827 --Applied To Document Accounting Amount
31828 , p_source_24 IN NUMBER
31829 --Distribution Multi Fund Additional Entry
31830 , p_source_54 IN VARCHAR2
31831 --Applied To Document Exchange Date
31832 , p_source_55 IN DATE
31833 )
31834 IS
31835
31836 l_component_type VARCHAR2(80);
31837 l_component_code VARCHAR2(30);
31838 l_component_type_code VARCHAR2(1);
31839 l_component_appl_id INTEGER;
31840 l_amb_context_code VARCHAR2(30);
31841 l_entity_code VARCHAR2(30);
31842 l_event_class_code VARCHAR2(30);
31843 l_ae_header_id NUMBER;
31844 l_event_type_code VARCHAR2(30);
31845 l_line_definition_code VARCHAR2(30);
31846 l_line_definition_owner_code VARCHAR2(1);
31847 --
31848 -- adr variables
31849 l_segment VARCHAR2(30);
31850 l_ccid NUMBER;
31851 l_adr_transaction_coa_id NUMBER;
31852 l_adr_accounting_coa_id NUMBER;
31853 l_adr_flexfield_segment_code VARCHAR2(30);
31854 l_adr_flex_value_set_id NUMBER;
31855 l_adr_value_type_code VARCHAR2(30);
31856 l_adr_value_combination_id NUMBER;
31857 l_adr_value_segment_code VARCHAR2(30);
31858
31859 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
31860 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
31861 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
31862 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
31863
31864 -- 4262811 Variables ------------------------------------------------------------------------------------------
31865 l_entered_amt_idx NUMBER;
31866 l_accted_amt_idx NUMBER;
31867 l_acc_rev_flag VARCHAR2(1);
31868 l_accrual_line_num NUMBER;
31869 l_tmp_amt NUMBER;
31870 l_acc_rev_natural_side_code VARCHAR2(1);
31871
31872 l_num_entries NUMBER;
31873 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
31874 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
31875 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
31876 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
31877 l_recog_line_1 NUMBER;
31878 l_recog_line_2 NUMBER;
31879
31880 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
31881 l_bflow_applied_to_amt NUMBER; -- 5132302
31882 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
31883
31884 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
31885
31886 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
31887 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
31888
31889 ---------------------------------------------------------------------------------------------------------------
31890
31891
31892 --
31893 -- bulk performance
31894 --
31895 l_balance_type_code VARCHAR2(1);
31896 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
31897 l_log_module VARCHAR2(240);
31898
31899 --
31900 -- Upgrade strategy
31901 --
31902 l_actual_upg_option VARCHAR2(1);
31903 l_enc_upg_option VARCHAR2(1);
31904
31905 --
31906 BEGIN
31907 --
31908 IF g_log_enabled THEN
31909 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_69';
31910 END IF;
31911 --
31912 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31913
31914 trace
31915 (p_msg => 'BEGIN of AcctLineType_69'
31916 ,p_level => C_LEVEL_PROCEDURE
31920 --
31917 ,p_module => l_log_module);
31918
31919 END IF;
31921 l_component_type := 'AMB_JLT';
31922 l_component_code := 'MISC_RCT_BNK_CHG';
31923 l_component_type_code := 'S';
31924 l_component_appl_id := 222;
31925 l_amb_context_code := 'DEFAULT';
31926 l_entity_code := 'RECEIPTS';
31927 l_event_class_code := 'MISC_RECEIPT';
31928 l_event_type_code := 'MISC_RECEIPT_ALL';
31929 l_line_definition_owner_code := 'S';
31930 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
31931 --
31932 l_balance_type_code := 'A';
31933 l_segment := NULL;
31934 l_ccid := NULL;
31935 l_adr_transaction_coa_id := NULL;
31936 l_adr_accounting_coa_id := NULL;
31937 l_adr_flexfield_segment_code := NULL;
31938 l_adr_flex_value_set_id := NULL;
31939 l_adr_value_type_code := NULL;
31940 l_adr_value_combination_id := NULL;
31941 l_adr_value_segment_code := NULL;
31942
31943 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
31944 l_bflow_class_code := ''; -- 4219869 Business Flow
31945 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
31946 l_budgetary_control_flag := 'N';
31947
31948 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31949 l_bflow_applied_to_amt := NULL; -- 5132302
31950 l_entered_amt_idx := NULL; -- 4262811
31951 l_accted_amt_idx := NULL; -- 4262811
31952 l_acc_rev_flag := NULL; -- 4262811
31953 l_accrual_line_num := NULL; -- 4262811
31954 l_tmp_amt := NULL; -- 4262811
31955 --
31956
31957 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
31958 l_balance_type_code <> 'B' THEN
31959 IF NVL(p_source_15,'
31960 ') = 'BANK_CHARGES' AND
31961 NVL(p_source_54,'
31962 ') = 'N'
31963 THEN
31964
31965 --
31966 XLA_AE_LINES_PKG.SetNewLine;
31967
31968 p_balance_type_code := l_balance_type_code;
31969 -- set the flag so later we will know whether the gain loss line needs to be created
31970
31971 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
31972 p_actual_flag :='A';
31973 END IF;
31974
31975 --
31976 -- bulk performance
31977 --
31978 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
31979 p_header_num => 0); -- 4262811
31980 --
31981 -- set accounting line options
31982 --
31983 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
31984 p_natural_side_code => 'C'
31985 , p_gain_or_loss_flag => 'N'
31986 , p_gl_transfer_mode_code => 'S'
31987 , p_acct_entry_type_code => 'A'
31988 , p_switch_side_flag => 'Y'
31989 , p_merge_duplicate_code => 'A'
31990 );
31991 --
31992 l_acc_rev_natural_side_code := 'D'; -- 4262811
31993 --
31994 --
31995 -- set accounting line type info
31996 --
31997 xla_ae_lines_pkg.SetAcctLineType
31998 (p_component_type => l_component_type
31999 ,p_event_type_code => l_event_type_code
32000 ,p_line_definition_owner_code => l_line_definition_owner_code
32001 ,p_line_definition_code => l_line_definition_code
32002 ,p_accounting_line_code => l_component_code
32003 ,p_accounting_line_type_code => l_component_type_code
32004 ,p_accounting_line_appl_id => l_component_appl_id
32005 ,p_amb_context_code => l_amb_context_code
32006 ,p_entity_code => l_entity_code
32007 ,p_event_class_code => l_event_class_code);
32008 --
32009 -- set accounting class
32010 --
32011 xla_ae_lines_pkg.SetAcctClass(
32012 p_accounting_class_code => 'BANK_CHG'
32013 , p_ae_header_id => l_ae_header_id
32014 );
32015
32016 --
32017 -- set rounding class
32018 --
32019 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
32020 'RECEIVABLE';
32021
32022 --
32023 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
32024 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
32025 --
32026 -- bulk performance
32027 --
32028 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
32029
32030 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
32031 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
32032
32033 -- 4955764
32034 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32035 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
32036
32037 -- 4458381 Public Sector Enh
32038
32039 --
32040 -- set accounting attributes for the line type
32041 --
32042 l_entered_amt_idx := 3;
32043 l_accted_amt_idx := 8;
32044 l_bflow_applied_to_amt_idx := NULL; -- 5132302
32045 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
32046 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
32047 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
32048 l_rec_acct_attrs.array_char_value(2) := p_source_18;
32052 l_rec_acct_attrs.array_char_value(4) := p_source_20;
32049 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
32050 l_rec_acct_attrs.array_num_value(3) := p_source_19;
32051 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
32053 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
32054 l_rec_acct_attrs.array_date_value(5) := p_source_55;
32055 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
32056 l_rec_acct_attrs.array_num_value(6) := p_source_22;
32057 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
32058 l_rec_acct_attrs.array_char_value(7) := p_source_23;
32059 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
32060 l_rec_acct_attrs.array_num_value(8) := p_source_24;
32061
32062 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
32063 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
32064
32065 ---------------------------------------------------------------------------------------------------------------
32066 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
32067 ---------------------------------------------------------------------------------------------------------------
32068 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
32069
32070 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32071 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32072
32073 IF xla_accounting_cache_pkg.GetValueChar
32074 (p_source_code => 'LEDGER_CATEGORY_CODE'
32075 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
32076 AND l_bflow_method_code = 'PRIOR_ENTRY'
32077 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
32078 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
32079 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
32080 )
32081 THEN
32082 xla_ae_lines_pkg.BflowUpgEntry
32083 (p_business_method_code => l_bflow_method_code
32084 ,p_business_class_code => l_bflow_class_code
32085 ,p_balance_type => l_balance_type_code);
32086 ELSE
32087 NULL;
32088 -- No business flow processing for business flow method of NONE.
32089 END IF;
32090
32091 --
32092 -- call analytical criteria
32093 --
32094
32095 --
32096 -- call description
32097 --
32098 -- No description or it is inherited.
32099 --
32100 -- call ADRs
32101 -- Bug 4922099
32102 --
32103 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32104 (NVL(l_actual_upg_option, 'N') = 'O') OR
32105 (NVL(l_enc_upg_option, 'N') = 'O')
32106 )
32107 THEN
32108 NULL;
32109 --
32110 --
32111
32112 l_ccid := AcctDerRule_11(
32113 p_application_id => p_application_id
32114 , p_ae_header_id => l_ae_header_id
32115 , p_source_10 => p_source_10
32116 , x_transaction_coa_id => l_adr_transaction_coa_id
32117 , x_accounting_coa_id => l_adr_accounting_coa_id
32118 , x_value_type_code => l_adr_value_type_code
32119 , p_side => 'NA'
32120 );
32121
32122 xla_ae_lines_pkg.set_ccid(
32123 p_code_combination_id => l_ccid
32124 , p_value_type_code => l_adr_value_type_code
32125 , p_transaction_coa_id => l_adr_transaction_coa_id
32126 , p_accounting_coa_id => l_adr_accounting_coa_id
32127 , p_adr_code => 'DIST_CCID'
32128 , p_adr_type_code => 'S'
32129 , p_component_type => l_component_type
32130 , p_component_code => l_component_code
32131 , p_component_type_code => l_component_type_code
32132 , p_component_appl_id => l_component_appl_id
32133 , p_amb_context_code => l_amb_context_code
32134 , p_side => 'NA'
32135 );
32136
32137
32138 --
32139 --
32140 END IF;
32141 --
32142 -- Bug 4922099
32143 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
32144 (NVL(l_enc_upg_option, 'N') = 'O')
32145 ) AND
32146 (l_bflow_method_code = 'PRIOR_ENTRY')
32147 )
32148 THEN
32149 IF
32150 --
32151 1 = 2
32152 --
32153 THEN
32154 xla_accounting_err_pkg.build_message
32155 (p_appli_s_name => 'XLA'
32156 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32157 ,p_token_1 => 'LINE_NUMBER'
32158 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
32159 ,p_token_2 => 'LINE_TYPE_NAME'
32160 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
32161 l_component_type
32162 ,l_component_code
32163 ,l_component_type_code
32164 ,l_component_appl_id
32168 )
32165 ,l_amb_context_code
32166 ,l_entity_code
32167 ,l_event_class_code
32169 ,p_token_3 => 'OWNER'
32170 ,p_value_3 => xla_lookups_pkg.get_meaning(
32171 p_lookup_type => 'XLA_OWNER_TYPE'
32172 ,p_lookup_code => l_component_type_code
32173 )
32174 ,p_token_4 => 'PRODUCT_NAME'
32175 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
32176 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
32177 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
32178 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
32179 ,p_ae_header_id => NULL
32180 );
32181
32182 IF (C_LEVEL_ERROR>= g_log_level) THEN
32183 trace
32184 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32185 ,p_level => C_LEVEL_ERROR
32186 ,p_module => l_log_module);
32187 END IF;
32188 END IF;
32189 END IF;
32190 --
32191 --
32192 ------------------------------------------------------------------------------------------------
32193 -- 4219869 Business Flow
32194 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
32195 -- Prior Entry. Currently, the following code is always generated.
32196 ------------------------------------------------------------------------------------------------
32197 XLA_AE_LINES_PKG.ValidateCurrentLine;
32198
32199 ------------------------------------------------------------------------------------
32200 -- 4219869 Business Flow
32201 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
32202 ------------------------------------------------------------------------------------
32203 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32204
32205 ----------------------------------------------------------------------------------
32206 -- 4219869 Business Flow
32207 -- Update journal entry status -- Need to generate this within IF <condition>
32208 ----------------------------------------------------------------------------------
32209 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32210 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
32211 ,p_balance_type_code => l_balance_type_code
32212 );
32213
32214 -------------------------------------------------------------------------------------------
32215 -- 4262811 - Generate the Accrual Reversal lines
32216 -------------------------------------------------------------------------------------------
32217 BEGIN
32218 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
32219 (g_array_event(p_event_id).array_value_num('header_index'));
32220 IF l_acc_rev_flag IS NULL THEN
32221 l_acc_rev_flag := 'N';
32222 END IF;
32223 EXCEPTION
32224 WHEN OTHERS THEN
32225 l_acc_rev_flag := 'N';
32226 END;
32227 --
32228 IF (l_acc_rev_flag = 'Y') THEN
32229
32230 -- 4645092 ------------------------------------------------------------------------------
32231 -- To allow MPA report to determine if it should generate report process
32232 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
32233 ------------------------------------------------------------------------------------------
32234
32235 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
32236 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
32237 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
32238 -- call ADRs
32239 -- Bug 4922099
32240 --
32241 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32242 (NVL(l_actual_upg_option, 'N') = 'O') OR
32243 (NVL(l_enc_upg_option, 'N') = 'O')
32244 )
32245 THEN
32246 NULL;
32247 --
32248 --
32249
32250 l_ccid := AcctDerRule_11(
32251 p_application_id => p_application_id
32252 , p_ae_header_id => l_ae_header_id
32253 , p_source_10 => p_source_10
32254 , x_transaction_coa_id => l_adr_transaction_coa_id
32255 , x_accounting_coa_id => l_adr_accounting_coa_id
32256 , x_value_type_code => l_adr_value_type_code
32257 , p_side => 'NA'
32258 );
32259
32260 xla_ae_lines_pkg.set_ccid(
32261 p_code_combination_id => l_ccid
32262 , p_value_type_code => l_adr_value_type_code
32263 , p_transaction_coa_id => l_adr_transaction_coa_id
32264 , p_accounting_coa_id => l_adr_accounting_coa_id
32265 , p_adr_code => 'DIST_CCID'
32266 , p_adr_type_code => 'S'
32267 , p_component_type => l_component_type
32271 , p_amb_context_code => l_amb_context_code
32268 , p_component_code => l_component_code
32269 , p_component_type_code => l_component_type_code
32270 , p_component_appl_id => l_component_appl_id
32272 , p_side => 'NA'
32273 );
32274
32275
32276 --
32277 --
32278 END IF;
32279
32280 --
32281 -- Update the line information that should be overwritten
32282 --
32283 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
32284 p_header_num => 1);
32285 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
32286
32287 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
32288
32289 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
32290 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
32291 END IF;
32292
32293 --
32294 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
32295 --
32296 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
32297 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
32298 ELSE
32299 ---------------------------------------------------------------------------------------------------
32300 -- 4262811a Switch Sign
32301 ---------------------------------------------------------------------------------------------------
32302 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
32303 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32304 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32305 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32306 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32307 -- 5132302
32308 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
32309 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32310
32311 END IF;
32312
32313 -- 4955764
32314 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32315 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
32316
32317
32318 XLA_AE_LINES_PKG.ValidateCurrentLine;
32319 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32320
32321 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32322 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
32323 ,p_balance_type_code => l_balance_type_code);
32324
32325 END IF;
32326
32327 -----------------------------------------------------------------------------------------
32328 -- 4262811 Multiperiod Accounting
32329 -----------------------------------------------------------------------------------------
32330 -- No MPA option is assigned.
32331
32332
32333 END IF;
32334 END IF;
32335 --
32336
32337 --
32338 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32339 trace
32340 (p_msg => 'END of AcctLineType_69'
32341 ,p_level => C_LEVEL_PROCEDURE
32342 ,p_module => l_log_module);
32343 END IF;
32344 --
32345 EXCEPTION
32346 WHEN xla_exceptions_pkg.application_exception THEN
32347 RAISE;
32348 WHEN OTHERS THEN
32349 xla_exceptions_pkg.raise_message
32350 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_69');
32351 END AcctLineType_69;
32352 --
32353
32354 ---------------------------------------
32355 --
32356 -- PRIVATE FUNCTION
32357 -- AcctLineType_70
32358 --
32359 ---------------------------------------
32360 PROCEDURE AcctLineType_70 (
32361 p_application_id IN NUMBER
32362 ,p_event_id IN NUMBER
32363 ,p_calculate_acctd_flag IN VARCHAR2
32364 ,p_calculate_g_l_flag IN VARCHAR2
32365 ,p_actual_flag IN OUT VARCHAR2
32366 ,p_balance_type_code OUT VARCHAR2
32367 ,p_gain_or_loss_ref OUT VARCHAR2
32368
32369 --Distribution GL Account
32370 , p_source_10 IN NUMBER
32371 --Distribution Source Type
32372 , p_source_15 IN VARCHAR2
32373 --Distribution Line Identifier
32374 , p_source_17 IN NUMBER
32375 --Distribution Type
32376 , p_source_18 IN VARCHAR2
32377 --Entered Amount
32378 , p_source_19 IN NUMBER
32379 --Currency Code
32380 , p_source_20 IN VARCHAR2
32381 --Exchange Rate
32382 , p_source_22 IN NUMBER
32383 --Exchange Rate Type
32384 , p_source_23 IN VARCHAR2
32385 --Applied To Document Accounting Amount
32386 , p_source_24 IN NUMBER
32387 --Distribution Multi Fund Additional Entry
32388 , p_source_54 IN VARCHAR2
32389 --Applied To Document Exchange Date
32390 , p_source_55 IN DATE
32391 )
32392 IS
32393
32394 l_component_type VARCHAR2(80);
32395 l_component_code VARCHAR2(30);
32396 l_component_type_code VARCHAR2(1);
32397 l_component_appl_id INTEGER;
32398 l_amb_context_code VARCHAR2(30);
32399 l_entity_code VARCHAR2(30);
32400 l_event_class_code VARCHAR2(30);
32404 l_line_definition_owner_code VARCHAR2(1);
32401 l_ae_header_id NUMBER;
32402 l_event_type_code VARCHAR2(30);
32403 l_line_definition_code VARCHAR2(30);
32405 --
32406 -- adr variables
32407 l_segment VARCHAR2(30);
32408 l_ccid NUMBER;
32409 l_adr_transaction_coa_id NUMBER;
32410 l_adr_accounting_coa_id NUMBER;
32411 l_adr_flexfield_segment_code VARCHAR2(30);
32412 l_adr_flex_value_set_id NUMBER;
32413 l_adr_value_type_code VARCHAR2(30);
32414 l_adr_value_combination_id NUMBER;
32415 l_adr_value_segment_code VARCHAR2(30);
32416
32417 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
32418 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
32419 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
32420 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
32421
32422 -- 4262811 Variables ------------------------------------------------------------------------------------------
32423 l_entered_amt_idx NUMBER;
32424 l_accted_amt_idx NUMBER;
32425 l_acc_rev_flag VARCHAR2(1);
32426 l_accrual_line_num NUMBER;
32427 l_tmp_amt NUMBER;
32428 l_acc_rev_natural_side_code VARCHAR2(1);
32429
32430 l_num_entries NUMBER;
32431 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
32432 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
32433 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
32434 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
32435 l_recog_line_1 NUMBER;
32436 l_recog_line_2 NUMBER;
32437
32438 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
32439 l_bflow_applied_to_amt NUMBER; -- 5132302
32440 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
32441
32442 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
32443
32444 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
32445 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
32446
32447 ---------------------------------------------------------------------------------------------------------------
32448
32449
32450 --
32451 -- bulk performance
32452 --
32453 l_balance_type_code VARCHAR2(1);
32454 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
32455 l_log_module VARCHAR2(240);
32456
32457 --
32458 -- Upgrade strategy
32459 --
32460 l_actual_upg_option VARCHAR2(1);
32461 l_enc_upg_option VARCHAR2(1);
32462
32463 --
32464 BEGIN
32465 --
32466 IF g_log_enabled THEN
32467 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_70';
32468 END IF;
32469 --
32470 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32471
32472 trace
32473 (p_msg => 'BEGIN of AcctLineType_70'
32474 ,p_level => C_LEVEL_PROCEDURE
32475 ,p_module => l_log_module);
32476
32477 END IF;
32478 --
32479 l_component_type := 'AMB_JLT';
32480 l_component_code := 'MISC_RCT_DEBT';
32481 l_component_type_code := 'S';
32482 l_component_appl_id := 222;
32483 l_amb_context_code := 'DEFAULT';
32484 l_entity_code := 'RECEIPTS';
32485 l_event_class_code := 'MISC_RECEIPT';
32486 l_event_type_code := 'MISC_RECEIPT_ALL';
32487 l_line_definition_owner_code := 'S';
32488 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
32489 --
32490 l_balance_type_code := 'A';
32491 l_segment := NULL;
32492 l_ccid := NULL;
32493 l_adr_transaction_coa_id := NULL;
32494 l_adr_accounting_coa_id := NULL;
32495 l_adr_flexfield_segment_code := NULL;
32496 l_adr_flex_value_set_id := NULL;
32497 l_adr_value_type_code := NULL;
32498 l_adr_value_combination_id := NULL;
32499 l_adr_value_segment_code := NULL;
32500
32501 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
32502 l_bflow_class_code := ''; -- 4219869 Business Flow
32503 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
32504 l_budgetary_control_flag := 'N';
32505
32506 l_bflow_applied_to_amt_idx := NULL; -- 5132302
32507 l_bflow_applied_to_amt := NULL; -- 5132302
32508 l_entered_amt_idx := NULL; -- 4262811
32509 l_accted_amt_idx := NULL; -- 4262811
32510 l_acc_rev_flag := NULL; -- 4262811
32511 l_accrual_line_num := NULL; -- 4262811
32512 l_tmp_amt := NULL; -- 4262811
32513 --
32514
32515 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
32516 l_balance_type_code <> 'B' THEN
32517 IF NVL(p_source_15,'
32518 ') = 'SHORT_TERM_DEBT' AND
32519 NVL(p_source_54,'
32520 ') = 'N'
32521 THEN
32522
32523 --
32524 XLA_AE_LINES_PKG.SetNewLine;
32525
32526 p_balance_type_code := l_balance_type_code;
32527 -- set the flag so later we will know whether the gain loss line needs to be created
32528
32529 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
32530 p_actual_flag :='A';
32531 END IF;
32532
32533 --
32534 -- bulk performance
32535 --
32539 -- set accounting line options
32536 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
32537 p_header_num => 0); -- 4262811
32538 --
32540 --
32541 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
32542 p_natural_side_code => 'C'
32543 , p_gain_or_loss_flag => 'N'
32544 , p_gl_transfer_mode_code => 'S'
32545 , p_acct_entry_type_code => 'A'
32546 , p_switch_side_flag => 'Y'
32547 , p_merge_duplicate_code => 'A'
32548 );
32549 --
32550 l_acc_rev_natural_side_code := 'D'; -- 4262811
32551 --
32552 --
32553 -- set accounting line type info
32554 --
32555 xla_ae_lines_pkg.SetAcctLineType
32556 (p_component_type => l_component_type
32557 ,p_event_type_code => l_event_type_code
32558 ,p_line_definition_owner_code => l_line_definition_owner_code
32559 ,p_line_definition_code => l_line_definition_code
32560 ,p_accounting_line_code => l_component_code
32561 ,p_accounting_line_type_code => l_component_type_code
32562 ,p_accounting_line_appl_id => l_component_appl_id
32563 ,p_amb_context_code => l_amb_context_code
32564 ,p_entity_code => l_entity_code
32565 ,p_event_class_code => l_event_class_code);
32566 --
32567 -- set accounting class
32568 --
32569 xla_ae_lines_pkg.SetAcctClass(
32570 p_accounting_class_code => 'SHORT_TERM_DEBT'
32571 , p_ae_header_id => l_ae_header_id
32572 );
32573
32574 --
32575 -- set rounding class
32576 --
32577 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
32578 'RECEIVABLE';
32579
32580 --
32581 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
32582 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
32583 --
32584 -- bulk performance
32585 --
32586 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
32587
32588 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
32589 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
32590
32591 -- 4955764
32592 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32593 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
32594
32595 -- 4458381 Public Sector Enh
32596
32597 --
32598 -- set accounting attributes for the line type
32599 --
32600 l_entered_amt_idx := 3;
32601 l_accted_amt_idx := 8;
32602 l_bflow_applied_to_amt_idx := NULL; -- 5132302
32603 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
32604 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
32605 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
32606 l_rec_acct_attrs.array_char_value(2) := p_source_18;
32607 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
32608 l_rec_acct_attrs.array_num_value(3) := p_source_19;
32609 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
32610 l_rec_acct_attrs.array_char_value(4) := p_source_20;
32611 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
32612 l_rec_acct_attrs.array_date_value(5) := p_source_55;
32613 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
32614 l_rec_acct_attrs.array_num_value(6) := p_source_22;
32615 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
32616 l_rec_acct_attrs.array_char_value(7) := p_source_23;
32617 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
32618 l_rec_acct_attrs.array_num_value(8) := p_source_24;
32619
32620 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
32621 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
32622
32623 ---------------------------------------------------------------------------------------------------------------
32624 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
32625 ---------------------------------------------------------------------------------------------------------------
32626 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
32627
32628 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32629 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32630
32631 IF xla_accounting_cache_pkg.GetValueChar
32632 (p_source_code => 'LEDGER_CATEGORY_CODE'
32633 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
32634 AND l_bflow_method_code = 'PRIOR_ENTRY'
32635 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
32636 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
32637 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
32638 )
32639 THEN
32640 xla_ae_lines_pkg.BflowUpgEntry
32641 (p_business_method_code => l_bflow_method_code
32642 ,p_business_class_code => l_bflow_class_code
32643 ,p_balance_type => l_balance_type_code);
32644 ELSE
32645 NULL;
32646 -- No business flow processing for business flow method of NONE.
32647 END IF;
32648
32649 --
32650 -- call analytical criteria
32651 --
32652
32653 --
32657 --
32654 -- call description
32655 --
32656 -- No description or it is inherited.
32658 -- call ADRs
32659 -- Bug 4922099
32660 --
32661 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32662 (NVL(l_actual_upg_option, 'N') = 'O') OR
32663 (NVL(l_enc_upg_option, 'N') = 'O')
32664 )
32665 THEN
32666 NULL;
32667 --
32668 --
32669
32670 l_ccid := AcctDerRule_11(
32671 p_application_id => p_application_id
32672 , p_ae_header_id => l_ae_header_id
32673 , p_source_10 => p_source_10
32674 , x_transaction_coa_id => l_adr_transaction_coa_id
32675 , x_accounting_coa_id => l_adr_accounting_coa_id
32676 , x_value_type_code => l_adr_value_type_code
32677 , p_side => 'NA'
32678 );
32679
32680 xla_ae_lines_pkg.set_ccid(
32681 p_code_combination_id => l_ccid
32682 , p_value_type_code => l_adr_value_type_code
32683 , p_transaction_coa_id => l_adr_transaction_coa_id
32684 , p_accounting_coa_id => l_adr_accounting_coa_id
32685 , p_adr_code => 'DIST_CCID'
32686 , p_adr_type_code => 'S'
32687 , p_component_type => l_component_type
32688 , p_component_code => l_component_code
32689 , p_component_type_code => l_component_type_code
32690 , p_component_appl_id => l_component_appl_id
32691 , p_amb_context_code => l_amb_context_code
32692 , p_side => 'NA'
32693 );
32694
32695
32696 --
32697 --
32698 END IF;
32699 --
32700 -- Bug 4922099
32701 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
32702 (NVL(l_enc_upg_option, 'N') = 'O')
32703 ) AND
32704 (l_bflow_method_code = 'PRIOR_ENTRY')
32705 )
32706 THEN
32707 IF
32708 --
32709 1 = 2
32710 --
32711 THEN
32712 xla_accounting_err_pkg.build_message
32713 (p_appli_s_name => 'XLA'
32714 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32715 ,p_token_1 => 'LINE_NUMBER'
32716 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
32717 ,p_token_2 => 'LINE_TYPE_NAME'
32718 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
32719 l_component_type
32720 ,l_component_code
32721 ,l_component_type_code
32722 ,l_component_appl_id
32723 ,l_amb_context_code
32724 ,l_entity_code
32725 ,l_event_class_code
32726 )
32727 ,p_token_3 => 'OWNER'
32728 ,p_value_3 => xla_lookups_pkg.get_meaning(
32729 p_lookup_type => 'XLA_OWNER_TYPE'
32730 ,p_lookup_code => l_component_type_code
32731 )
32732 ,p_token_4 => 'PRODUCT_NAME'
32733 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
32734 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
32735 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
32736 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
32737 ,p_ae_header_id => NULL
32738 );
32739
32740 IF (C_LEVEL_ERROR>= g_log_level) THEN
32741 trace
32742 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32743 ,p_level => C_LEVEL_ERROR
32744 ,p_module => l_log_module);
32745 END IF;
32746 END IF;
32747 END IF;
32748 --
32749 --
32750 ------------------------------------------------------------------------------------------------
32751 -- 4219869 Business Flow
32752 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
32753 -- Prior Entry. Currently, the following code is always generated.
32754 ------------------------------------------------------------------------------------------------
32755 XLA_AE_LINES_PKG.ValidateCurrentLine;
32756
32757 ------------------------------------------------------------------------------------
32758 -- 4219869 Business Flow
32759 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
32760 ------------------------------------------------------------------------------------
32761 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32762
32763 ----------------------------------------------------------------------------------
32764 -- 4219869 Business Flow
32768 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
32765 -- Update journal entry status -- Need to generate this within IF <condition>
32766 ----------------------------------------------------------------------------------
32767 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32769 ,p_balance_type_code => l_balance_type_code
32770 );
32771
32772 -------------------------------------------------------------------------------------------
32773 -- 4262811 - Generate the Accrual Reversal lines
32774 -------------------------------------------------------------------------------------------
32775 BEGIN
32776 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
32777 (g_array_event(p_event_id).array_value_num('header_index'));
32778 IF l_acc_rev_flag IS NULL THEN
32779 l_acc_rev_flag := 'N';
32780 END IF;
32781 EXCEPTION
32782 WHEN OTHERS THEN
32783 l_acc_rev_flag := 'N';
32784 END;
32785 --
32786 IF (l_acc_rev_flag = 'Y') THEN
32787
32788 -- 4645092 ------------------------------------------------------------------------------
32789 -- To allow MPA report to determine if it should generate report process
32790 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
32791 ------------------------------------------------------------------------------------------
32792
32793 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
32794 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
32795 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
32796 -- call ADRs
32797 -- Bug 4922099
32798 --
32799 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32800 (NVL(l_actual_upg_option, 'N') = 'O') OR
32801 (NVL(l_enc_upg_option, 'N') = 'O')
32802 )
32803 THEN
32804 NULL;
32805 --
32806 --
32807
32808 l_ccid := AcctDerRule_11(
32809 p_application_id => p_application_id
32810 , p_ae_header_id => l_ae_header_id
32811 , p_source_10 => p_source_10
32812 , x_transaction_coa_id => l_adr_transaction_coa_id
32813 , x_accounting_coa_id => l_adr_accounting_coa_id
32814 , x_value_type_code => l_adr_value_type_code
32815 , p_side => 'NA'
32816 );
32817
32818 xla_ae_lines_pkg.set_ccid(
32819 p_code_combination_id => l_ccid
32820 , p_value_type_code => l_adr_value_type_code
32821 , p_transaction_coa_id => l_adr_transaction_coa_id
32822 , p_accounting_coa_id => l_adr_accounting_coa_id
32823 , p_adr_code => 'DIST_CCID'
32824 , p_adr_type_code => 'S'
32825 , p_component_type => l_component_type
32826 , p_component_code => l_component_code
32827 , p_component_type_code => l_component_type_code
32828 , p_component_appl_id => l_component_appl_id
32829 , p_amb_context_code => l_amb_context_code
32830 , p_side => 'NA'
32831 );
32832
32833
32834 --
32835 --
32836 END IF;
32837
32838 --
32839 -- Update the line information that should be overwritten
32840 --
32841 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
32842 p_header_num => 1);
32843 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
32844
32845 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
32846
32847 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
32848 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
32849 END IF;
32850
32851 --
32852 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
32853 --
32854 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
32855 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
32856 ELSE
32857 ---------------------------------------------------------------------------------------------------
32858 -- 4262811a Switch Sign
32859 ---------------------------------------------------------------------------------------------------
32860 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
32861 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32862 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32863 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32864 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32865 -- 5132302
32866 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
32867 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32868
32869 END IF;
32870
32871 -- 4955764
32872 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32873 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
32874
32875
32876 XLA_AE_LINES_PKG.ValidateCurrentLine;
32877 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32878
32879 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32883 END IF;
32880 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
32881 ,p_balance_type_code => l_balance_type_code);
32882
32884
32885 -----------------------------------------------------------------------------------------
32886 -- 4262811 Multiperiod Accounting
32887 -----------------------------------------------------------------------------------------
32888 -- No MPA option is assigned.
32889
32890
32891 END IF;
32892 END IF;
32893 --
32894
32895 --
32896 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32897 trace
32898 (p_msg => 'END of AcctLineType_70'
32899 ,p_level => C_LEVEL_PROCEDURE
32900 ,p_module => l_log_module);
32901 END IF;
32902 --
32903 EXCEPTION
32904 WHEN xla_exceptions_pkg.application_exception THEN
32905 RAISE;
32906 WHEN OTHERS THEN
32907 xla_exceptions_pkg.raise_message
32908 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_70');
32909 END AcctLineType_70;
32910 --
32911
32912 ---------------------------------------
32913 --
32914 -- PRIVATE FUNCTION
32915 -- AcctLineType_71
32916 --
32917 ---------------------------------------
32918 PROCEDURE AcctLineType_71 (
32919 p_application_id IN NUMBER
32920 ,p_event_id IN NUMBER
32921 ,p_calculate_acctd_flag IN VARCHAR2
32922 ,p_calculate_g_l_flag IN VARCHAR2
32923 ,p_actual_flag IN OUT VARCHAR2
32924 ,p_balance_type_code OUT VARCHAR2
32925 ,p_gain_or_loss_ref OUT VARCHAR2
32926
32927 --Distribution GL Account
32928 , p_source_10 IN NUMBER
32929 --Distribution Source Type
32930 , p_source_15 IN VARCHAR2
32931 --Distribution Line Identifier
32932 , p_source_17 IN NUMBER
32933 --Distribution Type
32934 , p_source_18 IN VARCHAR2
32935 --Entered Amount
32936 , p_source_19 IN NUMBER
32937 --Currency Code
32938 , p_source_20 IN VARCHAR2
32939 --Exchange Rate
32940 , p_source_22 IN NUMBER
32941 --Exchange Rate Type
32942 , p_source_23 IN VARCHAR2
32943 --Applied To Document Accounting Amount
32944 , p_source_24 IN NUMBER
32945 --Distribution Multi Fund Additional Entry
32946 , p_source_54 IN VARCHAR2
32947 --Applied To Document Exchange Date
32948 , p_source_55 IN DATE
32949 )
32950 IS
32951
32952 l_component_type VARCHAR2(80);
32953 l_component_code VARCHAR2(30);
32954 l_component_type_code VARCHAR2(1);
32955 l_component_appl_id INTEGER;
32956 l_amb_context_code VARCHAR2(30);
32957 l_entity_code VARCHAR2(30);
32958 l_event_class_code VARCHAR2(30);
32959 l_ae_header_id NUMBER;
32960 l_event_type_code VARCHAR2(30);
32961 l_line_definition_code VARCHAR2(30);
32962 l_line_definition_owner_code VARCHAR2(1);
32963 --
32964 -- adr variables
32965 l_segment VARCHAR2(30);
32966 l_ccid NUMBER;
32967 l_adr_transaction_coa_id NUMBER;
32968 l_adr_accounting_coa_id NUMBER;
32969 l_adr_flexfield_segment_code VARCHAR2(30);
32970 l_adr_flex_value_set_id NUMBER;
32971 l_adr_value_type_code VARCHAR2(30);
32972 l_adr_value_combination_id NUMBER;
32973 l_adr_value_segment_code VARCHAR2(30);
32974
32975 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
32976 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
32977 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
32978 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
32979
32980 -- 4262811 Variables ------------------------------------------------------------------------------------------
32981 l_entered_amt_idx NUMBER;
32982 l_accted_amt_idx NUMBER;
32983 l_acc_rev_flag VARCHAR2(1);
32984 l_accrual_line_num NUMBER;
32985 l_tmp_amt NUMBER;
32986 l_acc_rev_natural_side_code VARCHAR2(1);
32987
32988 l_num_entries NUMBER;
32989 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
32990 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
32991 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
32992 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
32993 l_recog_line_1 NUMBER;
32994 l_recog_line_2 NUMBER;
32995
32996 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
32997 l_bflow_applied_to_amt NUMBER; -- 5132302
32998 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
32999
33000 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
33001
33002 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
33003 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
33004
33005 ---------------------------------------------------------------------------------------------------------------
33006
33007
33008 --
33009 -- bulk performance
33010 --
33011 l_balance_type_code VARCHAR2(1);
33012 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
33013 l_log_module VARCHAR2(240);
33014
33015 --
33016 -- Upgrade strategy
33017 --
33021 --
33018 l_actual_upg_option VARCHAR2(1);
33019 l_enc_upg_option VARCHAR2(1);
33020
33022 BEGIN
33023 --
33024 IF g_log_enabled THEN
33025 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_71';
33026 END IF;
33027 --
33028 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33029
33030 trace
33031 (p_msg => 'BEGIN of AcctLineType_71'
33032 ,p_level => C_LEVEL_PROCEDURE
33033 ,p_module => l_log_module);
33034
33035 END IF;
33036 --
33037 l_component_type := 'AMB_JLT';
33038 l_component_code := 'MISC_RCT_FACTOR';
33039 l_component_type_code := 'S';
33040 l_component_appl_id := 222;
33041 l_amb_context_code := 'DEFAULT';
33042 l_entity_code := 'RECEIPTS';
33043 l_event_class_code := 'MISC_RECEIPT';
33044 l_event_type_code := 'MISC_RECEIPT_ALL';
33045 l_line_definition_owner_code := 'S';
33046 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
33047 --
33048 l_balance_type_code := 'A';
33049 l_segment := NULL;
33050 l_ccid := NULL;
33051 l_adr_transaction_coa_id := NULL;
33052 l_adr_accounting_coa_id := NULL;
33053 l_adr_flexfield_segment_code := NULL;
33054 l_adr_flex_value_set_id := NULL;
33055 l_adr_value_type_code := NULL;
33056 l_adr_value_combination_id := NULL;
33057 l_adr_value_segment_code := NULL;
33058
33059 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
33060 l_bflow_class_code := ''; -- 4219869 Business Flow
33061 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
33062 l_budgetary_control_flag := 'N';
33063
33064 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33065 l_bflow_applied_to_amt := NULL; -- 5132302
33066 l_entered_amt_idx := NULL; -- 4262811
33067 l_accted_amt_idx := NULL; -- 4262811
33068 l_acc_rev_flag := NULL; -- 4262811
33069 l_accrual_line_num := NULL; -- 4262811
33070 l_tmp_amt := NULL; -- 4262811
33071 --
33072
33073 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
33074 l_balance_type_code <> 'B' THEN
33075 IF NVL(p_source_15,'
33076 ') = 'FACTOR' AND
33077 NVL(p_source_54,'
33078 ') = 'N'
33079 THEN
33080
33081 --
33082 XLA_AE_LINES_PKG.SetNewLine;
33083
33084 p_balance_type_code := l_balance_type_code;
33085 -- set the flag so later we will know whether the gain loss line needs to be created
33086
33087 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
33088 p_actual_flag :='A';
33089 END IF;
33090
33091 --
33092 -- bulk performance
33093 --
33094 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
33095 p_header_num => 0); -- 4262811
33096 --
33097 -- set accounting line options
33098 --
33099 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
33100 p_natural_side_code => 'C'
33101 , p_gain_or_loss_flag => 'N'
33102 , p_gl_transfer_mode_code => 'S'
33103 , p_acct_entry_type_code => 'A'
33104 , p_switch_side_flag => 'Y'
33105 , p_merge_duplicate_code => 'A'
33106 );
33107 --
33108 l_acc_rev_natural_side_code := 'D'; -- 4262811
33109 --
33110 --
33111 -- set accounting line type info
33112 --
33113 xla_ae_lines_pkg.SetAcctLineType
33114 (p_component_type => l_component_type
33115 ,p_event_type_code => l_event_type_code
33116 ,p_line_definition_owner_code => l_line_definition_owner_code
33117 ,p_line_definition_code => l_line_definition_code
33118 ,p_accounting_line_code => l_component_code
33119 ,p_accounting_line_type_code => l_component_type_code
33120 ,p_accounting_line_appl_id => l_component_appl_id
33121 ,p_amb_context_code => l_amb_context_code
33122 ,p_entity_code => l_entity_code
33123 ,p_event_class_code => l_event_class_code);
33124 --
33125 -- set accounting class
33126 --
33127 xla_ae_lines_pkg.SetAcctClass(
33128 p_accounting_class_code => 'FACTOR'
33129 , p_ae_header_id => l_ae_header_id
33130 );
33131
33132 --
33133 -- set rounding class
33134 --
33135 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
33136 'RECEIVABLE';
33137
33138 --
33139 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
33140 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
33141 --
33142 -- bulk performance
33143 --
33144 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
33145
33146 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
33147 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
33148
33149 -- 4955764
33150 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33151 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
33152
33153 -- 4458381 Public Sector Enh
33154
33155 --
33156 -- set accounting attributes for the line type
33160 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33157 --
33158 l_entered_amt_idx := 3;
33159 l_accted_amt_idx := 8;
33161 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
33162 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
33163 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
33164 l_rec_acct_attrs.array_char_value(2) := p_source_18;
33165 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
33166 l_rec_acct_attrs.array_num_value(3) := p_source_19;
33167 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
33168 l_rec_acct_attrs.array_char_value(4) := p_source_20;
33169 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
33170 l_rec_acct_attrs.array_date_value(5) := p_source_55;
33171 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
33172 l_rec_acct_attrs.array_num_value(6) := p_source_22;
33173 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
33174 l_rec_acct_attrs.array_char_value(7) := p_source_23;
33175 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
33176 l_rec_acct_attrs.array_num_value(8) := p_source_24;
33177
33178 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
33179 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
33180
33181 ---------------------------------------------------------------------------------------------------------------
33182 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
33183 ---------------------------------------------------------------------------------------------------------------
33184 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
33185
33186 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33187 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33188
33189 IF xla_accounting_cache_pkg.GetValueChar
33190 (p_source_code => 'LEDGER_CATEGORY_CODE'
33191 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
33192 AND l_bflow_method_code = 'PRIOR_ENTRY'
33193 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
33194 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
33195 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
33196 )
33197 THEN
33198 xla_ae_lines_pkg.BflowUpgEntry
33199 (p_business_method_code => l_bflow_method_code
33200 ,p_business_class_code => l_bflow_class_code
33201 ,p_balance_type => l_balance_type_code);
33202 ELSE
33203 NULL;
33204 -- No business flow processing for business flow method of NONE.
33205 END IF;
33206
33207 --
33208 -- call analytical criteria
33209 --
33210
33211 --
33212 -- call description
33213 --
33214 -- No description or it is inherited.
33215 --
33216 -- call ADRs
33217 -- Bug 4922099
33218 --
33219 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33220 (NVL(l_actual_upg_option, 'N') = 'O') OR
33221 (NVL(l_enc_upg_option, 'N') = 'O')
33222 )
33223 THEN
33224 NULL;
33225 --
33226 --
33227
33228 l_ccid := AcctDerRule_11(
33229 p_application_id => p_application_id
33230 , p_ae_header_id => l_ae_header_id
33231 , p_source_10 => p_source_10
33232 , x_transaction_coa_id => l_adr_transaction_coa_id
33233 , x_accounting_coa_id => l_adr_accounting_coa_id
33234 , x_value_type_code => l_adr_value_type_code
33235 , p_side => 'NA'
33236 );
33237
33238 xla_ae_lines_pkg.set_ccid(
33239 p_code_combination_id => l_ccid
33240 , p_value_type_code => l_adr_value_type_code
33241 , p_transaction_coa_id => l_adr_transaction_coa_id
33242 , p_accounting_coa_id => l_adr_accounting_coa_id
33243 , p_adr_code => 'DIST_CCID'
33244 , p_adr_type_code => 'S'
33245 , p_component_type => l_component_type
33246 , p_component_code => l_component_code
33247 , p_component_type_code => l_component_type_code
33248 , p_component_appl_id => l_component_appl_id
33249 , p_amb_context_code => l_amb_context_code
33250 , p_side => 'NA'
33251 );
33252
33253
33254 --
33255 --
33256 END IF;
33257 --
33258 -- Bug 4922099
33259 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
33260 (NVL(l_enc_upg_option, 'N') = 'O')
33261 ) AND
33262 (l_bflow_method_code = 'PRIOR_ENTRY')
33263 )
33264 THEN
33265 IF
33266 --
33267 1 = 2
33268 --
33269 THEN
33270 xla_accounting_err_pkg.build_message
33271 (p_appli_s_name => 'XLA'
33272 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33273 ,p_token_1 => 'LINE_NUMBER'
33274 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
33275 ,p_token_2 => 'LINE_TYPE_NAME'
33276 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
33277 l_component_type
33281 ,l_amb_context_code
33278 ,l_component_code
33279 ,l_component_type_code
33280 ,l_component_appl_id
33282 ,l_entity_code
33283 ,l_event_class_code
33284 )
33285 ,p_token_3 => 'OWNER'
33286 ,p_value_3 => xla_lookups_pkg.get_meaning(
33287 p_lookup_type => 'XLA_OWNER_TYPE'
33288 ,p_lookup_code => l_component_type_code
33289 )
33290 ,p_token_4 => 'PRODUCT_NAME'
33291 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
33292 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
33293 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
33294 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
33295 ,p_ae_header_id => NULL
33296 );
33297
33298 IF (C_LEVEL_ERROR>= g_log_level) THEN
33299 trace
33300 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33301 ,p_level => C_LEVEL_ERROR
33302 ,p_module => l_log_module);
33303 END IF;
33304 END IF;
33305 END IF;
33306 --
33307 --
33308 ------------------------------------------------------------------------------------------------
33309 -- 4219869 Business Flow
33310 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
33311 -- Prior Entry. Currently, the following code is always generated.
33312 ------------------------------------------------------------------------------------------------
33313 XLA_AE_LINES_PKG.ValidateCurrentLine;
33314
33315 ------------------------------------------------------------------------------------
33316 -- 4219869 Business Flow
33317 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
33318 ------------------------------------------------------------------------------------
33319 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33320
33321 ----------------------------------------------------------------------------------
33322 -- 4219869 Business Flow
33323 -- Update journal entry status -- Need to generate this within IF <condition>
33324 ----------------------------------------------------------------------------------
33325 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33326 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
33327 ,p_balance_type_code => l_balance_type_code
33328 );
33329
33330 -------------------------------------------------------------------------------------------
33331 -- 4262811 - Generate the Accrual Reversal lines
33332 -------------------------------------------------------------------------------------------
33333 BEGIN
33334 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
33335 (g_array_event(p_event_id).array_value_num('header_index'));
33336 IF l_acc_rev_flag IS NULL THEN
33337 l_acc_rev_flag := 'N';
33338 END IF;
33339 EXCEPTION
33340 WHEN OTHERS THEN
33341 l_acc_rev_flag := 'N';
33342 END;
33343 --
33344 IF (l_acc_rev_flag = 'Y') THEN
33345
33346 -- 4645092 ------------------------------------------------------------------------------
33347 -- To allow MPA report to determine if it should generate report process
33348 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
33349 ------------------------------------------------------------------------------------------
33350
33351 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
33352 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
33353 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
33354 -- call ADRs
33355 -- Bug 4922099
33356 --
33357 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33358 (NVL(l_actual_upg_option, 'N') = 'O') OR
33359 (NVL(l_enc_upg_option, 'N') = 'O')
33360 )
33361 THEN
33362 NULL;
33363 --
33364 --
33365
33366 l_ccid := AcctDerRule_11(
33367 p_application_id => p_application_id
33368 , p_ae_header_id => l_ae_header_id
33369 , p_source_10 => p_source_10
33370 , x_transaction_coa_id => l_adr_transaction_coa_id
33371 , x_accounting_coa_id => l_adr_accounting_coa_id
33372 , x_value_type_code => l_adr_value_type_code
33373 , p_side => 'NA'
33374 );
33375
33376 xla_ae_lines_pkg.set_ccid(
33377 p_code_combination_id => l_ccid
33378 , p_value_type_code => l_adr_value_type_code
33379 , p_transaction_coa_id => l_adr_transaction_coa_id
33380 , p_accounting_coa_id => l_adr_accounting_coa_id
33381 , p_adr_code => 'DIST_CCID'
33385 , p_component_type_code => l_component_type_code
33382 , p_adr_type_code => 'S'
33383 , p_component_type => l_component_type
33384 , p_component_code => l_component_code
33386 , p_component_appl_id => l_component_appl_id
33387 , p_amb_context_code => l_amb_context_code
33388 , p_side => 'NA'
33389 );
33390
33391
33392 --
33393 --
33394 END IF;
33395
33396 --
33397 -- Update the line information that should be overwritten
33398 --
33399 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
33400 p_header_num => 1);
33401 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
33402
33403 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
33404
33405 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
33406 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
33407 END IF;
33408
33409 --
33410 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
33411 --
33412 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
33413 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
33414 ELSE
33415 ---------------------------------------------------------------------------------------------------
33416 -- 4262811a Switch Sign
33417 ---------------------------------------------------------------------------------------------------
33418 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
33419 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33420 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33421 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33422 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33423 -- 5132302
33424 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
33425 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33426
33427 END IF;
33428
33429 -- 4955764
33430 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33431 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
33432
33433
33434 XLA_AE_LINES_PKG.ValidateCurrentLine;
33435 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33436
33437 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33438 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
33439 ,p_balance_type_code => l_balance_type_code);
33440
33441 END IF;
33442
33443 -----------------------------------------------------------------------------------------
33444 -- 4262811 Multiperiod Accounting
33445 -----------------------------------------------------------------------------------------
33446 -- No MPA option is assigned.
33447
33448
33449 END IF;
33450 END IF;
33451 --
33452
33453 --
33454 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33455 trace
33456 (p_msg => 'END of AcctLineType_71'
33457 ,p_level => C_LEVEL_PROCEDURE
33458 ,p_module => l_log_module);
33459 END IF;
33460 --
33461 EXCEPTION
33462 WHEN xla_exceptions_pkg.application_exception THEN
33463 RAISE;
33464 WHEN OTHERS THEN
33465 xla_exceptions_pkg.raise_message
33466 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_71');
33467 END AcctLineType_71;
33468 --
33469
33470 ---------------------------------------
33471 --
33472 -- PRIVATE FUNCTION
33473 -- AcctLineType_72
33474 --
33475 ---------------------------------------
33476 PROCEDURE AcctLineType_72 (
33477 p_application_id IN NUMBER
33478 ,p_event_id IN NUMBER
33479 ,p_calculate_acctd_flag IN VARCHAR2
33480 ,p_calculate_g_l_flag IN VARCHAR2
33481 ,p_actual_flag IN OUT VARCHAR2
33482 ,p_balance_type_code OUT VARCHAR2
33483 ,p_gain_or_loss_ref OUT VARCHAR2
33484
33485 --Distribution GL Account
33486 , p_source_10 IN NUMBER
33487 --Distribution Source Type
33488 , p_source_15 IN VARCHAR2
33489 --Distribution Line Identifier
33490 , p_source_17 IN NUMBER
33491 --Distribution Type
33492 , p_source_18 IN VARCHAR2
33493 --Entered Amount
33494 , p_source_19 IN NUMBER
33495 --Currency Code
33496 , p_source_20 IN VARCHAR2
33497 --Exchange Rate
33498 , p_source_22 IN NUMBER
33499 --Exchange Rate Type
33500 , p_source_23 IN VARCHAR2
33501 --Applied To Document Accounting Amount
33502 , p_source_24 IN NUMBER
33503 --Distribution Multi Fund Additional Entry
33504 , p_source_54 IN VARCHAR2
33505 --Applied To Document Exchange Date
33506 , p_source_55 IN DATE
33507 )
33508 IS
33509
33510 l_component_type VARCHAR2(80);
33511 l_component_code VARCHAR2(30);
33512 l_component_type_code VARCHAR2(1);
33513 l_component_appl_id INTEGER;
33514 l_amb_context_code VARCHAR2(30);
33518 l_event_type_code VARCHAR2(30);
33515 l_entity_code VARCHAR2(30);
33516 l_event_class_code VARCHAR2(30);
33517 l_ae_header_id NUMBER;
33519 l_line_definition_code VARCHAR2(30);
33520 l_line_definition_owner_code VARCHAR2(1);
33521 --
33522 -- adr variables
33523 l_segment VARCHAR2(30);
33524 l_ccid NUMBER;
33525 l_adr_transaction_coa_id NUMBER;
33526 l_adr_accounting_coa_id NUMBER;
33527 l_adr_flexfield_segment_code VARCHAR2(30);
33528 l_adr_flex_value_set_id NUMBER;
33529 l_adr_value_type_code VARCHAR2(30);
33530 l_adr_value_combination_id NUMBER;
33531 l_adr_value_segment_code VARCHAR2(30);
33532
33533 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
33534 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
33535 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
33536 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
33537
33538 -- 4262811 Variables ------------------------------------------------------------------------------------------
33539 l_entered_amt_idx NUMBER;
33540 l_accted_amt_idx NUMBER;
33541 l_acc_rev_flag VARCHAR2(1);
33542 l_accrual_line_num NUMBER;
33543 l_tmp_amt NUMBER;
33544 l_acc_rev_natural_side_code VARCHAR2(1);
33545
33546 l_num_entries NUMBER;
33547 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
33548 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
33549 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
33550 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
33551 l_recog_line_1 NUMBER;
33552 l_recog_line_2 NUMBER;
33553
33554 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
33555 l_bflow_applied_to_amt NUMBER; -- 5132302
33556 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
33557
33558 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
33559
33560 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
33561 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
33562
33563 ---------------------------------------------------------------------------------------------------------------
33564
33565
33566 --
33567 -- bulk performance
33568 --
33569 l_balance_type_code VARCHAR2(1);
33570 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
33571 l_log_module VARCHAR2(240);
33572
33573 --
33574 -- Upgrade strategy
33575 --
33576 l_actual_upg_option VARCHAR2(1);
33577 l_enc_upg_option VARCHAR2(1);
33578
33579 --
33580 BEGIN
33581 --
33582 IF g_log_enabled THEN
33583 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_72';
33584 END IF;
33585 --
33586 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33587
33588 trace
33589 (p_msg => 'BEGIN of AcctLineType_72'
33590 ,p_level => C_LEVEL_PROCEDURE
33591 ,p_module => l_log_module);
33592
33593 END IF;
33594 --
33595 l_component_type := 'AMB_JLT';
33596 l_component_code := 'MISC_RCT_MISCCASH';
33597 l_component_type_code := 'S';
33598 l_component_appl_id := 222;
33599 l_amb_context_code := 'DEFAULT';
33600 l_entity_code := 'RECEIPTS';
33601 l_event_class_code := 'MISC_RECEIPT';
33602 l_event_type_code := 'MISC_RECEIPT_ALL';
33603 l_line_definition_owner_code := 'S';
33604 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
33605 --
33606 l_balance_type_code := 'A';
33607 l_segment := NULL;
33608 l_ccid := NULL;
33609 l_adr_transaction_coa_id := NULL;
33610 l_adr_accounting_coa_id := NULL;
33611 l_adr_flexfield_segment_code := NULL;
33612 l_adr_flex_value_set_id := NULL;
33613 l_adr_value_type_code := NULL;
33614 l_adr_value_combination_id := NULL;
33615 l_adr_value_segment_code := NULL;
33616
33617 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
33618 l_bflow_class_code := ''; -- 4219869 Business Flow
33619 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
33620 l_budgetary_control_flag := 'N';
33621
33622 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33623 l_bflow_applied_to_amt := NULL; -- 5132302
33624 l_entered_amt_idx := NULL; -- 4262811
33625 l_accted_amt_idx := NULL; -- 4262811
33626 l_acc_rev_flag := NULL; -- 4262811
33627 l_accrual_line_num := NULL; -- 4262811
33628 l_tmp_amt := NULL; -- 4262811
33629 --
33630
33631 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
33632 l_balance_type_code <> 'B' THEN
33633 IF NVL(p_source_15,'
33634 ') = 'MISCCASH' AND
33635 NVL(p_source_54,'
33636 ') = 'N'
33637 THEN
33638
33639 --
33640 XLA_AE_LINES_PKG.SetNewLine;
33641
33642 p_balance_type_code := l_balance_type_code;
33643 -- set the flag so later we will know whether the gain loss line needs to be created
33644
33645 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
33646 p_actual_flag :='A';
33647 END IF;
33648
33649 --
33650 -- bulk performance
33651 --
33655 -- set accounting line options
33652 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
33653 p_header_num => 0); -- 4262811
33654 --
33656 --
33657 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
33658 p_natural_side_code => 'C'
33659 , p_gain_or_loss_flag => 'N'
33660 , p_gl_transfer_mode_code => 'S'
33661 , p_acct_entry_type_code => 'A'
33662 , p_switch_side_flag => 'Y'
33663 , p_merge_duplicate_code => 'A'
33664 );
33665 --
33666 l_acc_rev_natural_side_code := 'D'; -- 4262811
33667 --
33668 --
33669 -- set accounting line type info
33670 --
33671 xla_ae_lines_pkg.SetAcctLineType
33672 (p_component_type => l_component_type
33673 ,p_event_type_code => l_event_type_code
33674 ,p_line_definition_owner_code => l_line_definition_owner_code
33675 ,p_line_definition_code => l_line_definition_code
33676 ,p_accounting_line_code => l_component_code
33677 ,p_accounting_line_type_code => l_component_type_code
33678 ,p_accounting_line_appl_id => l_component_appl_id
33679 ,p_amb_context_code => l_amb_context_code
33680 ,p_entity_code => l_entity_code
33681 ,p_event_class_code => l_event_class_code);
33682 --
33683 -- set accounting class
33684 --
33685 xla_ae_lines_pkg.SetAcctClass(
33686 p_accounting_class_code => 'MISC_CASH'
33687 , p_ae_header_id => l_ae_header_id
33688 );
33689
33690 --
33691 -- set rounding class
33692 --
33693 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
33694 'RECEIVABLE';
33695
33696 --
33697 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
33698 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
33699 --
33700 -- bulk performance
33701 --
33702 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
33703
33704 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
33705 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
33706
33707 -- 4955764
33708 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33709 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
33710
33711 -- 4458381 Public Sector Enh
33712
33713 --
33714 -- set accounting attributes for the line type
33715 --
33716 l_entered_amt_idx := 3;
33717 l_accted_amt_idx := 8;
33718 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33719 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
33720 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
33721 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
33722 l_rec_acct_attrs.array_char_value(2) := p_source_18;
33723 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
33724 l_rec_acct_attrs.array_num_value(3) := p_source_19;
33725 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
33726 l_rec_acct_attrs.array_char_value(4) := p_source_20;
33727 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
33728 l_rec_acct_attrs.array_date_value(5) := p_source_55;
33729 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
33730 l_rec_acct_attrs.array_num_value(6) := p_source_22;
33731 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
33732 l_rec_acct_attrs.array_char_value(7) := p_source_23;
33733 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
33734 l_rec_acct_attrs.array_num_value(8) := p_source_24;
33735
33736 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
33737 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
33738
33739 ---------------------------------------------------------------------------------------------------------------
33740 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
33741 ---------------------------------------------------------------------------------------------------------------
33742 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
33743
33744 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33745 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33746
33747 IF xla_accounting_cache_pkg.GetValueChar
33748 (p_source_code => 'LEDGER_CATEGORY_CODE'
33749 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
33750 AND l_bflow_method_code = 'PRIOR_ENTRY'
33751 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
33752 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
33753 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
33754 )
33755 THEN
33756 xla_ae_lines_pkg.BflowUpgEntry
33757 (p_business_method_code => l_bflow_method_code
33758 ,p_business_class_code => l_bflow_class_code
33759 ,p_balance_type => l_balance_type_code);
33760 ELSE
33761 NULL;
33762 -- No business flow processing for business flow method of NONE.
33763 END IF;
33767 --
33764
33765 --
33766 -- call analytical criteria
33768
33769 --
33770 -- call description
33771 --
33772 -- No description or it is inherited.
33773 --
33774 -- call ADRs
33775 -- Bug 4922099
33776 --
33777 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33778 (NVL(l_actual_upg_option, 'N') = 'O') OR
33779 (NVL(l_enc_upg_option, 'N') = 'O')
33780 )
33781 THEN
33782 NULL;
33783 --
33784 --
33785
33786 l_ccid := AcctDerRule_11(
33787 p_application_id => p_application_id
33788 , p_ae_header_id => l_ae_header_id
33789 , p_source_10 => p_source_10
33790 , x_transaction_coa_id => l_adr_transaction_coa_id
33791 , x_accounting_coa_id => l_adr_accounting_coa_id
33792 , x_value_type_code => l_adr_value_type_code
33793 , p_side => 'NA'
33794 );
33795
33796 xla_ae_lines_pkg.set_ccid(
33797 p_code_combination_id => l_ccid
33798 , p_value_type_code => l_adr_value_type_code
33799 , p_transaction_coa_id => l_adr_transaction_coa_id
33800 , p_accounting_coa_id => l_adr_accounting_coa_id
33801 , p_adr_code => 'DIST_CCID'
33802 , p_adr_type_code => 'S'
33803 , p_component_type => l_component_type
33804 , p_component_code => l_component_code
33805 , p_component_type_code => l_component_type_code
33806 , p_component_appl_id => l_component_appl_id
33807 , p_amb_context_code => l_amb_context_code
33808 , p_side => 'NA'
33809 );
33810
33811
33812 --
33813 --
33814 END IF;
33815 --
33816 -- Bug 4922099
33817 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
33818 (NVL(l_enc_upg_option, 'N') = 'O')
33819 ) AND
33820 (l_bflow_method_code = 'PRIOR_ENTRY')
33821 )
33822 THEN
33823 IF
33824 --
33825 1 = 2
33826 --
33827 THEN
33828 xla_accounting_err_pkg.build_message
33829 (p_appli_s_name => 'XLA'
33830 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33831 ,p_token_1 => 'LINE_NUMBER'
33832 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
33833 ,p_token_2 => 'LINE_TYPE_NAME'
33834 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
33835 l_component_type
33836 ,l_component_code
33837 ,l_component_type_code
33838 ,l_component_appl_id
33839 ,l_amb_context_code
33840 ,l_entity_code
33841 ,l_event_class_code
33842 )
33843 ,p_token_3 => 'OWNER'
33844 ,p_value_3 => xla_lookups_pkg.get_meaning(
33845 p_lookup_type => 'XLA_OWNER_TYPE'
33846 ,p_lookup_code => l_component_type_code
33847 )
33848 ,p_token_4 => 'PRODUCT_NAME'
33849 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
33850 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
33851 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
33852 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
33853 ,p_ae_header_id => NULL
33854 );
33855
33856 IF (C_LEVEL_ERROR>= g_log_level) THEN
33857 trace
33858 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33859 ,p_level => C_LEVEL_ERROR
33860 ,p_module => l_log_module);
33861 END IF;
33862 END IF;
33863 END IF;
33864 --
33865 --
33866 ------------------------------------------------------------------------------------------------
33867 -- 4219869 Business Flow
33868 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
33869 -- Prior Entry. Currently, the following code is always generated.
33870 ------------------------------------------------------------------------------------------------
33871 XLA_AE_LINES_PKG.ValidateCurrentLine;
33872
33873 ------------------------------------------------------------------------------------
33874 -- 4219869 Business Flow
33875 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
33879 ----------------------------------------------------------------------------------
33876 ------------------------------------------------------------------------------------
33877 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33878
33880 -- 4219869 Business Flow
33881 -- Update journal entry status -- Need to generate this within IF <condition>
33882 ----------------------------------------------------------------------------------
33883 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33884 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
33885 ,p_balance_type_code => l_balance_type_code
33886 );
33887
33888 -------------------------------------------------------------------------------------------
33889 -- 4262811 - Generate the Accrual Reversal lines
33890 -------------------------------------------------------------------------------------------
33891 BEGIN
33892 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
33893 (g_array_event(p_event_id).array_value_num('header_index'));
33894 IF l_acc_rev_flag IS NULL THEN
33895 l_acc_rev_flag := 'N';
33896 END IF;
33897 EXCEPTION
33898 WHEN OTHERS THEN
33899 l_acc_rev_flag := 'N';
33900 END;
33901 --
33902 IF (l_acc_rev_flag = 'Y') THEN
33903
33904 -- 4645092 ------------------------------------------------------------------------------
33905 -- To allow MPA report to determine if it should generate report process
33906 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
33907 ------------------------------------------------------------------------------------------
33908
33909 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
33910 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
33911 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
33912 -- call ADRs
33913 -- Bug 4922099
33914 --
33915 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33916 (NVL(l_actual_upg_option, 'N') = 'O') OR
33917 (NVL(l_enc_upg_option, 'N') = 'O')
33918 )
33919 THEN
33920 NULL;
33921 --
33922 --
33923
33924 l_ccid := AcctDerRule_11(
33925 p_application_id => p_application_id
33926 , p_ae_header_id => l_ae_header_id
33927 , p_source_10 => p_source_10
33928 , x_transaction_coa_id => l_adr_transaction_coa_id
33929 , x_accounting_coa_id => l_adr_accounting_coa_id
33930 , x_value_type_code => l_adr_value_type_code
33931 , p_side => 'NA'
33932 );
33933
33934 xla_ae_lines_pkg.set_ccid(
33935 p_code_combination_id => l_ccid
33936 , p_value_type_code => l_adr_value_type_code
33937 , p_transaction_coa_id => l_adr_transaction_coa_id
33938 , p_accounting_coa_id => l_adr_accounting_coa_id
33939 , p_adr_code => 'DIST_CCID'
33940 , p_adr_type_code => 'S'
33941 , p_component_type => l_component_type
33942 , p_component_code => l_component_code
33943 , p_component_type_code => l_component_type_code
33944 , p_component_appl_id => l_component_appl_id
33945 , p_amb_context_code => l_amb_context_code
33946 , p_side => 'NA'
33947 );
33948
33949
33950 --
33951 --
33952 END IF;
33953
33954 --
33955 -- Update the line information that should be overwritten
33956 --
33957 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
33958 p_header_num => 1);
33959 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
33960
33961 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
33962
33963 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
33964 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
33965 END IF;
33966
33967 --
33968 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
33969 --
33970 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
33971 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
33972 ELSE
33973 ---------------------------------------------------------------------------------------------------
33974 -- 4262811a Switch Sign
33975 ---------------------------------------------------------------------------------------------------
33976 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
33977 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33978 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33979 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33980 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33981 -- 5132302
33982 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
33983 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33984
33985 END IF;
33986
33987 -- 4955764
33988 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33992 XLA_AE_LINES_PKG.ValidateCurrentLine;
33989 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
33990
33991
33993 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33994
33995 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33996 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
33997 ,p_balance_type_code => l_balance_type_code);
33998
33999 END IF;
34000
34001 -----------------------------------------------------------------------------------------
34002 -- 4262811 Multiperiod Accounting
34003 -----------------------------------------------------------------------------------------
34004 -- No MPA option is assigned.
34005
34006
34007 END IF;
34008 END IF;
34009 --
34010
34011 --
34012 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34013 trace
34014 (p_msg => 'END of AcctLineType_72'
34015 ,p_level => C_LEVEL_PROCEDURE
34016 ,p_module => l_log_module);
34017 END IF;
34018 --
34019 EXCEPTION
34020 WHEN xla_exceptions_pkg.application_exception THEN
34021 RAISE;
34022 WHEN OTHERS THEN
34023 xla_exceptions_pkg.raise_message
34024 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_72');
34025 END AcctLineType_72;
34026 --
34027
34028 ---------------------------------------
34029 --
34030 -- PRIVATE FUNCTION
34031 -- AcctLineType_73
34032 --
34033 ---------------------------------------
34034 PROCEDURE AcctLineType_73 (
34035 p_application_id IN NUMBER
34036 ,p_event_id IN NUMBER
34037 ,p_calculate_acctd_flag IN VARCHAR2
34038 ,p_calculate_g_l_flag IN VARCHAR2
34039 ,p_actual_flag IN OUT VARCHAR2
34040 ,p_balance_type_code OUT VARCHAR2
34041 ,p_gain_or_loss_ref OUT VARCHAR2
34042
34043 --Distribution GL Account
34044 , p_source_10 IN NUMBER
34045 --Distribution Source Type
34046 , p_source_15 IN VARCHAR2
34047 --Distribution Line Identifier
34048 , p_source_17 IN NUMBER
34049 --Distribution Type
34050 , p_source_18 IN VARCHAR2
34051 --Entered Amount
34052 , p_source_19 IN NUMBER
34053 --Currency Code
34054 , p_source_20 IN VARCHAR2
34055 --Exchange Rate
34056 , p_source_22 IN NUMBER
34057 --Exchange Rate Type
34058 , p_source_23 IN VARCHAR2
34059 --Applied To Document Accounting Amount
34060 , p_source_24 IN NUMBER
34061 --Distribution Multi Fund Additional Entry
34062 , p_source_54 IN VARCHAR2
34063 --Applied To Document Exchange Date
34064 , p_source_55 IN DATE
34065 )
34066 IS
34067
34068 l_component_type VARCHAR2(80);
34069 l_component_code VARCHAR2(30);
34070 l_component_type_code VARCHAR2(1);
34071 l_component_appl_id INTEGER;
34072 l_amb_context_code VARCHAR2(30);
34073 l_entity_code VARCHAR2(30);
34074 l_event_class_code VARCHAR2(30);
34075 l_ae_header_id NUMBER;
34076 l_event_type_code VARCHAR2(30);
34077 l_line_definition_code VARCHAR2(30);
34078 l_line_definition_owner_code VARCHAR2(1);
34079 --
34080 -- adr variables
34081 l_segment VARCHAR2(30);
34082 l_ccid NUMBER;
34083 l_adr_transaction_coa_id NUMBER;
34084 l_adr_accounting_coa_id NUMBER;
34085 l_adr_flexfield_segment_code VARCHAR2(30);
34086 l_adr_flex_value_set_id NUMBER;
34087 l_adr_value_type_code VARCHAR2(30);
34088 l_adr_value_combination_id NUMBER;
34089 l_adr_value_segment_code VARCHAR2(30);
34090
34091 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
34092 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
34093 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
34094 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
34095
34096 -- 4262811 Variables ------------------------------------------------------------------------------------------
34097 l_entered_amt_idx NUMBER;
34098 l_accted_amt_idx NUMBER;
34099 l_acc_rev_flag VARCHAR2(1);
34100 l_accrual_line_num NUMBER;
34101 l_tmp_amt NUMBER;
34102 l_acc_rev_natural_side_code VARCHAR2(1);
34103
34104 l_num_entries NUMBER;
34105 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
34106 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
34107 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
34108 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
34109 l_recog_line_1 NUMBER;
34110 l_recog_line_2 NUMBER;
34111
34112 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
34113 l_bflow_applied_to_amt NUMBER; -- 5132302
34114 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
34115
34116 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
34117
34118 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
34119 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
34120
34121 ---------------------------------------------------------------------------------------------------------------
34122
34123
34124 --
34125 -- bulk performance
34126 --
34127 l_balance_type_code VARCHAR2(1);
34131 --
34128 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
34129 l_log_module VARCHAR2(240);
34130
34132 -- Upgrade strategy
34133 --
34134 l_actual_upg_option VARCHAR2(1);
34135 l_enc_upg_option VARCHAR2(1);
34136
34137 --
34138 BEGIN
34139 --
34140 IF g_log_enabled THEN
34141 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_73';
34142 END IF;
34143 --
34144 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34145
34146 trace
34147 (p_msg => 'BEGIN of AcctLineType_73'
34148 ,p_level => C_LEVEL_PROCEDURE
34149 ,p_module => l_log_module);
34150
34151 END IF;
34152 --
34153 l_component_type := 'AMB_JLT';
34154 l_component_code := 'MISC_RCT_TAX';
34155 l_component_type_code := 'S';
34156 l_component_appl_id := 222;
34157 l_amb_context_code := 'DEFAULT';
34158 l_entity_code := 'RECEIPTS';
34159 l_event_class_code := 'MISC_RECEIPT';
34160 l_event_type_code := 'MISC_RECEIPT_ALL';
34161 l_line_definition_owner_code := 'S';
34162 l_line_definition_code := 'MFAR_MISC_RECEIPTS_ACCOUNT';
34163 --
34164 l_balance_type_code := 'A';
34165 l_segment := NULL;
34166 l_ccid := NULL;
34167 l_adr_transaction_coa_id := NULL;
34168 l_adr_accounting_coa_id := NULL;
34169 l_adr_flexfield_segment_code := NULL;
34170 l_adr_flex_value_set_id := NULL;
34171 l_adr_value_type_code := NULL;
34172 l_adr_value_combination_id := NULL;
34173 l_adr_value_segment_code := NULL;
34174
34175 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
34176 l_bflow_class_code := ''; -- 4219869 Business Flow
34177 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
34178 l_budgetary_control_flag := 'N';
34179
34180 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34181 l_bflow_applied_to_amt := NULL; -- 5132302
34182 l_entered_amt_idx := NULL; -- 4262811
34183 l_accted_amt_idx := NULL; -- 4262811
34184 l_acc_rev_flag := NULL; -- 4262811
34185 l_accrual_line_num := NULL; -- 4262811
34186 l_tmp_amt := NULL; -- 4262811
34187 --
34188
34189 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
34190 l_balance_type_code <> 'B' THEN
34191 IF NVL(p_source_15,'
34192 ') = 'TAX' AND
34193 NVL(p_source_54,'
34194 ') = 'N'
34195 THEN
34196
34197 --
34198 XLA_AE_LINES_PKG.SetNewLine;
34199
34200 p_balance_type_code := l_balance_type_code;
34201 -- set the flag so later we will know whether the gain loss line needs to be created
34202
34203 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
34204 p_actual_flag :='A';
34205 END IF;
34206
34207 --
34208 -- bulk performance
34209 --
34210 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
34211 p_header_num => 0); -- 4262811
34212 --
34213 -- set accounting line options
34214 --
34215 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
34216 p_natural_side_code => 'C'
34217 , p_gain_or_loss_flag => 'N'
34218 , p_gl_transfer_mode_code => 'S'
34219 , p_acct_entry_type_code => 'A'
34220 , p_switch_side_flag => 'Y'
34221 , p_merge_duplicate_code => 'A'
34222 );
34223 --
34224 l_acc_rev_natural_side_code := 'D'; -- 4262811
34225 --
34226 --
34227 -- set accounting line type info
34228 --
34229 xla_ae_lines_pkg.SetAcctLineType
34230 (p_component_type => l_component_type
34231 ,p_event_type_code => l_event_type_code
34232 ,p_line_definition_owner_code => l_line_definition_owner_code
34233 ,p_line_definition_code => l_line_definition_code
34234 ,p_accounting_line_code => l_component_code
34235 ,p_accounting_line_type_code => l_component_type_code
34236 ,p_accounting_line_appl_id => l_component_appl_id
34237 ,p_amb_context_code => l_amb_context_code
34238 ,p_entity_code => l_entity_code
34239 ,p_event_class_code => l_event_class_code);
34240 --
34241 -- set accounting class
34242 --
34243 xla_ae_lines_pkg.SetAcctClass(
34244 p_accounting_class_code => 'TAX'
34245 , p_ae_header_id => l_ae_header_id
34246 );
34247
34248 --
34249 -- set rounding class
34250 --
34251 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
34252 'RECEIVABLE';
34253
34254 --
34255 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
34256 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
34257 --
34258 -- bulk performance
34259 --
34260 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
34261
34262 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
34263 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
34264
34265 -- 4955764
34266 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34270
34267 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
34268
34269 -- 4458381 Public Sector Enh
34271 --
34272 -- set accounting attributes for the line type
34273 --
34274 l_entered_amt_idx := 3;
34275 l_accted_amt_idx := 8;
34276 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34277 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
34278 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_17);
34279 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
34280 l_rec_acct_attrs.array_char_value(2) := p_source_18;
34281 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
34282 l_rec_acct_attrs.array_num_value(3) := p_source_19;
34283 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
34284 l_rec_acct_attrs.array_char_value(4) := p_source_20;
34285 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
34286 l_rec_acct_attrs.array_date_value(5) := p_source_55;
34287 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
34288 l_rec_acct_attrs.array_num_value(6) := p_source_22;
34289 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
34290 l_rec_acct_attrs.array_char_value(7) := p_source_23;
34291 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
34292 l_rec_acct_attrs.array_num_value(8) := p_source_24;
34293
34294 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
34295 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
34296
34297 ---------------------------------------------------------------------------------------------------------------
34298 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
34299 ---------------------------------------------------------------------------------------------------------------
34300 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
34301
34302 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34303 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34304
34305 IF xla_accounting_cache_pkg.GetValueChar
34306 (p_source_code => 'LEDGER_CATEGORY_CODE'
34307 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
34308 AND l_bflow_method_code = 'PRIOR_ENTRY'
34309 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
34310 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
34311 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
34312 )
34313 THEN
34314 xla_ae_lines_pkg.BflowUpgEntry
34315 (p_business_method_code => l_bflow_method_code
34316 ,p_business_class_code => l_bflow_class_code
34317 ,p_balance_type => l_balance_type_code);
34318 ELSE
34319 NULL;
34320 -- No business flow processing for business flow method of NONE.
34321 END IF;
34322
34323 --
34324 -- call analytical criteria
34325 --
34326
34327 --
34328 -- call description
34329 --
34330 -- No description or it is inherited.
34331 --
34332 -- call ADRs
34333 -- Bug 4922099
34334 --
34335 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
34336 (NVL(l_actual_upg_option, 'N') = 'O') OR
34337 (NVL(l_enc_upg_option, 'N') = 'O')
34338 )
34339 THEN
34340 NULL;
34341 --
34342 --
34343
34344 l_ccid := AcctDerRule_11(
34345 p_application_id => p_application_id
34346 , p_ae_header_id => l_ae_header_id
34347 , p_source_10 => p_source_10
34348 , x_transaction_coa_id => l_adr_transaction_coa_id
34349 , x_accounting_coa_id => l_adr_accounting_coa_id
34350 , x_value_type_code => l_adr_value_type_code
34351 , p_side => 'NA'
34352 );
34353
34354 xla_ae_lines_pkg.set_ccid(
34355 p_code_combination_id => l_ccid
34356 , p_value_type_code => l_adr_value_type_code
34357 , p_transaction_coa_id => l_adr_transaction_coa_id
34358 , p_accounting_coa_id => l_adr_accounting_coa_id
34359 , p_adr_code => 'DIST_CCID'
34360 , p_adr_type_code => 'S'
34361 , p_component_type => l_component_type
34362 , p_component_code => l_component_code
34363 , p_component_type_code => l_component_type_code
34364 , p_component_appl_id => l_component_appl_id
34365 , p_amb_context_code => l_amb_context_code
34366 , p_side => 'NA'
34367 );
34368
34369
34370 --
34371 --
34372 END IF;
34373 --
34374 -- Bug 4922099
34375 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
34376 (NVL(l_enc_upg_option, 'N') = 'O')
34377 ) AND
34378 (l_bflow_method_code = 'PRIOR_ENTRY')
34379 )
34380 THEN
34381 IF
34382 --
34383 1 = 2
34384 --
34385 THEN
34386 xla_accounting_err_pkg.build_message
34387 (p_appli_s_name => 'XLA'
34388 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
34389 ,p_token_1 => 'LINE_NUMBER'
34390 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
34394 ,l_component_code
34391 ,p_token_2 => 'LINE_TYPE_NAME'
34392 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
34393 l_component_type
34395 ,l_component_type_code
34396 ,l_component_appl_id
34397 ,l_amb_context_code
34398 ,l_entity_code
34399 ,l_event_class_code
34400 )
34401 ,p_token_3 => 'OWNER'
34402 ,p_value_3 => xla_lookups_pkg.get_meaning(
34403 p_lookup_type => 'XLA_OWNER_TYPE'
34404 ,p_lookup_code => l_component_type_code
34405 )
34406 ,p_token_4 => 'PRODUCT_NAME'
34407 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
34408 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
34409 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
34410 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
34411 ,p_ae_header_id => NULL
34412 );
34413
34414 IF (C_LEVEL_ERROR>= g_log_level) THEN
34415 trace
34416 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
34417 ,p_level => C_LEVEL_ERROR
34418 ,p_module => l_log_module);
34419 END IF;
34420 END IF;
34421 END IF;
34422 --
34423 --
34424 ------------------------------------------------------------------------------------------------
34425 -- 4219869 Business Flow
34426 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
34427 -- Prior Entry. Currently, the following code is always generated.
34428 ------------------------------------------------------------------------------------------------
34429 XLA_AE_LINES_PKG.ValidateCurrentLine;
34430
34431 ------------------------------------------------------------------------------------
34432 -- 4219869 Business Flow
34433 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
34434 ------------------------------------------------------------------------------------
34435 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
34436
34437 ----------------------------------------------------------------------------------
34438 -- 4219869 Business Flow
34439 -- Update journal entry status -- Need to generate this within IF <condition>
34440 ----------------------------------------------------------------------------------
34441 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
34442 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
34443 ,p_balance_type_code => l_balance_type_code
34444 );
34445
34446 -------------------------------------------------------------------------------------------
34447 -- 4262811 - Generate the Accrual Reversal lines
34448 -------------------------------------------------------------------------------------------
34449 BEGIN
34450 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
34451 (g_array_event(p_event_id).array_value_num('header_index'));
34452 IF l_acc_rev_flag IS NULL THEN
34453 l_acc_rev_flag := 'N';
34454 END IF;
34455 EXCEPTION
34456 WHEN OTHERS THEN
34457 l_acc_rev_flag := 'N';
34458 END;
34459 --
34460 IF (l_acc_rev_flag = 'Y') THEN
34461
34462 -- 4645092 ------------------------------------------------------------------------------
34463 -- To allow MPA report to determine if it should generate report process
34464 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
34465 ------------------------------------------------------------------------------------------
34466
34467 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
34468 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
34469 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
34470 -- call ADRs
34471 -- Bug 4922099
34472 --
34473 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
34474 (NVL(l_actual_upg_option, 'N') = 'O') OR
34475 (NVL(l_enc_upg_option, 'N') = 'O')
34476 )
34477 THEN
34478 NULL;
34479 --
34480 --
34481
34482 l_ccid := AcctDerRule_11(
34483 p_application_id => p_application_id
34484 , p_ae_header_id => l_ae_header_id
34485 , p_source_10 => p_source_10
34486 , x_transaction_coa_id => l_adr_transaction_coa_id
34487 , x_accounting_coa_id => l_adr_accounting_coa_id
34488 , x_value_type_code => l_adr_value_type_code
34492 xla_ae_lines_pkg.set_ccid(
34489 , p_side => 'NA'
34490 );
34491
34493 p_code_combination_id => l_ccid
34494 , p_value_type_code => l_adr_value_type_code
34495 , p_transaction_coa_id => l_adr_transaction_coa_id
34496 , p_accounting_coa_id => l_adr_accounting_coa_id
34497 , p_adr_code => 'DIST_CCID'
34498 , p_adr_type_code => 'S'
34499 , p_component_type => l_component_type
34500 , p_component_code => l_component_code
34501 , p_component_type_code => l_component_type_code
34502 , p_component_appl_id => l_component_appl_id
34503 , p_amb_context_code => l_amb_context_code
34504 , p_side => 'NA'
34505 );
34506
34507
34508 --
34509 --
34510 END IF;
34511
34512 --
34513 -- Update the line information that should be overwritten
34514 --
34515 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
34516 p_header_num => 1);
34517 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
34518
34519 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
34520
34521 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
34522 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
34523 END IF;
34524
34525 --
34526 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
34527 --
34528 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
34529 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
34530 ELSE
34531 ---------------------------------------------------------------------------------------------------
34532 -- 4262811a Switch Sign
34533 ---------------------------------------------------------------------------------------------------
34534 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
34535 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34536 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34537 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34538 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34539 -- 5132302
34540 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
34541 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34542
34543 END IF;
34544
34545 -- 4955764
34546 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34547 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
34548
34549
34550 XLA_AE_LINES_PKG.ValidateCurrentLine;
34551 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
34552
34553 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
34554 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
34555 ,p_balance_type_code => l_balance_type_code);
34556
34557 END IF;
34558
34559 -----------------------------------------------------------------------------------------
34560 -- 4262811 Multiperiod Accounting
34561 -----------------------------------------------------------------------------------------
34562 -- No MPA option is assigned.
34563
34564
34565 END IF;
34566 END IF;
34567 --
34568
34569 --
34570 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34571 trace
34572 (p_msg => 'END of AcctLineType_73'
34573 ,p_level => C_LEVEL_PROCEDURE
34574 ,p_module => l_log_module);
34575 END IF;
34576 --
34577 EXCEPTION
34578 WHEN xla_exceptions_pkg.application_exception THEN
34579 RAISE;
34580 WHEN OTHERS THEN
34581 xla_exceptions_pkg.raise_message
34582 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_73');
34583 END AcctLineType_73;
34584 --
34585
34586 ---------------------------------------
34587 --
34588 -- PRIVATE FUNCTION
34589 -- AcctLineType_74
34590 --
34591 ---------------------------------------
34592 PROCEDURE AcctLineType_74 (
34593 p_application_id IN NUMBER
34594 ,p_event_id IN NUMBER
34595 ,p_calculate_acctd_flag IN VARCHAR2
34596 ,p_calculate_g_l_flag IN VARCHAR2
34597 ,p_actual_flag IN OUT VARCHAR2
34598 ,p_balance_type_code OUT VARCHAR2
34599 ,p_gain_or_loss_ref OUT VARCHAR2
34600
34601 --Distribution GL Account
34602 , p_source_10 IN NUMBER
34603 --Distribution Source Type
34604 , p_source_15 IN VARCHAR2
34605 --Distribution Line Identifier
34606 , p_source_17 IN NUMBER
34607 --Distribution Type
34608 , p_source_18 IN VARCHAR2
34609 --Exchange Date
34610 , p_source_21 IN DATE
34611 --Exchange Rate
34612 , p_source_22 IN NUMBER
34613 --Exchange Rate Type
34614 , p_source_23 IN VARCHAR2
34615 --Transaction Distribution Identifier
34619 --Distribution Multi Fund Additional Entry
34616 , p_source_29 IN NUMBER
34617 --Transaction Distribution Type
34618 , p_source_30 IN VARCHAR2
34620 , p_source_54 IN VARCHAR2
34621 --Receipt Applied To Application Identifier
34622 , p_source_58 IN NUMBER
34623 --Transaction Entity Code
34624 , p_source_59 IN VARCHAR2
34625 --Transaction Identifier
34626 , p_source_60 IN NUMBER
34627 --DIST_ENT_AMT_FROM
34628 , p_source_61 IN NUMBER
34629 --Applying Document Currency Code
34630 , p_source_62 IN VARCHAR2
34631 --Accounting Amount
34632 , p_source_63 IN NUMBER
34633 --Distribution Party Identifier
34634 , p_source_64 IN NUMBER
34635 --Distribution Party Site Id
34636 , p_source_65 IN NUMBER
34637 --Distribution Party Type
34638 , p_source_66 IN VARCHAR2
34639 )
34640 IS
34641
34642 l_component_type VARCHAR2(80);
34643 l_component_code VARCHAR2(30);
34644 l_component_type_code VARCHAR2(1);
34645 l_component_appl_id INTEGER;
34646 l_amb_context_code VARCHAR2(30);
34647 l_entity_code VARCHAR2(30);
34648 l_event_class_code VARCHAR2(30);
34649 l_ae_header_id NUMBER;
34650 l_event_type_code VARCHAR2(30);
34651 l_line_definition_code VARCHAR2(30);
34652 l_line_definition_owner_code VARCHAR2(1);
34653 --
34654 -- adr variables
34655 l_segment VARCHAR2(30);
34656 l_ccid NUMBER;
34657 l_adr_transaction_coa_id NUMBER;
34658 l_adr_accounting_coa_id NUMBER;
34659 l_adr_flexfield_segment_code VARCHAR2(30);
34660 l_adr_flex_value_set_id NUMBER;
34661 l_adr_value_type_code VARCHAR2(30);
34662 l_adr_value_combination_id NUMBER;
34663 l_adr_value_segment_code VARCHAR2(30);
34664
34665 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
34666 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
34667 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
34668 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
34669
34670 -- 4262811 Variables ------------------------------------------------------------------------------------------
34671 l_entered_amt_idx NUMBER;
34672 l_accted_amt_idx NUMBER;
34673 l_acc_rev_flag VARCHAR2(1);
34674 l_accrual_line_num NUMBER;
34675 l_tmp_amt NUMBER;
34676 l_acc_rev_natural_side_code VARCHAR2(1);
34677
34678 l_num_entries NUMBER;
34679 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
34680 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
34681 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
34682 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
34683 l_recog_line_1 NUMBER;
34684 l_recog_line_2 NUMBER;
34685
34686 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
34687 l_bflow_applied_to_amt NUMBER; -- 5132302
34688 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
34689
34690 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
34691
34692 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
34693 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
34694
34695 ---------------------------------------------------------------------------------------------------------------
34696
34697
34698 --
34699 -- bulk performance
34700 --
34701 l_balance_type_code VARCHAR2(1);
34702 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
34703 l_log_module VARCHAR2(240);
34704
34705 --
34706 -- Upgrade strategy
34707 --
34708 l_actual_upg_option VARCHAR2(1);
34709 l_enc_upg_option VARCHAR2(1);
34710
34711 --
34712 BEGIN
34713 --
34714 IF g_log_enabled THEN
34715 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_74';
34716 END IF;
34717 --
34718 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34719
34720 trace
34721 (p_msg => 'BEGIN of AcctLineType_74'
34722 ,p_level => C_LEVEL_PROCEDURE
34723 ,p_module => l_log_module);
34724
34725 END IF;
34726 --
34727 l_component_type := 'AMB_JLT';
34728 l_component_code := 'RCT_ACC';
34729 l_component_type_code := 'S';
34730 l_component_appl_id := 222;
34731 l_amb_context_code := 'DEFAULT';
34732 l_entity_code := 'RECEIPTS';
34733 l_event_class_code := 'RECEIPT';
34734 l_event_type_code := 'RECEIPT_ALL';
34735 l_line_definition_owner_code := 'S';
34736 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
34737 --
34738 l_balance_type_code := 'A';
34739 l_segment := NULL;
34740 l_ccid := NULL;
34741 l_adr_transaction_coa_id := NULL;
34742 l_adr_accounting_coa_id := NULL;
34743 l_adr_flexfield_segment_code := NULL;
34744 l_adr_flex_value_set_id := NULL;
34745 l_adr_value_type_code := NULL;
34746 l_adr_value_combination_id := NULL;
34747 l_adr_value_segment_code := NULL;
34748
34749 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
34753
34750 l_bflow_class_code := ''; -- 4219869 Business Flow
34751 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
34752 l_budgetary_control_flag := 'N';
34754 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34755 l_bflow_applied_to_amt := NULL; -- 5132302
34756 l_entered_amt_idx := NULL; -- 4262811
34757 l_accted_amt_idx := NULL; -- 4262811
34758 l_acc_rev_flag := NULL; -- 4262811
34759 l_accrual_line_num := NULL; -- 4262811
34760 l_tmp_amt := NULL; -- 4262811
34761 --
34762
34763 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
34764 l_balance_type_code <> 'B' THEN
34765 IF NVL(p_source_15,'
34766 ') = 'ACC' AND
34767 NVL(p_source_54,'
34768 ') = 'N'
34769 THEN
34770
34771 --
34772 XLA_AE_LINES_PKG.SetNewLine;
34773
34774 p_balance_type_code := l_balance_type_code;
34775 -- set the flag so later we will know whether the gain loss line needs to be created
34776
34777 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
34778 p_actual_flag :='A';
34779 END IF;
34780
34781 --
34782 -- bulk performance
34783 --
34784 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
34785 p_header_num => 0); -- 4262811
34786 --
34787 -- set accounting line options
34788 --
34789 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
34790 p_natural_side_code => 'C'
34791 , p_gain_or_loss_flag => 'N'
34792 , p_gl_transfer_mode_code => 'S'
34793 , p_acct_entry_type_code => 'A'
34794 , p_switch_side_flag => 'Y'
34795 , p_merge_duplicate_code => 'A'
34796 );
34797 --
34798 l_acc_rev_natural_side_code := 'D'; -- 4262811
34799 --
34800 --
34801 -- set accounting line type info
34802 --
34803 xla_ae_lines_pkg.SetAcctLineType
34804 (p_component_type => l_component_type
34805 ,p_event_type_code => l_event_type_code
34806 ,p_line_definition_owner_code => l_line_definition_owner_code
34807 ,p_line_definition_code => l_line_definition_code
34808 ,p_accounting_line_code => l_component_code
34809 ,p_accounting_line_type_code => l_component_type_code
34810 ,p_accounting_line_appl_id => l_component_appl_id
34811 ,p_amb_context_code => l_amb_context_code
34812 ,p_entity_code => l_entity_code
34813 ,p_event_class_code => l_event_class_code);
34814 --
34815 -- set accounting class
34816 --
34817 xla_ae_lines_pkg.SetAcctClass(
34818 p_accounting_class_code => 'ACC'
34819 , p_ae_header_id => l_ae_header_id
34820 );
34821
34822 --
34823 -- set rounding class
34824 --
34825 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
34826 'RECEIVABLE';
34827
34828 --
34829 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
34830 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
34831 --
34832 -- bulk performance
34833 --
34834 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
34835
34836 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
34837 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
34838
34839 -- 4955764
34840 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34841 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
34842
34843 -- 4458381 Public Sector Enh
34844
34845 --
34846 -- set accounting attributes for the line type
34847 --
34848 l_entered_amt_idx := 8;
34849 l_accted_amt_idx := 13;
34850 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34851 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
34852 l_rec_acct_attrs.array_num_value(1) := p_source_58;
34853 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
34854 l_rec_acct_attrs.array_char_value(2) := p_source_30;
34855 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
34856 l_rec_acct_attrs.array_char_value(3) := p_source_59;
34857 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
34858 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
34859 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
34860 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
34861 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
34862 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
34863 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
34864 l_rec_acct_attrs.array_char_value(7) := p_source_18;
34865 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
34866 l_rec_acct_attrs.array_num_value(8) := p_source_61;
34867 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
34868 l_rec_acct_attrs.array_char_value(9) := p_source_62;
34869 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
34870 l_rec_acct_attrs.array_date_value(10) := p_source_21;
34871 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
34872 l_rec_acct_attrs.array_num_value(11) := p_source_22;
34876 l_rec_acct_attrs.array_num_value(13) := p_source_63;
34873 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
34874 l_rec_acct_attrs.array_char_value(12) := p_source_23;
34875 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
34877 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
34878 l_rec_acct_attrs.array_num_value(14) := p_source_64;
34879 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
34880 l_rec_acct_attrs.array_num_value(15) := p_source_65;
34881 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
34882 l_rec_acct_attrs.array_char_value(16) := p_source_66;
34883
34884 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
34885 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
34886
34887 ---------------------------------------------------------------------------------------------------------------
34888 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
34889 ---------------------------------------------------------------------------------------------------------------
34890 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
34891
34892 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34893 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34894
34895 IF xla_accounting_cache_pkg.GetValueChar
34896 (p_source_code => 'LEDGER_CATEGORY_CODE'
34897 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
34898 AND l_bflow_method_code = 'PRIOR_ENTRY'
34899 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
34900 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
34901 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
34902 )
34903 THEN
34904 xla_ae_lines_pkg.BflowUpgEntry
34905 (p_business_method_code => l_bflow_method_code
34906 ,p_business_class_code => l_bflow_class_code
34907 ,p_balance_type => l_balance_type_code);
34908 ELSE
34909 NULL;
34910 -- No business flow processing for business flow method of NONE.
34911 END IF;
34912
34913 --
34914 -- call analytical criteria
34915 --
34916
34917 --
34918 -- call description
34919 --
34920 -- No description or it is inherited.
34921 --
34922 -- call ADRs
34923 -- Bug 4922099
34924 --
34925 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
34926 (NVL(l_actual_upg_option, 'N') = 'O') OR
34927 (NVL(l_enc_upg_option, 'N') = 'O')
34928 )
34929 THEN
34930 NULL;
34931 --
34932 --
34933
34934 l_ccid := AcctDerRule_11(
34935 p_application_id => p_application_id
34936 , p_ae_header_id => l_ae_header_id
34937 , p_source_10 => p_source_10
34938 , x_transaction_coa_id => l_adr_transaction_coa_id
34939 , x_accounting_coa_id => l_adr_accounting_coa_id
34940 , x_value_type_code => l_adr_value_type_code
34941 , p_side => 'NA'
34942 );
34943
34944 xla_ae_lines_pkg.set_ccid(
34945 p_code_combination_id => l_ccid
34946 , p_value_type_code => l_adr_value_type_code
34947 , p_transaction_coa_id => l_adr_transaction_coa_id
34948 , p_accounting_coa_id => l_adr_accounting_coa_id
34949 , p_adr_code => 'DIST_CCID'
34950 , p_adr_type_code => 'S'
34951 , p_component_type => l_component_type
34952 , p_component_code => l_component_code
34953 , p_component_type_code => l_component_type_code
34954 , p_component_appl_id => l_component_appl_id
34955 , p_amb_context_code => l_amb_context_code
34956 , p_side => 'NA'
34957 );
34958
34959
34960 --
34961 --
34962 END IF;
34963 --
34964 -- Bug 4922099
34965 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
34966 (NVL(l_enc_upg_option, 'N') = 'O')
34967 ) AND
34968 (l_bflow_method_code = 'PRIOR_ENTRY')
34969 )
34970 THEN
34971 IF
34972 --
34973 1 = 2
34974 --
34975 THEN
34976 xla_accounting_err_pkg.build_message
34977 (p_appli_s_name => 'XLA'
34978 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
34979 ,p_token_1 => 'LINE_NUMBER'
34980 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
34981 ,p_token_2 => 'LINE_TYPE_NAME'
34982 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
34983 l_component_type
34984 ,l_component_code
34985 ,l_component_type_code
34986 ,l_component_appl_id
34987 ,l_amb_context_code
34988 ,l_entity_code
34989 ,l_event_class_code
34993 p_lookup_type => 'XLA_OWNER_TYPE'
34990 )
34991 ,p_token_3 => 'OWNER'
34992 ,p_value_3 => xla_lookups_pkg.get_meaning(
34994 ,p_lookup_code => l_component_type_code
34995 )
34996 ,p_token_4 => 'PRODUCT_NAME'
34997 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
34998 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
34999 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
35000 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
35001 ,p_ae_header_id => NULL
35002 );
35003
35004 IF (C_LEVEL_ERROR>= g_log_level) THEN
35005 trace
35006 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35007 ,p_level => C_LEVEL_ERROR
35008 ,p_module => l_log_module);
35009 END IF;
35010 END IF;
35011 END IF;
35012 --
35013 --
35014 ------------------------------------------------------------------------------------------------
35015 -- 4219869 Business Flow
35016 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
35017 -- Prior Entry. Currently, the following code is always generated.
35018 ------------------------------------------------------------------------------------------------
35019 XLA_AE_LINES_PKG.ValidateCurrentLine;
35020
35021 ------------------------------------------------------------------------------------
35022 -- 4219869 Business Flow
35023 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
35024 ------------------------------------------------------------------------------------
35025 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35026
35027 ----------------------------------------------------------------------------------
35028 -- 4219869 Business Flow
35029 -- Update journal entry status -- Need to generate this within IF <condition>
35030 ----------------------------------------------------------------------------------
35031 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35032 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
35033 ,p_balance_type_code => l_balance_type_code
35034 );
35035
35036 -------------------------------------------------------------------------------------------
35037 -- 4262811 - Generate the Accrual Reversal lines
35038 -------------------------------------------------------------------------------------------
35039 BEGIN
35040 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
35041 (g_array_event(p_event_id).array_value_num('header_index'));
35042 IF l_acc_rev_flag IS NULL THEN
35043 l_acc_rev_flag := 'N';
35044 END IF;
35045 EXCEPTION
35046 WHEN OTHERS THEN
35047 l_acc_rev_flag := 'N';
35048 END;
35049 --
35050 IF (l_acc_rev_flag = 'Y') THEN
35051
35052 -- 4645092 ------------------------------------------------------------------------------
35053 -- To allow MPA report to determine if it should generate report process
35054 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
35055 ------------------------------------------------------------------------------------------
35056
35057 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
35058 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
35059 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
35060 -- call ADRs
35061 -- Bug 4922099
35062 --
35063 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35064 (NVL(l_actual_upg_option, 'N') = 'O') OR
35065 (NVL(l_enc_upg_option, 'N') = 'O')
35066 )
35067 THEN
35068 NULL;
35069 --
35070 --
35071
35072 l_ccid := AcctDerRule_11(
35073 p_application_id => p_application_id
35074 , p_ae_header_id => l_ae_header_id
35075 , p_source_10 => p_source_10
35076 , x_transaction_coa_id => l_adr_transaction_coa_id
35077 , x_accounting_coa_id => l_adr_accounting_coa_id
35078 , x_value_type_code => l_adr_value_type_code
35079 , p_side => 'NA'
35080 );
35081
35082 xla_ae_lines_pkg.set_ccid(
35083 p_code_combination_id => l_ccid
35084 , p_value_type_code => l_adr_value_type_code
35085 , p_transaction_coa_id => l_adr_transaction_coa_id
35086 , p_accounting_coa_id => l_adr_accounting_coa_id
35087 , p_adr_code => 'DIST_CCID'
35088 , p_adr_type_code => 'S'
35089 , p_component_type => l_component_type
35090 , p_component_code => l_component_code
35091 , p_component_type_code => l_component_type_code
35092 , p_component_appl_id => l_component_appl_id
35093 , p_amb_context_code => l_amb_context_code
35094 , p_side => 'NA'
35095 );
35096
35097
35098 --
35099 --
35100 END IF;
35101
35102 --
35103 -- Update the line information that should be overwritten
35104 --
35105 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
35106 p_header_num => 1);
35107 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
35108
35109 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
35110
35111 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
35112 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
35113 END IF;
35114
35115 --
35116 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
35117 --
35118 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
35119 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
35120 ELSE
35121 ---------------------------------------------------------------------------------------------------
35122 -- 4262811a Switch Sign
35123 ---------------------------------------------------------------------------------------------------
35124 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
35125 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35126 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35127 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35128 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35129 -- 5132302
35130 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
35131 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35132
35133 END IF;
35134
35135 -- 4955764
35136 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35137 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
35138
35139
35140 XLA_AE_LINES_PKG.ValidateCurrentLine;
35141 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35142
35143 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35144 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
35145 ,p_balance_type_code => l_balance_type_code);
35146
35147 END IF;
35148
35149 -----------------------------------------------------------------------------------------
35150 -- 4262811 Multiperiod Accounting
35151 -----------------------------------------------------------------------------------------
35152 -- No MPA option is assigned.
35153
35154
35155 END IF;
35156 END IF;
35157 --
35158
35159 --
35160 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35161 trace
35162 (p_msg => 'END of AcctLineType_74'
35163 ,p_level => C_LEVEL_PROCEDURE
35164 ,p_module => l_log_module);
35165 END IF;
35166 --
35167 EXCEPTION
35168 WHEN xla_exceptions_pkg.application_exception THEN
35169 RAISE;
35170 WHEN OTHERS THEN
35171 xla_exceptions_pkg.raise_message
35172 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_74');
35173 END AcctLineType_74;
35174 --
35175
35176 ---------------------------------------
35177 --
35178 -- PRIVATE FUNCTION
35179 -- AcctLineType_75
35180 --
35181 ---------------------------------------
35182 PROCEDURE AcctLineType_75 (
35183 p_application_id IN NUMBER
35184 ,p_event_id IN NUMBER
35185 ,p_calculate_acctd_flag IN VARCHAR2
35186 ,p_calculate_g_l_flag IN VARCHAR2
35187 ,p_actual_flag IN OUT VARCHAR2
35188 ,p_balance_type_code OUT VARCHAR2
35189 ,p_gain_or_loss_ref OUT VARCHAR2
35190
35191 --Remittance Bank Account Cash Account
35192 , p_source_5 IN NUMBER
35193 --Transaction Distribution GL Account
35194 , p_source_14 IN NUMBER
35195 --Distribution Source Type
35196 , p_source_15 IN VARCHAR2
35197 --Distribution Line Identifier
35198 , p_source_17 IN NUMBER
35199 --Distribution Type
35203 --Exchange Rate
35200 , p_source_18 IN VARCHAR2
35201 --Exchange Date
35202 , p_source_21 IN DATE
35204 , p_source_22 IN NUMBER
35205 --Exchange Rate Type
35206 , p_source_23 IN VARCHAR2
35207 --Transaction Distribution Account Class
35208 , p_source_28 IN VARCHAR2
35209 --Transaction Distribution Identifier
35210 , p_source_29 IN NUMBER
35211 --Transaction Distribution Type
35212 , p_source_30 IN VARCHAR2
35213 --Distribution Multi Fund Additional Entry
35214 , p_source_54 IN VARCHAR2
35215 --Receipt Class Require Remittance Flag
35216 , p_source_56 IN VARCHAR2
35217 --Receipt Class Confirm Flag
35218 , p_source_57 IN VARCHAR2
35219 --Receipt Applied To Application Identifier
35220 , p_source_58 IN NUMBER
35221 --Transaction Entity Code
35222 , p_source_59 IN VARCHAR2
35223 --Transaction Identifier
35224 , p_source_60 IN NUMBER
35225 --DIST_ENT_AMT_FROM
35226 , p_source_61 IN NUMBER
35227 --Applying Document Currency Code
35228 , p_source_62 IN VARCHAR2
35229 --Accounting Amount
35230 , p_source_63 IN NUMBER
35231 --Distribution Party Identifier
35232 , p_source_64 IN NUMBER
35233 --Distribution Party Site Id
35234 , p_source_65 IN NUMBER
35235 --Distribution Party Type
35236 , p_source_66 IN VARCHAR2
35237 )
35238 IS
35239
35240 l_component_type VARCHAR2(80);
35241 l_component_code VARCHAR2(30);
35242 l_component_type_code VARCHAR2(1);
35243 l_component_appl_id INTEGER;
35244 l_amb_context_code VARCHAR2(30);
35245 l_entity_code VARCHAR2(30);
35246 l_event_class_code VARCHAR2(30);
35247 l_ae_header_id NUMBER;
35248 l_event_type_code VARCHAR2(30);
35249 l_line_definition_code VARCHAR2(30);
35250 l_line_definition_owner_code VARCHAR2(1);
35251 --
35252 -- adr variables
35253 l_segment VARCHAR2(30);
35254 l_ccid NUMBER;
35255 l_adr_transaction_coa_id NUMBER;
35256 l_adr_accounting_coa_id NUMBER;
35257 l_adr_flexfield_segment_code VARCHAR2(30);
35258 l_adr_flex_value_set_id NUMBER;
35259 l_adr_value_type_code VARCHAR2(30);
35260 l_adr_value_combination_id NUMBER;
35261 l_adr_value_segment_code VARCHAR2(30);
35262
35263 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
35264 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
35265 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
35266 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
35267
35268 -- 4262811 Variables ------------------------------------------------------------------------------------------
35269 l_entered_amt_idx NUMBER;
35270 l_accted_amt_idx NUMBER;
35271 l_acc_rev_flag VARCHAR2(1);
35272 l_accrual_line_num NUMBER;
35273 l_tmp_amt NUMBER;
35274 l_acc_rev_natural_side_code VARCHAR2(1);
35275
35276 l_num_entries NUMBER;
35277 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
35278 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
35279 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
35280 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
35281 l_recog_line_1 NUMBER;
35282 l_recog_line_2 NUMBER;
35283
35284 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
35285 l_bflow_applied_to_amt NUMBER; -- 5132302
35286 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
35287
35288 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
35289
35290 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
35291 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
35292
35293 ---------------------------------------------------------------------------------------------------------------
35294
35295
35296 --
35297 -- bulk performance
35298 --
35299 l_balance_type_code VARCHAR2(1);
35300 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
35301 l_log_module VARCHAR2(240);
35302
35303 --
35304 -- Upgrade strategy
35305 --
35306 l_actual_upg_option VARCHAR2(1);
35307 l_enc_upg_option VARCHAR2(1);
35308
35309 --
35310 BEGIN
35311 --
35312 IF g_log_enabled THEN
35313 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_75';
35314 END IF;
35315 --
35316 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35317
35318 trace
35319 (p_msg => 'BEGIN of AcctLineType_75'
35320 ,p_level => C_LEVEL_PROCEDURE
35321 ,p_module => l_log_module);
35322
35323 END IF;
35324 --
35325 l_component_type := 'AMB_JLT';
35326 l_component_code := 'RCT_APP_MFAR_TRX_CASH';
35327 l_component_type_code := 'S';
35328 l_component_appl_id := 222;
35329 l_amb_context_code := 'DEFAULT';
35330 l_entity_code := 'RECEIPTS';
35331 l_event_class_code := 'RECEIPT';
35332 l_event_type_code := 'RECEIPT_ALL';
35333 l_line_definition_owner_code := 'S';
35337 l_segment := NULL;
35334 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
35335 --
35336 l_balance_type_code := 'A';
35338 l_ccid := NULL;
35339 l_adr_transaction_coa_id := NULL;
35340 l_adr_accounting_coa_id := NULL;
35341 l_adr_flexfield_segment_code := NULL;
35342 l_adr_flex_value_set_id := NULL;
35343 l_adr_value_type_code := NULL;
35344 l_adr_value_combination_id := NULL;
35345 l_adr_value_segment_code := NULL;
35346
35347 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
35348 l_bflow_class_code := ''; -- 4219869 Business Flow
35349 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
35350 l_budgetary_control_flag := 'N';
35351
35352 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35353 l_bflow_applied_to_amt := NULL; -- 5132302
35354 l_entered_amt_idx := NULL; -- 4262811
35355 l_accted_amt_idx := NULL; -- 4262811
35356 l_acc_rev_flag := NULL; -- 4262811
35357 l_accrual_line_num := NULL; -- 4262811
35358 l_tmp_amt := NULL; -- 4262811
35359 --
35360
35361 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
35362 l_balance_type_code <> 'B' THEN
35363 IF (NVL(p_source_28,'
35364 ') = 'REV' OR
35365 NVL(p_source_28,'
35366 ') = 'TAX' OR
35367 NVL(p_source_28,'
35368 ') = 'FREIGHT' OR
35369 NVL(p_source_28,'
35370 ') = 'CHARGES' OR
35371 NVL(p_source_28,'
35372 ') = 'ROUND') AND
35373 NVL(p_source_15,'
35374 ') = 'REC' AND
35375 NVL(p_source_54,'
35376 ') = 'N' AND
35377 NVL(p_source_56,'
35378 ') = 'N' AND
35379 NVL(p_source_57,'
35380 ') = 'N'
35381 THEN
35382
35383 --
35384 XLA_AE_LINES_PKG.SetNewLine;
35385
35386 p_balance_type_code := l_balance_type_code;
35387 -- set the flag so later we will know whether the gain loss line needs to be created
35388
35389 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
35390 p_actual_flag :='A';
35391 END IF;
35392
35393 --
35394 -- bulk performance
35395 --
35396 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
35397 p_header_num => 0); -- 4262811
35398 --
35399 -- set accounting line options
35400 --
35401 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
35402 p_natural_side_code => 'D'
35403 , p_gain_or_loss_flag => 'N'
35404 , p_gl_transfer_mode_code => 'S'
35405 , p_acct_entry_type_code => 'A'
35406 , p_switch_side_flag => 'Y'
35407 , p_merge_duplicate_code => 'A'
35408 );
35409 --
35410 l_acc_rev_natural_side_code := 'C'; -- 4262811
35411 --
35412 --
35413 -- set accounting line type info
35414 --
35415 xla_ae_lines_pkg.SetAcctLineType
35416 (p_component_type => l_component_type
35417 ,p_event_type_code => l_event_type_code
35418 ,p_line_definition_owner_code => l_line_definition_owner_code
35419 ,p_line_definition_code => l_line_definition_code
35420 ,p_accounting_line_code => l_component_code
35421 ,p_accounting_line_type_code => l_component_type_code
35422 ,p_accounting_line_appl_id => l_component_appl_id
35423 ,p_amb_context_code => l_amb_context_code
35424 ,p_entity_code => l_entity_code
35425 ,p_event_class_code => l_event_class_code);
35426 --
35427 -- set accounting class
35428 --
35429 xla_ae_lines_pkg.SetAcctClass(
35430 p_accounting_class_code => 'CASH'
35431 , p_ae_header_id => l_ae_header_id
35432 );
35433
35434 --
35435 -- set rounding class
35436 --
35437 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
35438 'RECEIVABLE';
35439
35440 --
35441 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
35442 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
35443 --
35444 -- bulk performance
35445 --
35446 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
35447
35448 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
35449 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
35450
35451 -- 4955764
35452 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35453 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
35454
35455 -- 4458381 Public Sector Enh
35456
35457 --
35458 -- set accounting attributes for the line type
35459 --
35460 l_entered_amt_idx := 8;
35461 l_accted_amt_idx := 13;
35462 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35463 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
35464 l_rec_acct_attrs.array_num_value(1) := p_source_58;
35465 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
35466 l_rec_acct_attrs.array_char_value(2) := p_source_30;
35467 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
35468 l_rec_acct_attrs.array_char_value(3) := p_source_59;
35469 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
35473 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
35470 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
35471 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
35472 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
35474 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
35475 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
35476 l_rec_acct_attrs.array_char_value(7) := p_source_18;
35477 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
35478 l_rec_acct_attrs.array_num_value(8) := p_source_61;
35479 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
35480 l_rec_acct_attrs.array_char_value(9) := p_source_62;
35481 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
35482 l_rec_acct_attrs.array_date_value(10) := p_source_21;
35483 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
35484 l_rec_acct_attrs.array_num_value(11) := p_source_22;
35485 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
35486 l_rec_acct_attrs.array_char_value(12) := p_source_23;
35487 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
35488 l_rec_acct_attrs.array_num_value(13) := p_source_63;
35489 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
35490 l_rec_acct_attrs.array_num_value(14) := p_source_64;
35491 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
35492 l_rec_acct_attrs.array_num_value(15) := p_source_65;
35493 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
35494 l_rec_acct_attrs.array_char_value(16) := p_source_66;
35495
35496 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
35497 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
35498
35499 ---------------------------------------------------------------------------------------------------------------
35500 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
35501 ---------------------------------------------------------------------------------------------------------------
35502 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
35503
35504 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
35505 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
35506
35507 IF xla_accounting_cache_pkg.GetValueChar
35508 (p_source_code => 'LEDGER_CATEGORY_CODE'
35509 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
35510 AND l_bflow_method_code = 'PRIOR_ENTRY'
35511 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
35512 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
35513 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
35514 )
35515 THEN
35516 xla_ae_lines_pkg.BflowUpgEntry
35517 (p_business_method_code => l_bflow_method_code
35518 ,p_business_class_code => l_bflow_class_code
35519 ,p_balance_type => l_balance_type_code);
35520 ELSE
35521 NULL;
35522 -- No business flow processing for business flow method of NONE.
35523 END IF;
35524
35525 --
35526 -- call analytical criteria
35527 --
35528
35529 --
35530 -- call description
35531 --
35532
35533 xla_ae_lines_pkg.SetLineDescription(
35534 p_ae_header_id => l_ae_header_id
35535 ,p_description => Description_1 (
35536 p_application_id => p_application_id
35537 , p_ae_header_id => l_ae_header_id
35538 )
35539 );
35540
35541
35542 --
35543 -- call ADRs
35544 -- Bug 4922099
35545 --
35546 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35547 (NVL(l_actual_upg_option, 'N') = 'O') OR
35548 (NVL(l_enc_upg_option, 'N') = 'O')
35549 )
35550 THEN
35551 NULL;
35552 --
35553 --
35554
35555 l_ccid := AcctDerRule_18(
35556 p_application_id => p_application_id
35557 , p_ae_header_id => l_ae_header_id
35558 , p_source_14 => p_source_14
35559 , x_transaction_coa_id => l_adr_transaction_coa_id
35560 , x_accounting_coa_id => l_adr_accounting_coa_id
35561 , x_value_type_code => l_adr_value_type_code
35562 , p_side => 'NA'
35563 );
35564
35565 xla_ae_lines_pkg.set_ccid(
35566 p_code_combination_id => l_ccid
35567 , p_value_type_code => l_adr_value_type_code
35568 , p_transaction_coa_id => l_adr_transaction_coa_id
35569 , p_accounting_coa_id => l_adr_accounting_coa_id
35570 , p_adr_code => 'TRX_DIST_CCID'
35571 , p_adr_type_code => 'S'
35572 , p_component_type => l_component_type
35573 , p_component_code => l_component_code
35574 , p_component_type_code => l_component_type_code
35575 , p_component_appl_id => l_component_appl_id
35576 , p_amb_context_code => l_amb_context_code
35577 , p_side => 'NA'
35578 );
35579
35580
35581 l_segment := AcctDerRule_6(
35582 p_application_id => p_application_id
35583 , p_ae_header_id => l_ae_header_id
35584 , p_source_5 => p_source_5
35585 , x_transaction_coa_id => l_adr_transaction_coa_id
35586 , x_accounting_coa_id => l_adr_accounting_coa_id
35587 , x_flexfield_segment_code => l_adr_flexfield_segment_code
35591 , x_value_segment_code => l_adr_value_segment_code
35588 , x_flex_value_set_id => l_adr_flex_value_set_id
35589 , x_value_type_code => l_adr_value_type_code
35590 , x_value_combination_id => l_adr_value_combination_id
35592 , p_side => 'NA'
35593 , p_override_seg_flag => 'Y'
35594 );
35595
35596 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
35597
35598 xla_ae_lines_pkg.set_segment(
35599 p_to_segment_code => 'GL_ACCOUNT'
35600 , p_segment_value => l_segment
35601 , p_from_segment_code => l_adr_value_segment_code
35602 , p_from_combination_id => l_adr_value_combination_id
35603 , p_value_type_code => l_adr_value_type_code
35604 , p_transaction_coa_id => l_adr_transaction_coa_id
35605 , p_accounting_coa_id => l_adr_accounting_coa_id
35606 , p_flexfield_segment_code => l_adr_flexfield_segment_code
35607 , p_flex_value_set_id => l_adr_flex_value_set_id
35608 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
35609 , p_adr_type_code => 'S'
35610 , p_component_type => l_component_type
35611 , p_component_code => l_component_code
35612 , p_component_type_code => l_component_type_code
35613 , p_component_appl_id => l_component_appl_id
35614 , p_amb_context_code => l_amb_context_code
35615 , p_entity_code => 'RECEIPTS'
35616 , p_event_class_code => 'RECEIPT'
35617 , p_side => 'NA'
35618 );
35619
35620 END IF;
35621
35622 --
35623 --
35624 END IF;
35625 --
35626 -- Bug 4922099
35627 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
35628 (NVL(l_enc_upg_option, 'N') = 'O')
35629 ) AND
35630 (l_bflow_method_code = 'PRIOR_ENTRY')
35631 )
35632 THEN
35633 IF
35634 --
35635 1 = 2
35636 --
35637 THEN
35638 xla_accounting_err_pkg.build_message
35639 (p_appli_s_name => 'XLA'
35640 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35641 ,p_token_1 => 'LINE_NUMBER'
35642 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
35643 ,p_token_2 => 'LINE_TYPE_NAME'
35644 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
35645 l_component_type
35646 ,l_component_code
35647 ,l_component_type_code
35648 ,l_component_appl_id
35649 ,l_amb_context_code
35650 ,l_entity_code
35651 ,l_event_class_code
35652 )
35653 ,p_token_3 => 'OWNER'
35654 ,p_value_3 => xla_lookups_pkg.get_meaning(
35655 p_lookup_type => 'XLA_OWNER_TYPE'
35656 ,p_lookup_code => l_component_type_code
35657 )
35658 ,p_token_4 => 'PRODUCT_NAME'
35659 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
35660 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
35661 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
35662 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
35663 ,p_ae_header_id => NULL
35664 );
35665
35666 IF (C_LEVEL_ERROR>= g_log_level) THEN
35667 trace
35668 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35669 ,p_level => C_LEVEL_ERROR
35670 ,p_module => l_log_module);
35671 END IF;
35672 END IF;
35673 END IF;
35674 --
35675 --
35676 ------------------------------------------------------------------------------------------------
35677 -- 4219869 Business Flow
35678 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
35679 -- Prior Entry. Currently, the following code is always generated.
35680 ------------------------------------------------------------------------------------------------
35681 XLA_AE_LINES_PKG.ValidateCurrentLine;
35682
35683 ------------------------------------------------------------------------------------
35684 -- 4219869 Business Flow
35685 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
35686 ------------------------------------------------------------------------------------
35687 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35688
35689 ----------------------------------------------------------------------------------
35690 -- 4219869 Business Flow
35694 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
35691 -- Update journal entry status -- Need to generate this within IF <condition>
35692 ----------------------------------------------------------------------------------
35693 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35695 ,p_balance_type_code => l_balance_type_code
35696 );
35697
35698 -------------------------------------------------------------------------------------------
35699 -- 4262811 - Generate the Accrual Reversal lines
35700 -------------------------------------------------------------------------------------------
35701 BEGIN
35702 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
35703 (g_array_event(p_event_id).array_value_num('header_index'));
35704 IF l_acc_rev_flag IS NULL THEN
35705 l_acc_rev_flag := 'N';
35706 END IF;
35707 EXCEPTION
35708 WHEN OTHERS THEN
35709 l_acc_rev_flag := 'N';
35710 END;
35711 --
35712 IF (l_acc_rev_flag = 'Y') THEN
35713
35714 -- 4645092 ------------------------------------------------------------------------------
35715 -- To allow MPA report to determine if it should generate report process
35716 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
35717 ------------------------------------------------------------------------------------------
35718
35719 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
35720 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
35721 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
35722 -- call ADRs
35723 -- Bug 4922099
35724 --
35725 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35726 (NVL(l_actual_upg_option, 'N') = 'O') OR
35727 (NVL(l_enc_upg_option, 'N') = 'O')
35728 )
35729 THEN
35730 NULL;
35731 --
35732 --
35733
35734 l_ccid := AcctDerRule_18(
35735 p_application_id => p_application_id
35736 , p_ae_header_id => l_ae_header_id
35737 , p_source_14 => p_source_14
35738 , x_transaction_coa_id => l_adr_transaction_coa_id
35739 , x_accounting_coa_id => l_adr_accounting_coa_id
35740 , x_value_type_code => l_adr_value_type_code
35741 , p_side => 'NA'
35742 );
35743
35744 xla_ae_lines_pkg.set_ccid(
35745 p_code_combination_id => l_ccid
35746 , p_value_type_code => l_adr_value_type_code
35747 , p_transaction_coa_id => l_adr_transaction_coa_id
35748 , p_accounting_coa_id => l_adr_accounting_coa_id
35749 , p_adr_code => 'TRX_DIST_CCID'
35750 , p_adr_type_code => 'S'
35751 , p_component_type => l_component_type
35752 , p_component_code => l_component_code
35753 , p_component_type_code => l_component_type_code
35754 , p_component_appl_id => l_component_appl_id
35755 , p_amb_context_code => l_amb_context_code
35756 , p_side => 'NA'
35757 );
35758
35759
35760 l_segment := AcctDerRule_6(
35761 p_application_id => p_application_id
35762 , p_ae_header_id => l_ae_header_id
35763 , p_source_5 => p_source_5
35764 , x_transaction_coa_id => l_adr_transaction_coa_id
35765 , x_accounting_coa_id => l_adr_accounting_coa_id
35766 , x_flexfield_segment_code => l_adr_flexfield_segment_code
35767 , x_flex_value_set_id => l_adr_flex_value_set_id
35768 , x_value_type_code => l_adr_value_type_code
35769 , x_value_combination_id => l_adr_value_combination_id
35770 , x_value_segment_code => l_adr_value_segment_code
35771 , p_side => 'NA'
35772 , p_override_seg_flag => 'Y'
35773 );
35774
35775 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
35776
35777 xla_ae_lines_pkg.set_segment(
35778 p_to_segment_code => 'GL_ACCOUNT'
35779 , p_segment_value => l_segment
35780 , p_from_segment_code => l_adr_value_segment_code
35781 , p_from_combination_id => l_adr_value_combination_id
35782 , p_value_type_code => l_adr_value_type_code
35783 , p_transaction_coa_id => l_adr_transaction_coa_id
35784 , p_accounting_coa_id => l_adr_accounting_coa_id
35785 , p_flexfield_segment_code => l_adr_flexfield_segment_code
35786 , p_flex_value_set_id => l_adr_flex_value_set_id
35787 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
35788 , p_adr_type_code => 'S'
35789 , p_component_type => l_component_type
35790 , p_component_code => l_component_code
35791 , p_component_type_code => l_component_type_code
35792 , p_component_appl_id => l_component_appl_id
35793 , p_amb_context_code => l_amb_context_code
35794 , p_entity_code => 'RECEIPTS'
35795 , p_event_class_code => 'RECEIPT'
35796 , p_side => 'NA'
35797 );
35798
35799 END IF;
35800
35801 --
35802 --
35803 END IF;
35804
35805 --
35806 -- Update the line information that should be overwritten
35807 --
35808 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
35809 p_header_num => 1);
35810 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
35811
35815 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
35812 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
35813
35814 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
35816 END IF;
35817
35818 --
35819 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
35820 --
35821 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
35822 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
35823 ELSE
35824 ---------------------------------------------------------------------------------------------------
35825 -- 4262811a Switch Sign
35826 ---------------------------------------------------------------------------------------------------
35827 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
35828 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35829 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35830 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35831 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35832 -- 5132302
35833 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
35834 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35835
35836 END IF;
35837
35838 -- 4955764
35839 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35840 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
35841
35842
35843 XLA_AE_LINES_PKG.ValidateCurrentLine;
35844 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35845
35846 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35847 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
35848 ,p_balance_type_code => l_balance_type_code);
35849
35850 END IF;
35851
35852 -----------------------------------------------------------------------------------------
35853 -- 4262811 Multiperiod Accounting
35854 -----------------------------------------------------------------------------------------
35855 -- No MPA option is assigned.
35856
35857
35858 END IF;
35859 END IF;
35860 --
35861
35862 --
35863 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35864 trace
35865 (p_msg => 'END of AcctLineType_75'
35866 ,p_level => C_LEVEL_PROCEDURE
35867 ,p_module => l_log_module);
35868 END IF;
35869 --
35870 EXCEPTION
35871 WHEN xla_exceptions_pkg.application_exception THEN
35872 RAISE;
35873 WHEN OTHERS THEN
35874 xla_exceptions_pkg.raise_message
35875 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_75');
35876 END AcctLineType_75;
35877 --
35878
35879 ---------------------------------------
35880 --
35881 -- PRIVATE FUNCTION
35882 -- AcctLineType_76
35883 --
35884 ---------------------------------------
35885 PROCEDURE AcctLineType_76 (
35886 p_application_id IN NUMBER
35887 ,p_event_id IN NUMBER
35888 ,p_calculate_acctd_flag IN VARCHAR2
35889 ,p_calculate_g_l_flag IN VARCHAR2
35890 ,p_actual_flag IN OUT VARCHAR2
35891 ,p_balance_type_code OUT VARCHAR2
35892 ,p_gain_or_loss_ref OUT VARCHAR2
35893
35894 --Remittance Bank Account Cash Account
35895 , p_source_5 IN NUMBER
35896 --Transaction Distribution GL Account
35897 , p_source_14 IN NUMBER
35898 --Distribution Source Type
35899 , p_source_15 IN VARCHAR2
35900 --Distribution Line Identifier
35901 , p_source_17 IN NUMBER
35902 --Distribution Type
35903 , p_source_18 IN VARCHAR2
35904 --Exchange Date
35905 , p_source_21 IN DATE
35906 --Exchange Rate
35907 , p_source_22 IN NUMBER
35908 --Exchange Rate Type
35909 , p_source_23 IN VARCHAR2
35910 --Transaction Distribution Identifier
35911 , p_source_29 IN NUMBER
35912 --Transaction Distribution Type
35913 , p_source_30 IN VARCHAR2
35914 --Distribution Multi Fund Additional Entry
35915 , p_source_54 IN VARCHAR2
35916 --Receipt Class Require Remittance Flag
35917 , p_source_56 IN VARCHAR2
35918 --Receipt Applied To Application Identifier
35919 , p_source_58 IN NUMBER
35920 --Transaction Entity Code
35921 , p_source_59 IN VARCHAR2
35922 --Transaction Identifier
35923 , p_source_60 IN NUMBER
35924 --DIST_ENT_AMT_FROM
35925 , p_source_61 IN NUMBER
35926 --Applying Document Currency Code
35927 , p_source_62 IN VARCHAR2
35928 --Accounting Amount
35929 , p_source_63 IN NUMBER
35930 --Distribution Party Identifier
35931 , p_source_64 IN NUMBER
35932 --Distribution Party Site Id
35933 , p_source_65 IN NUMBER
35934 --Distribution Party Type
35935 , p_source_66 IN VARCHAR2
35936 )
35937 IS
35938
35939 l_component_type VARCHAR2(80);
35940 l_component_code VARCHAR2(30);
35941 l_component_type_code VARCHAR2(1);
35942 l_component_appl_id INTEGER;
35943 l_amb_context_code VARCHAR2(30);
35944 l_entity_code VARCHAR2(30);
35948 l_line_definition_code VARCHAR2(30);
35945 l_event_class_code VARCHAR2(30);
35946 l_ae_header_id NUMBER;
35947 l_event_type_code VARCHAR2(30);
35949 l_line_definition_owner_code VARCHAR2(1);
35950 --
35951 -- adr variables
35952 l_segment VARCHAR2(30);
35953 l_ccid NUMBER;
35954 l_adr_transaction_coa_id NUMBER;
35955 l_adr_accounting_coa_id NUMBER;
35956 l_adr_flexfield_segment_code VARCHAR2(30);
35957 l_adr_flex_value_set_id NUMBER;
35958 l_adr_value_type_code VARCHAR2(30);
35959 l_adr_value_combination_id NUMBER;
35960 l_adr_value_segment_code VARCHAR2(30);
35961
35962 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
35963 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
35964 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
35965 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
35966
35967 -- 4262811 Variables ------------------------------------------------------------------------------------------
35968 l_entered_amt_idx NUMBER;
35969 l_accted_amt_idx NUMBER;
35970 l_acc_rev_flag VARCHAR2(1);
35971 l_accrual_line_num NUMBER;
35972 l_tmp_amt NUMBER;
35973 l_acc_rev_natural_side_code VARCHAR2(1);
35974
35975 l_num_entries NUMBER;
35976 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
35977 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
35978 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
35979 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
35980 l_recog_line_1 NUMBER;
35981 l_recog_line_2 NUMBER;
35982
35983 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
35984 l_bflow_applied_to_amt NUMBER; -- 5132302
35985 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
35986
35987 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
35988
35989 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
35990 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
35991
35992 ---------------------------------------------------------------------------------------------------------------
35993
35994
35995 --
35996 -- bulk performance
35997 --
35998 l_balance_type_code VARCHAR2(1);
35999 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
36000 l_log_module VARCHAR2(240);
36001
36002 --
36003 -- Upgrade strategy
36004 --
36005 l_actual_upg_option VARCHAR2(1);
36006 l_enc_upg_option VARCHAR2(1);
36007
36008 --
36009 BEGIN
36010 --
36011 IF g_log_enabled THEN
36012 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_76';
36013 END IF;
36014 --
36015 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36016
36017 trace
36018 (p_msg => 'BEGIN of AcctLineType_76'
36019 ,p_level => C_LEVEL_PROCEDURE
36020 ,p_module => l_log_module);
36021
36022 END IF;
36023 --
36024 l_component_type := 'AMB_JLT';
36025 l_component_code := 'RCT_APP_MFAR_TRX_CM_CASH';
36026 l_component_type_code := 'S';
36027 l_component_appl_id := 222;
36028 l_amb_context_code := 'DEFAULT';
36029 l_entity_code := 'RECEIPTS';
36030 l_event_class_code := 'RECEIPT';
36031 l_event_type_code := 'RECEIPT_ALL';
36032 l_line_definition_owner_code := 'S';
36033 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
36034 --
36035 l_balance_type_code := 'A';
36036 l_segment := NULL;
36037 l_ccid := NULL;
36038 l_adr_transaction_coa_id := NULL;
36039 l_adr_accounting_coa_id := NULL;
36040 l_adr_flexfield_segment_code := NULL;
36041 l_adr_flex_value_set_id := NULL;
36042 l_adr_value_type_code := NULL;
36043 l_adr_value_combination_id := NULL;
36044 l_adr_value_segment_code := NULL;
36045
36046 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
36047 l_bflow_class_code := ''; -- 4219869 Business Flow
36048 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
36049 l_budgetary_control_flag := 'N';
36050
36051 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36052 l_bflow_applied_to_amt := NULL; -- 5132302
36053 l_entered_amt_idx := NULL; -- 4262811
36054 l_accted_amt_idx := NULL; -- 4262811
36055 l_acc_rev_flag := NULL; -- 4262811
36056 l_accrual_line_num := NULL; -- 4262811
36057 l_tmp_amt := NULL; -- 4262811
36058 --
36059
36063 ') = 'CASH' AND
36060 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
36061 l_balance_type_code <> 'B' THEN
36062 IF NVL(p_source_15,'
36064 NVL(p_source_54,'
36065 ') = 'Y' AND
36066 NVL(p_source_56,'
36067 ') = 'Y'
36068 THEN
36069
36070 --
36071 XLA_AE_LINES_PKG.SetNewLine;
36072
36073 p_balance_type_code := l_balance_type_code;
36074 -- set the flag so later we will know whether the gain loss line needs to be created
36075
36076 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
36077 p_actual_flag :='A';
36078 END IF;
36079
36080 --
36081 -- bulk performance
36082 --
36083 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
36084 p_header_num => 0); -- 4262811
36085 --
36086 -- set accounting line options
36087 --
36088 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
36089 p_natural_side_code => 'C'
36090 , p_gain_or_loss_flag => 'N'
36091 , p_gl_transfer_mode_code => 'S'
36092 , p_acct_entry_type_code => 'A'
36093 , p_switch_side_flag => 'Y'
36094 , p_merge_duplicate_code => 'A'
36095 );
36096 --
36097 l_acc_rev_natural_side_code := 'D'; -- 4262811
36098 --
36099 --
36100 -- set accounting line type info
36101 --
36102 xla_ae_lines_pkg.SetAcctLineType
36103 (p_component_type => l_component_type
36104 ,p_event_type_code => l_event_type_code
36105 ,p_line_definition_owner_code => l_line_definition_owner_code
36106 ,p_line_definition_code => l_line_definition_code
36107 ,p_accounting_line_code => l_component_code
36108 ,p_accounting_line_type_code => l_component_type_code
36109 ,p_accounting_line_appl_id => l_component_appl_id
36110 ,p_amb_context_code => l_amb_context_code
36111 ,p_entity_code => l_entity_code
36112 ,p_event_class_code => l_event_class_code);
36113 --
36114 -- set accounting class
36115 --
36116 xla_ae_lines_pkg.SetAcctClass(
36117 p_accounting_class_code => 'CASH'
36118 , p_ae_header_id => l_ae_header_id
36119 );
36120
36121 --
36122 -- set rounding class
36123 --
36124 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
36125 'RECEIVABLE';
36126
36127 --
36128 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
36129 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
36130 --
36131 -- bulk performance
36132 --
36133 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
36134
36135 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
36136 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
36137
36138 -- 4955764
36139 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36140 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
36141
36142 -- 4458381 Public Sector Enh
36143
36144 --
36145 -- set accounting attributes for the line type
36146 --
36147 l_entered_amt_idx := 8;
36148 l_accted_amt_idx := 13;
36149 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36150 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
36151 l_rec_acct_attrs.array_num_value(1) := p_source_58;
36152 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
36153 l_rec_acct_attrs.array_char_value(2) := p_source_30;
36154 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
36155 l_rec_acct_attrs.array_char_value(3) := p_source_59;
36156 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
36157 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
36158 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
36159 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
36163 l_rec_acct_attrs.array_char_value(7) := p_source_18;
36160 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
36161 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
36162 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
36164 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
36165 l_rec_acct_attrs.array_num_value(8) := p_source_61;
36166 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
36167 l_rec_acct_attrs.array_char_value(9) := p_source_62;
36168 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
36169 l_rec_acct_attrs.array_date_value(10) := p_source_21;
36170 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
36171 l_rec_acct_attrs.array_num_value(11) := p_source_22;
36172 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
36173 l_rec_acct_attrs.array_char_value(12) := p_source_23;
36174 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
36175 l_rec_acct_attrs.array_num_value(13) := p_source_63;
36176 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
36177 l_rec_acct_attrs.array_num_value(14) := p_source_64;
36178 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
36179 l_rec_acct_attrs.array_num_value(15) := p_source_65;
36180 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
36181 l_rec_acct_attrs.array_char_value(16) := p_source_66;
36182
36183 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
36184 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
36185
36186 ---------------------------------------------------------------------------------------------------------------
36187 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
36188 ---------------------------------------------------------------------------------------------------------------
36189 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
36190
36191 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36192 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36193
36194 IF xla_accounting_cache_pkg.GetValueChar
36195 (p_source_code => 'LEDGER_CATEGORY_CODE'
36196 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
36197 AND l_bflow_method_code = 'PRIOR_ENTRY'
36198 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
36199 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
36200 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
36201 )
36202 THEN
36203 xla_ae_lines_pkg.BflowUpgEntry
36204 (p_business_method_code => l_bflow_method_code
36205 ,p_business_class_code => l_bflow_class_code
36206 ,p_balance_type => l_balance_type_code);
36207 ELSE
36208 NULL;
36209 -- No business flow processing for business flow method of NONE.
36210 END IF;
36211
36212 --
36213 -- call analytical criteria
36214 --
36215
36216 --
36217 -- call description
36218 --
36219
36220 xla_ae_lines_pkg.SetLineDescription(
36221 p_ae_header_id => l_ae_header_id
36222 ,p_description => Description_1 (
36223 p_application_id => p_application_id
36224 , p_ae_header_id => l_ae_header_id
36225 )
36226 );
36227
36228
36229 --
36230 -- call ADRs
36231 -- Bug 4922099
36232 --
36233 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36234 (NVL(l_actual_upg_option, 'N') = 'O') OR
36235 (NVL(l_enc_upg_option, 'N') = 'O')
36236 )
36237 THEN
36238 NULL;
36239 --
36240 --
36241
36242 l_ccid := AcctDerRule_18(
36243 p_application_id => p_application_id
36244 , p_ae_header_id => l_ae_header_id
36245 , p_source_14 => p_source_14
36246 , x_transaction_coa_id => l_adr_transaction_coa_id
36247 , x_accounting_coa_id => l_adr_accounting_coa_id
36248 , x_value_type_code => l_adr_value_type_code
36249 , p_side => 'NA'
36250 );
36251
36252 xla_ae_lines_pkg.set_ccid(
36253 p_code_combination_id => l_ccid
36254 , p_value_type_code => l_adr_value_type_code
36255 , p_transaction_coa_id => l_adr_transaction_coa_id
36256 , p_accounting_coa_id => l_adr_accounting_coa_id
36257 , p_adr_code => 'TRX_DIST_CCID'
36258 , p_adr_type_code => 'S'
36259 , p_component_type => l_component_type
36260 , p_component_code => l_component_code
36261 , p_component_type_code => l_component_type_code
36262 , p_component_appl_id => l_component_appl_id
36263 , p_amb_context_code => l_amb_context_code
36264 , p_side => 'NA'
36265 );
36266
36267
36268 l_segment := AcctDerRule_6(
36269 p_application_id => p_application_id
36270 , p_ae_header_id => l_ae_header_id
36271 , p_source_5 => p_source_5
36272 , x_transaction_coa_id => l_adr_transaction_coa_id
36273 , x_accounting_coa_id => l_adr_accounting_coa_id
36274 , x_flexfield_segment_code => l_adr_flexfield_segment_code
36275 , x_flex_value_set_id => l_adr_flex_value_set_id
36276 , x_value_type_code => l_adr_value_type_code
36277 , x_value_combination_id => l_adr_value_combination_id
36281 );
36278 , x_value_segment_code => l_adr_value_segment_code
36279 , p_side => 'NA'
36280 , p_override_seg_flag => 'Y'
36282
36283 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
36284
36285 xla_ae_lines_pkg.set_segment(
36286 p_to_segment_code => 'GL_ACCOUNT'
36287 , p_segment_value => l_segment
36288 , p_from_segment_code => l_adr_value_segment_code
36289 , p_from_combination_id => l_adr_value_combination_id
36290 , p_value_type_code => l_adr_value_type_code
36291 , p_transaction_coa_id => l_adr_transaction_coa_id
36292 , p_accounting_coa_id => l_adr_accounting_coa_id
36293 , p_flexfield_segment_code => l_adr_flexfield_segment_code
36294 , p_flex_value_set_id => l_adr_flex_value_set_id
36295 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
36296 , p_adr_type_code => 'S'
36297 , p_component_type => l_component_type
36298 , p_component_code => l_component_code
36299 , p_component_type_code => l_component_type_code
36300 , p_component_appl_id => l_component_appl_id
36301 , p_amb_context_code => l_amb_context_code
36302 , p_entity_code => 'RECEIPTS'
36303 , p_event_class_code => 'RECEIPT'
36304 , p_side => 'NA'
36305 );
36306
36307 END IF;
36308
36309 --
36310 --
36311 END IF;
36312 --
36313 -- Bug 4922099
36314 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
36315 (NVL(l_enc_upg_option, 'N') = 'O')
36316 ) AND
36317 (l_bflow_method_code = 'PRIOR_ENTRY')
36318 )
36319 THEN
36320 IF
36321 --
36322 1 = 2
36323 --
36324 THEN
36325 xla_accounting_err_pkg.build_message
36326 (p_appli_s_name => 'XLA'
36327 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36328 ,p_token_1 => 'LINE_NUMBER'
36329 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
36330 ,p_token_2 => 'LINE_TYPE_NAME'
36331 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
36332 l_component_type
36333 ,l_component_code
36334 ,l_component_type_code
36335 ,l_component_appl_id
36336 ,l_amb_context_code
36337 ,l_entity_code
36338 ,l_event_class_code
36339 )
36340 ,p_token_3 => 'OWNER'
36341 ,p_value_3 => xla_lookups_pkg.get_meaning(
36342 p_lookup_type => 'XLA_OWNER_TYPE'
36343 ,p_lookup_code => l_component_type_code
36344 )
36345 ,p_token_4 => 'PRODUCT_NAME'
36346 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
36347 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
36348 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
36349 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
36350 ,p_ae_header_id => NULL
36351 );
36352
36353 IF (C_LEVEL_ERROR>= g_log_level) THEN
36354 trace
36355 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36356 ,p_level => C_LEVEL_ERROR
36357 ,p_module => l_log_module);
36358 END IF;
36359 END IF;
36360 END IF;
36361 --
36362 --
36363 ------------------------------------------------------------------------------------------------
36364 -- 4219869 Business Flow
36365 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
36366 -- Prior Entry. Currently, the following code is always generated.
36367 ------------------------------------------------------------------------------------------------
36368 XLA_AE_LINES_PKG.ValidateCurrentLine;
36369
36370 ------------------------------------------------------------------------------------
36371 -- 4219869 Business Flow
36372 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
36373 ------------------------------------------------------------------------------------
36374 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36375
36376 ----------------------------------------------------------------------------------
36377 -- 4219869 Business Flow
36378 -- Update journal entry status -- Need to generate this within IF <condition>
36379 ----------------------------------------------------------------------------------
36380 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36384
36381 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
36382 ,p_balance_type_code => l_balance_type_code
36383 );
36385 -------------------------------------------------------------------------------------------
36386 -- 4262811 - Generate the Accrual Reversal lines
36387 -------------------------------------------------------------------------------------------
36388 BEGIN
36389 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
36390 (g_array_event(p_event_id).array_value_num('header_index'));
36391 IF l_acc_rev_flag IS NULL THEN
36392 l_acc_rev_flag := 'N';
36393 END IF;
36394 EXCEPTION
36395 WHEN OTHERS THEN
36396 l_acc_rev_flag := 'N';
36397 END;
36398 --
36399 IF (l_acc_rev_flag = 'Y') THEN
36400
36401 -- 4645092 ------------------------------------------------------------------------------
36402 -- To allow MPA report to determine if it should generate report process
36403 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
36404 ------------------------------------------------------------------------------------------
36405
36406 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
36407 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
36408 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
36409 -- call ADRs
36410 -- Bug 4922099
36411 --
36412 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36413 (NVL(l_actual_upg_option, 'N') = 'O') OR
36414 (NVL(l_enc_upg_option, 'N') = 'O')
36415 )
36416 THEN
36417 NULL;
36418 --
36419 --
36420
36421 l_ccid := AcctDerRule_18(
36422 p_application_id => p_application_id
36423 , p_ae_header_id => l_ae_header_id
36424 , p_source_14 => p_source_14
36425 , x_transaction_coa_id => l_adr_transaction_coa_id
36426 , x_accounting_coa_id => l_adr_accounting_coa_id
36427 , x_value_type_code => l_adr_value_type_code
36428 , p_side => 'NA'
36429 );
36430
36431 xla_ae_lines_pkg.set_ccid(
36432 p_code_combination_id => l_ccid
36433 , p_value_type_code => l_adr_value_type_code
36434 , p_transaction_coa_id => l_adr_transaction_coa_id
36435 , p_accounting_coa_id => l_adr_accounting_coa_id
36436 , p_adr_code => 'TRX_DIST_CCID'
36437 , p_adr_type_code => 'S'
36438 , p_component_type => l_component_type
36439 , p_component_code => l_component_code
36440 , p_component_type_code => l_component_type_code
36441 , p_component_appl_id => l_component_appl_id
36442 , p_amb_context_code => l_amb_context_code
36443 , p_side => 'NA'
36444 );
36445
36446
36447 l_segment := AcctDerRule_6(
36448 p_application_id => p_application_id
36449 , p_ae_header_id => l_ae_header_id
36450 , p_source_5 => p_source_5
36451 , x_transaction_coa_id => l_adr_transaction_coa_id
36452 , x_accounting_coa_id => l_adr_accounting_coa_id
36453 , x_flexfield_segment_code => l_adr_flexfield_segment_code
36454 , x_flex_value_set_id => l_adr_flex_value_set_id
36455 , x_value_type_code => l_adr_value_type_code
36456 , x_value_combination_id => l_adr_value_combination_id
36457 , x_value_segment_code => l_adr_value_segment_code
36458 , p_side => 'NA'
36459 , p_override_seg_flag => 'Y'
36460 );
36461
36462 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
36463
36464 xla_ae_lines_pkg.set_segment(
36465 p_to_segment_code => 'GL_ACCOUNT'
36466 , p_segment_value => l_segment
36467 , p_from_segment_code => l_adr_value_segment_code
36471 , p_accounting_coa_id => l_adr_accounting_coa_id
36468 , p_from_combination_id => l_adr_value_combination_id
36469 , p_value_type_code => l_adr_value_type_code
36470 , p_transaction_coa_id => l_adr_transaction_coa_id
36472 , p_flexfield_segment_code => l_adr_flexfield_segment_code
36473 , p_flex_value_set_id => l_adr_flex_value_set_id
36474 , p_adr_code => 'MFAR_RCT_NATURAL_SEGMENT'
36475 , p_adr_type_code => 'S'
36476 , p_component_type => l_component_type
36477 , p_component_code => l_component_code
36478 , p_component_type_code => l_component_type_code
36479 , p_component_appl_id => l_component_appl_id
36480 , p_amb_context_code => l_amb_context_code
36481 , p_entity_code => 'RECEIPTS'
36482 , p_event_class_code => 'RECEIPT'
36483 , p_side => 'NA'
36484 );
36485
36486 END IF;
36487
36488 --
36489 --
36490 END IF;
36491
36492 --
36493 -- Update the line information that should be overwritten
36494 --
36495 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
36496 p_header_num => 1);
36497 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
36498
36499 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
36500
36501 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
36502 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
36503 END IF;
36504
36505 --
36506 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
36507 --
36508 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
36509 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
36510 ELSE
36511 ---------------------------------------------------------------------------------------------------
36512 -- 4262811a Switch Sign
36513 ---------------------------------------------------------------------------------------------------
36514 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
36515 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36516 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36517 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36518 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36519 -- 5132302
36520 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
36521 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36522
36523 END IF;
36524
36525 -- 4955764
36526 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36527 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
36528
36529
36530 XLA_AE_LINES_PKG.ValidateCurrentLine;
36531 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36532
36533 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36534 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
36535 ,p_balance_type_code => l_balance_type_code);
36536
36537 END IF;
36538
36539 -----------------------------------------------------------------------------------------
36540 -- 4262811 Multiperiod Accounting
36541 -----------------------------------------------------------------------------------------
36542 -- No MPA option is assigned.
36543
36547 --
36544
36545 END IF;
36546 END IF;
36548
36549 --
36550 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36551 trace
36552 (p_msg => 'END of AcctLineType_76'
36553 ,p_level => C_LEVEL_PROCEDURE
36554 ,p_module => l_log_module);
36555 END IF;
36556 --
36557 EXCEPTION
36558 WHEN xla_exceptions_pkg.application_exception THEN
36559 RAISE;
36560 WHEN OTHERS THEN
36561 xla_exceptions_pkg.raise_message
36562 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_76');
36563 END AcctLineType_76;
36564 --
36565
36566 ---------------------------------------
36567 --
36568 -- PRIVATE FUNCTION
36569 -- AcctLineType_77
36570 --
36571 ---------------------------------------
36572 PROCEDURE AcctLineType_77 (
36573 p_application_id IN NUMBER
36574 ,p_event_id IN NUMBER
36575 ,p_calculate_acctd_flag IN VARCHAR2
36576 ,p_calculate_g_l_flag IN VARCHAR2
36577 ,p_actual_flag IN OUT VARCHAR2
36578 ,p_balance_type_code OUT VARCHAR2
36579 ,p_gain_or_loss_ref OUT VARCHAR2
36580
36581 --Remittance Bank Account Confirmation Account
36582 , p_source_3 IN NUMBER
36583 --Transaction Distribution GL Account
36584 , p_source_14 IN NUMBER
36585 --Distribution Source Type
36586 , p_source_15 IN VARCHAR2
36587 --Distribution Line Identifier
36588 , p_source_17 IN NUMBER
36589 --Distribution Type
36590 , p_source_18 IN VARCHAR2
36591 --Exchange Date
36592 , p_source_21 IN DATE
36593 --Exchange Rate
36594 , p_source_22 IN NUMBER
36595 --Exchange Rate Type
36596 , p_source_23 IN VARCHAR2
36597 --Transaction Distribution Identifier
36598 , p_source_29 IN NUMBER
36599 --Transaction Distribution Type
36600 , p_source_30 IN VARCHAR2
36601 --Distribution Multi Fund Additional Entry
36602 , p_source_54 IN VARCHAR2
36603 --Receipt Applied To Application Identifier
36604 , p_source_58 IN NUMBER
36605 --Transaction Entity Code
36606 , p_source_59 IN VARCHAR2
36607 --Transaction Identifier
36608 , p_source_60 IN NUMBER
36609 --DIST_ENT_AMT_FROM
36610 , p_source_61 IN NUMBER
36611 --Applying Document Currency Code
36612 , p_source_62 IN VARCHAR2
36613 --Accounting Amount
36614 , p_source_63 IN NUMBER
36615 --Distribution Party Identifier
36616 , p_source_64 IN NUMBER
36617 --Distribution Party Site Id
36618 , p_source_65 IN NUMBER
36619 --Distribution Party Type
36620 , p_source_66 IN VARCHAR2
36621 )
36622 IS
36623
36624 l_component_type VARCHAR2(80);
36625 l_component_code VARCHAR2(30);
36626 l_component_type_code VARCHAR2(1);
36627 l_component_appl_id INTEGER;
36628 l_amb_context_code VARCHAR2(30);
36629 l_entity_code VARCHAR2(30);
36630 l_event_class_code VARCHAR2(30);
36631 l_ae_header_id NUMBER;
36632 l_event_type_code VARCHAR2(30);
36633 l_line_definition_code VARCHAR2(30);
36634 l_line_definition_owner_code VARCHAR2(1);
36635 --
36636 -- adr variables
36637 l_segment VARCHAR2(30);
36638 l_ccid NUMBER;
36639 l_adr_transaction_coa_id NUMBER;
36640 l_adr_accounting_coa_id NUMBER;
36641 l_adr_flexfield_segment_code VARCHAR2(30);
36642 l_adr_flex_value_set_id NUMBER;
36643 l_adr_value_type_code VARCHAR2(30);
36644 l_adr_value_combination_id NUMBER;
36645 l_adr_value_segment_code VARCHAR2(30);
36646
36647 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
36648 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
36649 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
36650 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
36651
36652 -- 4262811 Variables ------------------------------------------------------------------------------------------
36653 l_entered_amt_idx NUMBER;
36654 l_accted_amt_idx NUMBER;
36655 l_acc_rev_flag VARCHAR2(1);
36656 l_accrual_line_num NUMBER;
36657 l_tmp_amt NUMBER;
36658 l_acc_rev_natural_side_code VARCHAR2(1);
36659
36660 l_num_entries NUMBER;
36661 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
36662 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
36663 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
36664 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
36665 l_recog_line_1 NUMBER;
36666 l_recog_line_2 NUMBER;
36667
36668 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
36669 l_bflow_applied_to_amt NUMBER; -- 5132302
36670 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
36671
36672 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
36673
36674 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
36675 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
36676
36677 ---------------------------------------------------------------------------------------------------------------
36678
36679
36680 --
36681 -- bulk performance
36682 --
36686
36683 l_balance_type_code VARCHAR2(1);
36684 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
36685 l_log_module VARCHAR2(240);
36687 --
36688 -- Upgrade strategy
36689 --
36690 l_actual_upg_option VARCHAR2(1);
36691 l_enc_upg_option VARCHAR2(1);
36692
36693 --
36694 BEGIN
36695 --
36696 IF g_log_enabled THEN
36697 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_77';
36698 END IF;
36699 --
36700 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36701
36702 trace
36703 (p_msg => 'BEGIN of AcctLineType_77'
36704 ,p_level => C_LEVEL_PROCEDURE
36705 ,p_module => l_log_module);
36706
36707 END IF;
36708 --
36709 l_component_type := 'AMB_JLT';
36710 l_component_code := 'RCT_APP_MFAR_TRX_CONFIRMATION';
36711 l_component_type_code := 'S';
36712 l_component_appl_id := 222;
36713 l_amb_context_code := 'DEFAULT';
36714 l_entity_code := 'RECEIPTS';
36715 l_event_class_code := 'RECEIPT';
36716 l_event_type_code := 'RECEIPT_ALL';
36717 l_line_definition_owner_code := 'S';
36718 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
36719 --
36720 l_balance_type_code := 'A';
36721 l_segment := NULL;
36722 l_ccid := NULL;
36723 l_adr_transaction_coa_id := NULL;
36724 l_adr_accounting_coa_id := NULL;
36725 l_adr_flexfield_segment_code := NULL;
36726 l_adr_flex_value_set_id := NULL;
36727 l_adr_value_type_code := NULL;
36728 l_adr_value_combination_id := NULL;
36729 l_adr_value_segment_code := NULL;
36730
36731 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
36732 l_bflow_class_code := ''; -- 4219869 Business Flow
36733 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
36734 l_budgetary_control_flag := 'N';
36735
36736 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36737 l_bflow_applied_to_amt := NULL; -- 5132302
36738 l_entered_amt_idx := NULL; -- 4262811
36739 l_accted_amt_idx := NULL; -- 4262811
36740 l_acc_rev_flag := NULL; -- 4262811
36741 l_accrual_line_num := NULL; -- 4262811
36742 l_tmp_amt := NULL; -- 4262811
36743 --
36744
36745 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
36746 l_balance_type_code <> 'B' THEN
36747 IF NVL(p_source_15,'
36748 ') = 'CONFIRMATION' AND
36749 NVL(p_source_54,'
36750 ') = 'Y'
36751 THEN
36752
36753 --
36754 XLA_AE_LINES_PKG.SetNewLine;
36755
36756 p_balance_type_code := l_balance_type_code;
36757 -- set the flag so later we will know whether the gain loss line needs to be created
36758
36759 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
36760 p_actual_flag :='A';
36761 END IF;
36762
36763 --
36764 -- bulk performance
36765 --
36766 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
36767 p_header_num => 0); -- 4262811
36768 --
36769 -- set accounting line options
36770 --
36771 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
36772 p_natural_side_code => 'C'
36773 , p_gain_or_loss_flag => 'N'
36774 , p_gl_transfer_mode_code => 'S'
36775 , p_acct_entry_type_code => 'A'
36776 , p_switch_side_flag => 'Y'
36777 , p_merge_duplicate_code => 'A'
36778 );
36779 --
36780 l_acc_rev_natural_side_code := 'D'; -- 4262811
36781 --
36782 --
36783 -- set accounting line type info
36784 --
36785 xla_ae_lines_pkg.SetAcctLineType
36786 (p_component_type => l_component_type
36787 ,p_event_type_code => l_event_type_code
36788 ,p_line_definition_owner_code => l_line_definition_owner_code
36789 ,p_line_definition_code => l_line_definition_code
36790 ,p_accounting_line_code => l_component_code
36791 ,p_accounting_line_type_code => l_component_type_code
36792 ,p_accounting_line_appl_id => l_component_appl_id
36793 ,p_amb_context_code => l_amb_context_code
36794 ,p_entity_code => l_entity_code
36795 ,p_event_class_code => l_event_class_code);
36796 --
36797 -- set accounting class
36798 --
36799 xla_ae_lines_pkg.SetAcctClass(
36800 p_accounting_class_code => 'CONFIRMATION'
36801 , p_ae_header_id => l_ae_header_id
36802 );
36803
36804 --
36805 -- set rounding class
36806 --
36807 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
36808 'RECEIVABLE';
36809
36810 --
36811 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
36812 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
36813 --
36814 -- bulk performance
36815 --
36816 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
36817
36818 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
36819 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
36823 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
36820
36821 -- 4955764
36822 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36824
36825 -- 4458381 Public Sector Enh
36826
36827 --
36828 -- set accounting attributes for the line type
36829 --
36830 l_entered_amt_idx := 8;
36831 l_accted_amt_idx := 13;
36832 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36833 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
36834 l_rec_acct_attrs.array_num_value(1) := p_source_58;
36835 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
36836 l_rec_acct_attrs.array_char_value(2) := p_source_30;
36837 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
36838 l_rec_acct_attrs.array_char_value(3) := p_source_59;
36839 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
36840 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
36841 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
36842 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
36843 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
36844 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
36845 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
36846 l_rec_acct_attrs.array_char_value(7) := p_source_18;
36847 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
36848 l_rec_acct_attrs.array_num_value(8) := p_source_61;
36849 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
36850 l_rec_acct_attrs.array_char_value(9) := p_source_62;
36851 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
36852 l_rec_acct_attrs.array_date_value(10) := p_source_21;
36853 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
36854 l_rec_acct_attrs.array_num_value(11) := p_source_22;
36855 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
36856 l_rec_acct_attrs.array_char_value(12) := p_source_23;
36857 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
36858 l_rec_acct_attrs.array_num_value(13) := p_source_63;
36859 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
36860 l_rec_acct_attrs.array_num_value(14) := p_source_64;
36861 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
36862 l_rec_acct_attrs.array_num_value(15) := p_source_65;
36863 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
36864 l_rec_acct_attrs.array_char_value(16) := p_source_66;
36865
36866 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
36867 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
36868
36869 ---------------------------------------------------------------------------------------------------------------
36870 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
36871 ---------------------------------------------------------------------------------------------------------------
36872 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
36873
36874 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36875 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36876
36877 IF xla_accounting_cache_pkg.GetValueChar
36878 (p_source_code => 'LEDGER_CATEGORY_CODE'
36879 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
36880 AND l_bflow_method_code = 'PRIOR_ENTRY'
36881 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
36882 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
36883 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
36884 )
36885 THEN
36886 xla_ae_lines_pkg.BflowUpgEntry
36887 (p_business_method_code => l_bflow_method_code
36888 ,p_business_class_code => l_bflow_class_code
36889 ,p_balance_type => l_balance_type_code);
36890 ELSE
36891 NULL;
36892 -- No business flow processing for business flow method of NONE.
36893 END IF;
36894
36895 --
36896 -- call analytical criteria
36897 --
36898
36899 --
36900 -- call description
36901 --
36902
36903 xla_ae_lines_pkg.SetLineDescription(
36904 p_ae_header_id => l_ae_header_id
36905 ,p_description => Description_1 (
36906 p_application_id => p_application_id
36907 , p_ae_header_id => l_ae_header_id
36908 )
36909 );
36910
36911
36912 --
36913 -- call ADRs
36914 -- Bug 4922099
36915 --
36916 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36917 (NVL(l_actual_upg_option, 'N') = 'O') OR
36918 (NVL(l_enc_upg_option, 'N') = 'O')
36919 )
36920 THEN
36921 NULL;
36922 --
36923 --
36924
36925 l_ccid := AcctDerRule_18(
36926 p_application_id => p_application_id
36927 , p_ae_header_id => l_ae_header_id
36928 , p_source_14 => p_source_14
36929 , x_transaction_coa_id => l_adr_transaction_coa_id
36930 , x_accounting_coa_id => l_adr_accounting_coa_id
36931 , x_value_type_code => l_adr_value_type_code
36932 , p_side => 'NA'
36933 );
36934
36938 , p_transaction_coa_id => l_adr_transaction_coa_id
36935 xla_ae_lines_pkg.set_ccid(
36936 p_code_combination_id => l_ccid
36937 , p_value_type_code => l_adr_value_type_code
36939 , p_accounting_coa_id => l_adr_accounting_coa_id
36940 , p_adr_code => 'TRX_DIST_CCID'
36941 , p_adr_type_code => 'S'
36942 , p_component_type => l_component_type
36943 , p_component_code => l_component_code
36944 , p_component_type_code => l_component_type_code
36945 , p_component_appl_id => l_component_appl_id
36946 , p_amb_context_code => l_amb_context_code
36947 , p_side => 'NA'
36948 );
36949
36950
36951 l_segment := AcctDerRule_4(
36952 p_application_id => p_application_id
36953 , p_ae_header_id => l_ae_header_id
36954 , p_source_3 => p_source_3
36955 , x_transaction_coa_id => l_adr_transaction_coa_id
36956 , x_accounting_coa_id => l_adr_accounting_coa_id
36957 , x_flexfield_segment_code => l_adr_flexfield_segment_code
36958 , x_flex_value_set_id => l_adr_flex_value_set_id
36959 , x_value_type_code => l_adr_value_type_code
36960 , x_value_combination_id => l_adr_value_combination_id
36961 , x_value_segment_code => l_adr_value_segment_code
36962 , p_side => 'NA'
36963 , p_override_seg_flag => 'Y'
36964 );
36965
36966 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
36967
36968 xla_ae_lines_pkg.set_segment(
36969 p_to_segment_code => 'GL_ACCOUNT'
36970 , p_segment_value => l_segment
36971 , p_from_segment_code => l_adr_value_segment_code
36972 , p_from_combination_id => l_adr_value_combination_id
36973 , p_value_type_code => l_adr_value_type_code
36974 , p_transaction_coa_id => l_adr_transaction_coa_id
36975 , p_accounting_coa_id => l_adr_accounting_coa_id
36976 , p_flexfield_segment_code => l_adr_flexfield_segment_code
36977 , p_flex_value_set_id => l_adr_flex_value_set_id
36978 , p_adr_code => 'MFAR_RCT_CONFIRMATION_NATSEG'
36979 , p_adr_type_code => 'S'
36980 , p_component_type => l_component_type
36981 , p_component_code => l_component_code
36982 , p_component_type_code => l_component_type_code
36983 , p_component_appl_id => l_component_appl_id
36984 , p_amb_context_code => l_amb_context_code
36985 , p_entity_code => 'RECEIPTS'
36986 , p_event_class_code => 'RECEIPT'
36987 , p_side => 'NA'
36988 );
36989
36990 END IF;
36991
36992 --
36993 --
36994 END IF;
36995 --
36996 -- Bug 4922099
36997 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
36998 (NVL(l_enc_upg_option, 'N') = 'O')
36999 ) AND
37000 (l_bflow_method_code = 'PRIOR_ENTRY')
37001 )
37002 THEN
37003 IF
37004 --
37005 1 = 2
37006 --
37007 THEN
37008 xla_accounting_err_pkg.build_message
37009 (p_appli_s_name => 'XLA'
37010 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37011 ,p_token_1 => 'LINE_NUMBER'
37012 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
37013 ,p_token_2 => 'LINE_TYPE_NAME'
37014 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
37015 l_component_type
37016 ,l_component_code
37017 ,l_component_type_code
37018 ,l_component_appl_id
37019 ,l_amb_context_code
37020 ,l_entity_code
37021 ,l_event_class_code
37022 )
37023 ,p_token_3 => 'OWNER'
37024 ,p_value_3 => xla_lookups_pkg.get_meaning(
37025 p_lookup_type => 'XLA_OWNER_TYPE'
37026 ,p_lookup_code => l_component_type_code
37027 )
37028 ,p_token_4 => 'PRODUCT_NAME'
37029 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
37030 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
37031 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
37032 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
37033 ,p_ae_header_id => NULL
37037 trace
37034 );
37035
37036 IF (C_LEVEL_ERROR>= g_log_level) THEN
37038 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37039 ,p_level => C_LEVEL_ERROR
37040 ,p_module => l_log_module);
37041 END IF;
37042 END IF;
37043 END IF;
37044 --
37045 --
37046 ------------------------------------------------------------------------------------------------
37047 -- 4219869 Business Flow
37048 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
37049 -- Prior Entry. Currently, the following code is always generated.
37050 ------------------------------------------------------------------------------------------------
37051 XLA_AE_LINES_PKG.ValidateCurrentLine;
37052
37053 ------------------------------------------------------------------------------------
37054 -- 4219869 Business Flow
37055 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
37056 ------------------------------------------------------------------------------------
37057 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37058
37059 ----------------------------------------------------------------------------------
37060 -- 4219869 Business Flow
37061 -- Update journal entry status -- Need to generate this within IF <condition>
37062 ----------------------------------------------------------------------------------
37063 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37064 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
37065 ,p_balance_type_code => l_balance_type_code
37066 );
37067
37068 -------------------------------------------------------------------------------------------
37069 -- 4262811 - Generate the Accrual Reversal lines
37070 -------------------------------------------------------------------------------------------
37071 BEGIN
37072 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
37073 (g_array_event(p_event_id).array_value_num('header_index'));
37074 IF l_acc_rev_flag IS NULL THEN
37075 l_acc_rev_flag := 'N';
37076 END IF;
37077 EXCEPTION
37078 WHEN OTHERS THEN
37079 l_acc_rev_flag := 'N';
37080 END;
37081 --
37082 IF (l_acc_rev_flag = 'Y') THEN
37083
37084 -- 4645092 ------------------------------------------------------------------------------
37085 -- To allow MPA report to determine if it should generate report process
37086 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
37087 ------------------------------------------------------------------------------------------
37088
37089 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
37090 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
37091 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
37092 -- call ADRs
37093 -- Bug 4922099
37094 --
37095 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37096 (NVL(l_actual_upg_option, 'N') = 'O') OR
37097 (NVL(l_enc_upg_option, 'N') = 'O')
37098 )
37099 THEN
37100 NULL;
37101 --
37102 --
37103
37104 l_ccid := AcctDerRule_18(
37105 p_application_id => p_application_id
37106 , p_ae_header_id => l_ae_header_id
37107 , p_source_14 => p_source_14
37108 , x_transaction_coa_id => l_adr_transaction_coa_id
37109 , x_accounting_coa_id => l_adr_accounting_coa_id
37110 , x_value_type_code => l_adr_value_type_code
37111 , p_side => 'NA'
37112 );
37113
37114 xla_ae_lines_pkg.set_ccid(
37115 p_code_combination_id => l_ccid
37116 , p_value_type_code => l_adr_value_type_code
37117 , p_transaction_coa_id => l_adr_transaction_coa_id
37118 , p_accounting_coa_id => l_adr_accounting_coa_id
37119 , p_adr_code => 'TRX_DIST_CCID'
37120 , p_adr_type_code => 'S'
37121 , p_component_type => l_component_type
37122 , p_component_code => l_component_code
37123 , p_component_type_code => l_component_type_code
37124 , p_component_appl_id => l_component_appl_id
37125 , p_amb_context_code => l_amb_context_code
37126 , p_side => 'NA'
37127 );
37128
37129
37130 l_segment := AcctDerRule_4(
37131 p_application_id => p_application_id
37132 , p_ae_header_id => l_ae_header_id
37133 , p_source_3 => p_source_3
37134 , x_transaction_coa_id => l_adr_transaction_coa_id
37135 , x_accounting_coa_id => l_adr_accounting_coa_id
37136 , x_flexfield_segment_code => l_adr_flexfield_segment_code
37137 , x_flex_value_set_id => l_adr_flex_value_set_id
37138 , x_value_type_code => l_adr_value_type_code
37139 , x_value_combination_id => l_adr_value_combination_id
37140 , x_value_segment_code => l_adr_value_segment_code
37141 , p_side => 'NA'
37142 , p_override_seg_flag => 'Y'
37143 );
37144
37145 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
37146
37147 xla_ae_lines_pkg.set_segment(
37148 p_to_segment_code => 'GL_ACCOUNT'
37149 , p_segment_value => l_segment
37150 , p_from_segment_code => l_adr_value_segment_code
37151 , p_from_combination_id => l_adr_value_combination_id
37155 , p_flexfield_segment_code => l_adr_flexfield_segment_code
37152 , p_value_type_code => l_adr_value_type_code
37153 , p_transaction_coa_id => l_adr_transaction_coa_id
37154 , p_accounting_coa_id => l_adr_accounting_coa_id
37156 , p_flex_value_set_id => l_adr_flex_value_set_id
37157 , p_adr_code => 'MFAR_RCT_CONFIRMATION_NATSEG'
37158 , p_adr_type_code => 'S'
37159 , p_component_type => l_component_type
37160 , p_component_code => l_component_code
37161 , p_component_type_code => l_component_type_code
37162 , p_component_appl_id => l_component_appl_id
37163 , p_amb_context_code => l_amb_context_code
37164 , p_entity_code => 'RECEIPTS'
37165 , p_event_class_code => 'RECEIPT'
37166 , p_side => 'NA'
37167 );
37168
37169 END IF;
37170
37171 --
37172 --
37173 END IF;
37174
37175 --
37176 -- Update the line information that should be overwritten
37177 --
37178 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
37179 p_header_num => 1);
37180 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
37181
37182 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
37183
37184 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
37185 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
37186 END IF;
37187
37188 --
37189 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
37190 --
37191 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
37192 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
37193 ELSE
37194 ---------------------------------------------------------------------------------------------------
37195 -- 4262811a Switch Sign
37196 ---------------------------------------------------------------------------------------------------
37197 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
37198 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37199 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37200 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37201 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37202 -- 5132302
37203 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
37204 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37205
37206 END IF;
37207
37208 -- 4955764
37209 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37210 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
37211
37212
37213 XLA_AE_LINES_PKG.ValidateCurrentLine;
37214 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37215
37216 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37217 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
37218 ,p_balance_type_code => l_balance_type_code);
37219
37220 END IF;
37221
37222 -----------------------------------------------------------------------------------------
37223 -- 4262811 Multiperiod Accounting
37224 -----------------------------------------------------------------------------------------
37225 -- No MPA option is assigned.
37226
37227
37228 END IF;
37229 END IF;
37230 --
37231
37232 --
37233 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37234 trace
37235 (p_msg => 'END of AcctLineType_77'
37236 ,p_level => C_LEVEL_PROCEDURE
37237 ,p_module => l_log_module);
37238 END IF;
37239 --
37240 EXCEPTION
37241 WHEN xla_exceptions_pkg.application_exception THEN
37242 RAISE;
37243 WHEN OTHERS THEN
37244 xla_exceptions_pkg.raise_message
37245 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_77');
37246 END AcctLineType_77;
37247 --
37248
37249 ---------------------------------------
37250 --
37251 -- PRIVATE FUNCTION
37252 -- AcctLineType_78
37253 --
37254 ---------------------------------------
37255 PROCEDURE AcctLineType_78 (
37256 p_application_id IN NUMBER
37257 ,p_event_id IN NUMBER
37258 ,p_calculate_acctd_flag IN VARCHAR2
37259 ,p_calculate_g_l_flag IN VARCHAR2
37260 ,p_actual_flag IN OUT VARCHAR2
37261 ,p_balance_type_code OUT VARCHAR2
37262 ,p_gain_or_loss_ref OUT VARCHAR2
37263
37264 --Distribution Source Type
37265 , p_source_15 IN VARCHAR2
37266 --Distribution Line Identifier
37267 , p_source_17 IN NUMBER
37268 --Distribution Type
37269 , p_source_18 IN VARCHAR2
37270 --Entered Amount
37271 , p_source_19 IN NUMBER
37272 --Currency Code
37273 , p_source_20 IN VARCHAR2
37274 --Applied To Document Accounting Amount
37275 , p_source_24 IN NUMBER
37276 --Transaction Distribution Account Class
37277 , p_source_28 IN VARCHAR2
37278 --Transaction Distribution Identifier
37282 --Distribution Multi Fund Additional Entry
37279 , p_source_29 IN NUMBER
37280 --Transaction Distribution Type
37281 , p_source_30 IN VARCHAR2
37283 , p_source_54 IN VARCHAR2
37284 --Receipt Applied To Application Identifier
37285 , p_source_58 IN NUMBER
37286 --Transaction Entity Code
37287 , p_source_59 IN VARCHAR2
37288 --Transaction Identifier
37289 , p_source_60 IN NUMBER
37290 --Distribution Party Type
37291 , p_source_66 IN VARCHAR2
37292 )
37293 IS
37294
37295 l_component_type VARCHAR2(80);
37296 l_component_code VARCHAR2(30);
37297 l_component_type_code VARCHAR2(1);
37298 l_component_appl_id INTEGER;
37299 l_amb_context_code VARCHAR2(30);
37300 l_entity_code VARCHAR2(30);
37301 l_event_class_code VARCHAR2(30);
37302 l_ae_header_id NUMBER;
37303 l_event_type_code VARCHAR2(30);
37304 l_line_definition_code VARCHAR2(30);
37305 l_line_definition_owner_code VARCHAR2(1);
37306 --
37307 -- adr variables
37308 l_segment VARCHAR2(30);
37309 l_ccid NUMBER;
37310 l_adr_transaction_coa_id NUMBER;
37311 l_adr_accounting_coa_id NUMBER;
37312 l_adr_flexfield_segment_code VARCHAR2(30);
37313 l_adr_flex_value_set_id NUMBER;
37314 l_adr_value_type_code VARCHAR2(30);
37315 l_adr_value_combination_id NUMBER;
37316 l_adr_value_segment_code VARCHAR2(30);
37317
37318 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
37319 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
37320 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
37321 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
37322
37323 -- 4262811 Variables ------------------------------------------------------------------------------------------
37324 l_entered_amt_idx NUMBER;
37325 l_accted_amt_idx NUMBER;
37326 l_acc_rev_flag VARCHAR2(1);
37327 l_accrual_line_num NUMBER;
37328 l_tmp_amt NUMBER;
37329 l_acc_rev_natural_side_code VARCHAR2(1);
37330
37331 l_num_entries NUMBER;
37332 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
37333 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
37334 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
37335 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
37336 l_recog_line_1 NUMBER;
37337 l_recog_line_2 NUMBER;
37338
37339 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
37340 l_bflow_applied_to_amt NUMBER; -- 5132302
37341 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
37342
37343 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
37344
37345 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
37346 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
37347
37348 ---------------------------------------------------------------------------------------------------------------
37349
37350
37351 --
37352 -- bulk performance
37353 --
37354 l_balance_type_code VARCHAR2(1);
37355 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
37356 l_log_module VARCHAR2(240);
37357
37358 --
37359 -- Upgrade strategy
37360 --
37361 l_actual_upg_option VARCHAR2(1);
37362 l_enc_upg_option VARCHAR2(1);
37363
37364 --
37365 BEGIN
37366 --
37367 IF g_log_enabled THEN
37368 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_78';
37369 END IF;
37370 --
37371 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37372
37373 trace
37374 (p_msg => 'BEGIN of AcctLineType_78'
37375 ,p_level => C_LEVEL_PROCEDURE
37376 ,p_module => l_log_module);
37377
37378 END IF;
37379 --
37380 l_component_type := 'AMB_JLT';
37381 l_component_code := 'RCT_APP_MFAR_TRX_REC';
37382 l_component_type_code := 'S';
37383 l_component_appl_id := 222;
37384 l_amb_context_code := 'DEFAULT';
37385 l_entity_code := 'RECEIPTS';
37386 l_event_class_code := 'RECEIPT';
37387 l_event_type_code := 'RECEIPT_ALL';
37388 l_line_definition_owner_code := 'S';
37389 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
37390 --
37391 l_balance_type_code := 'A';
37392 l_segment := NULL;
37393 l_ccid := NULL;
37394 l_adr_transaction_coa_id := NULL;
37395 l_adr_accounting_coa_id := NULL;
37396 l_adr_flexfield_segment_code := NULL;
37397 l_adr_flex_value_set_id := NULL;
37398 l_adr_value_type_code := NULL;
37399 l_adr_value_combination_id := NULL;
37400 l_adr_value_segment_code := NULL;
37401
37402 l_bflow_method_code := 'PRIOR_ENTRY'; -- 4219869 Business Flow
37403 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
37404 l_inherit_desc_flag := 'Y'; -- 4219869 Business Flow
37405 l_budgetary_control_flag := 'N';
37406
37407 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37408 l_bflow_applied_to_amt := NULL; -- 5132302
37409 l_entered_amt_idx := NULL; -- 4262811
37413 l_tmp_amt := NULL; -- 4262811
37410 l_accted_amt_idx := NULL; -- 4262811
37411 l_acc_rev_flag := NULL; -- 4262811
37412 l_accrual_line_num := NULL; -- 4262811
37414 --
37415
37416 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
37417 l_balance_type_code <> 'B' THEN
37418 IF (NVL(p_source_28,'
37419 ') = 'REV' OR
37420 NVL(p_source_28,'
37421 ') = 'TAX' OR
37422 NVL(p_source_28,'
37423 ') = 'FREIGHT' OR
37424 NVL(p_source_28,'
37425 ') = 'ROUND' OR
37426 NVL(p_source_28,'
37427 ') = 'CHARGES') AND
37428 NVL(p_source_15,'
37429 ') = 'REC' AND
37430 NVL(p_source_54,'
37431 ') = 'N'
37432 THEN
37433
37434 --
37435 XLA_AE_LINES_PKG.SetNewLine;
37436
37437 p_balance_type_code := l_balance_type_code;
37438 -- set the flag so later we will know whether the gain loss line needs to be created
37439
37440 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
37441 p_actual_flag :='A';
37442 END IF;
37443
37444 --
37445 -- bulk performance
37446 --
37447 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
37448 p_header_num => 0); -- 4262811
37449 --
37450 -- set accounting line options
37451 --
37452 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
37453 p_natural_side_code => 'C'
37454 , p_gain_or_loss_flag => 'N'
37455 , p_gl_transfer_mode_code => 'S'
37456 , p_acct_entry_type_code => 'A'
37457 , p_switch_side_flag => 'Y'
37458 , p_merge_duplicate_code => 'A'
37459 );
37460 --
37461 l_acc_rev_natural_side_code := 'D'; -- 4262811
37462 --
37463 --
37464 -- set accounting line type info
37465 --
37466 xla_ae_lines_pkg.SetAcctLineType
37467 (p_component_type => l_component_type
37468 ,p_event_type_code => l_event_type_code
37469 ,p_line_definition_owner_code => l_line_definition_owner_code
37470 ,p_line_definition_code => l_line_definition_code
37471 ,p_accounting_line_code => l_component_code
37472 ,p_accounting_line_type_code => l_component_type_code
37473 ,p_accounting_line_appl_id => l_component_appl_id
37474 ,p_amb_context_code => l_amb_context_code
37475 ,p_entity_code => l_entity_code
37476 ,p_event_class_code => l_event_class_code);
37477 --
37478 -- set accounting class
37479 --
37480 xla_ae_lines_pkg.SetAcctClass(
37481 p_accounting_class_code => 'RECEIVABLE'
37482 , p_ae_header_id => l_ae_header_id
37483 );
37484
37485 --
37486 -- set rounding class
37487 --
37488 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
37489 'RECEIVABLE';
37490
37491 --
37492 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
37493 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
37494 --
37495 -- bulk performance
37496 --
37497 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
37498
37499 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
37500 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
37501
37502 -- 4955764
37503 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37504 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
37505
37506 -- 4458381 Public Sector Enh
37507
37508 --
37509 -- set accounting attributes for the line type
37510 --
37511 l_entered_amt_idx := 8;
37512 l_accted_amt_idx := 10;
37513 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37514 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
37515 l_rec_acct_attrs.array_num_value(1) := p_source_58;
37516 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
37517 l_rec_acct_attrs.array_char_value(2) := p_source_30;
37518 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
37519 l_rec_acct_attrs.array_char_value(3) := p_source_59;
37520 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
37521 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
37522 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
37523 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
37524 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
37525 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
37526 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
37527 l_rec_acct_attrs.array_char_value(7) := p_source_18;
37528 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
37529 l_rec_acct_attrs.array_num_value(8) := p_source_19;
37530 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
37531 l_rec_acct_attrs.array_char_value(9) := p_source_20;
37532 l_rec_acct_attrs.array_acct_attr_code(10) := 'LEDGER_AMOUNT';
37533 l_rec_acct_attrs.array_num_value(10) := p_source_24;
37534 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
37535 l_rec_acct_attrs.array_char_value(11) := p_source_66;
37536
37537 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
37541 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
37538 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
37539
37540 ---------------------------------------------------------------------------------------------------------------
37542 ---------------------------------------------------------------------------------------------------------------
37543 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
37544
37545 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37546 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37547
37548 IF xla_accounting_cache_pkg.GetValueChar
37549 (p_source_code => 'LEDGER_CATEGORY_CODE'
37550 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
37551 AND l_bflow_method_code = 'PRIOR_ENTRY'
37552 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
37553 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
37554 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
37555 )
37556 THEN
37557 xla_ae_lines_pkg.BflowUpgEntry
37558 (p_business_method_code => l_bflow_method_code
37559 ,p_business_class_code => l_bflow_class_code
37560 ,p_balance_type => l_balance_type_code);
37561 ELSE
37562 NULL;
37563 XLA_AE_LINES_PKG.business_flow_validation(
37564 p_business_method_code => l_bflow_method_code
37565 ,p_business_class_code => l_bflow_class_code
37566 ,p_inherit_description_flag => l_inherit_desc_flag);
37567 END IF;
37568
37569 --
37570 -- call analytical criteria
37571 --
37572 -- Inherited Analytical Criteria for business flow method of Prior Entry.
37573 --
37574 -- call description
37575 --
37576 -- No description or it is inherited.
37577 --
37578 -- call ADRs
37579 -- Bug 4922099
37580 --
37581 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37582 (NVL(l_actual_upg_option, 'N') = 'O') OR
37583 (NVL(l_enc_upg_option, 'N') = 'O')
37584 )
37585 THEN
37586 NULL;
37587 --
37588 --
37589
37590 --
37591 --
37592 END IF;
37593 --
37594 -- Bug 4922099
37595 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
37596 (NVL(l_enc_upg_option, 'N') = 'O')
37597 ) AND
37598 (l_bflow_method_code = 'PRIOR_ENTRY')
37599 )
37600 THEN
37601 IF
37602 --
37603 1 = 1
37604 --
37605 THEN
37606 xla_accounting_err_pkg.build_message
37607 (p_appli_s_name => 'XLA'
37608 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37609 ,p_token_1 => 'LINE_NUMBER'
37610 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
37611 ,p_token_2 => 'LINE_TYPE_NAME'
37612 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
37613 l_component_type
37614 ,l_component_code
37615 ,l_component_type_code
37616 ,l_component_appl_id
37617 ,l_amb_context_code
37618 ,l_entity_code
37619 ,l_event_class_code
37620 )
37621 ,p_token_3 => 'OWNER'
37622 ,p_value_3 => xla_lookups_pkg.get_meaning(
37623 p_lookup_type => 'XLA_OWNER_TYPE'
37624 ,p_lookup_code => l_component_type_code
37625 )
37626 ,p_token_4 => 'PRODUCT_NAME'
37627 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
37628 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
37629 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
37630 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
37631 ,p_ae_header_id => NULL
37632 );
37633
37634 IF (C_LEVEL_ERROR>= g_log_level) THEN
37635 trace
37636 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37637 ,p_level => C_LEVEL_ERROR
37638 ,p_module => l_log_module);
37639 END IF;
37640 END IF;
37641 END IF;
37645 -- 4219869 Business Flow
37642 --
37643 --
37644 ------------------------------------------------------------------------------------------------
37646 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
37647 -- Prior Entry. Currently, the following code is always generated.
37648 ------------------------------------------------------------------------------------------------
37649 -- No ValidateCurrentLine for business flow method of Prior Entry
37650
37651 ------------------------------------------------------------------------------------
37652 -- 4219869 Business Flow
37653 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
37654 ------------------------------------------------------------------------------------
37655 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37656
37657 ----------------------------------------------------------------------------------
37658 -- 4219869 Business Flow
37659 -- Update journal entry status -- Need to generate this within IF <condition>
37660 ----------------------------------------------------------------------------------
37661 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37662 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
37663 ,p_balance_type_code => l_balance_type_code
37664 );
37665
37666 -------------------------------------------------------------------------------------------
37667 -- 4262811 - Generate the Accrual Reversal lines
37668 -------------------------------------------------------------------------------------------
37669 BEGIN
37670 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
37671 (g_array_event(p_event_id).array_value_num('header_index'));
37672 IF l_acc_rev_flag IS NULL THEN
37673 l_acc_rev_flag := 'N';
37674 END IF;
37675 EXCEPTION
37676 WHEN OTHERS THEN
37677 l_acc_rev_flag := 'N';
37678 END;
37679 --
37680 IF (l_acc_rev_flag = 'Y') THEN
37681
37682 -- 4645092 ------------------------------------------------------------------------------
37683 -- To allow MPA report to determine if it should generate report process
37684 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
37685 ------------------------------------------------------------------------------------------
37686
37687 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
37688 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
37689 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
37690 -- call ADRs
37691 -- Bug 4922099
37692 --
37693 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37694 (NVL(l_actual_upg_option, 'N') = 'O') OR
37695 (NVL(l_enc_upg_option, 'N') = 'O')
37696 )
37697 THEN
37698 NULL;
37699 --
37700 --
37701
37702 --
37703 --
37704 END IF;
37705
37706 --
37707 -- Update the line information that should be overwritten
37708 --
37709 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
37710 p_header_num => 1);
37711 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
37712
37713 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
37714
37715 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
37716 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
37717 END IF;
37718
37719 --
37720 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
37721 --
37722 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
37723 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
37724 ELSE
37725 ---------------------------------------------------------------------------------------------------
37726 -- 4262811a Switch Sign
37727 ---------------------------------------------------------------------------------------------------
37728 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
37729 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37730 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37731 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37732 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37733 -- 5132302
37734 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
37735 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37736
37737 END IF;
37738
37739 -- 4955764
37740 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37741 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
37742
37743
37744 XLA_AE_LINES_PKG.ValidateCurrentLine;
37745 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37746
37747 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37748 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
37749 ,p_balance_type_code => l_balance_type_code);
37750
37751 END IF;
37752
37756 -- No MPA option is assigned.
37753 -----------------------------------------------------------------------------------------
37754 -- 4262811 Multiperiod Accounting
37755 -----------------------------------------------------------------------------------------
37757
37758
37759 END IF;
37760 END IF;
37761 --
37762
37763 --
37764 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37765 trace
37766 (p_msg => 'END of AcctLineType_78'
37767 ,p_level => C_LEVEL_PROCEDURE
37768 ,p_module => l_log_module);
37769 END IF;
37770 --
37771 EXCEPTION
37772 WHEN xla_exceptions_pkg.application_exception THEN
37773 RAISE;
37774 WHEN OTHERS THEN
37775 xla_exceptions_pkg.raise_message
37776 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_78');
37777 END AcctLineType_78;
37778 --
37779
37780 ---------------------------------------
37781 --
37782 -- PRIVATE FUNCTION
37783 -- AcctLineType_79
37784 --
37785 ---------------------------------------
37786 PROCEDURE AcctLineType_79 (
37787 p_application_id IN NUMBER
37788 ,p_event_id IN NUMBER
37789 ,p_calculate_acctd_flag IN VARCHAR2
37790 ,p_calculate_g_l_flag IN VARCHAR2
37791 ,p_actual_flag IN OUT VARCHAR2
37792 ,p_balance_type_code OUT VARCHAR2
37793 ,p_gain_or_loss_ref OUT VARCHAR2
37794
37795 --Remittance Bank Account Remittance Account
37796 , p_source_6 IN NUMBER
37797 --Transaction Distribution GL Account
37798 , p_source_14 IN NUMBER
37799 --Distribution Source Type
37800 , p_source_15 IN VARCHAR2
37801 --Distribution Line Identifier
37802 , p_source_17 IN NUMBER
37803 --Distribution Type
37804 , p_source_18 IN VARCHAR2
37805 --Exchange Date
37806 , p_source_21 IN DATE
37807 --Exchange Rate
37808 , p_source_22 IN NUMBER
37809 --Exchange Rate Type
37810 , p_source_23 IN VARCHAR2
37811 --Transaction Distribution Identifier
37812 , p_source_29 IN NUMBER
37813 --Transaction Distribution Type
37814 , p_source_30 IN VARCHAR2
37815 --Distribution Multi Fund Additional Entry
37816 , p_source_54 IN VARCHAR2
37817 --Receipt Applied To Application Identifier
37818 , p_source_58 IN NUMBER
37819 --Transaction Entity Code
37820 , p_source_59 IN VARCHAR2
37821 --Transaction Identifier
37822 , p_source_60 IN NUMBER
37823 --DIST_ENT_AMT_FROM
37824 , p_source_61 IN NUMBER
37825 --Applying Document Currency Code
37826 , p_source_62 IN VARCHAR2
37827 --Accounting Amount
37828 , p_source_63 IN NUMBER
37829 --Distribution Party Identifier
37830 , p_source_64 IN NUMBER
37831 --Distribution Party Site Id
37832 , p_source_65 IN NUMBER
37833 --Distribution Party Type
37834 , p_source_66 IN VARCHAR2
37835 )
37836 IS
37837
37838 l_component_type VARCHAR2(80);
37839 l_component_code VARCHAR2(30);
37840 l_component_type_code VARCHAR2(1);
37841 l_component_appl_id INTEGER;
37842 l_amb_context_code VARCHAR2(30);
37843 l_entity_code VARCHAR2(30);
37844 l_event_class_code VARCHAR2(30);
37845 l_ae_header_id NUMBER;
37846 l_event_type_code VARCHAR2(30);
37847 l_line_definition_code VARCHAR2(30);
37848 l_line_definition_owner_code VARCHAR2(1);
37849 --
37850 -- adr variables
37851 l_segment VARCHAR2(30);
37852 l_ccid NUMBER;
37853 l_adr_transaction_coa_id NUMBER;
37854 l_adr_accounting_coa_id NUMBER;
37855 l_adr_flexfield_segment_code VARCHAR2(30);
37856 l_adr_flex_value_set_id NUMBER;
37857 l_adr_value_type_code VARCHAR2(30);
37858 l_adr_value_combination_id NUMBER;
37859 l_adr_value_segment_code VARCHAR2(30);
37860
37861 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
37862 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
37863 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
37864 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
37865
37866 -- 4262811 Variables ------------------------------------------------------------------------------------------
37867 l_entered_amt_idx NUMBER;
37868 l_accted_amt_idx NUMBER;
37869 l_acc_rev_flag VARCHAR2(1);
37870 l_accrual_line_num NUMBER;
37871 l_tmp_amt NUMBER;
37872 l_acc_rev_natural_side_code VARCHAR2(1);
37873
37874 l_num_entries NUMBER;
37875 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
37876 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
37877 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
37878 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
37879 l_recog_line_1 NUMBER;
37880 l_recog_line_2 NUMBER;
37881
37882 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
37883 l_bflow_applied_to_amt NUMBER; -- 5132302
37884 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
37885
37886 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
37887
37888 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
37892
37889 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
37890
37891 ---------------------------------------------------------------------------------------------------------------
37893
37894 --
37895 -- bulk performance
37896 --
37897 l_balance_type_code VARCHAR2(1);
37898 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
37899 l_log_module VARCHAR2(240);
37900
37901 --
37902 -- Upgrade strategy
37903 --
37904 l_actual_upg_option VARCHAR2(1);
37905 l_enc_upg_option VARCHAR2(1);
37906
37907 --
37908 BEGIN
37909 --
37910 IF g_log_enabled THEN
37911 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_79';
37912 END IF;
37913 --
37914 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37915
37916 trace
37917 (p_msg => 'BEGIN of AcctLineType_79'
37918 ,p_level => C_LEVEL_PROCEDURE
37919 ,p_module => l_log_module);
37920
37921 END IF;
37922 --
37923 l_component_type := 'AMB_JLT';
37924 l_component_code := 'RCT_APP_MFAR_TRX_REMITTANCE';
37925 l_component_type_code := 'S';
37926 l_component_appl_id := 222;
37927 l_amb_context_code := 'DEFAULT';
37928 l_entity_code := 'RECEIPTS';
37929 l_event_class_code := 'RECEIPT';
37930 l_event_type_code := 'RECEIPT_ALL';
37931 l_line_definition_owner_code := 'S';
37932 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
37933 --
37934 l_balance_type_code := 'A';
37935 l_segment := NULL;
37936 l_ccid := NULL;
37937 l_adr_transaction_coa_id := NULL;
37938 l_adr_accounting_coa_id := NULL;
37939 l_adr_flexfield_segment_code := NULL;
37940 l_adr_flex_value_set_id := NULL;
37941 l_adr_value_type_code := NULL;
37942 l_adr_value_combination_id := NULL;
37943 l_adr_value_segment_code := NULL;
37944
37945 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
37946 l_bflow_class_code := ''; -- 4219869 Business Flow
37947 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
37948 l_budgetary_control_flag := 'N';
37949
37950 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37951 l_bflow_applied_to_amt := NULL; -- 5132302
37952 l_entered_amt_idx := NULL; -- 4262811
37953 l_accted_amt_idx := NULL; -- 4262811
37954 l_acc_rev_flag := NULL; -- 4262811
37955 l_accrual_line_num := NULL; -- 4262811
37956 l_tmp_amt := NULL; -- 4262811
37957 --
37958
37959 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
37960 l_balance_type_code <> 'B' THEN
37961 IF NVL(p_source_15,'
37962 ') = 'REMITTANCE' AND
37963 NVL(p_source_54,'
37964 ') = 'Y'
37965 THEN
37966
37967 --
37968 XLA_AE_LINES_PKG.SetNewLine;
37969
37970 p_balance_type_code := l_balance_type_code;
37971 -- set the flag so later we will know whether the gain loss line needs to be created
37972
37973 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
37974 p_actual_flag :='A';
37975 END IF;
37976
37977 --
37978 -- bulk performance
37979 --
37980 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
37981 p_header_num => 0); -- 4262811
37982 --
37983 -- set accounting line options
37984 --
37985 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
37986 p_natural_side_code => 'C'
37987 , p_gain_or_loss_flag => 'N'
37988 , p_gl_transfer_mode_code => 'S'
37989 , p_acct_entry_type_code => 'A'
37990 , p_switch_side_flag => 'Y'
37991 , p_merge_duplicate_code => 'A'
37992 );
37993 --
37994 l_acc_rev_natural_side_code := 'D'; -- 4262811
37995 --
37996 --
37997 -- set accounting line type info
37998 --
37999 xla_ae_lines_pkg.SetAcctLineType
38000 (p_component_type => l_component_type
38001 ,p_event_type_code => l_event_type_code
38002 ,p_line_definition_owner_code => l_line_definition_owner_code
38003 ,p_line_definition_code => l_line_definition_code
38004 ,p_accounting_line_code => l_component_code
38005 ,p_accounting_line_type_code => l_component_type_code
38006 ,p_accounting_line_appl_id => l_component_appl_id
38007 ,p_amb_context_code => l_amb_context_code
38008 ,p_entity_code => l_entity_code
38009 ,p_event_class_code => l_event_class_code);
38010 --
38011 -- set accounting class
38012 --
38013 xla_ae_lines_pkg.SetAcctClass(
38014 p_accounting_class_code => 'REMITTANCE'
38015 , p_ae_header_id => l_ae_header_id
38016 );
38017
38018 --
38019 -- set rounding class
38020 --
38021 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
38022 'RECEIVABLE';
38023
38024 --
38025 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
38026 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
38027 --
38028 -- bulk performance
38029 --
38030 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
38034
38031
38032 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
38033 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
38035 -- 4955764
38036 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38037 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
38038
38039 -- 4458381 Public Sector Enh
38040
38041 --
38042 -- set accounting attributes for the line type
38043 --
38044 l_entered_amt_idx := 8;
38045 l_accted_amt_idx := 13;
38046 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38047 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
38048 l_rec_acct_attrs.array_num_value(1) := p_source_58;
38049 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
38050 l_rec_acct_attrs.array_char_value(2) := p_source_30;
38051 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
38052 l_rec_acct_attrs.array_char_value(3) := p_source_59;
38053 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
38054 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
38055 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
38056 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
38057 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
38058 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
38059 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
38060 l_rec_acct_attrs.array_char_value(7) := p_source_18;
38061 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
38062 l_rec_acct_attrs.array_num_value(8) := p_source_61;
38063 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
38064 l_rec_acct_attrs.array_char_value(9) := p_source_62;
38065 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
38066 l_rec_acct_attrs.array_date_value(10) := p_source_21;
38067 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
38068 l_rec_acct_attrs.array_num_value(11) := p_source_22;
38069 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
38070 l_rec_acct_attrs.array_char_value(12) := p_source_23;
38071 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
38072 l_rec_acct_attrs.array_num_value(13) := p_source_63;
38073 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
38074 l_rec_acct_attrs.array_num_value(14) := p_source_64;
38075 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
38076 l_rec_acct_attrs.array_num_value(15) := p_source_65;
38077 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
38078 l_rec_acct_attrs.array_char_value(16) := p_source_66;
38079
38080 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
38081 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
38082
38083 ---------------------------------------------------------------------------------------------------------------
38084 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
38085 ---------------------------------------------------------------------------------------------------------------
38086 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
38087
38088 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38089 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38090
38091 IF xla_accounting_cache_pkg.GetValueChar
38092 (p_source_code => 'LEDGER_CATEGORY_CODE'
38093 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
38094 AND l_bflow_method_code = 'PRIOR_ENTRY'
38095 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
38096 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
38097 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
38098 )
38099 THEN
38100 xla_ae_lines_pkg.BflowUpgEntry
38101 (p_business_method_code => l_bflow_method_code
38102 ,p_business_class_code => l_bflow_class_code
38103 ,p_balance_type => l_balance_type_code);
38104 ELSE
38105 NULL;
38106 -- No business flow processing for business flow method of NONE.
38107 END IF;
38108
38109 --
38110 -- call analytical criteria
38111 --
38112
38113 --
38114 -- call description
38115 --
38116
38117 xla_ae_lines_pkg.SetLineDescription(
38118 p_ae_header_id => l_ae_header_id
38119 ,p_description => Description_1 (
38120 p_application_id => p_application_id
38121 , p_ae_header_id => l_ae_header_id
38122 )
38123 );
38124
38125
38126 --
38127 -- call ADRs
38128 -- Bug 4922099
38129 --
38130 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38131 (NVL(l_actual_upg_option, 'N') = 'O') OR
38132 (NVL(l_enc_upg_option, 'N') = 'O')
38133 )
38134 THEN
38135 NULL;
38136 --
38137 --
38138
38139 l_ccid := AcctDerRule_18(
38140 p_application_id => p_application_id
38141 , p_ae_header_id => l_ae_header_id
38142 , p_source_14 => p_source_14
38143 , x_transaction_coa_id => l_adr_transaction_coa_id
38144 , x_accounting_coa_id => l_adr_accounting_coa_id
38145 , x_value_type_code => l_adr_value_type_code
38146 , p_side => 'NA'
38147 );
38148
38149 xla_ae_lines_pkg.set_ccid(
38153 , p_accounting_coa_id => l_adr_accounting_coa_id
38150 p_code_combination_id => l_ccid
38151 , p_value_type_code => l_adr_value_type_code
38152 , p_transaction_coa_id => l_adr_transaction_coa_id
38154 , p_adr_code => 'TRX_DIST_CCID'
38155 , p_adr_type_code => 'S'
38156 , p_component_type => l_component_type
38157 , p_component_code => l_component_code
38158 , p_component_type_code => l_component_type_code
38159 , p_component_appl_id => l_component_appl_id
38160 , p_amb_context_code => l_amb_context_code
38161 , p_side => 'NA'
38162 );
38163
38164
38165 l_segment := AcctDerRule_7(
38166 p_application_id => p_application_id
38167 , p_ae_header_id => l_ae_header_id
38168 , p_source_6 => p_source_6
38169 , x_transaction_coa_id => l_adr_transaction_coa_id
38170 , x_accounting_coa_id => l_adr_accounting_coa_id
38171 , x_flexfield_segment_code => l_adr_flexfield_segment_code
38172 , x_flex_value_set_id => l_adr_flex_value_set_id
38173 , x_value_type_code => l_adr_value_type_code
38174 , x_value_combination_id => l_adr_value_combination_id
38175 , x_value_segment_code => l_adr_value_segment_code
38176 , p_side => 'NA'
38177 , p_override_seg_flag => 'Y'
38178 );
38179
38180 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
38181
38182 xla_ae_lines_pkg.set_segment(
38183 p_to_segment_code => 'GL_ACCOUNT'
38184 , p_segment_value => l_segment
38185 , p_from_segment_code => l_adr_value_segment_code
38186 , p_from_combination_id => l_adr_value_combination_id
38187 , p_value_type_code => l_adr_value_type_code
38188 , p_transaction_coa_id => l_adr_transaction_coa_id
38189 , p_accounting_coa_id => l_adr_accounting_coa_id
38190 , p_flexfield_segment_code => l_adr_flexfield_segment_code
38191 , p_flex_value_set_id => l_adr_flex_value_set_id
38192 , p_adr_code => 'MFAR_RCT_REMITTANCE_NATSEG'
38193 , p_adr_type_code => 'S'
38194 , p_component_type => l_component_type
38195 , p_component_code => l_component_code
38196 , p_component_type_code => l_component_type_code
38197 , p_component_appl_id => l_component_appl_id
38198 , p_amb_context_code => l_amb_context_code
38199 , p_entity_code => 'RECEIPTS'
38200 , p_event_class_code => 'RECEIPT'
38201 , p_side => 'NA'
38202 );
38203
38204 END IF;
38205
38206 --
38207 --
38208 END IF;
38209 --
38210 -- Bug 4922099
38211 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
38212 (NVL(l_enc_upg_option, 'N') = 'O')
38213 ) AND
38214 (l_bflow_method_code = 'PRIOR_ENTRY')
38215 )
38216 THEN
38217 IF
38218 --
38219 1 = 2
38220 --
38221 THEN
38222 xla_accounting_err_pkg.build_message
38223 (p_appli_s_name => 'XLA'
38224 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38225 ,p_token_1 => 'LINE_NUMBER'
38226 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
38227 ,p_token_2 => 'LINE_TYPE_NAME'
38228 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
38229 l_component_type
38230 ,l_component_code
38231 ,l_component_type_code
38232 ,l_component_appl_id
38233 ,l_amb_context_code
38234 ,l_entity_code
38235 ,l_event_class_code
38236 )
38237 ,p_token_3 => 'OWNER'
38238 ,p_value_3 => xla_lookups_pkg.get_meaning(
38239 p_lookup_type => 'XLA_OWNER_TYPE'
38240 ,p_lookup_code => l_component_type_code
38241 )
38242 ,p_token_4 => 'PRODUCT_NAME'
38243 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
38244 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
38245 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
38246 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
38247 ,p_ae_header_id => NULL
38248 );
38249
38253 ,p_level => C_LEVEL_ERROR
38250 IF (C_LEVEL_ERROR>= g_log_level) THEN
38251 trace
38252 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38254 ,p_module => l_log_module);
38255 END IF;
38256 END IF;
38257 END IF;
38258 --
38259 --
38260 ------------------------------------------------------------------------------------------------
38261 -- 4219869 Business Flow
38262 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
38263 -- Prior Entry. Currently, the following code is always generated.
38264 ------------------------------------------------------------------------------------------------
38265 XLA_AE_LINES_PKG.ValidateCurrentLine;
38266
38267 ------------------------------------------------------------------------------------
38268 -- 4219869 Business Flow
38269 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
38270 ------------------------------------------------------------------------------------
38271 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38272
38273 ----------------------------------------------------------------------------------
38274 -- 4219869 Business Flow
38275 -- Update journal entry status -- Need to generate this within IF <condition>
38276 ----------------------------------------------------------------------------------
38277 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38278 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
38279 ,p_balance_type_code => l_balance_type_code
38280 );
38281
38282 -------------------------------------------------------------------------------------------
38283 -- 4262811 - Generate the Accrual Reversal lines
38284 -------------------------------------------------------------------------------------------
38285 BEGIN
38286 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
38287 (g_array_event(p_event_id).array_value_num('header_index'));
38288 IF l_acc_rev_flag IS NULL THEN
38289 l_acc_rev_flag := 'N';
38290 END IF;
38291 EXCEPTION
38292 WHEN OTHERS THEN
38293 l_acc_rev_flag := 'N';
38294 END;
38295 --
38296 IF (l_acc_rev_flag = 'Y') THEN
38297
38298 -- 4645092 ------------------------------------------------------------------------------
38299 -- To allow MPA report to determine if it should generate report process
38300 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
38301 ------------------------------------------------------------------------------------------
38302
38303 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
38304 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
38305 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
38306 -- call ADRs
38307 -- Bug 4922099
38308 --
38309 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38310 (NVL(l_actual_upg_option, 'N') = 'O') OR
38311 (NVL(l_enc_upg_option, 'N') = 'O')
38312 )
38313 THEN
38314 NULL;
38315 --
38316 --
38317
38318 l_ccid := AcctDerRule_18(
38319 p_application_id => p_application_id
38320 , p_ae_header_id => l_ae_header_id
38321 , p_source_14 => p_source_14
38322 , x_transaction_coa_id => l_adr_transaction_coa_id
38323 , x_accounting_coa_id => l_adr_accounting_coa_id
38324 , x_value_type_code => l_adr_value_type_code
38325 , p_side => 'NA'
38326 );
38327
38328 xla_ae_lines_pkg.set_ccid(
38329 p_code_combination_id => l_ccid
38330 , p_value_type_code => l_adr_value_type_code
38331 , p_transaction_coa_id => l_adr_transaction_coa_id
38332 , p_accounting_coa_id => l_adr_accounting_coa_id
38333 , p_adr_code => 'TRX_DIST_CCID'
38334 , p_adr_type_code => 'S'
38335 , p_component_type => l_component_type
38336 , p_component_code => l_component_code
38337 , p_component_type_code => l_component_type_code
38338 , p_component_appl_id => l_component_appl_id
38339 , p_amb_context_code => l_amb_context_code
38340 , p_side => 'NA'
38341 );
38342
38343
38344 l_segment := AcctDerRule_7(
38345 p_application_id => p_application_id
38346 , p_ae_header_id => l_ae_header_id
38347 , p_source_6 => p_source_6
38348 , x_transaction_coa_id => l_adr_transaction_coa_id
38349 , x_accounting_coa_id => l_adr_accounting_coa_id
38350 , x_flexfield_segment_code => l_adr_flexfield_segment_code
38351 , x_flex_value_set_id => l_adr_flex_value_set_id
38352 , x_value_type_code => l_adr_value_type_code
38353 , x_value_combination_id => l_adr_value_combination_id
38354 , x_value_segment_code => l_adr_value_segment_code
38355 , p_side => 'NA'
38356 , p_override_seg_flag => 'Y'
38357 );
38358
38359 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
38360
38361 xla_ae_lines_pkg.set_segment(
38362 p_to_segment_code => 'GL_ACCOUNT'
38363 , p_segment_value => l_segment
38364 , p_from_segment_code => l_adr_value_segment_code
38365 , p_from_combination_id => l_adr_value_combination_id
38366 , p_value_type_code => l_adr_value_type_code
38370 , p_flex_value_set_id => l_adr_flex_value_set_id
38367 , p_transaction_coa_id => l_adr_transaction_coa_id
38368 , p_accounting_coa_id => l_adr_accounting_coa_id
38369 , p_flexfield_segment_code => l_adr_flexfield_segment_code
38371 , p_adr_code => 'MFAR_RCT_REMITTANCE_NATSEG'
38372 , p_adr_type_code => 'S'
38373 , p_component_type => l_component_type
38374 , p_component_code => l_component_code
38375 , p_component_type_code => l_component_type_code
38376 , p_component_appl_id => l_component_appl_id
38377 , p_amb_context_code => l_amb_context_code
38378 , p_entity_code => 'RECEIPTS'
38379 , p_event_class_code => 'RECEIPT'
38380 , p_side => 'NA'
38381 );
38382
38383 END IF;
38384
38385 --
38386 --
38387 END IF;
38388
38389 --
38390 -- Update the line information that should be overwritten
38391 --
38392 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
38393 p_header_num => 1);
38394 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
38395
38396 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
38397
38398 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
38399 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
38400 END IF;
38401
38402 --
38403 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
38404 --
38405 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
38406 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
38407 ELSE
38408 ---------------------------------------------------------------------------------------------------
38409 -- 4262811a Switch Sign
38410 ---------------------------------------------------------------------------------------------------
38411 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
38412 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38413 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38414 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38415 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38416 -- 5132302
38417 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
38418 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38419
38420 END IF;
38421
38422 -- 4955764
38423 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38424 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
38425
38426
38427 XLA_AE_LINES_PKG.ValidateCurrentLine;
38428 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38429
38430 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38431 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
38432 ,p_balance_type_code => l_balance_type_code);
38433
38434 END IF;
38435
38436 -----------------------------------------------------------------------------------------
38437 -- 4262811 Multiperiod Accounting
38438 -----------------------------------------------------------------------------------------
38439 -- No MPA option is assigned.
38440
38441
38442 END IF;
38443 END IF;
38444 --
38445
38446 --
38447 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38448 trace
38449 (p_msg => 'END of AcctLineType_79'
38450 ,p_level => C_LEVEL_PROCEDURE
38451 ,p_module => l_log_module);
38452 END IF;
38453 --
38454 EXCEPTION
38455 WHEN xla_exceptions_pkg.application_exception THEN
38456 RAISE;
38457 WHEN OTHERS THEN
38458 xla_exceptions_pkg.raise_message
38459 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_79');
38460 END AcctLineType_79;
38461 --
38462
38463 ---------------------------------------
38464 --
38465 -- PRIVATE FUNCTION
38466 -- AcctLineType_80
38467 --
38468 ---------------------------------------
38469 PROCEDURE AcctLineType_80 (
38470 p_application_id IN NUMBER
38471 ,p_event_id IN NUMBER
38472 ,p_calculate_acctd_flag IN VARCHAR2
38473 ,p_calculate_g_l_flag IN VARCHAR2
38474 ,p_actual_flag IN OUT VARCHAR2
38475 ,p_balance_type_code OUT VARCHAR2
38476 ,p_gain_or_loss_ref OUT VARCHAR2
38477
38478 --Distribution GL Account
38479 , p_source_10 IN NUMBER
38480 --Distribution Source Type
38481 , p_source_15 IN VARCHAR2
38482 --Distribution Line Identifier
38483 , p_source_17 IN NUMBER
38484 --Distribution Type
38485 , p_source_18 IN VARCHAR2
38486 --Exchange Date
38487 , p_source_21 IN DATE
38488 --Exchange Rate
38489 , p_source_22 IN NUMBER
38490 --Exchange Rate Type
38494 --Transaction Distribution Type
38491 , p_source_23 IN VARCHAR2
38492 --Transaction Distribution Identifier
38493 , p_source_29 IN NUMBER
38495 , p_source_30 IN VARCHAR2
38496 --Distribution Multi Fund Additional Entry
38497 , p_source_54 IN VARCHAR2
38498 --Receipt Applied To Application Identifier
38499 , p_source_58 IN NUMBER
38500 --Transaction Entity Code
38501 , p_source_59 IN VARCHAR2
38502 --Transaction Identifier
38503 , p_source_60 IN NUMBER
38504 --DIST_ENT_AMT_FROM
38505 , p_source_61 IN NUMBER
38506 --Applying Document Currency Code
38507 , p_source_62 IN VARCHAR2
38508 --Accounting Amount
38509 , p_source_63 IN NUMBER
38510 --Distribution Party Identifier
38511 , p_source_64 IN NUMBER
38512 --Distribution Party Site Id
38513 , p_source_65 IN NUMBER
38514 --Distribution Party Type
38515 , p_source_66 IN VARCHAR2
38516 )
38517 IS
38518
38519 l_component_type VARCHAR2(80);
38520 l_component_code VARCHAR2(30);
38521 l_component_type_code VARCHAR2(1);
38522 l_component_appl_id INTEGER;
38523 l_amb_context_code VARCHAR2(30);
38524 l_entity_code VARCHAR2(30);
38525 l_event_class_code VARCHAR2(30);
38526 l_ae_header_id NUMBER;
38527 l_event_type_code VARCHAR2(30);
38528 l_line_definition_code VARCHAR2(30);
38529 l_line_definition_owner_code VARCHAR2(1);
38530 --
38531 -- adr variables
38532 l_segment VARCHAR2(30);
38533 l_ccid NUMBER;
38534 l_adr_transaction_coa_id NUMBER;
38535 l_adr_accounting_coa_id NUMBER;
38536 l_adr_flexfield_segment_code VARCHAR2(30);
38537 l_adr_flex_value_set_id NUMBER;
38538 l_adr_value_type_code VARCHAR2(30);
38539 l_adr_value_combination_id NUMBER;
38540 l_adr_value_segment_code VARCHAR2(30);
38541
38542 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
38543 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
38544 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
38545 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
38546
38547 -- 4262811 Variables ------------------------------------------------------------------------------------------
38548 l_entered_amt_idx NUMBER;
38549 l_accted_amt_idx NUMBER;
38550 l_acc_rev_flag VARCHAR2(1);
38551 l_accrual_line_num NUMBER;
38552 l_tmp_amt NUMBER;
38553 l_acc_rev_natural_side_code VARCHAR2(1);
38554
38555 l_num_entries NUMBER;
38556 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
38557 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
38558 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
38559 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
38560 l_recog_line_1 NUMBER;
38561 l_recog_line_2 NUMBER;
38562
38563 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
38564 l_bflow_applied_to_amt NUMBER; -- 5132302
38565 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
38566
38567 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
38568
38569 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
38570 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
38571
38572 ---------------------------------------------------------------------------------------------------------------
38573
38574
38575 --
38576 -- bulk performance
38577 --
38578 l_balance_type_code VARCHAR2(1);
38579 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
38580 l_log_module VARCHAR2(240);
38581
38582 --
38583 -- Upgrade strategy
38584 --
38585 l_actual_upg_option VARCHAR2(1);
38586 l_enc_upg_option VARCHAR2(1);
38587
38588 --
38589 BEGIN
38590 --
38591 IF g_log_enabled THEN
38592 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_80';
38593 END IF;
38594 --
38595 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38596
38597 trace
38598 (p_msg => 'BEGIN of AcctLineType_80'
38599 ,p_level => C_LEVEL_PROCEDURE
38600 ,p_module => l_log_module);
38601
38602 END IF;
38603 --
38604 l_component_type := 'AMB_JLT';
38605 l_component_code := 'RCT_BNK_CHG';
38606 l_component_type_code := 'S';
38607 l_component_appl_id := 222;
38608 l_amb_context_code := 'DEFAULT';
38609 l_entity_code := 'RECEIPTS';
38610 l_event_class_code := 'RECEIPT';
38611 l_event_type_code := 'RECEIPT_ALL';
38612 l_line_definition_owner_code := 'S';
38613 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
38614 --
38615 l_balance_type_code := 'A';
38616 l_segment := NULL;
38617 l_ccid := NULL;
38618 l_adr_transaction_coa_id := NULL;
38619 l_adr_accounting_coa_id := NULL;
38620 l_adr_flexfield_segment_code := NULL;
38621 l_adr_flex_value_set_id := NULL;
38622 l_adr_value_type_code := NULL;
38623 l_adr_value_combination_id := NULL;
38627 l_bflow_class_code := ''; -- 4219869 Business Flow
38624 l_adr_value_segment_code := NULL;
38625
38626 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
38628 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
38629 l_budgetary_control_flag := 'N';
38630
38631 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38632 l_bflow_applied_to_amt := NULL; -- 5132302
38633 l_entered_amt_idx := NULL; -- 4262811
38634 l_accted_amt_idx := NULL; -- 4262811
38635 l_acc_rev_flag := NULL; -- 4262811
38636 l_accrual_line_num := NULL; -- 4262811
38637 l_tmp_amt := NULL; -- 4262811
38638 --
38639
38640 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
38641 l_balance_type_code <> 'B' THEN
38642 IF NVL(p_source_15,'
38643 ') = 'BANK_CHARGES' AND
38644 NVL(p_source_54,'
38645 ') = 'N'
38646 THEN
38647
38648 --
38649 XLA_AE_LINES_PKG.SetNewLine;
38650
38651 p_balance_type_code := l_balance_type_code;
38652 -- set the flag so later we will know whether the gain loss line needs to be created
38653
38654 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
38655 p_actual_flag :='A';
38656 END IF;
38657
38658 --
38659 -- bulk performance
38660 --
38661 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
38662 p_header_num => 0); -- 4262811
38663 --
38664 -- set accounting line options
38665 --
38666 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
38667 p_natural_side_code => 'C'
38668 , p_gain_or_loss_flag => 'N'
38669 , p_gl_transfer_mode_code => 'S'
38670 , p_acct_entry_type_code => 'A'
38671 , p_switch_side_flag => 'Y'
38672 , p_merge_duplicate_code => 'A'
38673 );
38674 --
38675 l_acc_rev_natural_side_code := 'D'; -- 4262811
38676 --
38677 --
38678 -- set accounting line type info
38679 --
38680 xla_ae_lines_pkg.SetAcctLineType
38681 (p_component_type => l_component_type
38682 ,p_event_type_code => l_event_type_code
38683 ,p_line_definition_owner_code => l_line_definition_owner_code
38684 ,p_line_definition_code => l_line_definition_code
38685 ,p_accounting_line_code => l_component_code
38686 ,p_accounting_line_type_code => l_component_type_code
38687 ,p_accounting_line_appl_id => l_component_appl_id
38688 ,p_amb_context_code => l_amb_context_code
38689 ,p_entity_code => l_entity_code
38690 ,p_event_class_code => l_event_class_code);
38691 --
38692 -- set accounting class
38693 --
38694 xla_ae_lines_pkg.SetAcctClass(
38695 p_accounting_class_code => 'BANK_CHG'
38696 , p_ae_header_id => l_ae_header_id
38697 );
38698
38699 --
38700 -- set rounding class
38701 --
38702 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
38703 'RECEIVABLE';
38704
38705 --
38706 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
38707 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
38708 --
38709 -- bulk performance
38710 --
38711 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
38712
38713 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
38714 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
38715
38716 -- 4955764
38717 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38718 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
38719
38720 -- 4458381 Public Sector Enh
38721
38722 --
38723 -- set accounting attributes for the line type
38724 --
38725 l_entered_amt_idx := 8;
38726 l_accted_amt_idx := 13;
38727 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38728 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
38729 l_rec_acct_attrs.array_num_value(1) := p_source_58;
38730 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
38731 l_rec_acct_attrs.array_char_value(2) := p_source_30;
38732 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
38733 l_rec_acct_attrs.array_char_value(3) := p_source_59;
38734 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
38735 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
38736 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
38737 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
38738 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
38739 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
38740 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
38741 l_rec_acct_attrs.array_char_value(7) := p_source_18;
38742 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
38743 l_rec_acct_attrs.array_num_value(8) := p_source_61;
38744 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
38745 l_rec_acct_attrs.array_char_value(9) := p_source_62;
38749 l_rec_acct_attrs.array_num_value(11) := p_source_22;
38746 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
38747 l_rec_acct_attrs.array_date_value(10) := p_source_21;
38748 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
38750 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
38751 l_rec_acct_attrs.array_char_value(12) := p_source_23;
38752 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
38753 l_rec_acct_attrs.array_num_value(13) := p_source_63;
38754 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
38755 l_rec_acct_attrs.array_num_value(14) := p_source_64;
38756 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
38757 l_rec_acct_attrs.array_num_value(15) := p_source_65;
38758 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
38759 l_rec_acct_attrs.array_char_value(16) := p_source_66;
38760
38761 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
38762 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
38763
38764 ---------------------------------------------------------------------------------------------------------------
38765 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
38766 ---------------------------------------------------------------------------------------------------------------
38767 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
38768
38769 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38770 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38771
38772 IF xla_accounting_cache_pkg.GetValueChar
38773 (p_source_code => 'LEDGER_CATEGORY_CODE'
38774 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
38775 AND l_bflow_method_code = 'PRIOR_ENTRY'
38776 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
38777 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
38778 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
38779 )
38780 THEN
38781 xla_ae_lines_pkg.BflowUpgEntry
38782 (p_business_method_code => l_bflow_method_code
38783 ,p_business_class_code => l_bflow_class_code
38784 ,p_balance_type => l_balance_type_code);
38785 ELSE
38786 NULL;
38787 -- No business flow processing for business flow method of NONE.
38788 END IF;
38789
38790 --
38791 -- call analytical criteria
38792 --
38793
38794 --
38795 -- call description
38796 --
38797 -- No description or it is inherited.
38798 --
38799 -- call ADRs
38800 -- Bug 4922099
38801 --
38802 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38803 (NVL(l_actual_upg_option, 'N') = 'O') OR
38804 (NVL(l_enc_upg_option, 'N') = 'O')
38805 )
38806 THEN
38807 NULL;
38808 --
38809 --
38810
38811 l_ccid := AcctDerRule_11(
38812 p_application_id => p_application_id
38813 , p_ae_header_id => l_ae_header_id
38814 , p_source_10 => p_source_10
38815 , x_transaction_coa_id => l_adr_transaction_coa_id
38816 , x_accounting_coa_id => l_adr_accounting_coa_id
38817 , x_value_type_code => l_adr_value_type_code
38818 , p_side => 'NA'
38819 );
38820
38821 xla_ae_lines_pkg.set_ccid(
38822 p_code_combination_id => l_ccid
38823 , p_value_type_code => l_adr_value_type_code
38824 , p_transaction_coa_id => l_adr_transaction_coa_id
38825 , p_accounting_coa_id => l_adr_accounting_coa_id
38826 , p_adr_code => 'DIST_CCID'
38827 , p_adr_type_code => 'S'
38828 , p_component_type => l_component_type
38829 , p_component_code => l_component_code
38830 , p_component_type_code => l_component_type_code
38831 , p_component_appl_id => l_component_appl_id
38832 , p_amb_context_code => l_amb_context_code
38833 , p_side => 'NA'
38834 );
38835
38836
38837 --
38838 --
38839 END IF;
38840 --
38841 -- Bug 4922099
38842 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
38843 (NVL(l_enc_upg_option, 'N') = 'O')
38844 ) AND
38845 (l_bflow_method_code = 'PRIOR_ENTRY')
38846 )
38847 THEN
38848 IF
38849 --
38850 1 = 2
38851 --
38852 THEN
38853 xla_accounting_err_pkg.build_message
38854 (p_appli_s_name => 'XLA'
38855 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38856 ,p_token_1 => 'LINE_NUMBER'
38857 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
38858 ,p_token_2 => 'LINE_TYPE_NAME'
38859 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
38860 l_component_type
38861 ,l_component_code
38862 ,l_component_type_code
38863 ,l_component_appl_id
38867 )
38864 ,l_amb_context_code
38865 ,l_entity_code
38866 ,l_event_class_code
38868 ,p_token_3 => 'OWNER'
38869 ,p_value_3 => xla_lookups_pkg.get_meaning(
38870 p_lookup_type => 'XLA_OWNER_TYPE'
38871 ,p_lookup_code => l_component_type_code
38872 )
38873 ,p_token_4 => 'PRODUCT_NAME'
38874 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
38875 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
38876 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
38877 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
38878 ,p_ae_header_id => NULL
38879 );
38880
38881 IF (C_LEVEL_ERROR>= g_log_level) THEN
38882 trace
38883 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38884 ,p_level => C_LEVEL_ERROR
38885 ,p_module => l_log_module);
38886 END IF;
38887 END IF;
38888 END IF;
38889 --
38890 --
38891 ------------------------------------------------------------------------------------------------
38892 -- 4219869 Business Flow
38893 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
38894 -- Prior Entry. Currently, the following code is always generated.
38895 ------------------------------------------------------------------------------------------------
38896 XLA_AE_LINES_PKG.ValidateCurrentLine;
38897
38898 ------------------------------------------------------------------------------------
38899 -- 4219869 Business Flow
38900 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
38901 ------------------------------------------------------------------------------------
38902 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38903
38904 ----------------------------------------------------------------------------------
38905 -- 4219869 Business Flow
38906 -- Update journal entry status -- Need to generate this within IF <condition>
38907 ----------------------------------------------------------------------------------
38908 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38909 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
38910 ,p_balance_type_code => l_balance_type_code
38911 );
38912
38913 -------------------------------------------------------------------------------------------
38914 -- 4262811 - Generate the Accrual Reversal lines
38915 -------------------------------------------------------------------------------------------
38916 BEGIN
38917 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
38918 (g_array_event(p_event_id).array_value_num('header_index'));
38919 IF l_acc_rev_flag IS NULL THEN
38920 l_acc_rev_flag := 'N';
38921 END IF;
38922 EXCEPTION
38923 WHEN OTHERS THEN
38924 l_acc_rev_flag := 'N';
38925 END;
38926 --
38927 IF (l_acc_rev_flag = 'Y') THEN
38928
38929 -- 4645092 ------------------------------------------------------------------------------
38930 -- To allow MPA report to determine if it should generate report process
38931 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
38932 ------------------------------------------------------------------------------------------
38933
38934 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
38935 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
38936 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
38937 -- call ADRs
38938 -- Bug 4922099
38939 --
38940 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38941 (NVL(l_actual_upg_option, 'N') = 'O') OR
38942 (NVL(l_enc_upg_option, 'N') = 'O')
38943 )
38944 THEN
38945 NULL;
38946 --
38947 --
38948
38949 l_ccid := AcctDerRule_11(
38950 p_application_id => p_application_id
38951 , p_ae_header_id => l_ae_header_id
38952 , p_source_10 => p_source_10
38953 , x_transaction_coa_id => l_adr_transaction_coa_id
38954 , x_accounting_coa_id => l_adr_accounting_coa_id
38955 , x_value_type_code => l_adr_value_type_code
38956 , p_side => 'NA'
38957 );
38958
38959 xla_ae_lines_pkg.set_ccid(
38960 p_code_combination_id => l_ccid
38961 , p_value_type_code => l_adr_value_type_code
38962 , p_transaction_coa_id => l_adr_transaction_coa_id
38963 , p_accounting_coa_id => l_adr_accounting_coa_id
38964 , p_adr_code => 'DIST_CCID'
38965 , p_adr_type_code => 'S'
38966 , p_component_type => l_component_type
38967 , p_component_code => l_component_code
38968 , p_component_type_code => l_component_type_code
38969 , p_component_appl_id => l_component_appl_id
38973
38970 , p_amb_context_code => l_amb_context_code
38971 , p_side => 'NA'
38972 );
38974
38975 --
38976 --
38977 END IF;
38978
38979 --
38980 -- Update the line information that should be overwritten
38981 --
38982 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
38983 p_header_num => 1);
38984 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
38985
38986 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
38987
38988 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
38989 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
38990 END IF;
38991
38992 --
38993 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
38994 --
38995 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
38996 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
38997 ELSE
38998 ---------------------------------------------------------------------------------------------------
38999 -- 4262811a Switch Sign
39000 ---------------------------------------------------------------------------------------------------
39001 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
39002 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39003 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39004 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39005 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39006 -- 5132302
39007 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
39008 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39009
39010 END IF;
39011
39012 -- 4955764
39013 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39014 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
39015
39016
39017 XLA_AE_LINES_PKG.ValidateCurrentLine;
39018 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
39019
39020 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
39021 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
39022 ,p_balance_type_code => l_balance_type_code);
39023
39024 END IF;
39025
39026 -----------------------------------------------------------------------------------------
39027 -- 4262811 Multiperiod Accounting
39028 -----------------------------------------------------------------------------------------
39029 -- No MPA option is assigned.
39030
39031
39032 END IF;
39033 END IF;
39034 --
39035
39036 --
39037 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39038 trace
39039 (p_msg => 'END of AcctLineType_80'
39040 ,p_level => C_LEVEL_PROCEDURE
39041 ,p_module => l_log_module);
39042 END IF;
39043 --
39044 EXCEPTION
39045 WHEN xla_exceptions_pkg.application_exception THEN
39046 RAISE;
39047 WHEN OTHERS THEN
39048 xla_exceptions_pkg.raise_message
39049 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_80');
39050 END AcctLineType_80;
39051 --
39052
39053 ---------------------------------------
39054 --
39055 -- PRIVATE FUNCTION
39056 -- AcctLineType_81
39057 --
39058 ---------------------------------------
39059 PROCEDURE AcctLineType_81 (
39060 p_application_id IN NUMBER
39061 ,p_event_id IN NUMBER
39062 ,p_calculate_acctd_flag IN VARCHAR2
39063 ,p_calculate_g_l_flag IN VARCHAR2
39064 ,p_actual_flag IN OUT VARCHAR2
39065 ,p_balance_type_code OUT VARCHAR2
39066 ,p_gain_or_loss_ref OUT VARCHAR2
39067
39068 --Distribution GL Account
39069 , p_source_10 IN NUMBER
39070 --Distribution Source Type
39071 , p_source_15 IN VARCHAR2
39072 --Distribution Line Identifier
39073 , p_source_17 IN NUMBER
39074 --Distribution Type
39075 , p_source_18 IN VARCHAR2
39076 --Exchange Date
39077 , p_source_21 IN DATE
39078 --Exchange Rate
39079 , p_source_22 IN NUMBER
39080 --Exchange Rate Type
39081 , p_source_23 IN VARCHAR2
39082 --Transaction Distribution Identifier
39083 , p_source_29 IN NUMBER
39084 --Transaction Distribution Type
39085 , p_source_30 IN VARCHAR2
39086 --Distribution Multi Fund Additional Entry
39087 , p_source_54 IN VARCHAR2
39088 --Receipt Applied To Application Identifier
39089 , p_source_58 IN NUMBER
39090 --Transaction Entity Code
39091 , p_source_59 IN VARCHAR2
39092 --Transaction Identifier
39093 , p_source_60 IN NUMBER
39094 --DIST_ENT_AMT_FROM
39095 , p_source_61 IN NUMBER
39096 --Applying Document Currency Code
39097 , p_source_62 IN VARCHAR2
39098 --Accounting Amount
39099 , p_source_63 IN NUMBER
39100 --Distribution Party Identifier
39101 , p_source_64 IN NUMBER
39102 --Distribution Party Site Id
39103 , p_source_65 IN NUMBER
39104 --Distribution Party Type
39108
39105 , p_source_66 IN VARCHAR2
39106 )
39107 IS
39109 l_component_type VARCHAR2(80);
39110 l_component_code VARCHAR2(30);
39111 l_component_type_code VARCHAR2(1);
39112 l_component_appl_id INTEGER;
39113 l_amb_context_code VARCHAR2(30);
39114 l_entity_code VARCHAR2(30);
39115 l_event_class_code VARCHAR2(30);
39116 l_ae_header_id NUMBER;
39117 l_event_type_code VARCHAR2(30);
39118 l_line_definition_code VARCHAR2(30);
39119 l_line_definition_owner_code VARCHAR2(1);
39120 --
39121 -- adr variables
39122 l_segment VARCHAR2(30);
39123 l_ccid NUMBER;
39124 l_adr_transaction_coa_id NUMBER;
39125 l_adr_accounting_coa_id NUMBER;
39126 l_adr_flexfield_segment_code VARCHAR2(30);
39127 l_adr_flex_value_set_id NUMBER;
39128 l_adr_value_type_code VARCHAR2(30);
39129 l_adr_value_combination_id NUMBER;
39130 l_adr_value_segment_code VARCHAR2(30);
39131
39132 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
39133 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
39134 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
39135 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
39136
39137 -- 4262811 Variables ------------------------------------------------------------------------------------------
39138 l_entered_amt_idx NUMBER;
39139 l_accted_amt_idx NUMBER;
39140 l_acc_rev_flag VARCHAR2(1);
39141 l_accrual_line_num NUMBER;
39142 l_tmp_amt NUMBER;
39143 l_acc_rev_natural_side_code VARCHAR2(1);
39144
39145 l_num_entries NUMBER;
39146 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
39147 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
39148 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
39149 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
39150 l_recog_line_1 NUMBER;
39151 l_recog_line_2 NUMBER;
39152
39153 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
39154 l_bflow_applied_to_amt NUMBER; -- 5132302
39155 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
39156
39157 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
39158
39159 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
39160 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
39161
39162 ---------------------------------------------------------------------------------------------------------------
39163
39164
39165 --
39166 -- bulk performance
39167 --
39168 l_balance_type_code VARCHAR2(1);
39169 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
39170 l_log_module VARCHAR2(240);
39171
39172 --
39173 -- Upgrade strategy
39174 --
39175 l_actual_upg_option VARCHAR2(1);
39176 l_enc_upg_option VARCHAR2(1);
39177
39178 --
39179 BEGIN
39180 --
39181 IF g_log_enabled THEN
39182 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_81';
39183 END IF;
39184 --
39185 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39186
39187 trace
39188 (p_msg => 'BEGIN of AcctLineType_81'
39189 ,p_level => C_LEVEL_PROCEDURE
39190 ,p_module => l_log_module);
39191
39192 END IF;
39193 --
39194 l_component_type := 'AMB_JLT';
39195 l_component_code := 'RCT_CASH';
39196 l_component_type_code := 'S';
39197 l_component_appl_id := 222;
39198 l_amb_context_code := 'DEFAULT';
39199 l_entity_code := 'RECEIPTS';
39200 l_event_class_code := 'RECEIPT';
39201 l_event_type_code := 'RECEIPT_ALL';
39202 l_line_definition_owner_code := 'S';
39203 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
39204 --
39205 l_balance_type_code := 'A';
39206 l_segment := NULL;
39207 l_ccid := NULL;
39208 l_adr_transaction_coa_id := NULL;
39209 l_adr_accounting_coa_id := NULL;
39210 l_adr_flexfield_segment_code := NULL;
39211 l_adr_flex_value_set_id := NULL;
39212 l_adr_value_type_code := NULL;
39213 l_adr_value_combination_id := NULL;
39214 l_adr_value_segment_code := NULL;
39215
39216 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
39217 l_bflow_class_code := ''; -- 4219869 Business Flow
39218 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
39219 l_budgetary_control_flag := 'N';
39220
39221 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39222 l_bflow_applied_to_amt := NULL; -- 5132302
39223 l_entered_amt_idx := NULL; -- 4262811
39224 l_accted_amt_idx := NULL; -- 4262811
39225 l_acc_rev_flag := NULL; -- 4262811
39226 l_accrual_line_num := NULL; -- 4262811
39227 l_tmp_amt := NULL; -- 4262811
39228 --
39229
39230 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
39231 l_balance_type_code <> 'B' THEN
39232 IF NVL(p_source_15,'
39233 ') = 'CASH' AND
39234 NVL(p_source_54,'
39235 ') = 'N'
39236 THEN
39237
39238 --
39239 XLA_AE_LINES_PKG.SetNewLine;
39240
39241 p_balance_type_code := l_balance_type_code;
39245 p_actual_flag :='A';
39242 -- set the flag so later we will know whether the gain loss line needs to be created
39243
39244 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
39246 END IF;
39247
39248 --
39249 -- bulk performance
39250 --
39251 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
39252 p_header_num => 0); -- 4262811
39253 --
39254 -- set accounting line options
39255 --
39256 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
39257 p_natural_side_code => 'C'
39258 , p_gain_or_loss_flag => 'N'
39259 , p_gl_transfer_mode_code => 'S'
39260 , p_acct_entry_type_code => 'A'
39261 , p_switch_side_flag => 'Y'
39262 , p_merge_duplicate_code => 'A'
39263 );
39264 --
39265 l_acc_rev_natural_side_code := 'D'; -- 4262811
39266 --
39267 --
39268 -- set accounting line type info
39269 --
39270 xla_ae_lines_pkg.SetAcctLineType
39271 (p_component_type => l_component_type
39272 ,p_event_type_code => l_event_type_code
39273 ,p_line_definition_owner_code => l_line_definition_owner_code
39274 ,p_line_definition_code => l_line_definition_code
39275 ,p_accounting_line_code => l_component_code
39276 ,p_accounting_line_type_code => l_component_type_code
39277 ,p_accounting_line_appl_id => l_component_appl_id
39278 ,p_amb_context_code => l_amb_context_code
39279 ,p_entity_code => l_entity_code
39280 ,p_event_class_code => l_event_class_code);
39281 --
39282 -- set accounting class
39283 --
39284 xla_ae_lines_pkg.SetAcctClass(
39285 p_accounting_class_code => 'CASH'
39286 , p_ae_header_id => l_ae_header_id
39287 );
39288
39289 --
39290 -- set rounding class
39291 --
39292 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
39293 'RECEIVABLE';
39294
39295 --
39296 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
39297 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
39298 --
39299 -- bulk performance
39300 --
39301 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
39302
39303 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
39304 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
39305
39306 -- 4955764
39307 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39308 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
39309
39310 -- 4458381 Public Sector Enh
39311
39312 --
39313 -- set accounting attributes for the line type
39314 --
39315 l_entered_amt_idx := 8;
39316 l_accted_amt_idx := 13;
39317 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39318 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
39319 l_rec_acct_attrs.array_num_value(1) := p_source_58;
39320 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
39321 l_rec_acct_attrs.array_char_value(2) := p_source_30;
39322 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
39323 l_rec_acct_attrs.array_char_value(3) := p_source_59;
39324 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
39325 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
39326 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
39327 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
39328 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
39329 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
39330 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
39331 l_rec_acct_attrs.array_char_value(7) := p_source_18;
39332 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
39333 l_rec_acct_attrs.array_num_value(8) := p_source_61;
39334 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
39335 l_rec_acct_attrs.array_char_value(9) := p_source_62;
39336 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
39337 l_rec_acct_attrs.array_date_value(10) := p_source_21;
39338 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
39339 l_rec_acct_attrs.array_num_value(11) := p_source_22;
39340 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
39341 l_rec_acct_attrs.array_char_value(12) := p_source_23;
39342 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
39343 l_rec_acct_attrs.array_num_value(13) := p_source_63;
39344 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
39345 l_rec_acct_attrs.array_num_value(14) := p_source_64;
39346 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
39347 l_rec_acct_attrs.array_num_value(15) := p_source_65;
39348 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
39349 l_rec_acct_attrs.array_char_value(16) := p_source_66;
39350
39351 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
39352 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
39353
39354 ---------------------------------------------------------------------------------------------------------------
39355 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
39359 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39356 ---------------------------------------------------------------------------------------------------------------
39357 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
39358
39360 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39361
39362 IF xla_accounting_cache_pkg.GetValueChar
39363 (p_source_code => 'LEDGER_CATEGORY_CODE'
39364 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
39365 AND l_bflow_method_code = 'PRIOR_ENTRY'
39366 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
39367 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
39368 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
39369 )
39370 THEN
39371 xla_ae_lines_pkg.BflowUpgEntry
39372 (p_business_method_code => l_bflow_method_code
39373 ,p_business_class_code => l_bflow_class_code
39374 ,p_balance_type => l_balance_type_code);
39375 ELSE
39376 NULL;
39377 -- No business flow processing for business flow method of NONE.
39378 END IF;
39379
39380 --
39381 -- call analytical criteria
39382 --
39383
39384 --
39385 -- call description
39386 --
39387 -- No description or it is inherited.
39388 --
39389 -- call ADRs
39390 -- Bug 4922099
39391 --
39392 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39393 (NVL(l_actual_upg_option, 'N') = 'O') OR
39394 (NVL(l_enc_upg_option, 'N') = 'O')
39395 )
39396 THEN
39397 NULL;
39398 --
39399 --
39400
39401 l_ccid := AcctDerRule_11(
39402 p_application_id => p_application_id
39403 , p_ae_header_id => l_ae_header_id
39404 , p_source_10 => p_source_10
39405 , x_transaction_coa_id => l_adr_transaction_coa_id
39406 , x_accounting_coa_id => l_adr_accounting_coa_id
39407 , x_value_type_code => l_adr_value_type_code
39408 , p_side => 'NA'
39409 );
39410
39411 xla_ae_lines_pkg.set_ccid(
39412 p_code_combination_id => l_ccid
39413 , p_value_type_code => l_adr_value_type_code
39414 , p_transaction_coa_id => l_adr_transaction_coa_id
39415 , p_accounting_coa_id => l_adr_accounting_coa_id
39416 , p_adr_code => 'DIST_CCID'
39417 , p_adr_type_code => 'S'
39418 , p_component_type => l_component_type
39419 , p_component_code => l_component_code
39420 , p_component_type_code => l_component_type_code
39421 , p_component_appl_id => l_component_appl_id
39422 , p_amb_context_code => l_amb_context_code
39423 , p_side => 'NA'
39424 );
39425
39426
39427 --
39428 --
39429 END IF;
39430 --
39431 -- Bug 4922099
39432 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
39433 (NVL(l_enc_upg_option, 'N') = 'O')
39434 ) AND
39435 (l_bflow_method_code = 'PRIOR_ENTRY')
39436 )
39437 THEN
39438 IF
39439 --
39440 1 = 2
39441 --
39442 THEN
39443 xla_accounting_err_pkg.build_message
39444 (p_appli_s_name => 'XLA'
39445 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
39446 ,p_token_1 => 'LINE_NUMBER'
39447 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
39448 ,p_token_2 => 'LINE_TYPE_NAME'
39449 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
39450 l_component_type
39451 ,l_component_code
39452 ,l_component_type_code
39453 ,l_component_appl_id
39454 ,l_amb_context_code
39455 ,l_entity_code
39456 ,l_event_class_code
39457 )
39458 ,p_token_3 => 'OWNER'
39459 ,p_value_3 => xla_lookups_pkg.get_meaning(
39460 p_lookup_type => 'XLA_OWNER_TYPE'
39461 ,p_lookup_code => l_component_type_code
39462 )
39463 ,p_token_4 => 'PRODUCT_NAME'
39464 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
39465 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
39466 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
39467 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
39471 IF (C_LEVEL_ERROR>= g_log_level) THEN
39468 ,p_ae_header_id => NULL
39469 );
39470
39472 trace
39473 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
39474 ,p_level => C_LEVEL_ERROR
39475 ,p_module => l_log_module);
39476 END IF;
39477 END IF;
39478 END IF;
39479 --
39480 --
39481 ------------------------------------------------------------------------------------------------
39482 -- 4219869 Business Flow
39483 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
39484 -- Prior Entry. Currently, the following code is always generated.
39485 ------------------------------------------------------------------------------------------------
39486 XLA_AE_LINES_PKG.ValidateCurrentLine;
39487
39488 ------------------------------------------------------------------------------------
39489 -- 4219869 Business Flow
39490 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
39491 ------------------------------------------------------------------------------------
39492 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
39493
39494 ----------------------------------------------------------------------------------
39495 -- 4219869 Business Flow
39496 -- Update journal entry status -- Need to generate this within IF <condition>
39497 ----------------------------------------------------------------------------------
39498 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
39499 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
39500 ,p_balance_type_code => l_balance_type_code
39501 );
39502
39503 -------------------------------------------------------------------------------------------
39504 -- 4262811 - Generate the Accrual Reversal lines
39505 -------------------------------------------------------------------------------------------
39506 BEGIN
39507 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
39508 (g_array_event(p_event_id).array_value_num('header_index'));
39509 IF l_acc_rev_flag IS NULL THEN
39510 l_acc_rev_flag := 'N';
39511 END IF;
39512 EXCEPTION
39513 WHEN OTHERS THEN
39514 l_acc_rev_flag := 'N';
39515 END;
39516 --
39517 IF (l_acc_rev_flag = 'Y') THEN
39518
39519 -- 4645092 ------------------------------------------------------------------------------
39520 -- To allow MPA report to determine if it should generate report process
39521 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
39522 ------------------------------------------------------------------------------------------
39523
39524 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
39525 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
39526 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
39527 -- call ADRs
39528 -- Bug 4922099
39529 --
39530 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39531 (NVL(l_actual_upg_option, 'N') = 'O') OR
39532 (NVL(l_enc_upg_option, 'N') = 'O')
39533 )
39534 THEN
39535 NULL;
39536 --
39537 --
39538
39539 l_ccid := AcctDerRule_11(
39540 p_application_id => p_application_id
39541 , p_ae_header_id => l_ae_header_id
39542 , p_source_10 => p_source_10
39543 , x_transaction_coa_id => l_adr_transaction_coa_id
39544 , x_accounting_coa_id => l_adr_accounting_coa_id
39545 , x_value_type_code => l_adr_value_type_code
39546 , p_side => 'NA'
39547 );
39548
39549 xla_ae_lines_pkg.set_ccid(
39550 p_code_combination_id => l_ccid
39551 , p_value_type_code => l_adr_value_type_code
39552 , p_transaction_coa_id => l_adr_transaction_coa_id
39553 , p_accounting_coa_id => l_adr_accounting_coa_id
39554 , p_adr_code => 'DIST_CCID'
39555 , p_adr_type_code => 'S'
39556 , p_component_type => l_component_type
39557 , p_component_code => l_component_code
39558 , p_component_type_code => l_component_type_code
39559 , p_component_appl_id => l_component_appl_id
39560 , p_amb_context_code => l_amb_context_code
39561 , p_side => 'NA'
39562 );
39563
39564
39565 --
39566 --
39567 END IF;
39568
39569 --
39570 -- Update the line information that should be overwritten
39571 --
39572 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
39573 p_header_num => 1);
39574 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
39575
39576 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
39577
39578 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
39579 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
39580 END IF;
39581
39582 --
39583 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
39584 --
39585 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
39586 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
39587 ELSE
39591 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
39588 ---------------------------------------------------------------------------------------------------
39589 -- 4262811a Switch Sign
39590 ---------------------------------------------------------------------------------------------------
39592 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39593 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39594 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39595 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39596 -- 5132302
39597 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
39598 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39599
39600 END IF;
39601
39602 -- 4955764
39603 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39604 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
39605
39606
39607 XLA_AE_LINES_PKG.ValidateCurrentLine;
39608 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
39609
39610 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
39611 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
39612 ,p_balance_type_code => l_balance_type_code);
39613
39614 END IF;
39615
39616 -----------------------------------------------------------------------------------------
39617 -- 4262811 Multiperiod Accounting
39618 -----------------------------------------------------------------------------------------
39619 -- No MPA option is assigned.
39620
39621
39622 END IF;
39623 END IF;
39624 --
39625
39626 --
39627 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39628 trace
39629 (p_msg => 'END of AcctLineType_81'
39630 ,p_level => C_LEVEL_PROCEDURE
39631 ,p_module => l_log_module);
39632 END IF;
39633 --
39634 EXCEPTION
39635 WHEN xla_exceptions_pkg.application_exception THEN
39636 RAISE;
39637 WHEN OTHERS THEN
39638 xla_exceptions_pkg.raise_message
39639 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_81');
39640 END AcctLineType_81;
39641 --
39642
39643 ---------------------------------------
39644 --
39645 -- PRIVATE FUNCTION
39646 -- AcctLineType_82
39647 --
39648 ---------------------------------------
39649 PROCEDURE AcctLineType_82 (
39650 p_application_id IN NUMBER
39651 ,p_event_id IN NUMBER
39652 ,p_calculate_acctd_flag IN VARCHAR2
39653 ,p_calculate_g_l_flag IN VARCHAR2
39654 ,p_actual_flag IN OUT VARCHAR2
39655 ,p_balance_type_code OUT VARCHAR2
39656 ,p_gain_or_loss_ref OUT VARCHAR2
39657
39658 --Distribution GL Account
39659 , p_source_10 IN NUMBER
39660 --Distribution Source Type
39661 , p_source_15 IN VARCHAR2
39662 --Receivable Activity Type
39663 , p_source_16 IN VARCHAR2
39664 --Distribution Line Identifier
39665 , p_source_17 IN NUMBER
39666 --Distribution Type
39667 , p_source_18 IN VARCHAR2
39668 --Exchange Date
39669 , p_source_21 IN DATE
39670 --Exchange Rate
39671 , p_source_22 IN NUMBER
39672 --Transaction Distribution Identifier
39673 , p_source_29 IN NUMBER
39674 --Transaction Distribution Type
39675 , p_source_30 IN VARCHAR2
39676 --Distribution Multi Fund Additional Entry
39677 , p_source_54 IN VARCHAR2
39678 --Receipt Applied To Application Identifier
39679 , p_source_58 IN NUMBER
39680 --Transaction Entity Code
39681 , p_source_59 IN VARCHAR2
39682 --Transaction Identifier
39683 , p_source_60 IN NUMBER
39684 --DIST_ENT_AMT_FROM
39685 , p_source_61 IN NUMBER
39686 --Applying Document Currency Code
39687 , p_source_62 IN VARCHAR2
39688 --Accounting Amount
39689 , p_source_63 IN NUMBER
39690 --Distribution Party Identifier
39691 , p_source_64 IN NUMBER
39692 --Distribution Party Site Id
39693 , p_source_65 IN NUMBER
39694 --Distribution Party Type
39695 , p_source_66 IN VARCHAR2
39696 --Applied To Document Exchange Rate Type
39697 , p_source_67 IN VARCHAR2
39698 )
39699 IS
39700
39701 l_component_type VARCHAR2(80);
39702 l_component_code VARCHAR2(30);
39703 l_component_type_code VARCHAR2(1);
39704 l_component_appl_id INTEGER;
39705 l_amb_context_code VARCHAR2(30);
39706 l_entity_code VARCHAR2(30);
39707 l_event_class_code VARCHAR2(30);
39708 l_ae_header_id NUMBER;
39709 l_event_type_code VARCHAR2(30);
39710 l_line_definition_code VARCHAR2(30);
39711 l_line_definition_owner_code VARCHAR2(1);
39712 --
39713 -- adr variables
39714 l_segment VARCHAR2(30);
39715 l_ccid NUMBER;
39716 l_adr_transaction_coa_id NUMBER;
39717 l_adr_accounting_coa_id NUMBER;
39718 l_adr_flexfield_segment_code VARCHAR2(30);
39719 l_adr_flex_value_set_id NUMBER;
39720 l_adr_value_type_code VARCHAR2(30);
39721 l_adr_value_combination_id NUMBER;
39722 l_adr_value_segment_code VARCHAR2(30);
39723
39727 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
39724 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
39725 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
39726 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
39728
39729 -- 4262811 Variables ------------------------------------------------------------------------------------------
39730 l_entered_amt_idx NUMBER;
39731 l_accted_amt_idx NUMBER;
39732 l_acc_rev_flag VARCHAR2(1);
39733 l_accrual_line_num NUMBER;
39734 l_tmp_amt NUMBER;
39735 l_acc_rev_natural_side_code VARCHAR2(1);
39736
39737 l_num_entries NUMBER;
39738 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
39739 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
39740 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
39741 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
39742 l_recog_line_1 NUMBER;
39743 l_recog_line_2 NUMBER;
39744
39745 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
39746 l_bflow_applied_to_amt NUMBER; -- 5132302
39747 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
39748
39749 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
39750
39751 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
39752 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
39753
39754 ---------------------------------------------------------------------------------------------------------------
39755
39756
39757 --
39758 -- bulk performance
39759 --
39760 l_balance_type_code VARCHAR2(1);
39761 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
39762 l_log_module VARCHAR2(240);
39763
39764 --
39765 -- Upgrade strategy
39766 --
39767 l_actual_upg_option VARCHAR2(1);
39768 l_enc_upg_option VARCHAR2(1);
39769
39770 --
39771 BEGIN
39772 --
39773 IF g_log_enabled THEN
39774 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_82';
39775 END IF;
39776 --
39777 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39778
39779 trace
39780 (p_msg => 'BEGIN of AcctLineType_82'
39781 ,p_level => C_LEVEL_PROCEDURE
39782 ,p_module => l_log_module);
39783
39784 END IF;
39785 --
39786 l_component_type := 'AMB_JLT';
39787 l_component_code := 'RCT_CLAIM';
39788 l_component_type_code := 'S';
39789 l_component_appl_id := 222;
39790 l_amb_context_code := 'DEFAULT';
39791 l_entity_code := 'RECEIPTS';
39792 l_event_class_code := 'RECEIPT';
39793 l_event_type_code := 'RECEIPT_ALL';
39794 l_line_definition_owner_code := 'S';
39795 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
39796 --
39797 l_balance_type_code := 'A';
39798 l_segment := NULL;
39799 l_ccid := NULL;
39800 l_adr_transaction_coa_id := NULL;
39801 l_adr_accounting_coa_id := NULL;
39802 l_adr_flexfield_segment_code := NULL;
39803 l_adr_flex_value_set_id := NULL;
39804 l_adr_value_type_code := NULL;
39805 l_adr_value_combination_id := NULL;
39806 l_adr_value_segment_code := NULL;
39807
39808 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
39809 l_bflow_class_code := ''; -- 4219869 Business Flow
39810 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
39811 l_budgetary_control_flag := 'N';
39812
39813 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39814 l_bflow_applied_to_amt := NULL; -- 5132302
39815 l_entered_amt_idx := NULL; -- 4262811
39816 l_accted_amt_idx := NULL; -- 4262811
39817 l_acc_rev_flag := NULL; -- 4262811
39818 l_accrual_line_num := NULL; -- 4262811
39819 l_tmp_amt := NULL; -- 4262811
39820 --
39821
39822 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
39823 l_balance_type_code <> 'B' THEN
39824 IF NVL(p_source_15,'
39825 ') = 'OTHER ACC' AND
39826 NVL(p_source_16,'
39827 ') = 'CLAIM_INVESTIGATION' AND
39828 NVL(p_source_54,'
39829 ') = 'N'
39830 THEN
39831
39832 --
39833 XLA_AE_LINES_PKG.SetNewLine;
39834
39835 p_balance_type_code := l_balance_type_code;
39836 -- set the flag so later we will know whether the gain loss line needs to be created
39837
39838 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
39839 p_actual_flag :='A';
39840 END IF;
39841
39842 --
39843 -- bulk performance
39844 --
39845 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
39846 p_header_num => 0); -- 4262811
39847 --
39848 -- set accounting line options
39849 --
39850 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
39851 p_natural_side_code => 'C'
39852 , p_gain_or_loss_flag => 'N'
39853 , p_gl_transfer_mode_code => 'S'
39854 , p_acct_entry_type_code => 'A'
39855 , p_switch_side_flag => 'Y'
39856 , p_merge_duplicate_code => 'A'
39857 );
39858 --
39859 l_acc_rev_natural_side_code := 'D'; -- 4262811
39860 --
39861 --
39865 (p_component_type => l_component_type
39862 -- set accounting line type info
39863 --
39864 xla_ae_lines_pkg.SetAcctLineType
39866 ,p_event_type_code => l_event_type_code
39867 ,p_line_definition_owner_code => l_line_definition_owner_code
39868 ,p_line_definition_code => l_line_definition_code
39869 ,p_accounting_line_code => l_component_code
39870 ,p_accounting_line_type_code => l_component_type_code
39871 ,p_accounting_line_appl_id => l_component_appl_id
39872 ,p_amb_context_code => l_amb_context_code
39873 ,p_entity_code => l_entity_code
39874 ,p_event_class_code => l_event_class_code);
39875 --
39876 -- set accounting class
39877 --
39878 xla_ae_lines_pkg.SetAcctClass(
39879 p_accounting_class_code => 'CLAIM'
39880 , p_ae_header_id => l_ae_header_id
39881 );
39882
39883 --
39884 -- set rounding class
39885 --
39886 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
39887 'RECEIVABLE';
39888
39889 --
39890 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
39891 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
39892 --
39893 -- bulk performance
39894 --
39895 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
39896
39897 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
39898 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
39899
39900 -- 4955764
39901 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39902 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
39903
39904 -- 4458381 Public Sector Enh
39905
39906 --
39907 -- set accounting attributes for the line type
39908 --
39909 l_entered_amt_idx := 8;
39910 l_accted_amt_idx := 13;
39911 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39912 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
39913 l_rec_acct_attrs.array_num_value(1) := p_source_58;
39914 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
39915 l_rec_acct_attrs.array_char_value(2) := p_source_30;
39916 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
39917 l_rec_acct_attrs.array_char_value(3) := p_source_59;
39918 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
39919 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
39920 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
39921 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
39922 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
39923 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
39924 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
39925 l_rec_acct_attrs.array_char_value(7) := p_source_18;
39926 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
39927 l_rec_acct_attrs.array_num_value(8) := p_source_61;
39928 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
39929 l_rec_acct_attrs.array_char_value(9) := p_source_62;
39930 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
39931 l_rec_acct_attrs.array_date_value(10) := p_source_21;
39932 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
39933 l_rec_acct_attrs.array_num_value(11) := p_source_22;
39934 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
39935 l_rec_acct_attrs.array_char_value(12) := p_source_67;
39936 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
39937 l_rec_acct_attrs.array_num_value(13) := p_source_63;
39938 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
39939 l_rec_acct_attrs.array_num_value(14) := p_source_64;
39940 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
39941 l_rec_acct_attrs.array_num_value(15) := p_source_65;
39942 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
39943 l_rec_acct_attrs.array_char_value(16) := p_source_66;
39944
39945 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
39946 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
39947
39948 ---------------------------------------------------------------------------------------------------------------
39949 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
39950 ---------------------------------------------------------------------------------------------------------------
39951 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
39952
39953 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39954 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39955
39956 IF xla_accounting_cache_pkg.GetValueChar
39957 (p_source_code => 'LEDGER_CATEGORY_CODE'
39958 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
39959 AND l_bflow_method_code = 'PRIOR_ENTRY'
39960 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
39961 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
39962 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
39963 )
39964 THEN
39965 xla_ae_lines_pkg.BflowUpgEntry
39966 (p_business_method_code => l_bflow_method_code
39967 ,p_business_class_code => l_bflow_class_code
39971 -- No business flow processing for business flow method of NONE.
39968 ,p_balance_type => l_balance_type_code);
39969 ELSE
39970 NULL;
39972 END IF;
39973
39974 --
39975 -- call analytical criteria
39976 --
39977
39978 --
39979 -- call description
39980 --
39981 -- No description or it is inherited.
39982 --
39983 -- call ADRs
39984 -- Bug 4922099
39985 --
39986 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39987 (NVL(l_actual_upg_option, 'N') = 'O') OR
39988 (NVL(l_enc_upg_option, 'N') = 'O')
39989 )
39990 THEN
39991 NULL;
39992 --
39993 --
39994
39995 l_ccid := AcctDerRule_11(
39996 p_application_id => p_application_id
39997 , p_ae_header_id => l_ae_header_id
39998 , p_source_10 => p_source_10
39999 , x_transaction_coa_id => l_adr_transaction_coa_id
40000 , x_accounting_coa_id => l_adr_accounting_coa_id
40001 , x_value_type_code => l_adr_value_type_code
40002 , p_side => 'NA'
40003 );
40004
40005 xla_ae_lines_pkg.set_ccid(
40006 p_code_combination_id => l_ccid
40007 , p_value_type_code => l_adr_value_type_code
40008 , p_transaction_coa_id => l_adr_transaction_coa_id
40009 , p_accounting_coa_id => l_adr_accounting_coa_id
40010 , p_adr_code => 'DIST_CCID'
40011 , p_adr_type_code => 'S'
40012 , p_component_type => l_component_type
40013 , p_component_code => l_component_code
40014 , p_component_type_code => l_component_type_code
40015 , p_component_appl_id => l_component_appl_id
40016 , p_amb_context_code => l_amb_context_code
40017 , p_side => 'NA'
40018 );
40019
40020
40021 --
40022 --
40023 END IF;
40024 --
40025 -- Bug 4922099
40026 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
40027 (NVL(l_enc_upg_option, 'N') = 'O')
40028 ) AND
40029 (l_bflow_method_code = 'PRIOR_ENTRY')
40030 )
40031 THEN
40032 IF
40033 --
40034 1 = 2
40035 --
40036 THEN
40037 xla_accounting_err_pkg.build_message
40038 (p_appli_s_name => 'XLA'
40039 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40040 ,p_token_1 => 'LINE_NUMBER'
40041 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
40042 ,p_token_2 => 'LINE_TYPE_NAME'
40043 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
40044 l_component_type
40045 ,l_component_code
40046 ,l_component_type_code
40047 ,l_component_appl_id
40048 ,l_amb_context_code
40049 ,l_entity_code
40050 ,l_event_class_code
40051 )
40052 ,p_token_3 => 'OWNER'
40053 ,p_value_3 => xla_lookups_pkg.get_meaning(
40054 p_lookup_type => 'XLA_OWNER_TYPE'
40055 ,p_lookup_code => l_component_type_code
40056 )
40057 ,p_token_4 => 'PRODUCT_NAME'
40058 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
40059 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
40060 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
40061 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
40062 ,p_ae_header_id => NULL
40063 );
40064
40065 IF (C_LEVEL_ERROR>= g_log_level) THEN
40066 trace
40067 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40068 ,p_level => C_LEVEL_ERROR
40069 ,p_module => l_log_module);
40070 END IF;
40071 END IF;
40072 END IF;
40073 --
40074 --
40075 ------------------------------------------------------------------------------------------------
40076 -- 4219869 Business Flow
40077 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
40078 -- Prior Entry. Currently, the following code is always generated.
40079 ------------------------------------------------------------------------------------------------
40080 XLA_AE_LINES_PKG.ValidateCurrentLine;
40081
40082 ------------------------------------------------------------------------------------
40083 -- 4219869 Business Flow
40087
40084 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
40085 ------------------------------------------------------------------------------------
40086 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40088 ----------------------------------------------------------------------------------
40089 -- 4219869 Business Flow
40090 -- Update journal entry status -- Need to generate this within IF <condition>
40091 ----------------------------------------------------------------------------------
40092 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40093 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
40094 ,p_balance_type_code => l_balance_type_code
40095 );
40096
40097 -------------------------------------------------------------------------------------------
40098 -- 4262811 - Generate the Accrual Reversal lines
40099 -------------------------------------------------------------------------------------------
40100 BEGIN
40101 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
40102 (g_array_event(p_event_id).array_value_num('header_index'));
40103 IF l_acc_rev_flag IS NULL THEN
40104 l_acc_rev_flag := 'N';
40105 END IF;
40106 EXCEPTION
40107 WHEN OTHERS THEN
40108 l_acc_rev_flag := 'N';
40109 END;
40110 --
40111 IF (l_acc_rev_flag = 'Y') THEN
40112
40113 -- 4645092 ------------------------------------------------------------------------------
40114 -- To allow MPA report to determine if it should generate report process
40115 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
40116 ------------------------------------------------------------------------------------------
40117
40118 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
40119 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
40120 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
40121 -- call ADRs
40122 -- Bug 4922099
40123 --
40124 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40125 (NVL(l_actual_upg_option, 'N') = 'O') OR
40126 (NVL(l_enc_upg_option, 'N') = 'O')
40127 )
40128 THEN
40129 NULL;
40130 --
40131 --
40132
40133 l_ccid := AcctDerRule_11(
40134 p_application_id => p_application_id
40135 , p_ae_header_id => l_ae_header_id
40136 , p_source_10 => p_source_10
40137 , x_transaction_coa_id => l_adr_transaction_coa_id
40138 , x_accounting_coa_id => l_adr_accounting_coa_id
40139 , x_value_type_code => l_adr_value_type_code
40140 , p_side => 'NA'
40141 );
40142
40143 xla_ae_lines_pkg.set_ccid(
40144 p_code_combination_id => l_ccid
40145 , p_value_type_code => l_adr_value_type_code
40146 , p_transaction_coa_id => l_adr_transaction_coa_id
40147 , p_accounting_coa_id => l_adr_accounting_coa_id
40148 , p_adr_code => 'DIST_CCID'
40149 , p_adr_type_code => 'S'
40150 , p_component_type => l_component_type
40151 , p_component_code => l_component_code
40152 , p_component_type_code => l_component_type_code
40153 , p_component_appl_id => l_component_appl_id
40154 , p_amb_context_code => l_amb_context_code
40155 , p_side => 'NA'
40156 );
40157
40158
40159 --
40160 --
40161 END IF;
40162
40163 --
40164 -- Update the line information that should be overwritten
40165 --
40166 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
40167 p_header_num => 1);
40168 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
40169
40170 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
40171
40172 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
40173 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
40174 END IF;
40175
40176 --
40177 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
40178 --
40179 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
40180 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
40181 ELSE
40182 ---------------------------------------------------------------------------------------------------
40183 -- 4262811a Switch Sign
40184 ---------------------------------------------------------------------------------------------------
40185 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
40186 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40187 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40188 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40189 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40190 -- 5132302
40191 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
40192 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40193
40194 END IF;
40195
40196 -- 4955764
40200
40197 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40198 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
40199
40201 XLA_AE_LINES_PKG.ValidateCurrentLine;
40202 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40203
40204 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40205 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
40206 ,p_balance_type_code => l_balance_type_code);
40207
40208 END IF;
40209
40210 -----------------------------------------------------------------------------------------
40211 -- 4262811 Multiperiod Accounting
40212 -----------------------------------------------------------------------------------------
40213 -- No MPA option is assigned.
40214
40215
40216 END IF;
40217 END IF;
40218 --
40219
40220 --
40221 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40222 trace
40223 (p_msg => 'END of AcctLineType_82'
40224 ,p_level => C_LEVEL_PROCEDURE
40225 ,p_module => l_log_module);
40226 END IF;
40227 --
40228 EXCEPTION
40229 WHEN xla_exceptions_pkg.application_exception THEN
40230 RAISE;
40231 WHEN OTHERS THEN
40232 xla_exceptions_pkg.raise_message
40233 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_82');
40234 END AcctLineType_82;
40235 --
40236
40237 ---------------------------------------
40238 --
40239 -- PRIVATE FUNCTION
40240 -- AcctLineType_83
40241 --
40242 ---------------------------------------
40243 PROCEDURE AcctLineType_83 (
40244 p_application_id IN NUMBER
40245 ,p_event_id IN NUMBER
40246 ,p_calculate_acctd_flag IN VARCHAR2
40247 ,p_calculate_g_l_flag IN VARCHAR2
40248 ,p_actual_flag IN OUT VARCHAR2
40249 ,p_balance_type_code OUT VARCHAR2
40250 ,p_gain_or_loss_ref OUT VARCHAR2
40251
40252 --Distribution GL Account
40253 , p_source_10 IN NUMBER
40254 --Distribution Source Type
40255 , p_source_15 IN VARCHAR2
40256 --Distribution Line Identifier
40257 , p_source_17 IN NUMBER
40258 --Distribution Type
40259 , p_source_18 IN VARCHAR2
40260 --Exchange Date
40261 , p_source_21 IN DATE
40262 --Exchange Rate
40263 , p_source_22 IN NUMBER
40264 --Exchange Rate Type
40265 , p_source_23 IN VARCHAR2
40266 --Transaction Distribution Identifier
40267 , p_source_29 IN NUMBER
40268 --Transaction Distribution Type
40269 , p_source_30 IN VARCHAR2
40270 --Distribution Multi Fund Additional Entry
40271 , p_source_54 IN VARCHAR2
40272 --Receipt Applied To Application Identifier
40273 , p_source_58 IN NUMBER
40274 --Transaction Entity Code
40275 , p_source_59 IN VARCHAR2
40276 --Transaction Identifier
40277 , p_source_60 IN NUMBER
40278 --DIST_ENT_AMT_FROM
40279 , p_source_61 IN NUMBER
40280 --Applying Document Currency Code
40281 , p_source_62 IN VARCHAR2
40282 --Accounting Amount
40283 , p_source_63 IN NUMBER
40284 --Distribution Party Identifier
40285 , p_source_64 IN NUMBER
40286 --Distribution Party Site Id
40287 , p_source_65 IN NUMBER
40288 --Distribution Party Type
40289 , p_source_66 IN VARCHAR2
40290 )
40291 IS
40292
40293 l_component_type VARCHAR2(80);
40294 l_component_code VARCHAR2(30);
40295 l_component_type_code VARCHAR2(1);
40296 l_component_appl_id INTEGER;
40297 l_amb_context_code VARCHAR2(30);
40298 l_entity_code VARCHAR2(30);
40299 l_event_class_code VARCHAR2(30);
40300 l_ae_header_id NUMBER;
40301 l_event_type_code VARCHAR2(30);
40302 l_line_definition_code VARCHAR2(30);
40303 l_line_definition_owner_code VARCHAR2(1);
40304 --
40305 -- adr variables
40306 l_segment VARCHAR2(30);
40307 l_ccid NUMBER;
40308 l_adr_transaction_coa_id NUMBER;
40309 l_adr_accounting_coa_id NUMBER;
40310 l_adr_flexfield_segment_code VARCHAR2(30);
40311 l_adr_flex_value_set_id NUMBER;
40312 l_adr_value_type_code VARCHAR2(30);
40313 l_adr_value_combination_id NUMBER;
40314 l_adr_value_segment_code VARCHAR2(30);
40315
40316 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
40317 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
40318 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
40319 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
40320
40321 -- 4262811 Variables ------------------------------------------------------------------------------------------
40322 l_entered_amt_idx NUMBER;
40323 l_accted_amt_idx NUMBER;
40324 l_acc_rev_flag VARCHAR2(1);
40325 l_accrual_line_num NUMBER;
40326 l_tmp_amt NUMBER;
40327 l_acc_rev_natural_side_code VARCHAR2(1);
40328
40329 l_num_entries NUMBER;
40330 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
40331 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
40332 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
40333 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
40334 l_recog_line_1 NUMBER;
40335 l_recog_line_2 NUMBER;
40336
40340
40337 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
40338 l_bflow_applied_to_amt NUMBER; -- 5132302
40339 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
40341 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
40342
40343 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
40344 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
40345
40346 ---------------------------------------------------------------------------------------------------------------
40347
40348
40349 --
40350 -- bulk performance
40351 --
40352 l_balance_type_code VARCHAR2(1);
40353 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
40354 l_log_module VARCHAR2(240);
40355
40356 --
40357 -- Upgrade strategy
40358 --
40359 l_actual_upg_option VARCHAR2(1);
40360 l_enc_upg_option VARCHAR2(1);
40361
40362 --
40363 BEGIN
40364 --
40365 IF g_log_enabled THEN
40366 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_83';
40367 END IF;
40368 --
40369 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40370
40371 trace
40372 (p_msg => 'BEGIN of AcctLineType_83'
40373 ,p_level => C_LEVEL_PROCEDURE
40374 ,p_module => l_log_module);
40375
40376 END IF;
40377 --
40378 l_component_type := 'AMB_JLT';
40379 l_component_code := 'RCT_CONFIRM';
40380 l_component_type_code := 'S';
40381 l_component_appl_id := 222;
40382 l_amb_context_code := 'DEFAULT';
40383 l_entity_code := 'RECEIPTS';
40384 l_event_class_code := 'RECEIPT';
40385 l_event_type_code := 'RECEIPT_ALL';
40386 l_line_definition_owner_code := 'S';
40387 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
40388 --
40389 l_balance_type_code := 'A';
40390 l_segment := NULL;
40391 l_ccid := NULL;
40392 l_adr_transaction_coa_id := NULL;
40393 l_adr_accounting_coa_id := NULL;
40394 l_adr_flexfield_segment_code := NULL;
40395 l_adr_flex_value_set_id := NULL;
40396 l_adr_value_type_code := NULL;
40397 l_adr_value_combination_id := NULL;
40398 l_adr_value_segment_code := NULL;
40399
40400 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
40401 l_bflow_class_code := ''; -- 4219869 Business Flow
40402 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
40403 l_budgetary_control_flag := 'N';
40404
40405 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40406 l_bflow_applied_to_amt := NULL; -- 5132302
40407 l_entered_amt_idx := NULL; -- 4262811
40408 l_accted_amt_idx := NULL; -- 4262811
40409 l_acc_rev_flag := NULL; -- 4262811
40410 l_accrual_line_num := NULL; -- 4262811
40411 l_tmp_amt := NULL; -- 4262811
40412 --
40413
40414 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
40415 l_balance_type_code <> 'B' THEN
40416 IF NVL(p_source_15,'
40417 ') = 'CONFIRMATION' AND
40418 NVL(p_source_54,'
40419 ') = 'N'
40420 THEN
40421
40422 --
40423 XLA_AE_LINES_PKG.SetNewLine;
40424
40425 p_balance_type_code := l_balance_type_code;
40426 -- set the flag so later we will know whether the gain loss line needs to be created
40427
40428 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
40429 p_actual_flag :='A';
40430 END IF;
40431
40432 --
40433 -- bulk performance
40434 --
40435 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
40436 p_header_num => 0); -- 4262811
40437 --
40438 -- set accounting line options
40439 --
40440 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
40441 p_natural_side_code => 'C'
40442 , p_gain_or_loss_flag => 'N'
40443 , p_gl_transfer_mode_code => 'S'
40444 , p_acct_entry_type_code => 'A'
40445 , p_switch_side_flag => 'Y'
40446 , p_merge_duplicate_code => 'A'
40447 );
40448 --
40449 l_acc_rev_natural_side_code := 'D'; -- 4262811
40450 --
40451 --
40452 -- set accounting line type info
40453 --
40454 xla_ae_lines_pkg.SetAcctLineType
40455 (p_component_type => l_component_type
40456 ,p_event_type_code => l_event_type_code
40457 ,p_line_definition_owner_code => l_line_definition_owner_code
40458 ,p_line_definition_code => l_line_definition_code
40459 ,p_accounting_line_code => l_component_code
40460 ,p_accounting_line_type_code => l_component_type_code
40461 ,p_accounting_line_appl_id => l_component_appl_id
40462 ,p_amb_context_code => l_amb_context_code
40463 ,p_entity_code => l_entity_code
40464 ,p_event_class_code => l_event_class_code);
40465 --
40466 -- set accounting class
40467 --
40468 xla_ae_lines_pkg.SetAcctClass(
40469 p_accounting_class_code => 'CONFIRMATION'
40470 , p_ae_header_id => l_ae_header_id
40471 );
40472
40473 --
40474 -- set rounding class
40475 --
40476 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
40477 'RECEIVABLE';
40478
40482 --
40479 --
40480 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
40481 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
40483 -- bulk performance
40484 --
40485 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
40486
40487 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
40488 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
40489
40490 -- 4955764
40491 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40492 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
40493
40494 -- 4458381 Public Sector Enh
40495
40496 --
40497 -- set accounting attributes for the line type
40498 --
40499 l_entered_amt_idx := 8;
40500 l_accted_amt_idx := 13;
40501 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40502 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
40503 l_rec_acct_attrs.array_num_value(1) := p_source_58;
40504 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
40505 l_rec_acct_attrs.array_char_value(2) := p_source_30;
40506 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
40507 l_rec_acct_attrs.array_char_value(3) := p_source_59;
40508 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
40509 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
40510 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
40511 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
40512 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
40513 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
40514 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
40515 l_rec_acct_attrs.array_char_value(7) := p_source_18;
40516 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
40517 l_rec_acct_attrs.array_num_value(8) := p_source_61;
40518 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
40519 l_rec_acct_attrs.array_char_value(9) := p_source_62;
40520 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
40521 l_rec_acct_attrs.array_date_value(10) := p_source_21;
40522 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
40523 l_rec_acct_attrs.array_num_value(11) := p_source_22;
40524 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
40525 l_rec_acct_attrs.array_char_value(12) := p_source_23;
40526 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
40527 l_rec_acct_attrs.array_num_value(13) := p_source_63;
40528 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
40529 l_rec_acct_attrs.array_num_value(14) := p_source_64;
40530 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
40531 l_rec_acct_attrs.array_num_value(15) := p_source_65;
40532 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
40533 l_rec_acct_attrs.array_char_value(16) := p_source_66;
40534
40535 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
40536 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
40537
40538 ---------------------------------------------------------------------------------------------------------------
40539 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
40540 ---------------------------------------------------------------------------------------------------------------
40541 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
40542
40543 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
40544 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
40545
40546 IF xla_accounting_cache_pkg.GetValueChar
40547 (p_source_code => 'LEDGER_CATEGORY_CODE'
40548 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
40549 AND l_bflow_method_code = 'PRIOR_ENTRY'
40550 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
40551 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
40552 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
40553 )
40554 THEN
40555 xla_ae_lines_pkg.BflowUpgEntry
40556 (p_business_method_code => l_bflow_method_code
40557 ,p_business_class_code => l_bflow_class_code
40558 ,p_balance_type => l_balance_type_code);
40559 ELSE
40560 NULL;
40561 -- No business flow processing for business flow method of NONE.
40562 END IF;
40563
40564 --
40565 -- call analytical criteria
40566 --
40567
40568 --
40569 -- call description
40570 --
40571 -- No description or it is inherited.
40572 --
40573 -- call ADRs
40574 -- Bug 4922099
40575 --
40576 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40577 (NVL(l_actual_upg_option, 'N') = 'O') OR
40578 (NVL(l_enc_upg_option, 'N') = 'O')
40579 )
40580 THEN
40581 NULL;
40582 --
40583 --
40584
40585 l_ccid := AcctDerRule_11(
40586 p_application_id => p_application_id
40587 , p_ae_header_id => l_ae_header_id
40588 , p_source_10 => p_source_10
40589 , x_transaction_coa_id => l_adr_transaction_coa_id
40590 , x_accounting_coa_id => l_adr_accounting_coa_id
40591 , x_value_type_code => l_adr_value_type_code
40595 xla_ae_lines_pkg.set_ccid(
40592 , p_side => 'NA'
40593 );
40594
40596 p_code_combination_id => l_ccid
40597 , p_value_type_code => l_adr_value_type_code
40598 , p_transaction_coa_id => l_adr_transaction_coa_id
40599 , p_accounting_coa_id => l_adr_accounting_coa_id
40600 , p_adr_code => 'DIST_CCID'
40601 , p_adr_type_code => 'S'
40602 , p_component_type => l_component_type
40603 , p_component_code => l_component_code
40604 , p_component_type_code => l_component_type_code
40605 , p_component_appl_id => l_component_appl_id
40606 , p_amb_context_code => l_amb_context_code
40607 , p_side => 'NA'
40608 );
40609
40610
40611 --
40612 --
40613 END IF;
40614 --
40615 -- Bug 4922099
40616 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
40617 (NVL(l_enc_upg_option, 'N') = 'O')
40618 ) AND
40619 (l_bflow_method_code = 'PRIOR_ENTRY')
40620 )
40621 THEN
40622 IF
40623 --
40624 1 = 2
40625 --
40626 THEN
40627 xla_accounting_err_pkg.build_message
40628 (p_appli_s_name => 'XLA'
40629 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40630 ,p_token_1 => 'LINE_NUMBER'
40631 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
40632 ,p_token_2 => 'LINE_TYPE_NAME'
40633 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
40634 l_component_type
40635 ,l_component_code
40636 ,l_component_type_code
40637 ,l_component_appl_id
40638 ,l_amb_context_code
40639 ,l_entity_code
40640 ,l_event_class_code
40641 )
40642 ,p_token_3 => 'OWNER'
40643 ,p_value_3 => xla_lookups_pkg.get_meaning(
40644 p_lookup_type => 'XLA_OWNER_TYPE'
40645 ,p_lookup_code => l_component_type_code
40646 )
40647 ,p_token_4 => 'PRODUCT_NAME'
40648 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
40649 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
40650 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
40651 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
40652 ,p_ae_header_id => NULL
40653 );
40654
40655 IF (C_LEVEL_ERROR>= g_log_level) THEN
40656 trace
40657 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40658 ,p_level => C_LEVEL_ERROR
40659 ,p_module => l_log_module);
40660 END IF;
40661 END IF;
40662 END IF;
40663 --
40664 --
40665 ------------------------------------------------------------------------------------------------
40666 -- 4219869 Business Flow
40667 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
40668 -- Prior Entry. Currently, the following code is always generated.
40669 ------------------------------------------------------------------------------------------------
40670 XLA_AE_LINES_PKG.ValidateCurrentLine;
40671
40672 ------------------------------------------------------------------------------------
40673 -- 4219869 Business Flow
40674 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
40675 ------------------------------------------------------------------------------------
40676 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40677
40678 ----------------------------------------------------------------------------------
40679 -- 4219869 Business Flow
40680 -- Update journal entry status -- Need to generate this within IF <condition>
40681 ----------------------------------------------------------------------------------
40682 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40683 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
40684 ,p_balance_type_code => l_balance_type_code
40685 );
40686
40687 -------------------------------------------------------------------------------------------
40688 -- 4262811 - Generate the Accrual Reversal lines
40689 -------------------------------------------------------------------------------------------
40690 BEGIN
40691 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
40692 (g_array_event(p_event_id).array_value_num('header_index'));
40693 IF l_acc_rev_flag IS NULL THEN
40694 l_acc_rev_flag := 'N';
40698 l_acc_rev_flag := 'N';
40695 END IF;
40696 EXCEPTION
40697 WHEN OTHERS THEN
40699 END;
40700 --
40701 IF (l_acc_rev_flag = 'Y') THEN
40702
40703 -- 4645092 ------------------------------------------------------------------------------
40704 -- To allow MPA report to determine if it should generate report process
40705 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
40706 ------------------------------------------------------------------------------------------
40707
40708 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
40709 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
40710 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
40711 -- call ADRs
40712 -- Bug 4922099
40713 --
40714 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40715 (NVL(l_actual_upg_option, 'N') = 'O') OR
40716 (NVL(l_enc_upg_option, 'N') = 'O')
40717 )
40718 THEN
40719 NULL;
40720 --
40721 --
40722
40723 l_ccid := AcctDerRule_11(
40724 p_application_id => p_application_id
40725 , p_ae_header_id => l_ae_header_id
40726 , p_source_10 => p_source_10
40727 , x_transaction_coa_id => l_adr_transaction_coa_id
40728 , x_accounting_coa_id => l_adr_accounting_coa_id
40729 , x_value_type_code => l_adr_value_type_code
40730 , p_side => 'NA'
40731 );
40732
40733 xla_ae_lines_pkg.set_ccid(
40734 p_code_combination_id => l_ccid
40735 , p_value_type_code => l_adr_value_type_code
40736 , p_transaction_coa_id => l_adr_transaction_coa_id
40737 , p_accounting_coa_id => l_adr_accounting_coa_id
40738 , p_adr_code => 'DIST_CCID'
40739 , p_adr_type_code => 'S'
40740 , p_component_type => l_component_type
40741 , p_component_code => l_component_code
40742 , p_component_type_code => l_component_type_code
40743 , p_component_appl_id => l_component_appl_id
40744 , p_amb_context_code => l_amb_context_code
40745 , p_side => 'NA'
40746 );
40747
40748
40749 --
40750 --
40751 END IF;
40752
40753 --
40754 -- Update the line information that should be overwritten
40755 --
40756 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
40757 p_header_num => 1);
40758 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
40759
40760 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
40761
40762 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
40763 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
40764 END IF;
40765
40766 --
40767 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
40768 --
40769 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
40770 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
40771 ELSE
40772 ---------------------------------------------------------------------------------------------------
40773 -- 4262811a Switch Sign
40774 ---------------------------------------------------------------------------------------------------
40775 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
40776 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40777 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40778 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40779 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40780 -- 5132302
40781 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
40782 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40783
40784 END IF;
40785
40786 -- 4955764
40787 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40788 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
40789
40790
40791 XLA_AE_LINES_PKG.ValidateCurrentLine;
40792 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40793
40794 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40795 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
40796 ,p_balance_type_code => l_balance_type_code);
40797
40798 END IF;
40799
40800 -----------------------------------------------------------------------------------------
40801 -- 4262811 Multiperiod Accounting
40802 -----------------------------------------------------------------------------------------
40803 -- No MPA option is assigned.
40804
40805
40806 END IF;
40807 END IF;
40808 --
40809
40810 --
40811 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40812 trace
40813 (p_msg => 'END of AcctLineType_83'
40814 ,p_level => C_LEVEL_PROCEDURE
40815 ,p_module => l_log_module);
40816 END IF;
40817 --
40818 EXCEPTION
40819 WHEN xla_exceptions_pkg.application_exception THEN
40820 RAISE;
40824 END AcctLineType_83;
40821 WHEN OTHERS THEN
40822 xla_exceptions_pkg.raise_message
40823 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_83');
40825 --
40826
40827 ---------------------------------------
40828 --
40829 -- PRIVATE FUNCTION
40830 -- AcctLineType_84
40831 --
40832 ---------------------------------------
40833 PROCEDURE AcctLineType_84 (
40834 p_application_id IN NUMBER
40835 ,p_event_id IN NUMBER
40836 ,p_calculate_acctd_flag IN VARCHAR2
40837 ,p_calculate_g_l_flag IN VARCHAR2
40838 ,p_actual_flag IN OUT VARCHAR2
40839 ,p_balance_type_code OUT VARCHAR2
40840 ,p_gain_or_loss_ref OUT VARCHAR2
40841
40842 --Distribution GL Account
40843 , p_source_10 IN NUMBER
40844 --Distribution Source Type
40845 , p_source_15 IN VARCHAR2
40846 --Distribution Line Identifier
40847 , p_source_17 IN NUMBER
40848 --Distribution Type
40849 , p_source_18 IN VARCHAR2
40850 --Exchange Date
40851 , p_source_21 IN DATE
40852 --Exchange Rate
40853 , p_source_22 IN NUMBER
40854 --Exchange Rate Type
40855 , p_source_23 IN VARCHAR2
40856 --Transaction Distribution Identifier
40857 , p_source_29 IN NUMBER
40858 --Transaction Distribution Type
40859 , p_source_30 IN VARCHAR2
40860 --Distribution Multi Fund Additional Entry
40861 , p_source_54 IN VARCHAR2
40862 --Receipt Applied To Application Identifier
40863 , p_source_58 IN NUMBER
40864 --Transaction Entity Code
40865 , p_source_59 IN VARCHAR2
40866 --Transaction Identifier
40867 , p_source_60 IN NUMBER
40868 --DIST_ENT_AMT_FROM
40869 , p_source_61 IN NUMBER
40870 --Applying Document Currency Code
40871 , p_source_62 IN VARCHAR2
40872 --Accounting Amount
40873 , p_source_63 IN NUMBER
40874 --Distribution Party Identifier
40875 , p_source_64 IN NUMBER
40876 --Distribution Party Site Id
40877 , p_source_65 IN NUMBER
40878 --Distribution Party Type
40879 , p_source_66 IN VARCHAR2
40880 )
40881 IS
40882
40883 l_component_type VARCHAR2(80);
40884 l_component_code VARCHAR2(30);
40885 l_component_type_code VARCHAR2(1);
40886 l_component_appl_id INTEGER;
40887 l_amb_context_code VARCHAR2(30);
40888 l_entity_code VARCHAR2(30);
40889 l_event_class_code VARCHAR2(30);
40890 l_ae_header_id NUMBER;
40891 l_event_type_code VARCHAR2(30);
40892 l_line_definition_code VARCHAR2(30);
40893 l_line_definition_owner_code VARCHAR2(1);
40894 --
40895 -- adr variables
40896 l_segment VARCHAR2(30);
40897 l_ccid NUMBER;
40898 l_adr_transaction_coa_id NUMBER;
40899 l_adr_accounting_coa_id NUMBER;
40900 l_adr_flexfield_segment_code VARCHAR2(30);
40901 l_adr_flex_value_set_id NUMBER;
40902 l_adr_value_type_code VARCHAR2(30);
40903 l_adr_value_combination_id NUMBER;
40904 l_adr_value_segment_code VARCHAR2(30);
40905
40906 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
40907 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
40908 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
40909 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
40910
40911 -- 4262811 Variables ------------------------------------------------------------------------------------------
40912 l_entered_amt_idx NUMBER;
40913 l_accted_amt_idx NUMBER;
40914 l_acc_rev_flag VARCHAR2(1);
40915 l_accrual_line_num NUMBER;
40916 l_tmp_amt NUMBER;
40917 l_acc_rev_natural_side_code VARCHAR2(1);
40918
40919 l_num_entries NUMBER;
40920 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
40921 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
40922 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
40923 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
40924 l_recog_line_1 NUMBER;
40925 l_recog_line_2 NUMBER;
40926
40927 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
40928 l_bflow_applied_to_amt NUMBER; -- 5132302
40929 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
40930
40931 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
40932
40933 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
40934 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
40935
40936 ---------------------------------------------------------------------------------------------------------------
40937
40938
40939 --
40940 -- bulk performance
40941 --
40942 l_balance_type_code VARCHAR2(1);
40943 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
40944 l_log_module VARCHAR2(240);
40945
40946 --
40947 -- Upgrade strategy
40948 --
40949 l_actual_upg_option VARCHAR2(1);
40950 l_enc_upg_option VARCHAR2(1);
40951
40952 --
40953 BEGIN
40954 --
40955 IF g_log_enabled THEN
40956 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_84';
40957 END IF;
40958 --
40959 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40960
40961 trace
40962 (p_msg => 'BEGIN of AcctLineType_84'
40966 END IF;
40963 ,p_level => C_LEVEL_PROCEDURE
40964 ,p_module => l_log_module);
40965
40967 --
40968 l_component_type := 'AMB_JLT';
40969 l_component_code := 'RCT_CURR_ROUND';
40970 l_component_type_code := 'S';
40971 l_component_appl_id := 222;
40972 l_amb_context_code := 'DEFAULT';
40973 l_entity_code := 'RECEIPTS';
40974 l_event_class_code := 'RECEIPT';
40975 l_event_type_code := 'RECEIPT_ALL';
40976 l_line_definition_owner_code := 'S';
40977 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
40978 --
40979 l_balance_type_code := 'A';
40980 l_segment := NULL;
40981 l_ccid := NULL;
40982 l_adr_transaction_coa_id := NULL;
40983 l_adr_accounting_coa_id := NULL;
40984 l_adr_flexfield_segment_code := NULL;
40985 l_adr_flex_value_set_id := NULL;
40986 l_adr_value_type_code := NULL;
40987 l_adr_value_combination_id := NULL;
40988 l_adr_value_segment_code := NULL;
40989
40990 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
40991 l_bflow_class_code := ''; -- 4219869 Business Flow
40992 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
40993 l_budgetary_control_flag := 'N';
40994
40995 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40996 l_bflow_applied_to_amt := NULL; -- 5132302
40997 l_entered_amt_idx := NULL; -- 4262811
40998 l_accted_amt_idx := NULL; -- 4262811
40999 l_acc_rev_flag := NULL; -- 4262811
41000 l_accrual_line_num := NULL; -- 4262811
41001 l_tmp_amt := NULL; -- 4262811
41002 --
41003
41004 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
41005 l_balance_type_code <> 'B' THEN
41006 IF NVL(p_source_15,'
41007 ') = 'CURR_ROUND' AND
41008 NVL(p_source_54,'
41009 ') = 'N'
41010 THEN
41011
41012 --
41013 XLA_AE_LINES_PKG.SetNewLine;
41014
41015 p_balance_type_code := l_balance_type_code;
41016 -- set the flag so later we will know whether the gain loss line needs to be created
41017
41018 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
41019 p_actual_flag :='A';
41020 END IF;
41021
41022 --
41023 -- bulk performance
41024 --
41025 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
41026 p_header_num => 0); -- 4262811
41027 --
41028 -- set accounting line options
41029 --
41030 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
41031 p_natural_side_code => 'C'
41032 , p_gain_or_loss_flag => 'N'
41033 , p_gl_transfer_mode_code => 'S'
41034 , p_acct_entry_type_code => 'A'
41035 , p_switch_side_flag => 'Y'
41036 , p_merge_duplicate_code => 'A'
41037 );
41038 --
41039 l_acc_rev_natural_side_code := 'D'; -- 4262811
41040 --
41041 --
41042 -- set accounting line type info
41043 --
41044 xla_ae_lines_pkg.SetAcctLineType
41045 (p_component_type => l_component_type
41046 ,p_event_type_code => l_event_type_code
41047 ,p_line_definition_owner_code => l_line_definition_owner_code
41048 ,p_line_definition_code => l_line_definition_code
41049 ,p_accounting_line_code => l_component_code
41050 ,p_accounting_line_type_code => l_component_type_code
41051 ,p_accounting_line_appl_id => l_component_appl_id
41052 ,p_amb_context_code => l_amb_context_code
41053 ,p_entity_code => l_entity_code
41054 ,p_event_class_code => l_event_class_code);
41055 --
41056 -- set accounting class
41057 --
41058 xla_ae_lines_pkg.SetAcctClass(
41059 p_accounting_class_code => 'ROUNDING'
41060 , p_ae_header_id => l_ae_header_id
41061 );
41062
41063 --
41064 -- set rounding class
41065 --
41066 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
41067 'RECEIVABLE';
41068
41069 --
41070 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
41071 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
41072 --
41073 -- bulk performance
41074 --
41075 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
41076
41077 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
41078 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
41079
41080 -- 4955764
41081 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41082 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
41083
41084 -- 4458381 Public Sector Enh
41085
41086 --
41087 -- set accounting attributes for the line type
41088 --
41089 l_entered_amt_idx := 8;
41090 l_accted_amt_idx := 13;
41091 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41092 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
41093 l_rec_acct_attrs.array_num_value(1) := p_source_58;
41094 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
41095 l_rec_acct_attrs.array_char_value(2) := p_source_30;
41099 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
41096 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
41097 l_rec_acct_attrs.array_char_value(3) := p_source_59;
41098 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
41100 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
41101 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
41102 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
41103 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
41104 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
41105 l_rec_acct_attrs.array_char_value(7) := p_source_18;
41106 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
41107 l_rec_acct_attrs.array_num_value(8) := p_source_61;
41108 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
41109 l_rec_acct_attrs.array_char_value(9) := p_source_62;
41110 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
41111 l_rec_acct_attrs.array_date_value(10) := p_source_21;
41112 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
41113 l_rec_acct_attrs.array_num_value(11) := p_source_22;
41114 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
41115 l_rec_acct_attrs.array_char_value(12) := p_source_23;
41116 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
41117 l_rec_acct_attrs.array_num_value(13) := p_source_63;
41118 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
41119 l_rec_acct_attrs.array_num_value(14) := p_source_64;
41120 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
41121 l_rec_acct_attrs.array_num_value(15) := p_source_65;
41122 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
41123 l_rec_acct_attrs.array_char_value(16) := p_source_66;
41124
41125 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
41126 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
41127
41128 ---------------------------------------------------------------------------------------------------------------
41129 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
41130 ---------------------------------------------------------------------------------------------------------------
41131 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
41132
41133 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41134 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41135
41136 IF xla_accounting_cache_pkg.GetValueChar
41137 (p_source_code => 'LEDGER_CATEGORY_CODE'
41138 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
41139 AND l_bflow_method_code = 'PRIOR_ENTRY'
41140 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
41141 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
41142 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
41143 )
41144 THEN
41145 xla_ae_lines_pkg.BflowUpgEntry
41146 (p_business_method_code => l_bflow_method_code
41147 ,p_business_class_code => l_bflow_class_code
41148 ,p_balance_type => l_balance_type_code);
41149 ELSE
41150 NULL;
41151 -- No business flow processing for business flow method of NONE.
41152 END IF;
41153
41154 --
41155 -- call analytical criteria
41156 --
41157
41158 --
41159 -- call description
41160 --
41161 -- No description or it is inherited.
41162 --
41163 -- call ADRs
41164 -- Bug 4922099
41165 --
41166 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41167 (NVL(l_actual_upg_option, 'N') = 'O') OR
41168 (NVL(l_enc_upg_option, 'N') = 'O')
41169 )
41170 THEN
41171 NULL;
41172 --
41173 --
41174
41175 l_ccid := AcctDerRule_11(
41176 p_application_id => p_application_id
41177 , p_ae_header_id => l_ae_header_id
41178 , p_source_10 => p_source_10
41179 , x_transaction_coa_id => l_adr_transaction_coa_id
41180 , x_accounting_coa_id => l_adr_accounting_coa_id
41181 , x_value_type_code => l_adr_value_type_code
41182 , p_side => 'NA'
41183 );
41184
41185 xla_ae_lines_pkg.set_ccid(
41186 p_code_combination_id => l_ccid
41187 , p_value_type_code => l_adr_value_type_code
41188 , p_transaction_coa_id => l_adr_transaction_coa_id
41189 , p_accounting_coa_id => l_adr_accounting_coa_id
41190 , p_adr_code => 'DIST_CCID'
41191 , p_adr_type_code => 'S'
41192 , p_component_type => l_component_type
41193 , p_component_code => l_component_code
41194 , p_component_type_code => l_component_type_code
41195 , p_component_appl_id => l_component_appl_id
41196 , p_amb_context_code => l_amb_context_code
41197 , p_side => 'NA'
41198 );
41199
41200
41201 --
41202 --
41203 END IF;
41204 --
41205 -- Bug 4922099
41206 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
41207 (NVL(l_enc_upg_option, 'N') = 'O')
41208 ) AND
41209 (l_bflow_method_code = 'PRIOR_ENTRY')
41210 )
41211 THEN
41212 IF
41213 --
41214 1 = 2
41215 --
41216 THEN
41217 xla_accounting_err_pkg.build_message
41221 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
41218 (p_appli_s_name => 'XLA'
41219 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41220 ,p_token_1 => 'LINE_NUMBER'
41222 ,p_token_2 => 'LINE_TYPE_NAME'
41223 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
41224 l_component_type
41225 ,l_component_code
41226 ,l_component_type_code
41227 ,l_component_appl_id
41228 ,l_amb_context_code
41229 ,l_entity_code
41230 ,l_event_class_code
41231 )
41232 ,p_token_3 => 'OWNER'
41233 ,p_value_3 => xla_lookups_pkg.get_meaning(
41234 p_lookup_type => 'XLA_OWNER_TYPE'
41235 ,p_lookup_code => l_component_type_code
41236 )
41237 ,p_token_4 => 'PRODUCT_NAME'
41238 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
41239 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
41240 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
41241 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
41242 ,p_ae_header_id => NULL
41243 );
41244
41245 IF (C_LEVEL_ERROR>= g_log_level) THEN
41246 trace
41247 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41248 ,p_level => C_LEVEL_ERROR
41249 ,p_module => l_log_module);
41250 END IF;
41251 END IF;
41252 END IF;
41253 --
41254 --
41255 ------------------------------------------------------------------------------------------------
41256 -- 4219869 Business Flow
41257 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
41258 -- Prior Entry. Currently, the following code is always generated.
41259 ------------------------------------------------------------------------------------------------
41260 XLA_AE_LINES_PKG.ValidateCurrentLine;
41261
41262 ------------------------------------------------------------------------------------
41263 -- 4219869 Business Flow
41264 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
41265 ------------------------------------------------------------------------------------
41266 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41267
41268 ----------------------------------------------------------------------------------
41269 -- 4219869 Business Flow
41270 -- Update journal entry status -- Need to generate this within IF <condition>
41271 ----------------------------------------------------------------------------------
41272 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41273 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
41274 ,p_balance_type_code => l_balance_type_code
41275 );
41276
41277 -------------------------------------------------------------------------------------------
41278 -- 4262811 - Generate the Accrual Reversal lines
41279 -------------------------------------------------------------------------------------------
41280 BEGIN
41281 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
41282 (g_array_event(p_event_id).array_value_num('header_index'));
41283 IF l_acc_rev_flag IS NULL THEN
41284 l_acc_rev_flag := 'N';
41285 END IF;
41286 EXCEPTION
41287 WHEN OTHERS THEN
41288 l_acc_rev_flag := 'N';
41289 END;
41290 --
41291 IF (l_acc_rev_flag = 'Y') THEN
41292
41293 -- 4645092 ------------------------------------------------------------------------------
41294 -- To allow MPA report to determine if it should generate report process
41295 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
41296 ------------------------------------------------------------------------------------------
41297
41298 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
41299 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
41300 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
41301 -- call ADRs
41302 -- Bug 4922099
41303 --
41304 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41305 (NVL(l_actual_upg_option, 'N') = 'O') OR
41306 (NVL(l_enc_upg_option, 'N') = 'O')
41307 )
41308 THEN
41309 NULL;
41310 --
41311 --
41312
41313 l_ccid := AcctDerRule_11(
41314 p_application_id => p_application_id
41315 , p_ae_header_id => l_ae_header_id
41316 , p_source_10 => p_source_10
41320 , p_side => 'NA'
41317 , x_transaction_coa_id => l_adr_transaction_coa_id
41318 , x_accounting_coa_id => l_adr_accounting_coa_id
41319 , x_value_type_code => l_adr_value_type_code
41321 );
41322
41323 xla_ae_lines_pkg.set_ccid(
41324 p_code_combination_id => l_ccid
41325 , p_value_type_code => l_adr_value_type_code
41326 , p_transaction_coa_id => l_adr_transaction_coa_id
41327 , p_accounting_coa_id => l_adr_accounting_coa_id
41328 , p_adr_code => 'DIST_CCID'
41329 , p_adr_type_code => 'S'
41330 , p_component_type => l_component_type
41331 , p_component_code => l_component_code
41332 , p_component_type_code => l_component_type_code
41333 , p_component_appl_id => l_component_appl_id
41334 , p_amb_context_code => l_amb_context_code
41335 , p_side => 'NA'
41336 );
41337
41338
41339 --
41340 --
41341 END IF;
41342
41343 --
41344 -- Update the line information that should be overwritten
41345 --
41346 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
41347 p_header_num => 1);
41348 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
41349
41350 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
41351
41352 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
41353 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
41354 END IF;
41355
41356 --
41357 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
41358 --
41359 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
41360 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
41361 ELSE
41362 ---------------------------------------------------------------------------------------------------
41363 -- 4262811a Switch Sign
41364 ---------------------------------------------------------------------------------------------------
41365 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
41366 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41367 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41368 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41369 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41370 -- 5132302
41371 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
41372 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41373
41374 END IF;
41375
41376 -- 4955764
41377 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41378 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
41379
41380
41381 XLA_AE_LINES_PKG.ValidateCurrentLine;
41382 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41383
41384 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41385 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
41386 ,p_balance_type_code => l_balance_type_code);
41387
41388 END IF;
41389
41390 -----------------------------------------------------------------------------------------
41391 -- 4262811 Multiperiod Accounting
41392 -----------------------------------------------------------------------------------------
41393 -- No MPA option is assigned.
41394
41395
41396 END IF;
41397 END IF;
41398 --
41399
41400 --
41401 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41402 trace
41403 (p_msg => 'END of AcctLineType_84'
41404 ,p_level => C_LEVEL_PROCEDURE
41405 ,p_module => l_log_module);
41406 END IF;
41407 --
41408 EXCEPTION
41409 WHEN xla_exceptions_pkg.application_exception THEN
41410 RAISE;
41411 WHEN OTHERS THEN
41412 xla_exceptions_pkg.raise_message
41413 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_84');
41414 END AcctLineType_84;
41415 --
41416
41417 ---------------------------------------
41418 --
41419 -- PRIVATE FUNCTION
41420 -- AcctLineType_85
41421 --
41422 ---------------------------------------
41423 PROCEDURE AcctLineType_85 (
41424 p_application_id IN NUMBER
41425 ,p_event_id IN NUMBER
41426 ,p_calculate_acctd_flag IN VARCHAR2
41427 ,p_calculate_g_l_flag IN VARCHAR2
41428 ,p_actual_flag IN OUT VARCHAR2
41429 ,p_balance_type_code OUT VARCHAR2
41430 ,p_gain_or_loss_ref OUT VARCHAR2
41431
41432 --Distribution GL Account
41433 , p_source_10 IN NUMBER
41434 --Distribution Source Type
41435 , p_source_15 IN VARCHAR2
41436 --Distribution Line Identifier
41437 , p_source_17 IN NUMBER
41438 --Distribution Type
41439 , p_source_18 IN VARCHAR2
41440 --Exchange Date
41441 , p_source_21 IN DATE
41442 --Exchange Rate
41443 , p_source_22 IN NUMBER
41444 --Exchange Rate Type
41445 , p_source_23 IN VARCHAR2
41449 , p_source_30 IN VARCHAR2
41446 --Transaction Distribution Identifier
41447 , p_source_29 IN NUMBER
41448 --Transaction Distribution Type
41450 --Distribution Multi Fund Additional Entry
41451 , p_source_54 IN VARCHAR2
41452 --Receipt Applied To Application Identifier
41453 , p_source_58 IN NUMBER
41454 --Transaction Entity Code
41455 , p_source_59 IN VARCHAR2
41456 --Transaction Identifier
41457 , p_source_60 IN NUMBER
41458 --DIST_ENT_AMT_FROM
41459 , p_source_61 IN NUMBER
41460 --Applying Document Currency Code
41461 , p_source_62 IN VARCHAR2
41462 --Accounting Amount
41463 , p_source_63 IN NUMBER
41464 --Distribution Party Identifier
41465 , p_source_64 IN NUMBER
41466 --Distribution Party Site Id
41467 , p_source_65 IN NUMBER
41468 --Distribution Party Type
41469 , p_source_66 IN VARCHAR2
41470 )
41471 IS
41472
41473 l_component_type VARCHAR2(80);
41474 l_component_code VARCHAR2(30);
41475 l_component_type_code VARCHAR2(1);
41476 l_component_appl_id INTEGER;
41477 l_amb_context_code VARCHAR2(30);
41478 l_entity_code VARCHAR2(30);
41479 l_event_class_code VARCHAR2(30);
41480 l_ae_header_id NUMBER;
41481 l_event_type_code VARCHAR2(30);
41482 l_line_definition_code VARCHAR2(30);
41483 l_line_definition_owner_code VARCHAR2(1);
41484 --
41485 -- adr variables
41486 l_segment VARCHAR2(30);
41487 l_ccid NUMBER;
41488 l_adr_transaction_coa_id NUMBER;
41489 l_adr_accounting_coa_id NUMBER;
41490 l_adr_flexfield_segment_code VARCHAR2(30);
41491 l_adr_flex_value_set_id NUMBER;
41492 l_adr_value_type_code VARCHAR2(30);
41493 l_adr_value_combination_id NUMBER;
41494 l_adr_value_segment_code VARCHAR2(30);
41495
41496 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
41497 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
41498 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
41499 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
41500
41501 -- 4262811 Variables ------------------------------------------------------------------------------------------
41502 l_entered_amt_idx NUMBER;
41503 l_accted_amt_idx NUMBER;
41504 l_acc_rev_flag VARCHAR2(1);
41505 l_accrual_line_num NUMBER;
41506 l_tmp_amt NUMBER;
41507 l_acc_rev_natural_side_code VARCHAR2(1);
41508
41509 l_num_entries NUMBER;
41510 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
41511 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
41512 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
41513 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
41514 l_recog_line_1 NUMBER;
41515 l_recog_line_2 NUMBER;
41516
41517 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
41518 l_bflow_applied_to_amt NUMBER; -- 5132302
41519 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
41520
41521 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
41522
41523 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
41524 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
41525
41526 ---------------------------------------------------------------------------------------------------------------
41527
41528
41529 --
41530 -- bulk performance
41531 --
41532 l_balance_type_code VARCHAR2(1);
41533 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
41534 l_log_module VARCHAR2(240);
41535
41536 --
41537 -- Upgrade strategy
41538 --
41539 l_actual_upg_option VARCHAR2(1);
41540 l_enc_upg_option VARCHAR2(1);
41541
41542 --
41543 BEGIN
41544 --
41545 IF g_log_enabled THEN
41546 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_85';
41547 END IF;
41548 --
41549 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41550
41551 trace
41552 (p_msg => 'BEGIN of AcctLineType_85'
41553 ,p_level => C_LEVEL_PROCEDURE
41554 ,p_module => l_log_module);
41555
41556 END IF;
41557 --
41558 l_component_type := 'AMB_JLT';
41559 l_component_code := 'RCT_DEBT';
41560 l_component_type_code := 'S';
41561 l_component_appl_id := 222;
41562 l_amb_context_code := 'DEFAULT';
41563 l_entity_code := 'RECEIPTS';
41564 l_event_class_code := 'RECEIPT';
41565 l_event_type_code := 'RECEIPT_ALL';
41566 l_line_definition_owner_code := 'S';
41567 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
41568 --
41569 l_balance_type_code := 'A';
41570 l_segment := NULL;
41571 l_ccid := NULL;
41572 l_adr_transaction_coa_id := NULL;
41573 l_adr_accounting_coa_id := NULL;
41574 l_adr_flexfield_segment_code := NULL;
41575 l_adr_flex_value_set_id := NULL;
41576 l_adr_value_type_code := NULL;
41577 l_adr_value_combination_id := NULL;
41578 l_adr_value_segment_code := NULL;
41579
41580 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
41581 l_bflow_class_code := ''; -- 4219869 Business Flow
41582 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
41586 l_bflow_applied_to_amt := NULL; -- 5132302
41583 l_budgetary_control_flag := 'N';
41584
41585 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41587 l_entered_amt_idx := NULL; -- 4262811
41588 l_accted_amt_idx := NULL; -- 4262811
41589 l_acc_rev_flag := NULL; -- 4262811
41590 l_accrual_line_num := NULL; -- 4262811
41591 l_tmp_amt := NULL; -- 4262811
41592 --
41593
41594 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
41595 l_balance_type_code <> 'B' THEN
41596 IF NVL(p_source_15,'
41597 ') = 'SHORT_TERM_DEBT' AND
41598 NVL(p_source_54,'
41599 ') = 'N'
41600 THEN
41601
41602 --
41603 XLA_AE_LINES_PKG.SetNewLine;
41604
41605 p_balance_type_code := l_balance_type_code;
41606 -- set the flag so later we will know whether the gain loss line needs to be created
41607
41608 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
41609 p_actual_flag :='A';
41610 END IF;
41611
41612 --
41613 -- bulk performance
41614 --
41615 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
41616 p_header_num => 0); -- 4262811
41617 --
41618 -- set accounting line options
41619 --
41620 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
41621 p_natural_side_code => 'C'
41622 , p_gain_or_loss_flag => 'N'
41623 , p_gl_transfer_mode_code => 'S'
41624 , p_acct_entry_type_code => 'A'
41625 , p_switch_side_flag => 'Y'
41626 , p_merge_duplicate_code => 'A'
41627 );
41628 --
41629 l_acc_rev_natural_side_code := 'D'; -- 4262811
41630 --
41631 --
41632 -- set accounting line type info
41633 --
41634 xla_ae_lines_pkg.SetAcctLineType
41635 (p_component_type => l_component_type
41636 ,p_event_type_code => l_event_type_code
41637 ,p_line_definition_owner_code => l_line_definition_owner_code
41638 ,p_line_definition_code => l_line_definition_code
41639 ,p_accounting_line_code => l_component_code
41640 ,p_accounting_line_type_code => l_component_type_code
41641 ,p_accounting_line_appl_id => l_component_appl_id
41642 ,p_amb_context_code => l_amb_context_code
41643 ,p_entity_code => l_entity_code
41644 ,p_event_class_code => l_event_class_code);
41645 --
41646 -- set accounting class
41647 --
41648 xla_ae_lines_pkg.SetAcctClass(
41649 p_accounting_class_code => 'SHORT_TERM_DEBT'
41650 , p_ae_header_id => l_ae_header_id
41651 );
41652
41653 --
41654 -- set rounding class
41655 --
41656 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
41657 'RECEIVABLE';
41658
41659 --
41660 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
41661 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
41662 --
41663 -- bulk performance
41664 --
41665 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
41666
41667 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
41668 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
41669
41670 -- 4955764
41671 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41672 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
41673
41674 -- 4458381 Public Sector Enh
41675
41676 --
41677 -- set accounting attributes for the line type
41678 --
41679 l_entered_amt_idx := 8;
41680 l_accted_amt_idx := 13;
41681 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41682 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
41683 l_rec_acct_attrs.array_num_value(1) := p_source_58;
41684 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
41685 l_rec_acct_attrs.array_char_value(2) := p_source_30;
41686 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
41687 l_rec_acct_attrs.array_char_value(3) := p_source_59;
41688 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
41689 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
41690 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
41691 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
41692 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
41693 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
41694 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
41695 l_rec_acct_attrs.array_char_value(7) := p_source_18;
41696 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
41697 l_rec_acct_attrs.array_num_value(8) := p_source_61;
41698 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
41699 l_rec_acct_attrs.array_char_value(9) := p_source_62;
41700 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
41701 l_rec_acct_attrs.array_date_value(10) := p_source_21;
41702 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
41703 l_rec_acct_attrs.array_num_value(11) := p_source_22;
41704 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
41705 l_rec_acct_attrs.array_char_value(12) := p_source_23;
41709 l_rec_acct_attrs.array_num_value(14) := p_source_64;
41706 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
41707 l_rec_acct_attrs.array_num_value(13) := p_source_63;
41708 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
41710 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
41711 l_rec_acct_attrs.array_num_value(15) := p_source_65;
41712 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
41713 l_rec_acct_attrs.array_char_value(16) := p_source_66;
41714
41715 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
41716 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
41717
41718 ---------------------------------------------------------------------------------------------------------------
41719 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
41720 ---------------------------------------------------------------------------------------------------------------
41721 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
41722
41723 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41724 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41725
41726 IF xla_accounting_cache_pkg.GetValueChar
41727 (p_source_code => 'LEDGER_CATEGORY_CODE'
41728 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
41729 AND l_bflow_method_code = 'PRIOR_ENTRY'
41730 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
41731 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
41732 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
41733 )
41734 THEN
41735 xla_ae_lines_pkg.BflowUpgEntry
41736 (p_business_method_code => l_bflow_method_code
41737 ,p_business_class_code => l_bflow_class_code
41738 ,p_balance_type => l_balance_type_code);
41739 ELSE
41740 NULL;
41741 -- No business flow processing for business flow method of NONE.
41742 END IF;
41743
41744 --
41745 -- call analytical criteria
41746 --
41747
41748 --
41749 -- call description
41750 --
41751 -- No description or it is inherited.
41752 --
41753 -- call ADRs
41754 -- Bug 4922099
41755 --
41756 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41757 (NVL(l_actual_upg_option, 'N') = 'O') OR
41758 (NVL(l_enc_upg_option, 'N') = 'O')
41759 )
41760 THEN
41761 NULL;
41762 --
41763 --
41764
41765 l_ccid := AcctDerRule_11(
41766 p_application_id => p_application_id
41767 , p_ae_header_id => l_ae_header_id
41768 , p_source_10 => p_source_10
41769 , x_transaction_coa_id => l_adr_transaction_coa_id
41770 , x_accounting_coa_id => l_adr_accounting_coa_id
41771 , x_value_type_code => l_adr_value_type_code
41772 , p_side => 'NA'
41773 );
41774
41775 xla_ae_lines_pkg.set_ccid(
41776 p_code_combination_id => l_ccid
41777 , p_value_type_code => l_adr_value_type_code
41778 , p_transaction_coa_id => l_adr_transaction_coa_id
41779 , p_accounting_coa_id => l_adr_accounting_coa_id
41780 , p_adr_code => 'DIST_CCID'
41781 , p_adr_type_code => 'S'
41782 , p_component_type => l_component_type
41783 , p_component_code => l_component_code
41784 , p_component_type_code => l_component_type_code
41785 , p_component_appl_id => l_component_appl_id
41786 , p_amb_context_code => l_amb_context_code
41787 , p_side => 'NA'
41788 );
41789
41790
41791 --
41792 --
41793 END IF;
41794 --
41795 -- Bug 4922099
41796 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
41797 (NVL(l_enc_upg_option, 'N') = 'O')
41798 ) AND
41799 (l_bflow_method_code = 'PRIOR_ENTRY')
41800 )
41801 THEN
41802 IF
41803 --
41804 1 = 2
41805 --
41806 THEN
41807 xla_accounting_err_pkg.build_message
41808 (p_appli_s_name => 'XLA'
41809 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41810 ,p_token_1 => 'LINE_NUMBER'
41811 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
41812 ,p_token_2 => 'LINE_TYPE_NAME'
41813 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
41814 l_component_type
41815 ,l_component_code
41816 ,l_component_type_code
41817 ,l_component_appl_id
41818 ,l_amb_context_code
41819 ,l_entity_code
41820 ,l_event_class_code
41821 )
41822 ,p_token_3 => 'OWNER'
41826 )
41823 ,p_value_3 => xla_lookups_pkg.get_meaning(
41824 p_lookup_type => 'XLA_OWNER_TYPE'
41825 ,p_lookup_code => l_component_type_code
41827 ,p_token_4 => 'PRODUCT_NAME'
41828 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
41829 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
41830 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
41831 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
41832 ,p_ae_header_id => NULL
41833 );
41834
41835 IF (C_LEVEL_ERROR>= g_log_level) THEN
41836 trace
41837 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41838 ,p_level => C_LEVEL_ERROR
41839 ,p_module => l_log_module);
41840 END IF;
41841 END IF;
41842 END IF;
41843 --
41844 --
41845 ------------------------------------------------------------------------------------------------
41846 -- 4219869 Business Flow
41847 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
41848 -- Prior Entry. Currently, the following code is always generated.
41849 ------------------------------------------------------------------------------------------------
41850 XLA_AE_LINES_PKG.ValidateCurrentLine;
41851
41852 ------------------------------------------------------------------------------------
41853 -- 4219869 Business Flow
41854 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
41855 ------------------------------------------------------------------------------------
41856 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41857
41858 ----------------------------------------------------------------------------------
41859 -- 4219869 Business Flow
41860 -- Update journal entry status -- Need to generate this within IF <condition>
41861 ----------------------------------------------------------------------------------
41862 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41863 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
41864 ,p_balance_type_code => l_balance_type_code
41865 );
41866
41867 -------------------------------------------------------------------------------------------
41868 -- 4262811 - Generate the Accrual Reversal lines
41869 -------------------------------------------------------------------------------------------
41870 BEGIN
41871 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
41872 (g_array_event(p_event_id).array_value_num('header_index'));
41873 IF l_acc_rev_flag IS NULL THEN
41874 l_acc_rev_flag := 'N';
41875 END IF;
41876 EXCEPTION
41877 WHEN OTHERS THEN
41878 l_acc_rev_flag := 'N';
41879 END;
41880 --
41881 IF (l_acc_rev_flag = 'Y') THEN
41882
41883 -- 4645092 ------------------------------------------------------------------------------
41884 -- To allow MPA report to determine if it should generate report process
41885 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
41886 ------------------------------------------------------------------------------------------
41887
41888 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
41889 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
41890 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
41891 -- call ADRs
41892 -- Bug 4922099
41893 --
41894 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41895 (NVL(l_actual_upg_option, 'N') = 'O') OR
41896 (NVL(l_enc_upg_option, 'N') = 'O')
41897 )
41898 THEN
41899 NULL;
41900 --
41901 --
41902
41903 l_ccid := AcctDerRule_11(
41904 p_application_id => p_application_id
41905 , p_ae_header_id => l_ae_header_id
41906 , p_source_10 => p_source_10
41907 , x_transaction_coa_id => l_adr_transaction_coa_id
41908 , x_accounting_coa_id => l_adr_accounting_coa_id
41909 , x_value_type_code => l_adr_value_type_code
41910 , p_side => 'NA'
41911 );
41912
41913 xla_ae_lines_pkg.set_ccid(
41914 p_code_combination_id => l_ccid
41915 , p_value_type_code => l_adr_value_type_code
41916 , p_transaction_coa_id => l_adr_transaction_coa_id
41917 , p_accounting_coa_id => l_adr_accounting_coa_id
41918 , p_adr_code => 'DIST_CCID'
41919 , p_adr_type_code => 'S'
41920 , p_component_type => l_component_type
41921 , p_component_code => l_component_code
41922 , p_component_type_code => l_component_type_code
41923 , p_component_appl_id => l_component_appl_id
41924 , p_amb_context_code => l_amb_context_code
41925 , p_side => 'NA'
41926 );
41927
41928
41929 --
41930 --
41931 END IF;
41932
41933 --
41934 -- Update the line information that should be overwritten
41935 --
41936 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
41940 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
41937 p_header_num => 1);
41938 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
41939
41941
41942 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
41943 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
41944 END IF;
41945
41946 --
41947 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
41948 --
41949 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
41950 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
41951 ELSE
41952 ---------------------------------------------------------------------------------------------------
41953 -- 4262811a Switch Sign
41954 ---------------------------------------------------------------------------------------------------
41955 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
41956 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41957 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41958 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41959 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41960 -- 5132302
41961 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
41962 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41963
41964 END IF;
41965
41966 -- 4955764
41967 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41968 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
41969
41970
41971 XLA_AE_LINES_PKG.ValidateCurrentLine;
41972 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41973
41974 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41975 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
41976 ,p_balance_type_code => l_balance_type_code);
41977
41978 END IF;
41979
41980 -----------------------------------------------------------------------------------------
41981 -- 4262811 Multiperiod Accounting
41982 -----------------------------------------------------------------------------------------
41983 -- No MPA option is assigned.
41984
41985
41986 END IF;
41987 END IF;
41988 --
41989
41990 --
41991 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41992 trace
41993 (p_msg => 'END of AcctLineType_85'
41994 ,p_level => C_LEVEL_PROCEDURE
41995 ,p_module => l_log_module);
41996 END IF;
41997 --
41998 EXCEPTION
41999 WHEN xla_exceptions_pkg.application_exception THEN
42000 RAISE;
42001 WHEN OTHERS THEN
42002 xla_exceptions_pkg.raise_message
42003 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_85');
42004 END AcctLineType_85;
42005 --
42006
42007 ---------------------------------------
42008 --
42009 -- PRIVATE FUNCTION
42010 -- AcctLineType_86
42011 --
42012 ---------------------------------------
42013 PROCEDURE AcctLineType_86 (
42014 p_application_id IN NUMBER
42015 ,p_event_id IN NUMBER
42016 ,p_calculate_acctd_flag IN VARCHAR2
42017 ,p_calculate_g_l_flag IN VARCHAR2
42018 ,p_actual_flag IN OUT VARCHAR2
42019 ,p_balance_type_code OUT VARCHAR2
42020 ,p_gain_or_loss_ref OUT VARCHAR2
42021
42022 --Distribution GL Account
42023 , p_source_10 IN NUMBER
42024 --Distribution Source Type
42025 , p_source_15 IN VARCHAR2
42026 --Distribution Line Identifier
42027 , p_source_17 IN NUMBER
42028 --Distribution Type
42029 , p_source_18 IN VARCHAR2
42030 --Entered Amount
42031 , p_source_19 IN NUMBER
42032 --Currency Code
42033 , p_source_20 IN VARCHAR2
42034 --Applied To Document Accounting Amount
42035 , p_source_24 IN NUMBER
42036 --Transaction Distribution Identifier
42037 , p_source_29 IN NUMBER
42038 --Transaction Distribution Type
42039 , p_source_30 IN VARCHAR2
42040 --Distribution Multi Fund Additional Entry
42041 , p_source_54 IN VARCHAR2
42042 --Applied To Document Exchange Date
42043 , p_source_55 IN DATE
42044 --Receipt Applied To Application Identifier
42045 , p_source_58 IN NUMBER
42046 --Transaction Entity Code
42047 , p_source_59 IN VARCHAR2
42048 --Transaction Identifier
42049 , p_source_60 IN NUMBER
42050 --Distribution Party Identifier
42051 , p_source_64 IN NUMBER
42052 --Distribution Party Site Id
42053 , p_source_65 IN NUMBER
42054 --Distribution Party Type
42055 , p_source_66 IN VARCHAR2
42056 --Applied To Document Exchange Rate Type
42057 , p_source_67 IN VARCHAR2
42058 --Applied To Document Exchange Rate
42059 , p_source_68 IN NUMBER
42060 )
42064 l_component_code VARCHAR2(30);
42061 IS
42062
42063 l_component_type VARCHAR2(80);
42065 l_component_type_code VARCHAR2(1);
42066 l_component_appl_id INTEGER;
42067 l_amb_context_code VARCHAR2(30);
42068 l_entity_code VARCHAR2(30);
42069 l_event_class_code VARCHAR2(30);
42070 l_ae_header_id NUMBER;
42071 l_event_type_code VARCHAR2(30);
42072 l_line_definition_code VARCHAR2(30);
42073 l_line_definition_owner_code VARCHAR2(1);
42074 --
42075 -- adr variables
42076 l_segment VARCHAR2(30);
42077 l_ccid NUMBER;
42078 l_adr_transaction_coa_id NUMBER;
42079 l_adr_accounting_coa_id NUMBER;
42080 l_adr_flexfield_segment_code VARCHAR2(30);
42081 l_adr_flex_value_set_id NUMBER;
42082 l_adr_value_type_code VARCHAR2(30);
42083 l_adr_value_combination_id NUMBER;
42084 l_adr_value_segment_code VARCHAR2(30);
42085
42086 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
42087 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
42088 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
42089 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
42090
42091 -- 4262811 Variables ------------------------------------------------------------------------------------------
42092 l_entered_amt_idx NUMBER;
42093 l_accted_amt_idx NUMBER;
42094 l_acc_rev_flag VARCHAR2(1);
42095 l_accrual_line_num NUMBER;
42096 l_tmp_amt NUMBER;
42097 l_acc_rev_natural_side_code VARCHAR2(1);
42098
42099 l_num_entries NUMBER;
42100 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
42101 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
42102 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
42103 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
42104 l_recog_line_1 NUMBER;
42105 l_recog_line_2 NUMBER;
42106
42107 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
42108 l_bflow_applied_to_amt NUMBER; -- 5132302
42109 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
42110
42111 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
42112
42113 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
42114 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
42115
42116 ---------------------------------------------------------------------------------------------------------------
42117
42118
42119 --
42120 -- bulk performance
42121 --
42122 l_balance_type_code VARCHAR2(1);
42123 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
42124 l_log_module VARCHAR2(240);
42125
42126 --
42127 -- Upgrade strategy
42128 --
42129 l_actual_upg_option VARCHAR2(1);
42130 l_enc_upg_option VARCHAR2(1);
42131
42132 --
42133 BEGIN
42134 --
42135 IF g_log_enabled THEN
42136 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_86';
42137 END IF;
42138 --
42139 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42140
42141 trace
42142 (p_msg => 'BEGIN of AcctLineType_86'
42143 ,p_level => C_LEVEL_PROCEDURE
42144 ,p_module => l_log_module);
42145
42146 END IF;
42147 --
42148 l_component_type := 'AMB_JLT';
42149 l_component_code := 'RCT_DEFERRED_TAX';
42150 l_component_type_code := 'S';
42151 l_component_appl_id := 222;
42152 l_amb_context_code := 'DEFAULT';
42153 l_entity_code := 'RECEIPTS';
42154 l_event_class_code := 'RECEIPT';
42155 l_event_type_code := 'RECEIPT_ALL';
42156 l_line_definition_owner_code := 'S';
42157 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
42158 --
42159 l_balance_type_code := 'A';
42160 l_segment := NULL;
42161 l_ccid := NULL;
42162 l_adr_transaction_coa_id := NULL;
42163 l_adr_accounting_coa_id := NULL;
42164 l_adr_flexfield_segment_code := NULL;
42165 l_adr_flex_value_set_id := NULL;
42166 l_adr_value_type_code := NULL;
42167 l_adr_value_combination_id := NULL;
42168 l_adr_value_segment_code := NULL;
42169
42170 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
42171 l_bflow_class_code := ''; -- 4219869 Business Flow
42172 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
42173 l_budgetary_control_flag := 'N';
42174
42175 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42176 l_bflow_applied_to_amt := NULL; -- 5132302
42177 l_entered_amt_idx := NULL; -- 4262811
42178 l_accted_amt_idx := NULL; -- 4262811
42179 l_acc_rev_flag := NULL; -- 4262811
42180 l_accrual_line_num := NULL; -- 4262811
42181 l_tmp_amt := NULL; -- 4262811
42182 --
42183
42184 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
42185 l_balance_type_code <> 'B' THEN
42186 IF NVL(p_source_15,'
42187 ') = 'DEFERRED_TAX' AND
42188 NVL(p_source_54,'
42189 ') = 'N'
42190 THEN
42191
42192 --
42193 XLA_AE_LINES_PKG.SetNewLine;
42194
42195 p_balance_type_code := l_balance_type_code;
42199 p_actual_flag :='A';
42196 -- set the flag so later we will know whether the gain loss line needs to be created
42197
42198 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
42200 END IF;
42201
42202 --
42203 -- bulk performance
42204 --
42205 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
42206 p_header_num => 0); -- 4262811
42207 --
42208 -- set accounting line options
42209 --
42210 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
42211 p_natural_side_code => 'C'
42212 , p_gain_or_loss_flag => 'N'
42213 , p_gl_transfer_mode_code => 'S'
42214 , p_acct_entry_type_code => 'A'
42215 , p_switch_side_flag => 'Y'
42216 , p_merge_duplicate_code => 'A'
42217 );
42218 --
42219 l_acc_rev_natural_side_code := 'D'; -- 4262811
42220 --
42221 --
42222 -- set accounting line type info
42223 --
42224 xla_ae_lines_pkg.SetAcctLineType
42225 (p_component_type => l_component_type
42226 ,p_event_type_code => l_event_type_code
42227 ,p_line_definition_owner_code => l_line_definition_owner_code
42228 ,p_line_definition_code => l_line_definition_code
42229 ,p_accounting_line_code => l_component_code
42230 ,p_accounting_line_type_code => l_component_type_code
42231 ,p_accounting_line_appl_id => l_component_appl_id
42232 ,p_amb_context_code => l_amb_context_code
42233 ,p_entity_code => l_entity_code
42234 ,p_event_class_code => l_event_class_code);
42235 --
42236 -- set accounting class
42237 --
42238 xla_ae_lines_pkg.SetAcctClass(
42239 p_accounting_class_code => 'DEFERRED_TAX'
42240 , p_ae_header_id => l_ae_header_id
42241 );
42242
42243 --
42244 -- set rounding class
42245 --
42246 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
42247 'RECEIVABLE';
42248
42249 --
42250 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
42251 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
42252 --
42253 -- bulk performance
42254 --
42255 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
42256
42257 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
42258 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
42259
42260 -- 4955764
42261 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42262 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
42263
42264 -- 4458381 Public Sector Enh
42265
42266 --
42267 -- set accounting attributes for the line type
42268 --
42269 l_entered_amt_idx := 8;
42270 l_accted_amt_idx := 13;
42271 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42272 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
42273 l_rec_acct_attrs.array_num_value(1) := p_source_58;
42274 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
42275 l_rec_acct_attrs.array_char_value(2) := p_source_30;
42276 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
42277 l_rec_acct_attrs.array_char_value(3) := p_source_59;
42278 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
42279 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
42280 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
42281 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
42282 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
42283 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
42284 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
42285 l_rec_acct_attrs.array_char_value(7) := p_source_18;
42286 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
42287 l_rec_acct_attrs.array_num_value(8) := p_source_19;
42288 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
42289 l_rec_acct_attrs.array_char_value(9) := p_source_20;
42290 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
42291 l_rec_acct_attrs.array_date_value(10) := p_source_55;
42292 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
42293 l_rec_acct_attrs.array_num_value(11) := p_source_68;
42294 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
42295 l_rec_acct_attrs.array_char_value(12) := p_source_67;
42296 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
42297 l_rec_acct_attrs.array_num_value(13) := p_source_24;
42298 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
42299 l_rec_acct_attrs.array_num_value(14) := p_source_64;
42300 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
42301 l_rec_acct_attrs.array_num_value(15) := p_source_65;
42302 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
42303 l_rec_acct_attrs.array_char_value(16) := p_source_66;
42304
42305 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
42306 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
42307
42308 ---------------------------------------------------------------------------------------------------------------
42309 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
42313 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42310 ---------------------------------------------------------------------------------------------------------------
42311 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
42312
42314 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42315
42316 IF xla_accounting_cache_pkg.GetValueChar
42317 (p_source_code => 'LEDGER_CATEGORY_CODE'
42318 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
42319 AND l_bflow_method_code = 'PRIOR_ENTRY'
42320 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
42321 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
42322 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
42323 )
42324 THEN
42325 xla_ae_lines_pkg.BflowUpgEntry
42326 (p_business_method_code => l_bflow_method_code
42327 ,p_business_class_code => l_bflow_class_code
42328 ,p_balance_type => l_balance_type_code);
42329 ELSE
42330 NULL;
42331 -- No business flow processing for business flow method of NONE.
42332 END IF;
42333
42334 --
42335 -- call analytical criteria
42336 --
42337
42338 --
42339 -- call description
42340 --
42341 -- No description or it is inherited.
42342 --
42343 -- call ADRs
42344 -- Bug 4922099
42345 --
42346 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42347 (NVL(l_actual_upg_option, 'N') = 'O') OR
42348 (NVL(l_enc_upg_option, 'N') = 'O')
42349 )
42350 THEN
42351 NULL;
42352 --
42353 --
42354
42355 l_ccid := AcctDerRule_11(
42356 p_application_id => p_application_id
42357 , p_ae_header_id => l_ae_header_id
42358 , p_source_10 => p_source_10
42359 , x_transaction_coa_id => l_adr_transaction_coa_id
42360 , x_accounting_coa_id => l_adr_accounting_coa_id
42361 , x_value_type_code => l_adr_value_type_code
42362 , p_side => 'NA'
42363 );
42364
42365 xla_ae_lines_pkg.set_ccid(
42366 p_code_combination_id => l_ccid
42367 , p_value_type_code => l_adr_value_type_code
42368 , p_transaction_coa_id => l_adr_transaction_coa_id
42369 , p_accounting_coa_id => l_adr_accounting_coa_id
42370 , p_adr_code => 'DIST_CCID'
42371 , p_adr_type_code => 'S'
42372 , p_component_type => l_component_type
42373 , p_component_code => l_component_code
42374 , p_component_type_code => l_component_type_code
42375 , p_component_appl_id => l_component_appl_id
42376 , p_amb_context_code => l_amb_context_code
42377 , p_side => 'NA'
42378 );
42379
42380
42381 --
42382 --
42383 END IF;
42384 --
42385 -- Bug 4922099
42386 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
42387 (NVL(l_enc_upg_option, 'N') = 'O')
42388 ) AND
42389 (l_bflow_method_code = 'PRIOR_ENTRY')
42390 )
42391 THEN
42392 IF
42393 --
42394 1 = 2
42395 --
42396 THEN
42397 xla_accounting_err_pkg.build_message
42398 (p_appli_s_name => 'XLA'
42399 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42400 ,p_token_1 => 'LINE_NUMBER'
42401 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
42402 ,p_token_2 => 'LINE_TYPE_NAME'
42403 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
42404 l_component_type
42405 ,l_component_code
42406 ,l_component_type_code
42407 ,l_component_appl_id
42408 ,l_amb_context_code
42409 ,l_entity_code
42410 ,l_event_class_code
42411 )
42412 ,p_token_3 => 'OWNER'
42413 ,p_value_3 => xla_lookups_pkg.get_meaning(
42414 p_lookup_type => 'XLA_OWNER_TYPE'
42415 ,p_lookup_code => l_component_type_code
42416 )
42417 ,p_token_4 => 'PRODUCT_NAME'
42418 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
42419 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
42420 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
42421 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
42425 IF (C_LEVEL_ERROR>= g_log_level) THEN
42422 ,p_ae_header_id => NULL
42423 );
42424
42426 trace
42427 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42428 ,p_level => C_LEVEL_ERROR
42429 ,p_module => l_log_module);
42430 END IF;
42431 END IF;
42432 END IF;
42433 --
42434 --
42435 ------------------------------------------------------------------------------------------------
42436 -- 4219869 Business Flow
42437 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
42438 -- Prior Entry. Currently, the following code is always generated.
42439 ------------------------------------------------------------------------------------------------
42440 XLA_AE_LINES_PKG.ValidateCurrentLine;
42441
42442 ------------------------------------------------------------------------------------
42443 -- 4219869 Business Flow
42444 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
42445 ------------------------------------------------------------------------------------
42446 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42447
42448 ----------------------------------------------------------------------------------
42449 -- 4219869 Business Flow
42450 -- Update journal entry status -- Need to generate this within IF <condition>
42451 ----------------------------------------------------------------------------------
42452 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42453 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
42454 ,p_balance_type_code => l_balance_type_code
42455 );
42456
42457 -------------------------------------------------------------------------------------------
42458 -- 4262811 - Generate the Accrual Reversal lines
42459 -------------------------------------------------------------------------------------------
42460 BEGIN
42461 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
42462 (g_array_event(p_event_id).array_value_num('header_index'));
42463 IF l_acc_rev_flag IS NULL THEN
42464 l_acc_rev_flag := 'N';
42465 END IF;
42466 EXCEPTION
42467 WHEN OTHERS THEN
42468 l_acc_rev_flag := 'N';
42469 END;
42470 --
42471 IF (l_acc_rev_flag = 'Y') THEN
42472
42473 -- 4645092 ------------------------------------------------------------------------------
42474 -- To allow MPA report to determine if it should generate report process
42475 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
42476 ------------------------------------------------------------------------------------------
42477
42478 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
42479 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
42480 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
42481 -- call ADRs
42482 -- Bug 4922099
42483 --
42484 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42485 (NVL(l_actual_upg_option, 'N') = 'O') OR
42486 (NVL(l_enc_upg_option, 'N') = 'O')
42487 )
42488 THEN
42489 NULL;
42490 --
42491 --
42492
42493 l_ccid := AcctDerRule_11(
42494 p_application_id => p_application_id
42495 , p_ae_header_id => l_ae_header_id
42496 , p_source_10 => p_source_10
42497 , x_transaction_coa_id => l_adr_transaction_coa_id
42498 , x_accounting_coa_id => l_adr_accounting_coa_id
42499 , x_value_type_code => l_adr_value_type_code
42500 , p_side => 'NA'
42501 );
42502
42503 xla_ae_lines_pkg.set_ccid(
42504 p_code_combination_id => l_ccid
42505 , p_value_type_code => l_adr_value_type_code
42506 , p_transaction_coa_id => l_adr_transaction_coa_id
42507 , p_accounting_coa_id => l_adr_accounting_coa_id
42508 , p_adr_code => 'DIST_CCID'
42509 , p_adr_type_code => 'S'
42510 , p_component_type => l_component_type
42511 , p_component_code => l_component_code
42512 , p_component_type_code => l_component_type_code
42513 , p_component_appl_id => l_component_appl_id
42514 , p_amb_context_code => l_amb_context_code
42515 , p_side => 'NA'
42516 );
42517
42518
42519 --
42520 --
42521 END IF;
42522
42523 --
42524 -- Update the line information that should be overwritten
42525 --
42526 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
42527 p_header_num => 1);
42528 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
42529
42530 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
42531
42532 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
42533 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
42534 END IF;
42535
42536 --
42537 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
42538 --
42539 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
42543 -- 4262811a Switch Sign
42540 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
42541 ELSE
42542 ---------------------------------------------------------------------------------------------------
42544 ---------------------------------------------------------------------------------------------------
42545 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
42546 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42547 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42548 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42549 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42550 -- 5132302
42551 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
42552 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42553
42554 END IF;
42555
42556 -- 4955764
42557 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42558 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
42559
42560
42561 XLA_AE_LINES_PKG.ValidateCurrentLine;
42562 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42563
42564 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42565 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
42566 ,p_balance_type_code => l_balance_type_code);
42567
42568 END IF;
42569
42570 -----------------------------------------------------------------------------------------
42571 -- 4262811 Multiperiod Accounting
42572 -----------------------------------------------------------------------------------------
42573 -- No MPA option is assigned.
42574
42575
42576 END IF;
42577 END IF;
42578 --
42579
42580 --
42581 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42582 trace
42583 (p_msg => 'END of AcctLineType_86'
42584 ,p_level => C_LEVEL_PROCEDURE
42585 ,p_module => l_log_module);
42586 END IF;
42587 --
42588 EXCEPTION
42589 WHEN xla_exceptions_pkg.application_exception THEN
42590 RAISE;
42591 WHEN OTHERS THEN
42592 xla_exceptions_pkg.raise_message
42593 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_86');
42594 END AcctLineType_86;
42595 --
42596
42597 ---------------------------------------
42598 --
42599 -- PRIVATE FUNCTION
42600 -- AcctLineType_87
42601 --
42602 ---------------------------------------
42603 PROCEDURE AcctLineType_87 (
42604 p_application_id IN NUMBER
42605 ,p_event_id IN NUMBER
42606 ,p_calculate_acctd_flag IN VARCHAR2
42607 ,p_calculate_g_l_flag IN VARCHAR2
42608 ,p_actual_flag IN OUT VARCHAR2
42609 ,p_balance_type_code OUT VARCHAR2
42610 ,p_gain_or_loss_ref OUT VARCHAR2
42611
42612 --Remittance Bank Account Earned Account
42613 , p_source_4 IN NUMBER
42614 --Transaction Distribution GL Account
42615 , p_source_14 IN NUMBER
42616 --Distribution Source Type
42617 , p_source_15 IN VARCHAR2
42618 --Distribution Line Identifier
42619 , p_source_17 IN NUMBER
42620 --Distribution Type
42621 , p_source_18 IN VARCHAR2
42622 --Entered Amount
42623 , p_source_19 IN NUMBER
42624 --Currency Code
42625 , p_source_20 IN VARCHAR2
42626 --Applied To Document Accounting Amount
42627 , p_source_24 IN NUMBER
42628 --Transaction Distribution Identifier
42629 , p_source_29 IN NUMBER
42630 --Transaction Distribution Type
42631 , p_source_30 IN VARCHAR2
42632 --Distribution Multi Fund Additional Entry
42633 , p_source_54 IN VARCHAR2
42634 --Applied To Document Exchange Date
42635 , p_source_55 IN DATE
42636 --Receipt Applied To Application Identifier
42637 , p_source_58 IN NUMBER
42638 --Transaction Entity Code
42639 , p_source_59 IN VARCHAR2
42640 --Transaction Identifier
42641 , p_source_60 IN NUMBER
42642 --Distribution Party Identifier
42643 , p_source_64 IN NUMBER
42644 --Distribution Party Site Id
42645 , p_source_65 IN NUMBER
42646 --Distribution Party Type
42647 , p_source_66 IN VARCHAR2
42648 --Applied To Document Exchange Rate Type
42649 , p_source_67 IN VARCHAR2
42650 --Applied To Document Exchange Rate
42651 , p_source_68 IN NUMBER
42652 )
42653 IS
42654
42655 l_component_type VARCHAR2(80);
42656 l_component_code VARCHAR2(30);
42657 l_component_type_code VARCHAR2(1);
42658 l_component_appl_id INTEGER;
42659 l_amb_context_code VARCHAR2(30);
42660 l_entity_code VARCHAR2(30);
42661 l_event_class_code VARCHAR2(30);
42662 l_ae_header_id NUMBER;
42663 l_event_type_code VARCHAR2(30);
42664 l_line_definition_code VARCHAR2(30);
42665 l_line_definition_owner_code VARCHAR2(1);
42666 --
42667 -- adr variables
42668 l_segment VARCHAR2(30);
42669 l_ccid NUMBER;
42670 l_adr_transaction_coa_id NUMBER;
42674 l_adr_value_type_code VARCHAR2(30);
42671 l_adr_accounting_coa_id NUMBER;
42672 l_adr_flexfield_segment_code VARCHAR2(30);
42673 l_adr_flex_value_set_id NUMBER;
42675 l_adr_value_combination_id NUMBER;
42676 l_adr_value_segment_code VARCHAR2(30);
42677
42678 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
42679 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
42680 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
42681 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
42682
42683 -- 4262811 Variables ------------------------------------------------------------------------------------------
42684 l_entered_amt_idx NUMBER;
42685 l_accted_amt_idx NUMBER;
42686 l_acc_rev_flag VARCHAR2(1);
42687 l_accrual_line_num NUMBER;
42688 l_tmp_amt NUMBER;
42689 l_acc_rev_natural_side_code VARCHAR2(1);
42690
42691 l_num_entries NUMBER;
42692 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
42693 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
42694 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
42695 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
42696 l_recog_line_1 NUMBER;
42697 l_recog_line_2 NUMBER;
42698
42699 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
42700 l_bflow_applied_to_amt NUMBER; -- 5132302
42701 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
42702
42703 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
42704
42705 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
42706 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
42707
42708 ---------------------------------------------------------------------------------------------------------------
42709
42710
42711 --
42712 -- bulk performance
42713 --
42714 l_balance_type_code VARCHAR2(1);
42715 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
42716 l_log_module VARCHAR2(240);
42717
42718 --
42719 -- Upgrade strategy
42720 --
42721 l_actual_upg_option VARCHAR2(1);
42722 l_enc_upg_option VARCHAR2(1);
42723
42724 --
42725 BEGIN
42726 --
42727 IF g_log_enabled THEN
42728 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_87';
42729 END IF;
42730 --
42731 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42732
42733 trace
42734 (p_msg => 'BEGIN of AcctLineType_87'
42735 ,p_level => C_LEVEL_PROCEDURE
42736 ,p_module => l_log_module);
42737
42738 END IF;
42739 --
42740 l_component_type := 'AMB_JLT';
42741 l_component_code := 'RCT_EDISC';
42742 l_component_type_code := 'S';
42743 l_component_appl_id := 222;
42744 l_amb_context_code := 'DEFAULT';
42745 l_entity_code := 'RECEIPTS';
42746 l_event_class_code := 'RECEIPT';
42747 l_event_type_code := 'RECEIPT_ALL';
42748 l_line_definition_owner_code := 'S';
42749 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
42750 --
42751 l_balance_type_code := 'A';
42752 l_segment := NULL;
42753 l_ccid := NULL;
42754 l_adr_transaction_coa_id := NULL;
42755 l_adr_accounting_coa_id := NULL;
42756 l_adr_flexfield_segment_code := NULL;
42757 l_adr_flex_value_set_id := NULL;
42758 l_adr_value_type_code := NULL;
42759 l_adr_value_combination_id := NULL;
42760 l_adr_value_segment_code := NULL;
42761
42762 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
42763 l_bflow_class_code := ''; -- 4219869 Business Flow
42764 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
42765 l_budgetary_control_flag := 'N';
42766
42767 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42768 l_bflow_applied_to_amt := NULL; -- 5132302
42769 l_entered_amt_idx := NULL; -- 4262811
42770 l_accted_amt_idx := NULL; -- 4262811
42771 l_acc_rev_flag := NULL; -- 4262811
42772 l_accrual_line_num := NULL; -- 4262811
42773 l_tmp_amt := NULL; -- 4262811
42774 --
42775
42776 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
42777 l_balance_type_code <> 'B' THEN
42778 IF NVL(p_source_15,'
42779 ') = 'EDISC' AND
42780 NVL(p_source_54,'
42781 ') = 'N'
42782 THEN
42783
42784 --
42785 XLA_AE_LINES_PKG.SetNewLine;
42786
42787 p_balance_type_code := l_balance_type_code;
42788 -- set the flag so later we will know whether the gain loss line needs to be created
42789
42790 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
42791 p_actual_flag :='A';
42792 END IF;
42793
42794 --
42795 -- bulk performance
42796 --
42797 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
42798 p_header_num => 0); -- 4262811
42799 --
42800 -- set accounting line options
42801 --
42802 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
42803 p_natural_side_code => 'C'
42804 , p_gain_or_loss_flag => 'N'
42805 , p_gl_transfer_mode_code => 'S'
42806 , p_acct_entry_type_code => 'A'
42810 --
42807 , p_switch_side_flag => 'Y'
42808 , p_merge_duplicate_code => 'A'
42809 );
42811 l_acc_rev_natural_side_code := 'D'; -- 4262811
42812 --
42813 --
42814 -- set accounting line type info
42815 --
42816 xla_ae_lines_pkg.SetAcctLineType
42817 (p_component_type => l_component_type
42818 ,p_event_type_code => l_event_type_code
42819 ,p_line_definition_owner_code => l_line_definition_owner_code
42820 ,p_line_definition_code => l_line_definition_code
42821 ,p_accounting_line_code => l_component_code
42822 ,p_accounting_line_type_code => l_component_type_code
42823 ,p_accounting_line_appl_id => l_component_appl_id
42824 ,p_amb_context_code => l_amb_context_code
42825 ,p_entity_code => l_entity_code
42826 ,p_event_class_code => l_event_class_code);
42827 --
42828 -- set accounting class
42829 --
42830 xla_ae_lines_pkg.SetAcctClass(
42831 p_accounting_class_code => 'EDISC'
42832 , p_ae_header_id => l_ae_header_id
42833 );
42834
42835 --
42836 -- set rounding class
42837 --
42838 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
42839 'RECEIVABLE';
42840
42841 --
42842 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
42843 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
42844 --
42845 -- bulk performance
42846 --
42847 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
42848
42849 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
42850 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
42851
42852 -- 4955764
42853 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42854 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
42855
42856 -- 4458381 Public Sector Enh
42857
42858 --
42859 -- set accounting attributes for the line type
42860 --
42861 l_entered_amt_idx := 8;
42862 l_accted_amt_idx := 13;
42863 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42864 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
42865 l_rec_acct_attrs.array_num_value(1) := p_source_58;
42866 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
42867 l_rec_acct_attrs.array_char_value(2) := p_source_30;
42868 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
42869 l_rec_acct_attrs.array_char_value(3) := p_source_59;
42870 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
42871 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
42872 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
42873 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
42874 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
42875 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
42876 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
42877 l_rec_acct_attrs.array_char_value(7) := p_source_18;
42878 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
42879 l_rec_acct_attrs.array_num_value(8) := p_source_19;
42880 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
42881 l_rec_acct_attrs.array_char_value(9) := p_source_20;
42882 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
42883 l_rec_acct_attrs.array_date_value(10) := p_source_55;
42884 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
42885 l_rec_acct_attrs.array_num_value(11) := p_source_68;
42886 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
42887 l_rec_acct_attrs.array_char_value(12) := p_source_67;
42888 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
42889 l_rec_acct_attrs.array_num_value(13) := p_source_24;
42890 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
42891 l_rec_acct_attrs.array_num_value(14) := p_source_64;
42892 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
42893 l_rec_acct_attrs.array_num_value(15) := p_source_65;
42894 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
42895 l_rec_acct_attrs.array_char_value(16) := p_source_66;
42896
42897 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
42898 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
42899
42900 ---------------------------------------------------------------------------------------------------------------
42901 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
42902 ---------------------------------------------------------------------------------------------------------------
42903 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
42904
42905 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42906 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42907
42908 IF xla_accounting_cache_pkg.GetValueChar
42909 (p_source_code => 'LEDGER_CATEGORY_CODE'
42913 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
42910 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
42911 AND l_bflow_method_code = 'PRIOR_ENTRY'
42912 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
42914 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
42915 )
42916 THEN
42917 xla_ae_lines_pkg.BflowUpgEntry
42918 (p_business_method_code => l_bflow_method_code
42919 ,p_business_class_code => l_bflow_class_code
42920 ,p_balance_type => l_balance_type_code);
42921 ELSE
42922 NULL;
42923 -- No business flow processing for business flow method of NONE.
42924 END IF;
42925
42926 --
42927 -- call analytical criteria
42928 --
42929
42930 --
42931 -- call description
42932 --
42933
42934 xla_ae_lines_pkg.SetLineDescription(
42935 p_ae_header_id => l_ae_header_id
42936 ,p_description => Description_1 (
42937 p_application_id => p_application_id
42938 , p_ae_header_id => l_ae_header_id
42939 )
42940 );
42941
42942
42943 --
42944 -- call ADRs
42945 -- Bug 4922099
42946 --
42947 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42948 (NVL(l_actual_upg_option, 'N') = 'O') OR
42949 (NVL(l_enc_upg_option, 'N') = 'O')
42950 )
42951 THEN
42952 NULL;
42953 --
42954 --
42955
42956 l_ccid := AcctDerRule_18(
42957 p_application_id => p_application_id
42958 , p_ae_header_id => l_ae_header_id
42959 , p_source_14 => p_source_14
42960 , x_transaction_coa_id => l_adr_transaction_coa_id
42961 , x_accounting_coa_id => l_adr_accounting_coa_id
42962 , x_value_type_code => l_adr_value_type_code
42963 , p_side => 'NA'
42964 );
42965
42966 xla_ae_lines_pkg.set_ccid(
42967 p_code_combination_id => l_ccid
42968 , p_value_type_code => l_adr_value_type_code
42969 , p_transaction_coa_id => l_adr_transaction_coa_id
42970 , p_accounting_coa_id => l_adr_accounting_coa_id
42971 , p_adr_code => 'TRX_DIST_CCID'
42972 , p_adr_type_code => 'S'
42973 , p_component_type => l_component_type
42974 , p_component_code => l_component_code
42975 , p_component_type_code => l_component_type_code
42976 , p_component_appl_id => l_component_appl_id
42977 , p_amb_context_code => l_amb_context_code
42978 , p_side => 'NA'
42979 );
42980
42981
42982 l_segment := AcctDerRule_5(
42983 p_application_id => p_application_id
42984 , p_ae_header_id => l_ae_header_id
42985 , p_source_4 => p_source_4
42986 , x_transaction_coa_id => l_adr_transaction_coa_id
42987 , x_accounting_coa_id => l_adr_accounting_coa_id
42988 , x_flexfield_segment_code => l_adr_flexfield_segment_code
42989 , x_flex_value_set_id => l_adr_flex_value_set_id
42990 , x_value_type_code => l_adr_value_type_code
42991 , x_value_combination_id => l_adr_value_combination_id
42992 , x_value_segment_code => l_adr_value_segment_code
42993 , p_side => 'NA'
42994 , p_override_seg_flag => 'Y'
42995 );
42996
42997 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
42998
42999 xla_ae_lines_pkg.set_segment(
43000 p_to_segment_code => 'GL_ACCOUNT'
43001 , p_segment_value => l_segment
43002 , p_from_segment_code => l_adr_value_segment_code
43003 , p_from_combination_id => l_adr_value_combination_id
43004 , p_value_type_code => l_adr_value_type_code
43005 , p_transaction_coa_id => l_adr_transaction_coa_id
43006 , p_accounting_coa_id => l_adr_accounting_coa_id
43007 , p_flexfield_segment_code => l_adr_flexfield_segment_code
43008 , p_flex_value_set_id => l_adr_flex_value_set_id
43009 , p_adr_code => 'MFAR_RCT_EARNED_NATURAL_SEG'
43010 , p_adr_type_code => 'S'
43011 , p_component_type => l_component_type
43012 , p_component_code => l_component_code
43013 , p_component_type_code => l_component_type_code
43014 , p_component_appl_id => l_component_appl_id
43015 , p_amb_context_code => l_amb_context_code
43016 , p_entity_code => 'RECEIPTS'
43017 , p_event_class_code => 'RECEIPT'
43018 , p_side => 'NA'
43019 );
43020
43021 END IF;
43022
43023 --
43024 --
43025 END IF;
43026 --
43027 -- Bug 4922099
43028 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
43029 (NVL(l_enc_upg_option, 'N') = 'O')
43030 ) AND
43031 (l_bflow_method_code = 'PRIOR_ENTRY')
43032 )
43033 THEN
43034 IF
43035 --
43036 1 = 2
43037 --
43038 THEN
43039 xla_accounting_err_pkg.build_message
43040 (p_appli_s_name => 'XLA'
43041 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43042 ,p_token_1 => 'LINE_NUMBER'
43043 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
43047 ,l_component_code
43044 ,p_token_2 => 'LINE_TYPE_NAME'
43045 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
43046 l_component_type
43048 ,l_component_type_code
43049 ,l_component_appl_id
43050 ,l_amb_context_code
43051 ,l_entity_code
43052 ,l_event_class_code
43053 )
43054 ,p_token_3 => 'OWNER'
43055 ,p_value_3 => xla_lookups_pkg.get_meaning(
43056 p_lookup_type => 'XLA_OWNER_TYPE'
43057 ,p_lookup_code => l_component_type_code
43058 )
43059 ,p_token_4 => 'PRODUCT_NAME'
43060 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
43061 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
43062 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
43063 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
43064 ,p_ae_header_id => NULL
43065 );
43066
43067 IF (C_LEVEL_ERROR>= g_log_level) THEN
43068 trace
43069 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43070 ,p_level => C_LEVEL_ERROR
43071 ,p_module => l_log_module);
43072 END IF;
43073 END IF;
43074 END IF;
43075 --
43076 --
43077 ------------------------------------------------------------------------------------------------
43078 -- 4219869 Business Flow
43079 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
43080 -- Prior Entry. Currently, the following code is always generated.
43081 ------------------------------------------------------------------------------------------------
43082 XLA_AE_LINES_PKG.ValidateCurrentLine;
43083
43084 ------------------------------------------------------------------------------------
43085 -- 4219869 Business Flow
43086 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
43087 ------------------------------------------------------------------------------------
43088 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43089
43090 ----------------------------------------------------------------------------------
43091 -- 4219869 Business Flow
43092 -- Update journal entry status -- Need to generate this within IF <condition>
43093 ----------------------------------------------------------------------------------
43094 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43095 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
43096 ,p_balance_type_code => l_balance_type_code
43097 );
43098
43099 -------------------------------------------------------------------------------------------
43100 -- 4262811 - Generate the Accrual Reversal lines
43101 -------------------------------------------------------------------------------------------
43102 BEGIN
43103 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
43104 (g_array_event(p_event_id).array_value_num('header_index'));
43105 IF l_acc_rev_flag IS NULL THEN
43106 l_acc_rev_flag := 'N';
43107 END IF;
43108 EXCEPTION
43109 WHEN OTHERS THEN
43110 l_acc_rev_flag := 'N';
43111 END;
43112 --
43113 IF (l_acc_rev_flag = 'Y') THEN
43114
43115 -- 4645092 ------------------------------------------------------------------------------
43116 -- To allow MPA report to determine if it should generate report process
43117 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
43118 ------------------------------------------------------------------------------------------
43119
43120 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
43121 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
43122 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
43123 -- call ADRs
43124 -- Bug 4922099
43125 --
43126 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43127 (NVL(l_actual_upg_option, 'N') = 'O') OR
43128 (NVL(l_enc_upg_option, 'N') = 'O')
43129 )
43130 THEN
43131 NULL;
43132 --
43133 --
43134
43135 l_ccid := AcctDerRule_18(
43136 p_application_id => p_application_id
43137 , p_ae_header_id => l_ae_header_id
43138 , p_source_14 => p_source_14
43139 , x_transaction_coa_id => l_adr_transaction_coa_id
43140 , x_accounting_coa_id => l_adr_accounting_coa_id
43141 , x_value_type_code => l_adr_value_type_code
43142 , p_side => 'NA'
43143 );
43144
43148 , p_transaction_coa_id => l_adr_transaction_coa_id
43145 xla_ae_lines_pkg.set_ccid(
43146 p_code_combination_id => l_ccid
43147 , p_value_type_code => l_adr_value_type_code
43149 , p_accounting_coa_id => l_adr_accounting_coa_id
43150 , p_adr_code => 'TRX_DIST_CCID'
43151 , p_adr_type_code => 'S'
43152 , p_component_type => l_component_type
43153 , p_component_code => l_component_code
43154 , p_component_type_code => l_component_type_code
43155 , p_component_appl_id => l_component_appl_id
43156 , p_amb_context_code => l_amb_context_code
43157 , p_side => 'NA'
43158 );
43159
43160
43161 l_segment := AcctDerRule_5(
43162 p_application_id => p_application_id
43163 , p_ae_header_id => l_ae_header_id
43164 , p_source_4 => p_source_4
43165 , x_transaction_coa_id => l_adr_transaction_coa_id
43166 , x_accounting_coa_id => l_adr_accounting_coa_id
43167 , x_flexfield_segment_code => l_adr_flexfield_segment_code
43168 , x_flex_value_set_id => l_adr_flex_value_set_id
43169 , x_value_type_code => l_adr_value_type_code
43170 , x_value_combination_id => l_adr_value_combination_id
43171 , x_value_segment_code => l_adr_value_segment_code
43172 , p_side => 'NA'
43173 , p_override_seg_flag => 'Y'
43174 );
43175
43176 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
43177
43178 xla_ae_lines_pkg.set_segment(
43179 p_to_segment_code => 'GL_ACCOUNT'
43180 , p_segment_value => l_segment
43181 , p_from_segment_code => l_adr_value_segment_code
43182 , p_from_combination_id => l_adr_value_combination_id
43183 , p_value_type_code => l_adr_value_type_code
43184 , p_transaction_coa_id => l_adr_transaction_coa_id
43185 , p_accounting_coa_id => l_adr_accounting_coa_id
43186 , p_flexfield_segment_code => l_adr_flexfield_segment_code
43187 , p_flex_value_set_id => l_adr_flex_value_set_id
43188 , p_adr_code => 'MFAR_RCT_EARNED_NATURAL_SEG'
43189 , p_adr_type_code => 'S'
43190 , p_component_type => l_component_type
43191 , p_component_code => l_component_code
43192 , p_component_type_code => l_component_type_code
43193 , p_component_appl_id => l_component_appl_id
43194 , p_amb_context_code => l_amb_context_code
43195 , p_entity_code => 'RECEIPTS'
43196 , p_event_class_code => 'RECEIPT'
43197 , p_side => 'NA'
43198 );
43199
43200 END IF;
43201
43202 --
43203 --
43204 END IF;
43205
43206 --
43207 -- Update the line information that should be overwritten
43208 --
43209 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
43210 p_header_num => 1);
43211 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
43212
43213 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
43214
43215 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
43216 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
43217 END IF;
43218
43219 --
43220 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
43221 --
43222 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
43223 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
43224 ELSE
43225 ---------------------------------------------------------------------------------------------------
43226 -- 4262811a Switch Sign
43227 ---------------------------------------------------------------------------------------------------
43228 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
43229 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43230 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43231 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43232 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43233 -- 5132302
43234 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
43235 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43236
43237 END IF;
43238
43239 -- 4955764
43240 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43241 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
43242
43243
43244 XLA_AE_LINES_PKG.ValidateCurrentLine;
43245 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43246
43247 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43248 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
43249 ,p_balance_type_code => l_balance_type_code);
43250
43251 END IF;
43252
43253 -----------------------------------------------------------------------------------------
43254 -- 4262811 Multiperiod Accounting
43258
43255 -----------------------------------------------------------------------------------------
43256 -- No MPA option is assigned.
43257
43259 END IF;
43260 END IF;
43261 --
43262
43263 --
43264 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43265 trace
43266 (p_msg => 'END of AcctLineType_87'
43267 ,p_level => C_LEVEL_PROCEDURE
43268 ,p_module => l_log_module);
43269 END IF;
43270 --
43271 EXCEPTION
43272 WHEN xla_exceptions_pkg.application_exception THEN
43273 RAISE;
43274 WHEN OTHERS THEN
43275 xla_exceptions_pkg.raise_message
43276 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_87');
43277 END AcctLineType_87;
43278 --
43279
43280 ---------------------------------------
43281 --
43282 -- PRIVATE FUNCTION
43283 -- AcctLineType_88
43284 --
43285 ---------------------------------------
43286 PROCEDURE AcctLineType_88 (
43287 p_application_id IN NUMBER
43288 ,p_event_id IN NUMBER
43289 ,p_calculate_acctd_flag IN VARCHAR2
43290 ,p_calculate_g_l_flag IN VARCHAR2
43291 ,p_actual_flag IN OUT VARCHAR2
43292 ,p_balance_type_code OUT VARCHAR2
43293 ,p_gain_or_loss_ref OUT VARCHAR2
43294
43295 --Distribution GL Account
43296 , p_source_10 IN NUMBER
43297 --Distribution Source Type
43298 , p_source_15 IN VARCHAR2
43299 --Distribution Line Identifier
43300 , p_source_17 IN NUMBER
43301 --Distribution Type
43302 , p_source_18 IN VARCHAR2
43303 --Entered Amount
43304 , p_source_19 IN NUMBER
43305 --Exchange Date
43306 , p_source_21 IN DATE
43307 --Exchange Rate
43308 , p_source_22 IN NUMBER
43309 --Exchange Rate Type
43310 , p_source_23 IN VARCHAR2
43311 --Applied To Document Accounting Amount
43312 , p_source_24 IN NUMBER
43313 --Transaction Distribution Identifier
43314 , p_source_29 IN NUMBER
43315 --Transaction Distribution Type
43316 , p_source_30 IN VARCHAR2
43317 --Receipt Applied To Application Identifier
43318 , p_source_58 IN NUMBER
43319 --Transaction Entity Code
43320 , p_source_59 IN VARCHAR2
43321 --Transaction Identifier
43322 , p_source_60 IN NUMBER
43323 --Applying Document Currency Code
43324 , p_source_62 IN VARCHAR2
43325 --Distribution Party Identifier
43326 , p_source_64 IN NUMBER
43327 --Distribution Party Site Id
43328 , p_source_65 IN NUMBER
43329 --Distribution Party Type
43330 , p_source_66 IN VARCHAR2
43331 )
43332 IS
43333
43334 l_component_type VARCHAR2(80);
43335 l_component_code VARCHAR2(30);
43336 l_component_type_code VARCHAR2(1);
43337 l_component_appl_id INTEGER;
43338 l_amb_context_code VARCHAR2(30);
43339 l_entity_code VARCHAR2(30);
43340 l_event_class_code VARCHAR2(30);
43341 l_ae_header_id NUMBER;
43342 l_event_type_code VARCHAR2(30);
43343 l_line_definition_code VARCHAR2(30);
43344 l_line_definition_owner_code VARCHAR2(1);
43345 --
43346 -- adr variables
43347 l_segment VARCHAR2(30);
43348 l_ccid NUMBER;
43349 l_adr_transaction_coa_id NUMBER;
43350 l_adr_accounting_coa_id NUMBER;
43351 l_adr_flexfield_segment_code VARCHAR2(30);
43352 l_adr_flex_value_set_id NUMBER;
43353 l_adr_value_type_code VARCHAR2(30);
43354 l_adr_value_combination_id NUMBER;
43355 l_adr_value_segment_code VARCHAR2(30);
43356
43357 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
43358 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
43359 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
43360 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
43361
43362 -- 4262811 Variables ------------------------------------------------------------------------------------------
43363 l_entered_amt_idx NUMBER;
43364 l_accted_amt_idx NUMBER;
43365 l_acc_rev_flag VARCHAR2(1);
43366 l_accrual_line_num NUMBER;
43367 l_tmp_amt NUMBER;
43368 l_acc_rev_natural_side_code VARCHAR2(1);
43369
43370 l_num_entries NUMBER;
43371 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
43372 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
43373 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
43374 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
43375 l_recog_line_1 NUMBER;
43376 l_recog_line_2 NUMBER;
43377
43378 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
43379 l_bflow_applied_to_amt NUMBER; -- 5132302
43380 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
43381
43382 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
43383
43384 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
43385 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
43386
43387 ---------------------------------------------------------------------------------------------------------------
43388
43389
43390 --
43391 -- bulk performance
43392 --
43396
43393 l_balance_type_code VARCHAR2(1);
43394 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
43395 l_log_module VARCHAR2(240);
43397 --
43398 -- Upgrade strategy
43399 --
43400 l_actual_upg_option VARCHAR2(1);
43401 l_enc_upg_option VARCHAR2(1);
43402
43403 --
43404 BEGIN
43405 --
43406 IF g_log_enabled THEN
43407 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_88';
43408 END IF;
43409 --
43410 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43411
43412 trace
43413 (p_msg => 'BEGIN of AcctLineType_88'
43414 ,p_level => C_LEVEL_PROCEDURE
43415 ,p_module => l_log_module);
43416
43417 END IF;
43418 --
43419 l_component_type := 'AMB_JLT';
43420 l_component_code := 'RCT_EXCH_GAIN';
43421 l_component_type_code := 'S';
43422 l_component_appl_id := 222;
43423 l_amb_context_code := 'DEFAULT';
43424 l_entity_code := 'RECEIPTS';
43425 l_event_class_code := 'RECEIPT';
43426 l_event_type_code := 'RECEIPT_ALL';
43427 l_line_definition_owner_code := 'S';
43428 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
43429 --
43430 l_balance_type_code := 'A';
43431 l_segment := NULL;
43432 l_ccid := NULL;
43433 l_adr_transaction_coa_id := NULL;
43434 l_adr_accounting_coa_id := NULL;
43435 l_adr_flexfield_segment_code := NULL;
43436 l_adr_flex_value_set_id := NULL;
43437 l_adr_value_type_code := NULL;
43438 l_adr_value_combination_id := NULL;
43439 l_adr_value_segment_code := NULL;
43440
43441 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
43442 l_bflow_class_code := ''; -- 4219869 Business Flow
43443 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
43444 l_budgetary_control_flag := 'N';
43445
43446 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43447 l_bflow_applied_to_amt := NULL; -- 5132302
43448 l_entered_amt_idx := NULL; -- 4262811
43449 l_accted_amt_idx := NULL; -- 4262811
43450 l_acc_rev_flag := NULL; -- 4262811
43451 l_accrual_line_num := NULL; -- 4262811
43452 l_tmp_amt := NULL; -- 4262811
43453 --
43454 IF ((p_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
43455 (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
43456 return;
43457 END IF;
43458
43459 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
43460 l_balance_type_code <> 'B' THEN
43461 IF NVL(p_source_15,'
43462 ') = 'EXCH_GAIN'
43463 THEN
43464
43465 --
43466 XLA_AE_LINES_PKG.SetNewLine;
43467
43468 p_balance_type_code := l_balance_type_code;
43469 -- set the flag so later we will know whether the gain loss line needs to be created
43470
43471 IF(l_balance_type_code = 'A' ) THEN
43472 p_actual_flag :='G';
43473 END IF;
43474
43475 --
43476 -- bulk performance
43477 --
43478 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
43479 p_header_num => 0); -- 4262811
43480 --
43481 -- set accounting line options
43482 --
43483 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
43484 p_natural_side_code => 'C'
43485 , p_gain_or_loss_flag => 'Y'
43486 , p_gl_transfer_mode_code => 'S'
43487 , p_acct_entry_type_code => 'A'
43488 , p_switch_side_flag => 'Y'
43489 , p_merge_duplicate_code => 'A'
43490 );
43491 --
43492 l_acc_rev_natural_side_code := 'D'; -- 4262811
43493 --
43494 --
43495 -- set accounting line type info
43496 --
43497 xla_ae_lines_pkg.SetAcctLineType
43498 (p_component_type => l_component_type
43499 ,p_event_type_code => l_event_type_code
43500 ,p_line_definition_owner_code => l_line_definition_owner_code
43501 ,p_line_definition_code => l_line_definition_code
43502 ,p_accounting_line_code => l_component_code
43503 ,p_accounting_line_type_code => l_component_type_code
43504 ,p_accounting_line_appl_id => l_component_appl_id
43505 ,p_amb_context_code => l_amb_context_code
43506 ,p_entity_code => l_entity_code
43507 ,p_event_class_code => l_event_class_code);
43508 --
43509 -- set accounting class
43510 --
43511 xla_ae_lines_pkg.SetAcctClass(
43512 p_accounting_class_code => 'GAIN'
43513 , p_ae_header_id => l_ae_header_id
43514 );
43515
43516 --
43517 -- set rounding class
43518 --
43519 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
43520 'RECEIVABLE';
43521
43522 --
43523 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
43524 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
43525 --
43526 -- bulk performance
43527 --
43531 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
43528 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
43529
43530 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
43532
43533 -- 4955764
43534 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43535 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
43536
43537 -- 4458381 Public Sector Enh
43538
43539 --
43540 -- set accounting attributes for the line type
43541 --
43542 l_entered_amt_idx := 8;
43543 l_accted_amt_idx := 13;
43544 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43545 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
43546 l_rec_acct_attrs.array_num_value(1) := p_source_58;
43547 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
43548 l_rec_acct_attrs.array_char_value(2) := p_source_30;
43549 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
43550 l_rec_acct_attrs.array_char_value(3) := p_source_59;
43551 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
43552 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
43553 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
43554 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
43555 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
43556 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
43557 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
43558 l_rec_acct_attrs.array_char_value(7) := p_source_18;
43559 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
43560 l_rec_acct_attrs.array_num_value(8) := p_source_19;
43561 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
43562 l_rec_acct_attrs.array_char_value(9) := p_source_62;
43563 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
43564 l_rec_acct_attrs.array_date_value(10) := p_source_21;
43565 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
43566 l_rec_acct_attrs.array_num_value(11) := p_source_22;
43567 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
43568 l_rec_acct_attrs.array_char_value(12) := p_source_23;
43569 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
43570 l_rec_acct_attrs.array_num_value(13) := p_source_24;
43571 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
43572 l_rec_acct_attrs.array_num_value(14) := p_source_64;
43573 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
43574 l_rec_acct_attrs.array_num_value(15) := p_source_65;
43575 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
43576 l_rec_acct_attrs.array_char_value(16) := p_source_66;
43577
43578 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
43579 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
43580
43581 ---------------------------------------------------------------------------------------------------------------
43582 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
43583 ---------------------------------------------------------------------------------------------------------------
43584 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
43585
43586 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43587 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43588
43589 IF xla_accounting_cache_pkg.GetValueChar
43590 (p_source_code => 'LEDGER_CATEGORY_CODE'
43591 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
43592 AND l_bflow_method_code = 'PRIOR_ENTRY'
43593 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
43594 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
43595 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
43596 )
43597 THEN
43598 xla_ae_lines_pkg.BflowUpgEntry
43599 (p_business_method_code => l_bflow_method_code
43600 ,p_business_class_code => l_bflow_class_code
43601 ,p_balance_type => l_balance_type_code);
43602 ELSE
43603 NULL;
43604 -- No business flow processing for business flow method of NONE.
43605 END IF;
43606
43607 --
43608 -- call analytical criteria
43609 --
43610
43611 --
43612 -- call description
43613 --
43614 -- No description or it is inherited.
43615 --
43616 -- call ADRs
43617 -- Bug 4922099
43618 --
43619 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43620 (NVL(l_actual_upg_option, 'N') = 'O') OR
43621 (NVL(l_enc_upg_option, 'N') = 'O')
43622 )
43623 THEN
43624 NULL;
43625 --
43626 --
43627
43628 l_ccid := AcctDerRule_11(
43629 p_application_id => p_application_id
43630 , p_ae_header_id => l_ae_header_id
43631 , p_source_10 => p_source_10
43632 , x_transaction_coa_id => l_adr_transaction_coa_id
43633 , x_accounting_coa_id => l_adr_accounting_coa_id
43634 , x_value_type_code => l_adr_value_type_code
43635 , p_side => 'NA'
43636 );
43637
43641 , p_transaction_coa_id => l_adr_transaction_coa_id
43638 xla_ae_lines_pkg.set_ccid(
43639 p_code_combination_id => l_ccid
43640 , p_value_type_code => l_adr_value_type_code
43642 , p_accounting_coa_id => l_adr_accounting_coa_id
43643 , p_adr_code => 'DIST_CCID'
43644 , p_adr_type_code => 'S'
43645 , p_component_type => l_component_type
43646 , p_component_code => l_component_code
43647 , p_component_type_code => l_component_type_code
43648 , p_component_appl_id => l_component_appl_id
43649 , p_amb_context_code => l_amb_context_code
43650 , p_side => 'NA'
43651 );
43652
43653
43654 --
43655 --
43656 END IF;
43657 --
43658 -- Bug 4922099
43659 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
43660 (NVL(l_enc_upg_option, 'N') = 'O')
43661 ) AND
43662 (l_bflow_method_code = 'PRIOR_ENTRY')
43663 )
43664 THEN
43665 IF
43666 --
43667 1 = 2
43668 --
43669 THEN
43670 xla_accounting_err_pkg.build_message
43671 (p_appli_s_name => 'XLA'
43672 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43673 ,p_token_1 => 'LINE_NUMBER'
43674 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
43675 ,p_token_2 => 'LINE_TYPE_NAME'
43676 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
43677 l_component_type
43678 ,l_component_code
43679 ,l_component_type_code
43680 ,l_component_appl_id
43681 ,l_amb_context_code
43682 ,l_entity_code
43683 ,l_event_class_code
43684 )
43685 ,p_token_3 => 'OWNER'
43686 ,p_value_3 => xla_lookups_pkg.get_meaning(
43687 p_lookup_type => 'XLA_OWNER_TYPE'
43688 ,p_lookup_code => l_component_type_code
43689 )
43690 ,p_token_4 => 'PRODUCT_NAME'
43691 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
43692 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
43693 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
43694 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
43695 ,p_ae_header_id => NULL
43696 );
43697
43698 IF (C_LEVEL_ERROR>= g_log_level) THEN
43699 trace
43700 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43701 ,p_level => C_LEVEL_ERROR
43702 ,p_module => l_log_module);
43703 END IF;
43704 END IF;
43705 END IF;
43706 --
43707 --
43708 ------------------------------------------------------------------------------------------------
43709 -- 4219869 Business Flow
43710 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
43711 -- Prior Entry. Currently, the following code is always generated.
43712 ------------------------------------------------------------------------------------------------
43713 XLA_AE_LINES_PKG.ValidateCurrentLine;
43714
43715 ------------------------------------------------------------------------------------
43716 -- 4219869 Business Flow
43717 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
43718 ------------------------------------------------------------------------------------
43719 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43720
43721 ----------------------------------------------------------------------------------
43722 -- 4219869 Business Flow
43723 -- Update journal entry status -- Need to generate this within IF <condition>
43724 ----------------------------------------------------------------------------------
43725 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43726 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
43727 ,p_balance_type_code => l_balance_type_code
43728 );
43729
43730 -------------------------------------------------------------------------------------------
43731 -- 4262811 - Generate the Accrual Reversal lines
43732 -------------------------------------------------------------------------------------------
43733 BEGIN
43734 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
43735 (g_array_event(p_event_id).array_value_num('header_index'));
43736 IF l_acc_rev_flag IS NULL THEN
43737 l_acc_rev_flag := 'N';
43738 END IF;
43742 END;
43739 EXCEPTION
43740 WHEN OTHERS THEN
43741 l_acc_rev_flag := 'N';
43743 --
43744 IF (l_acc_rev_flag = 'Y') THEN
43745
43746 -- 4645092 ------------------------------------------------------------------------------
43747 -- To allow MPA report to determine if it should generate report process
43748 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
43749 ------------------------------------------------------------------------------------------
43750
43751 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
43752 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
43753 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
43754 -- call ADRs
43755 -- Bug 4922099
43756 --
43757 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43758 (NVL(l_actual_upg_option, 'N') = 'O') OR
43759 (NVL(l_enc_upg_option, 'N') = 'O')
43760 )
43761 THEN
43762 NULL;
43763 --
43764 --
43765
43766 l_ccid := AcctDerRule_11(
43767 p_application_id => p_application_id
43768 , p_ae_header_id => l_ae_header_id
43769 , p_source_10 => p_source_10
43770 , x_transaction_coa_id => l_adr_transaction_coa_id
43771 , x_accounting_coa_id => l_adr_accounting_coa_id
43772 , x_value_type_code => l_adr_value_type_code
43773 , p_side => 'NA'
43774 );
43775
43776 xla_ae_lines_pkg.set_ccid(
43777 p_code_combination_id => l_ccid
43778 , p_value_type_code => l_adr_value_type_code
43779 , p_transaction_coa_id => l_adr_transaction_coa_id
43780 , p_accounting_coa_id => l_adr_accounting_coa_id
43781 , p_adr_code => 'DIST_CCID'
43782 , p_adr_type_code => 'S'
43783 , p_component_type => l_component_type
43784 , p_component_code => l_component_code
43785 , p_component_type_code => l_component_type_code
43786 , p_component_appl_id => l_component_appl_id
43787 , p_amb_context_code => l_amb_context_code
43788 , p_side => 'NA'
43789 );
43790
43791
43792 --
43793 --
43794 END IF;
43795
43796 --
43797 -- Update the line information that should be overwritten
43798 --
43799 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
43800 p_header_num => 1);
43801 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
43802
43803 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
43804
43805 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
43806 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
43807 END IF;
43808
43809 --
43810 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
43811 --
43812 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
43813 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
43814 ELSE
43815 ---------------------------------------------------------------------------------------------------
43816 -- 4262811a Switch Sign
43817 ---------------------------------------------------------------------------------------------------
43818 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
43819 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43820 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43821 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43822 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43823 -- 5132302
43824 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
43825 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43826
43827 END IF;
43828
43829 -- 4955764
43830 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43831 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
43832
43833
43834 XLA_AE_LINES_PKG.ValidateCurrentLine;
43835 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43836
43837 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43838 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
43839 ,p_balance_type_code => l_balance_type_code);
43840
43841 END IF;
43842
43843 -----------------------------------------------------------------------------------------
43844 -- 4262811 Multiperiod Accounting
43845 -----------------------------------------------------------------------------------------
43846 -- No MPA option is assigned.
43847
43848
43849 END IF;
43850 END IF;
43851 --
43852
43853 --
43854 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43855 trace
43856 (p_msg => 'END of AcctLineType_88'
43857 ,p_level => C_LEVEL_PROCEDURE
43858 ,p_module => l_log_module);
43859 END IF;
43860 --
43861 EXCEPTION
43862 WHEN xla_exceptions_pkg.application_exception THEN
43866 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_88');
43863 RAISE;
43864 WHEN OTHERS THEN
43865 xla_exceptions_pkg.raise_message
43867 END AcctLineType_88;
43868 --
43869
43870 ---------------------------------------
43871 --
43872 -- PRIVATE FUNCTION
43873 -- AcctLineType_89
43874 --
43875 ---------------------------------------
43876 PROCEDURE AcctLineType_89 (
43877 p_application_id IN NUMBER
43878 ,p_event_id IN NUMBER
43879 ,p_calculate_acctd_flag IN VARCHAR2
43880 ,p_calculate_g_l_flag IN VARCHAR2
43881 ,p_actual_flag IN OUT VARCHAR2
43882 ,p_balance_type_code OUT VARCHAR2
43883 ,p_gain_or_loss_ref OUT VARCHAR2
43884
43885 --Distribution GL Account
43886 , p_source_10 IN NUMBER
43887 --Distribution Source Type
43888 , p_source_15 IN VARCHAR2
43889 --Distribution Line Identifier
43890 , p_source_17 IN NUMBER
43891 --Distribution Type
43892 , p_source_18 IN VARCHAR2
43893 --Entered Amount
43894 , p_source_19 IN NUMBER
43895 --Exchange Date
43896 , p_source_21 IN DATE
43897 --Exchange Rate
43898 , p_source_22 IN NUMBER
43899 --Exchange Rate Type
43900 , p_source_23 IN VARCHAR2
43901 --Applied To Document Accounting Amount
43902 , p_source_24 IN NUMBER
43903 --Transaction Distribution Identifier
43904 , p_source_29 IN NUMBER
43905 --Transaction Distribution Type
43906 , p_source_30 IN VARCHAR2
43907 --Receipt Applied To Application Identifier
43908 , p_source_58 IN NUMBER
43909 --Transaction Entity Code
43910 , p_source_59 IN VARCHAR2
43911 --Transaction Identifier
43912 , p_source_60 IN NUMBER
43913 --Applying Document Currency Code
43914 , p_source_62 IN VARCHAR2
43915 --Distribution Party Identifier
43916 , p_source_64 IN NUMBER
43917 --Distribution Party Site Id
43918 , p_source_65 IN NUMBER
43919 --Distribution Party Type
43920 , p_source_66 IN VARCHAR2
43921 )
43922 IS
43923
43924 l_component_type VARCHAR2(80);
43925 l_component_code VARCHAR2(30);
43926 l_component_type_code VARCHAR2(1);
43927 l_component_appl_id INTEGER;
43928 l_amb_context_code VARCHAR2(30);
43929 l_entity_code VARCHAR2(30);
43930 l_event_class_code VARCHAR2(30);
43931 l_ae_header_id NUMBER;
43932 l_event_type_code VARCHAR2(30);
43933 l_line_definition_code VARCHAR2(30);
43934 l_line_definition_owner_code VARCHAR2(1);
43935 --
43936 -- adr variables
43937 l_segment VARCHAR2(30);
43938 l_ccid NUMBER;
43939 l_adr_transaction_coa_id NUMBER;
43940 l_adr_accounting_coa_id NUMBER;
43941 l_adr_flexfield_segment_code VARCHAR2(30);
43942 l_adr_flex_value_set_id NUMBER;
43943 l_adr_value_type_code VARCHAR2(30);
43944 l_adr_value_combination_id NUMBER;
43945 l_adr_value_segment_code VARCHAR2(30);
43946
43947 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
43948 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
43949 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
43950 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
43951
43952 -- 4262811 Variables ------------------------------------------------------------------------------------------
43953 l_entered_amt_idx NUMBER;
43954 l_accted_amt_idx NUMBER;
43955 l_acc_rev_flag VARCHAR2(1);
43956 l_accrual_line_num NUMBER;
43957 l_tmp_amt NUMBER;
43958 l_acc_rev_natural_side_code VARCHAR2(1);
43959
43960 l_num_entries NUMBER;
43961 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
43962 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
43963 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
43964 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
43965 l_recog_line_1 NUMBER;
43966 l_recog_line_2 NUMBER;
43967
43968 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
43969 l_bflow_applied_to_amt NUMBER; -- 5132302
43970 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
43971
43972 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
43973
43974 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
43975 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
43976
43977 ---------------------------------------------------------------------------------------------------------------
43978
43979
43980 --
43981 -- bulk performance
43982 --
43983 l_balance_type_code VARCHAR2(1);
43984 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
43985 l_log_module VARCHAR2(240);
43986
43987 --
43988 -- Upgrade strategy
43989 --
43990 l_actual_upg_option VARCHAR2(1);
43991 l_enc_upg_option VARCHAR2(1);
43992
43993 --
43994 BEGIN
43995 --
43996 IF g_log_enabled THEN
43997 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_89';
43998 END IF;
43999 --
44000 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44001
44002 trace
44003 (p_msg => 'BEGIN of AcctLineType_89'
44004 ,p_level => C_LEVEL_PROCEDURE
44008 --
44005 ,p_module => l_log_module);
44006
44007 END IF;
44009 l_component_type := 'AMB_JLT';
44010 l_component_code := 'RCT_EXCH_LOSS';
44011 l_component_type_code := 'S';
44012 l_component_appl_id := 222;
44013 l_amb_context_code := 'DEFAULT';
44014 l_entity_code := 'RECEIPTS';
44015 l_event_class_code := 'RECEIPT';
44016 l_event_type_code := 'RECEIPT_ALL';
44017 l_line_definition_owner_code := 'S';
44018 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
44019 --
44020 l_balance_type_code := 'A';
44021 l_segment := NULL;
44022 l_ccid := NULL;
44023 l_adr_transaction_coa_id := NULL;
44024 l_adr_accounting_coa_id := NULL;
44025 l_adr_flexfield_segment_code := NULL;
44026 l_adr_flex_value_set_id := NULL;
44027 l_adr_value_type_code := NULL;
44028 l_adr_value_combination_id := NULL;
44029 l_adr_value_segment_code := NULL;
44030
44031 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
44032 l_bflow_class_code := ''; -- 4219869 Business Flow
44033 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
44034 l_budgetary_control_flag := 'N';
44035
44036 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44037 l_bflow_applied_to_amt := NULL; -- 5132302
44038 l_entered_amt_idx := NULL; -- 4262811
44039 l_accted_amt_idx := NULL; -- 4262811
44040 l_acc_rev_flag := NULL; -- 4262811
44041 l_accrual_line_num := NULL; -- 4262811
44042 l_tmp_amt := NULL; -- 4262811
44043 --
44044 IF ((p_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
44045 (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
44046 return;
44047 END IF;
44048
44049 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
44050 l_balance_type_code <> 'B' THEN
44051 IF NVL(p_source_15,'
44052 ') = 'EXCH_LOSS'
44053 THEN
44054
44055 --
44056 XLA_AE_LINES_PKG.SetNewLine;
44057
44058 p_balance_type_code := l_balance_type_code;
44059 -- set the flag so later we will know whether the gain loss line needs to be created
44060
44061 IF(l_balance_type_code = 'A' ) THEN
44062 p_actual_flag :='G';
44063 END IF;
44064
44065 --
44066 -- bulk performance
44067 --
44068 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
44069 p_header_num => 0); -- 4262811
44070 --
44071 -- set accounting line options
44072 --
44073 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
44074 p_natural_side_code => 'C'
44075 , p_gain_or_loss_flag => 'Y'
44076 , p_gl_transfer_mode_code => 'S'
44077 , p_acct_entry_type_code => 'A'
44078 , p_switch_side_flag => 'Y'
44079 , p_merge_duplicate_code => 'A'
44080 );
44081 --
44082 l_acc_rev_natural_side_code := 'D'; -- 4262811
44083 --
44084 --
44085 -- set accounting line type info
44086 --
44087 xla_ae_lines_pkg.SetAcctLineType
44088 (p_component_type => l_component_type
44089 ,p_event_type_code => l_event_type_code
44090 ,p_line_definition_owner_code => l_line_definition_owner_code
44091 ,p_line_definition_code => l_line_definition_code
44092 ,p_accounting_line_code => l_component_code
44093 ,p_accounting_line_type_code => l_component_type_code
44094 ,p_accounting_line_appl_id => l_component_appl_id
44095 ,p_amb_context_code => l_amb_context_code
44096 ,p_entity_code => l_entity_code
44097 ,p_event_class_code => l_event_class_code);
44098 --
44099 -- set accounting class
44100 --
44101 xla_ae_lines_pkg.SetAcctClass(
44102 p_accounting_class_code => 'LOSS'
44103 , p_ae_header_id => l_ae_header_id
44104 );
44105
44106 --
44107 -- set rounding class
44108 --
44109 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
44110 'RECEIVABLE';
44111
44112 --
44113 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
44114 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
44115 --
44116 -- bulk performance
44117 --
44118 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
44119
44120 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
44121 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
44122
44123 -- 4955764
44124 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44125 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
44126
44127 -- 4458381 Public Sector Enh
44128
44129 --
44130 -- set accounting attributes for the line type
44131 --
44132 l_entered_amt_idx := 8;
44133 l_accted_amt_idx := 13;
44134 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44138 l_rec_acct_attrs.array_char_value(2) := p_source_30;
44135 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
44136 l_rec_acct_attrs.array_num_value(1) := p_source_58;
44137 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
44139 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
44140 l_rec_acct_attrs.array_char_value(3) := p_source_59;
44141 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
44142 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
44143 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
44144 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
44145 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
44146 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
44147 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
44148 l_rec_acct_attrs.array_char_value(7) := p_source_18;
44149 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
44150 l_rec_acct_attrs.array_num_value(8) := p_source_19;
44151 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
44152 l_rec_acct_attrs.array_char_value(9) := p_source_62;
44153 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
44154 l_rec_acct_attrs.array_date_value(10) := p_source_21;
44155 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
44156 l_rec_acct_attrs.array_num_value(11) := p_source_22;
44157 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
44158 l_rec_acct_attrs.array_char_value(12) := p_source_23;
44159 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
44160 l_rec_acct_attrs.array_num_value(13) := p_source_24;
44161 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
44162 l_rec_acct_attrs.array_num_value(14) := p_source_64;
44163 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
44164 l_rec_acct_attrs.array_num_value(15) := p_source_65;
44165 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
44166 l_rec_acct_attrs.array_char_value(16) := p_source_66;
44167
44168 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
44169 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
44170
44171 ---------------------------------------------------------------------------------------------------------------
44172 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
44173 ---------------------------------------------------------------------------------------------------------------
44174 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
44175
44176 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44177 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44178
44179 IF xla_accounting_cache_pkg.GetValueChar
44180 (p_source_code => 'LEDGER_CATEGORY_CODE'
44181 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
44182 AND l_bflow_method_code = 'PRIOR_ENTRY'
44183 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
44184 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
44185 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
44186 )
44187 THEN
44188 xla_ae_lines_pkg.BflowUpgEntry
44189 (p_business_method_code => l_bflow_method_code
44190 ,p_business_class_code => l_bflow_class_code
44191 ,p_balance_type => l_balance_type_code);
44192 ELSE
44193 NULL;
44194 -- No business flow processing for business flow method of NONE.
44195 END IF;
44196
44197 --
44198 -- call analytical criteria
44199 --
44200
44201 --
44202 -- call description
44203 --
44204 -- No description or it is inherited.
44205 --
44206 -- call ADRs
44207 -- Bug 4922099
44208 --
44209 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44210 (NVL(l_actual_upg_option, 'N') = 'O') OR
44211 (NVL(l_enc_upg_option, 'N') = 'O')
44212 )
44213 THEN
44214 NULL;
44215 --
44216 --
44217
44218 l_ccid := AcctDerRule_11(
44219 p_application_id => p_application_id
44220 , p_ae_header_id => l_ae_header_id
44221 , p_source_10 => p_source_10
44222 , x_transaction_coa_id => l_adr_transaction_coa_id
44223 , x_accounting_coa_id => l_adr_accounting_coa_id
44224 , x_value_type_code => l_adr_value_type_code
44225 , p_side => 'NA'
44226 );
44227
44228 xla_ae_lines_pkg.set_ccid(
44229 p_code_combination_id => l_ccid
44230 , p_value_type_code => l_adr_value_type_code
44231 , p_transaction_coa_id => l_adr_transaction_coa_id
44232 , p_accounting_coa_id => l_adr_accounting_coa_id
44233 , p_adr_code => 'DIST_CCID'
44234 , p_adr_type_code => 'S'
44235 , p_component_type => l_component_type
44236 , p_component_code => l_component_code
44237 , p_component_type_code => l_component_type_code
44238 , p_component_appl_id => l_component_appl_id
44239 , p_amb_context_code => l_amb_context_code
44240 , p_side => 'NA'
44241 );
44242
44243
44244 --
44245 --
44246 END IF;
44247 --
44248 -- Bug 4922099
44249 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
44253 )
44250 (NVL(l_enc_upg_option, 'N') = 'O')
44251 ) AND
44252 (l_bflow_method_code = 'PRIOR_ENTRY')
44254 THEN
44255 IF
44256 --
44257 1 = 2
44258 --
44259 THEN
44260 xla_accounting_err_pkg.build_message
44261 (p_appli_s_name => 'XLA'
44262 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44263 ,p_token_1 => 'LINE_NUMBER'
44264 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
44265 ,p_token_2 => 'LINE_TYPE_NAME'
44266 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
44267 l_component_type
44268 ,l_component_code
44269 ,l_component_type_code
44270 ,l_component_appl_id
44271 ,l_amb_context_code
44272 ,l_entity_code
44273 ,l_event_class_code
44274 )
44275 ,p_token_3 => 'OWNER'
44276 ,p_value_3 => xla_lookups_pkg.get_meaning(
44277 p_lookup_type => 'XLA_OWNER_TYPE'
44278 ,p_lookup_code => l_component_type_code
44279 )
44280 ,p_token_4 => 'PRODUCT_NAME'
44281 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
44282 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
44283 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
44284 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
44285 ,p_ae_header_id => NULL
44286 );
44287
44288 IF (C_LEVEL_ERROR>= g_log_level) THEN
44289 trace
44290 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44291 ,p_level => C_LEVEL_ERROR
44292 ,p_module => l_log_module);
44293 END IF;
44294 END IF;
44295 END IF;
44296 --
44297 --
44298 ------------------------------------------------------------------------------------------------
44299 -- 4219869 Business Flow
44300 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
44301 -- Prior Entry. Currently, the following code is always generated.
44302 ------------------------------------------------------------------------------------------------
44303 XLA_AE_LINES_PKG.ValidateCurrentLine;
44304
44305 ------------------------------------------------------------------------------------
44306 -- 4219869 Business Flow
44307 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
44308 ------------------------------------------------------------------------------------
44309 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44310
44311 ----------------------------------------------------------------------------------
44312 -- 4219869 Business Flow
44313 -- Update journal entry status -- Need to generate this within IF <condition>
44314 ----------------------------------------------------------------------------------
44315 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44316 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
44317 ,p_balance_type_code => l_balance_type_code
44318 );
44319
44320 -------------------------------------------------------------------------------------------
44321 -- 4262811 - Generate the Accrual Reversal lines
44322 -------------------------------------------------------------------------------------------
44323 BEGIN
44324 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
44325 (g_array_event(p_event_id).array_value_num('header_index'));
44326 IF l_acc_rev_flag IS NULL THEN
44327 l_acc_rev_flag := 'N';
44328 END IF;
44329 EXCEPTION
44330 WHEN OTHERS THEN
44331 l_acc_rev_flag := 'N';
44332 END;
44333 --
44334 IF (l_acc_rev_flag = 'Y') THEN
44335
44336 -- 4645092 ------------------------------------------------------------------------------
44337 -- To allow MPA report to determine if it should generate report process
44338 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
44339 ------------------------------------------------------------------------------------------
44340
44341 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
44342 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
44343 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
44344 -- call ADRs
44345 -- Bug 4922099
44346 --
44347 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44348 (NVL(l_actual_upg_option, 'N') = 'O') OR
44352 NULL;
44349 (NVL(l_enc_upg_option, 'N') = 'O')
44350 )
44351 THEN
44353 --
44354 --
44355
44356 l_ccid := AcctDerRule_11(
44357 p_application_id => p_application_id
44358 , p_ae_header_id => l_ae_header_id
44359 , p_source_10 => p_source_10
44360 , x_transaction_coa_id => l_adr_transaction_coa_id
44361 , x_accounting_coa_id => l_adr_accounting_coa_id
44362 , x_value_type_code => l_adr_value_type_code
44363 , p_side => 'NA'
44364 );
44365
44366 xla_ae_lines_pkg.set_ccid(
44367 p_code_combination_id => l_ccid
44368 , p_value_type_code => l_adr_value_type_code
44369 , p_transaction_coa_id => l_adr_transaction_coa_id
44370 , p_accounting_coa_id => l_adr_accounting_coa_id
44371 , p_adr_code => 'DIST_CCID'
44372 , p_adr_type_code => 'S'
44373 , p_component_type => l_component_type
44374 , p_component_code => l_component_code
44375 , p_component_type_code => l_component_type_code
44376 , p_component_appl_id => l_component_appl_id
44377 , p_amb_context_code => l_amb_context_code
44378 , p_side => 'NA'
44379 );
44380
44381
44382 --
44383 --
44384 END IF;
44385
44386 --
44387 -- Update the line information that should be overwritten
44388 --
44389 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
44390 p_header_num => 1);
44391 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
44392
44393 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
44394
44395 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
44396 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
44397 END IF;
44398
44399 --
44400 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
44401 --
44402 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
44403 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
44404 ELSE
44405 ---------------------------------------------------------------------------------------------------
44406 -- 4262811a Switch Sign
44407 ---------------------------------------------------------------------------------------------------
44408 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
44409 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44410 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44411 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44412 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44413 -- 5132302
44414 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
44415 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44416
44417 END IF;
44418
44419 -- 4955764
44420 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44421 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
44422
44423
44424 XLA_AE_LINES_PKG.ValidateCurrentLine;
44425 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44426
44427 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44428 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
44429 ,p_balance_type_code => l_balance_type_code);
44430
44431 END IF;
44432
44433 -----------------------------------------------------------------------------------------
44434 -- 4262811 Multiperiod Accounting
44435 -----------------------------------------------------------------------------------------
44436 -- No MPA option is assigned.
44437
44438
44439 END IF;
44440 END IF;
44441 --
44442
44443 --
44444 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44445 trace
44446 (p_msg => 'END of AcctLineType_89'
44447 ,p_level => C_LEVEL_PROCEDURE
44448 ,p_module => l_log_module);
44449 END IF;
44450 --
44451 EXCEPTION
44452 WHEN xla_exceptions_pkg.application_exception THEN
44453 RAISE;
44454 WHEN OTHERS THEN
44455 xla_exceptions_pkg.raise_message
44456 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_89');
44457 END AcctLineType_89;
44458 --
44459
44460 ---------------------------------------
44461 --
44462 -- PRIVATE FUNCTION
44463 -- AcctLineType_90
44464 --
44465 ---------------------------------------
44466 PROCEDURE AcctLineType_90 (
44467 p_application_id IN NUMBER
44468 ,p_event_id IN NUMBER
44469 ,p_calculate_acctd_flag IN VARCHAR2
44470 ,p_calculate_g_l_flag IN VARCHAR2
44471 ,p_actual_flag IN OUT VARCHAR2
44472 ,p_balance_type_code OUT VARCHAR2
44473 ,p_gain_or_loss_ref OUT VARCHAR2
44474
44475 --Distribution GL Account
44476 , p_source_10 IN NUMBER
44477 --Distribution Source Type
44478 , p_source_15 IN VARCHAR2
44482 , p_source_18 IN VARCHAR2
44479 --Distribution Line Identifier
44480 , p_source_17 IN NUMBER
44481 --Distribution Type
44483 --Exchange Date
44484 , p_source_21 IN DATE
44485 --Exchange Rate
44486 , p_source_22 IN NUMBER
44487 --Exchange Rate Type
44488 , p_source_23 IN VARCHAR2
44489 --Transaction Distribution Identifier
44490 , p_source_29 IN NUMBER
44491 --Transaction Distribution Type
44492 , p_source_30 IN VARCHAR2
44493 --Distribution Multi Fund Additional Entry
44494 , p_source_54 IN VARCHAR2
44495 --Receipt Applied To Application Identifier
44496 , p_source_58 IN NUMBER
44497 --Transaction Entity Code
44498 , p_source_59 IN VARCHAR2
44499 --Transaction Identifier
44500 , p_source_60 IN NUMBER
44501 --DIST_ENT_AMT_FROM
44502 , p_source_61 IN NUMBER
44503 --Applying Document Currency Code
44504 , p_source_62 IN VARCHAR2
44505 --Accounting Amount
44506 , p_source_63 IN NUMBER
44507 --Distribution Party Identifier
44508 , p_source_64 IN NUMBER
44509 --Distribution Party Site Id
44510 , p_source_65 IN NUMBER
44511 --Distribution Party Type
44512 , p_source_66 IN VARCHAR2
44513 --Distribution Source Table
44514 , p_source_69 IN VARCHAR2
44515 )
44516 IS
44517
44518 l_component_type VARCHAR2(80);
44519 l_component_code VARCHAR2(30);
44520 l_component_type_code VARCHAR2(1);
44521 l_component_appl_id INTEGER;
44522 l_amb_context_code VARCHAR2(30);
44523 l_entity_code VARCHAR2(30);
44524 l_event_class_code VARCHAR2(30);
44525 l_ae_header_id NUMBER;
44526 l_event_type_code VARCHAR2(30);
44527 l_line_definition_code VARCHAR2(30);
44528 l_line_definition_owner_code VARCHAR2(1);
44529 --
44530 -- adr variables
44531 l_segment VARCHAR2(30);
44532 l_ccid NUMBER;
44533 l_adr_transaction_coa_id NUMBER;
44534 l_adr_accounting_coa_id NUMBER;
44535 l_adr_flexfield_segment_code VARCHAR2(30);
44536 l_adr_flex_value_set_id NUMBER;
44537 l_adr_value_type_code VARCHAR2(30);
44538 l_adr_value_combination_id NUMBER;
44539 l_adr_value_segment_code VARCHAR2(30);
44540
44541 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
44542 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
44543 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
44544 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
44545
44546 -- 4262811 Variables ------------------------------------------------------------------------------------------
44547 l_entered_amt_idx NUMBER;
44548 l_accted_amt_idx NUMBER;
44549 l_acc_rev_flag VARCHAR2(1);
44550 l_accrual_line_num NUMBER;
44551 l_tmp_amt NUMBER;
44552 l_acc_rev_natural_side_code VARCHAR2(1);
44553
44554 l_num_entries NUMBER;
44555 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
44556 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
44557 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
44558 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
44559 l_recog_line_1 NUMBER;
44560 l_recog_line_2 NUMBER;
44561
44562 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
44563 l_bflow_applied_to_amt NUMBER; -- 5132302
44564 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
44565
44566 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
44567
44568 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
44569 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
44570
44571 ---------------------------------------------------------------------------------------------------------------
44572
44573
44574 --
44575 -- bulk performance
44576 --
44577 l_balance_type_code VARCHAR2(1);
44578 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
44579 l_log_module VARCHAR2(240);
44580
44581 --
44582 -- Upgrade strategy
44583 --
44584 l_actual_upg_option VARCHAR2(1);
44585 l_enc_upg_option VARCHAR2(1);
44586
44587 --
44588 BEGIN
44589 --
44590 IF g_log_enabled THEN
44591 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_90';
44592 END IF;
44593 --
44594 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44595
44596 trace
44597 (p_msg => 'BEGIN of AcctLineType_90'
44598 ,p_level => C_LEVEL_PROCEDURE
44599 ,p_module => l_log_module);
44600
44601 END IF;
44602 --
44603 l_component_type := 'AMB_JLT';
44604 l_component_code := 'RCT_FACTOR';
44605 l_component_type_code := 'S';
44606 l_component_appl_id := 222;
44607 l_amb_context_code := 'DEFAULT';
44608 l_entity_code := 'RECEIPTS';
44609 l_event_class_code := 'RECEIPT';
44610 l_event_type_code := 'RECEIPT_ALL';
44611 l_line_definition_owner_code := 'S';
44612 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
44613 --
44614 l_balance_type_code := 'A';
44615 l_segment := NULL;
44616 l_ccid := NULL;
44620 l_adr_flex_value_set_id := NULL;
44617 l_adr_transaction_coa_id := NULL;
44618 l_adr_accounting_coa_id := NULL;
44619 l_adr_flexfield_segment_code := NULL;
44621 l_adr_value_type_code := NULL;
44622 l_adr_value_combination_id := NULL;
44623 l_adr_value_segment_code := NULL;
44624
44625 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
44626 l_bflow_class_code := ''; -- 4219869 Business Flow
44627 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
44628 l_budgetary_control_flag := 'N';
44629
44630 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44631 l_bflow_applied_to_amt := NULL; -- 5132302
44632 l_entered_amt_idx := NULL; -- 4262811
44633 l_accted_amt_idx := NULL; -- 4262811
44634 l_acc_rev_flag := NULL; -- 4262811
44635 l_accrual_line_num := NULL; -- 4262811
44636 l_tmp_amt := NULL; -- 4262811
44637 --
44638
44639 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
44640 l_balance_type_code <> 'B' THEN
44641 IF NVL(p_source_15,'
44642 ') = 'FACTOR' AND
44643 NVL(p_source_69,'
44644 ') = 'CRH' AND
44645 NVL(p_source_54,'
44646 ') = 'N'
44647 THEN
44648
44649 --
44650 XLA_AE_LINES_PKG.SetNewLine;
44651
44652 p_balance_type_code := l_balance_type_code;
44653 -- set the flag so later we will know whether the gain loss line needs to be created
44654
44655 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
44656 p_actual_flag :='A';
44657 END IF;
44658
44659 --
44660 -- bulk performance
44661 --
44662 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
44663 p_header_num => 0); -- 4262811
44664 --
44665 -- set accounting line options
44666 --
44667 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
44668 p_natural_side_code => 'C'
44669 , p_gain_or_loss_flag => 'N'
44670 , p_gl_transfer_mode_code => 'S'
44671 , p_acct_entry_type_code => 'A'
44672 , p_switch_side_flag => 'Y'
44673 , p_merge_duplicate_code => 'A'
44674 );
44675 --
44676 l_acc_rev_natural_side_code := 'D'; -- 4262811
44677 --
44678 --
44679 -- set accounting line type info
44680 --
44681 xla_ae_lines_pkg.SetAcctLineType
44682 (p_component_type => l_component_type
44683 ,p_event_type_code => l_event_type_code
44684 ,p_line_definition_owner_code => l_line_definition_owner_code
44685 ,p_line_definition_code => l_line_definition_code
44686 ,p_accounting_line_code => l_component_code
44687 ,p_accounting_line_type_code => l_component_type_code
44688 ,p_accounting_line_appl_id => l_component_appl_id
44689 ,p_amb_context_code => l_amb_context_code
44690 ,p_entity_code => l_entity_code
44691 ,p_event_class_code => l_event_class_code);
44692 --
44693 -- set accounting class
44694 --
44695 xla_ae_lines_pkg.SetAcctClass(
44696 p_accounting_class_code => 'FACTOR'
44697 , p_ae_header_id => l_ae_header_id
44698 );
44699
44700 --
44701 -- set rounding class
44702 --
44703 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
44704 'RECEIVABLE';
44705
44706 --
44707 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
44708 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
44709 --
44710 -- bulk performance
44711 --
44712 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
44713
44714 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
44715 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
44716
44717 -- 4955764
44718 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44719 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
44720
44721 -- 4458381 Public Sector Enh
44722
44723 --
44724 -- set accounting attributes for the line type
44725 --
44726 l_entered_amt_idx := 8;
44727 l_accted_amt_idx := 13;
44728 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44729 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
44730 l_rec_acct_attrs.array_num_value(1) := p_source_58;
44731 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
44732 l_rec_acct_attrs.array_char_value(2) := p_source_30;
44733 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
44734 l_rec_acct_attrs.array_char_value(3) := p_source_59;
44735 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
44736 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
44737 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
44738 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
44739 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
44740 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
44741 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
44742 l_rec_acct_attrs.array_char_value(7) := p_source_18;
44746 l_rec_acct_attrs.array_char_value(9) := p_source_62;
44743 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
44744 l_rec_acct_attrs.array_num_value(8) := p_source_61;
44745 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
44747 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
44748 l_rec_acct_attrs.array_date_value(10) := p_source_21;
44749 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
44750 l_rec_acct_attrs.array_num_value(11) := p_source_22;
44751 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
44752 l_rec_acct_attrs.array_char_value(12) := p_source_23;
44753 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
44754 l_rec_acct_attrs.array_num_value(13) := p_source_63;
44755 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
44756 l_rec_acct_attrs.array_num_value(14) := p_source_64;
44757 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
44758 l_rec_acct_attrs.array_num_value(15) := p_source_65;
44759 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
44760 l_rec_acct_attrs.array_char_value(16) := p_source_66;
44761
44762 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
44763 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
44764
44765 ---------------------------------------------------------------------------------------------------------------
44766 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
44767 ---------------------------------------------------------------------------------------------------------------
44768 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
44769
44770 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44771 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44772
44773 IF xla_accounting_cache_pkg.GetValueChar
44774 (p_source_code => 'LEDGER_CATEGORY_CODE'
44775 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
44776 AND l_bflow_method_code = 'PRIOR_ENTRY'
44777 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
44778 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
44779 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
44780 )
44781 THEN
44782 xla_ae_lines_pkg.BflowUpgEntry
44783 (p_business_method_code => l_bflow_method_code
44784 ,p_business_class_code => l_bflow_class_code
44785 ,p_balance_type => l_balance_type_code);
44786 ELSE
44787 NULL;
44788 -- No business flow processing for business flow method of NONE.
44789 END IF;
44790
44791 --
44792 -- call analytical criteria
44793 --
44794
44795 --
44796 -- call description
44797 --
44798 -- No description or it is inherited.
44799 --
44800 -- call ADRs
44801 -- Bug 4922099
44802 --
44803 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44804 (NVL(l_actual_upg_option, 'N') = 'O') OR
44805 (NVL(l_enc_upg_option, 'N') = 'O')
44806 )
44807 THEN
44808 NULL;
44809 --
44810 --
44811
44812 l_ccid := AcctDerRule_11(
44813 p_application_id => p_application_id
44814 , p_ae_header_id => l_ae_header_id
44815 , p_source_10 => p_source_10
44816 , x_transaction_coa_id => l_adr_transaction_coa_id
44817 , x_accounting_coa_id => l_adr_accounting_coa_id
44818 , x_value_type_code => l_adr_value_type_code
44819 , p_side => 'NA'
44820 );
44821
44822 xla_ae_lines_pkg.set_ccid(
44823 p_code_combination_id => l_ccid
44824 , p_value_type_code => l_adr_value_type_code
44825 , p_transaction_coa_id => l_adr_transaction_coa_id
44826 , p_accounting_coa_id => l_adr_accounting_coa_id
44827 , p_adr_code => 'DIST_CCID'
44828 , p_adr_type_code => 'S'
44829 , p_component_type => l_component_type
44830 , p_component_code => l_component_code
44831 , p_component_type_code => l_component_type_code
44832 , p_component_appl_id => l_component_appl_id
44833 , p_amb_context_code => l_amb_context_code
44834 , p_side => 'NA'
44835 );
44836
44837
44838 --
44839 --
44840 END IF;
44841 --
44842 -- Bug 4922099
44843 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
44844 (NVL(l_enc_upg_option, 'N') = 'O')
44845 ) AND
44846 (l_bflow_method_code = 'PRIOR_ENTRY')
44847 )
44848 THEN
44849 IF
44850 --
44851 1 = 2
44852 --
44853 THEN
44854 xla_accounting_err_pkg.build_message
44855 (p_appli_s_name => 'XLA'
44856 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44857 ,p_token_1 => 'LINE_NUMBER'
44858 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
44859 ,p_token_2 => 'LINE_TYPE_NAME'
44860 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
44861 l_component_type
44865 ,l_amb_context_code
44862 ,l_component_code
44863 ,l_component_type_code
44864 ,l_component_appl_id
44866 ,l_entity_code
44867 ,l_event_class_code
44868 )
44869 ,p_token_3 => 'OWNER'
44870 ,p_value_3 => xla_lookups_pkg.get_meaning(
44871 p_lookup_type => 'XLA_OWNER_TYPE'
44872 ,p_lookup_code => l_component_type_code
44873 )
44874 ,p_token_4 => 'PRODUCT_NAME'
44875 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
44876 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
44877 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
44878 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
44879 ,p_ae_header_id => NULL
44880 );
44881
44882 IF (C_LEVEL_ERROR>= g_log_level) THEN
44883 trace
44884 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44885 ,p_level => C_LEVEL_ERROR
44886 ,p_module => l_log_module);
44887 END IF;
44888 END IF;
44889 END IF;
44890 --
44891 --
44892 ------------------------------------------------------------------------------------------------
44893 -- 4219869 Business Flow
44894 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
44895 -- Prior Entry. Currently, the following code is always generated.
44896 ------------------------------------------------------------------------------------------------
44897 XLA_AE_LINES_PKG.ValidateCurrentLine;
44898
44899 ------------------------------------------------------------------------------------
44900 -- 4219869 Business Flow
44901 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
44902 ------------------------------------------------------------------------------------
44903 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44904
44905 ----------------------------------------------------------------------------------
44906 -- 4219869 Business Flow
44907 -- Update journal entry status -- Need to generate this within IF <condition>
44908 ----------------------------------------------------------------------------------
44909 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44910 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
44911 ,p_balance_type_code => l_balance_type_code
44912 );
44913
44914 -------------------------------------------------------------------------------------------
44915 -- 4262811 - Generate the Accrual Reversal lines
44916 -------------------------------------------------------------------------------------------
44917 BEGIN
44918 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
44919 (g_array_event(p_event_id).array_value_num('header_index'));
44920 IF l_acc_rev_flag IS NULL THEN
44921 l_acc_rev_flag := 'N';
44922 END IF;
44923 EXCEPTION
44924 WHEN OTHERS THEN
44925 l_acc_rev_flag := 'N';
44926 END;
44927 --
44928 IF (l_acc_rev_flag = 'Y') THEN
44929
44930 -- 4645092 ------------------------------------------------------------------------------
44931 -- To allow MPA report to determine if it should generate report process
44932 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
44933 ------------------------------------------------------------------------------------------
44934
44935 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
44936 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
44937 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
44938 -- call ADRs
44939 -- Bug 4922099
44940 --
44941 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44942 (NVL(l_actual_upg_option, 'N') = 'O') OR
44943 (NVL(l_enc_upg_option, 'N') = 'O')
44944 )
44945 THEN
44946 NULL;
44947 --
44948 --
44949
44950 l_ccid := AcctDerRule_11(
44951 p_application_id => p_application_id
44952 , p_ae_header_id => l_ae_header_id
44953 , p_source_10 => p_source_10
44954 , x_transaction_coa_id => l_adr_transaction_coa_id
44955 , x_accounting_coa_id => l_adr_accounting_coa_id
44956 , x_value_type_code => l_adr_value_type_code
44957 , p_side => 'NA'
44958 );
44959
44960 xla_ae_lines_pkg.set_ccid(
44964 , p_accounting_coa_id => l_adr_accounting_coa_id
44961 p_code_combination_id => l_ccid
44962 , p_value_type_code => l_adr_value_type_code
44963 , p_transaction_coa_id => l_adr_transaction_coa_id
44965 , p_adr_code => 'DIST_CCID'
44966 , p_adr_type_code => 'S'
44967 , p_component_type => l_component_type
44968 , p_component_code => l_component_code
44969 , p_component_type_code => l_component_type_code
44970 , p_component_appl_id => l_component_appl_id
44971 , p_amb_context_code => l_amb_context_code
44972 , p_side => 'NA'
44973 );
44974
44975
44976 --
44977 --
44978 END IF;
44979
44980 --
44981 -- Update the line information that should be overwritten
44982 --
44983 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
44984 p_header_num => 1);
44985 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
44986
44987 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
44988
44989 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
44990 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
44991 END IF;
44992
44993 --
44994 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
44995 --
44996 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
44997 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
44998 ELSE
44999 ---------------------------------------------------------------------------------------------------
45000 -- 4262811a Switch Sign
45001 ---------------------------------------------------------------------------------------------------
45002 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
45003 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45004 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45005 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45006 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45007 -- 5132302
45008 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
45009 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45010
45011 END IF;
45012
45013 -- 4955764
45014 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45015 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
45016
45017
45018 XLA_AE_LINES_PKG.ValidateCurrentLine;
45019 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45020
45021 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45022 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
45023 ,p_balance_type_code => l_balance_type_code);
45024
45025 END IF;
45026
45027 -----------------------------------------------------------------------------------------
45028 -- 4262811 Multiperiod Accounting
45029 -----------------------------------------------------------------------------------------
45030 -- No MPA option is assigned.
45031
45032
45033 END IF;
45034 END IF;
45035 --
45036
45037 --
45038 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45039 trace
45040 (p_msg => 'END of AcctLineType_90'
45041 ,p_level => C_LEVEL_PROCEDURE
45042 ,p_module => l_log_module);
45043 END IF;
45044 --
45045 EXCEPTION
45046 WHEN xla_exceptions_pkg.application_exception THEN
45047 RAISE;
45048 WHEN OTHERS THEN
45049 xla_exceptions_pkg.raise_message
45050 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_90');
45051 END AcctLineType_90;
45052 --
45053
45054 ---------------------------------------
45055 --
45056 -- PRIVATE FUNCTION
45057 -- AcctLineType_91
45058 --
45059 ---------------------------------------
45060 PROCEDURE AcctLineType_91 (
45061 p_application_id IN NUMBER
45062 ,p_event_id IN NUMBER
45063 ,p_calculate_acctd_flag IN VARCHAR2
45064 ,p_calculate_g_l_flag IN VARCHAR2
45065 ,p_actual_flag IN OUT VARCHAR2
45066 ,p_balance_type_code OUT VARCHAR2
45067 ,p_gain_or_loss_ref OUT VARCHAR2
45068
45069 --Distribution GL Account
45070 , p_source_10 IN NUMBER
45071 --Distribution Source Type
45072 , p_source_15 IN VARCHAR2
45073 --Distribution Line Identifier
45074 , p_source_17 IN NUMBER
45075 --Distribution Type
45076 , p_source_18 IN VARCHAR2
45077 --Exchange Date
45078 , p_source_21 IN DATE
45079 --Exchange Rate
45080 , p_source_22 IN NUMBER
45081 --Exchange Rate Type
45082 , p_source_23 IN VARCHAR2
45083 --Transaction Distribution Identifier
45084 , p_source_29 IN NUMBER
45085 --Transaction Distribution Type
45086 , p_source_30 IN VARCHAR2
45090 , p_source_58 IN NUMBER
45087 --Distribution Multi Fund Additional Entry
45088 , p_source_54 IN VARCHAR2
45089 --Receipt Applied To Application Identifier
45091 --Transaction Entity Code
45092 , p_source_59 IN VARCHAR2
45093 --Transaction Identifier
45094 , p_source_60 IN NUMBER
45095 --DIST_ENT_AMT_FROM
45096 , p_source_61 IN NUMBER
45097 --Applying Document Currency Code
45098 , p_source_62 IN VARCHAR2
45099 --Accounting Amount
45100 , p_source_63 IN NUMBER
45101 --Distribution Party Identifier
45102 , p_source_64 IN NUMBER
45103 --Distribution Party Site Id
45104 , p_source_65 IN NUMBER
45105 --Distribution Party Type
45106 , p_source_66 IN VARCHAR2
45107 --Distribution Source Table
45108 , p_source_69 IN VARCHAR2
45109 )
45110 IS
45111
45112 l_component_type VARCHAR2(80);
45113 l_component_code VARCHAR2(30);
45114 l_component_type_code VARCHAR2(1);
45115 l_component_appl_id INTEGER;
45116 l_amb_context_code VARCHAR2(30);
45117 l_entity_code VARCHAR2(30);
45118 l_event_class_code VARCHAR2(30);
45119 l_ae_header_id NUMBER;
45120 l_event_type_code VARCHAR2(30);
45121 l_line_definition_code VARCHAR2(30);
45122 l_line_definition_owner_code VARCHAR2(1);
45123 --
45124 -- adr variables
45125 l_segment VARCHAR2(30);
45126 l_ccid NUMBER;
45127 l_adr_transaction_coa_id NUMBER;
45128 l_adr_accounting_coa_id NUMBER;
45129 l_adr_flexfield_segment_code VARCHAR2(30);
45130 l_adr_flex_value_set_id NUMBER;
45131 l_adr_value_type_code VARCHAR2(30);
45132 l_adr_value_combination_id NUMBER;
45133 l_adr_value_segment_code VARCHAR2(30);
45134
45135 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
45136 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
45137 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
45138 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
45139
45140 -- 4262811 Variables ------------------------------------------------------------------------------------------
45141 l_entered_amt_idx NUMBER;
45142 l_accted_amt_idx NUMBER;
45143 l_acc_rev_flag VARCHAR2(1);
45144 l_accrual_line_num NUMBER;
45145 l_tmp_amt NUMBER;
45146 l_acc_rev_natural_side_code VARCHAR2(1);
45147
45148 l_num_entries NUMBER;
45149 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
45150 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
45151 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
45152 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
45153 l_recog_line_1 NUMBER;
45154 l_recog_line_2 NUMBER;
45155
45156 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
45157 l_bflow_applied_to_amt NUMBER; -- 5132302
45158 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
45159
45160 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
45161
45162 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
45163 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
45164
45165 ---------------------------------------------------------------------------------------------------------------
45166
45167
45168 --
45169 -- bulk performance
45170 --
45171 l_balance_type_code VARCHAR2(1);
45172 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
45173 l_log_module VARCHAR2(240);
45174
45175 --
45176 -- Upgrade strategy
45177 --
45178 l_actual_upg_option VARCHAR2(1);
45179 l_enc_upg_option VARCHAR2(1);
45180
45181 --
45182 BEGIN
45183 --
45184 IF g_log_enabled THEN
45185 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_91';
45186 END IF;
45187 --
45188 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45189
45190 trace
45191 (p_msg => 'BEGIN of AcctLineType_91'
45192 ,p_level => C_LEVEL_PROCEDURE
45193 ,p_module => l_log_module);
45194
45195 END IF;
45196 --
45197 l_component_type := 'AMB_JLT';
45198 l_component_code := 'RCT_FACTOR_BR';
45199 l_component_type_code := 'S';
45200 l_component_appl_id := 222;
45201 l_amb_context_code := 'DEFAULT';
45202 l_entity_code := 'RECEIPTS';
45203 l_event_class_code := 'RECEIPT';
45204 l_event_type_code := 'RECEIPT_ALL';
45205 l_line_definition_owner_code := 'S';
45206 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
45207 --
45208 l_balance_type_code := 'A';
45209 l_segment := NULL;
45210 l_ccid := NULL;
45211 l_adr_transaction_coa_id := NULL;
45212 l_adr_accounting_coa_id := NULL;
45213 l_adr_flexfield_segment_code := NULL;
45214 l_adr_flex_value_set_id := NULL;
45215 l_adr_value_type_code := NULL;
45216 l_adr_value_combination_id := NULL;
45217 l_adr_value_segment_code := NULL;
45218
45219 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
45220 l_bflow_class_code := ''; -- 4219869 Business Flow
45221 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
45222 l_budgetary_control_flag := 'N';
45223
45227 l_accted_amt_idx := NULL; -- 4262811
45224 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45225 l_bflow_applied_to_amt := NULL; -- 5132302
45226 l_entered_amt_idx := NULL; -- 4262811
45228 l_acc_rev_flag := NULL; -- 4262811
45229 l_accrual_line_num := NULL; -- 4262811
45230 l_tmp_amt := NULL; -- 4262811
45231 --
45232
45233 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
45234 l_balance_type_code <> 'B' THEN
45235 IF NVL(p_source_15,'
45236 ') = 'FACTOR' AND
45237 NVL(p_source_69,'
45238 ') = 'RA' AND
45239 NVL(p_source_54,'
45240 ') = 'N'
45241 THEN
45242
45243 --
45244 XLA_AE_LINES_PKG.SetNewLine;
45245
45246 p_balance_type_code := l_balance_type_code;
45247 -- set the flag so later we will know whether the gain loss line needs to be created
45248
45249 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
45250 p_actual_flag :='A';
45251 END IF;
45252
45253 --
45254 -- bulk performance
45255 --
45256 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
45257 p_header_num => 0); -- 4262811
45258 --
45259 -- set accounting line options
45260 --
45261 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
45262 p_natural_side_code => 'C'
45263 , p_gain_or_loss_flag => 'N'
45264 , p_gl_transfer_mode_code => 'S'
45265 , p_acct_entry_type_code => 'A'
45266 , p_switch_side_flag => 'Y'
45267 , p_merge_duplicate_code => 'A'
45268 );
45269 --
45270 l_acc_rev_natural_side_code := 'D'; -- 4262811
45271 --
45272 --
45273 -- set accounting line type info
45274 --
45275 xla_ae_lines_pkg.SetAcctLineType
45276 (p_component_type => l_component_type
45277 ,p_event_type_code => l_event_type_code
45278 ,p_line_definition_owner_code => l_line_definition_owner_code
45279 ,p_line_definition_code => l_line_definition_code
45280 ,p_accounting_line_code => l_component_code
45281 ,p_accounting_line_type_code => l_component_type_code
45282 ,p_accounting_line_appl_id => l_component_appl_id
45283 ,p_amb_context_code => l_amb_context_code
45284 ,p_entity_code => l_entity_code
45285 ,p_event_class_code => l_event_class_code);
45286 --
45287 -- set accounting class
45288 --
45289 xla_ae_lines_pkg.SetAcctClass(
45290 p_accounting_class_code => 'FAC_BR'
45291 , p_ae_header_id => l_ae_header_id
45292 );
45293
45294 --
45295 -- set rounding class
45296 --
45297 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
45298 'RECEIVABLE';
45299
45300 --
45301 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
45302 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
45303 --
45304 -- bulk performance
45305 --
45306 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
45307
45308 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
45309 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
45310
45311 -- 4955764
45312 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45313 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
45314
45315 -- 4458381 Public Sector Enh
45316
45317 --
45318 -- set accounting attributes for the line type
45319 --
45320 l_entered_amt_idx := 8;
45321 l_accted_amt_idx := 13;
45322 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45323 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
45324 l_rec_acct_attrs.array_num_value(1) := p_source_58;
45325 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
45326 l_rec_acct_attrs.array_char_value(2) := p_source_30;
45327 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
45328 l_rec_acct_attrs.array_char_value(3) := p_source_59;
45329 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
45330 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
45331 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
45332 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
45333 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
45334 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
45335 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
45336 l_rec_acct_attrs.array_char_value(7) := p_source_18;
45337 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
45338 l_rec_acct_attrs.array_num_value(8) := p_source_61;
45339 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
45340 l_rec_acct_attrs.array_char_value(9) := p_source_62;
45341 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
45342 l_rec_acct_attrs.array_date_value(10) := p_source_21;
45343 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
45344 l_rec_acct_attrs.array_num_value(11) := p_source_22;
45345 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
45346 l_rec_acct_attrs.array_char_value(12) := p_source_23;
45350 l_rec_acct_attrs.array_num_value(14) := p_source_64;
45347 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
45348 l_rec_acct_attrs.array_num_value(13) := p_source_63;
45349 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
45351 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
45352 l_rec_acct_attrs.array_num_value(15) := p_source_65;
45353 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
45354 l_rec_acct_attrs.array_char_value(16) := p_source_66;
45355
45356 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
45357 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
45358
45359 ---------------------------------------------------------------------------------------------------------------
45360 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
45361 ---------------------------------------------------------------------------------------------------------------
45362 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
45363
45364 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45365 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45366
45367 IF xla_accounting_cache_pkg.GetValueChar
45368 (p_source_code => 'LEDGER_CATEGORY_CODE'
45369 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
45370 AND l_bflow_method_code = 'PRIOR_ENTRY'
45371 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
45372 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
45373 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
45374 )
45375 THEN
45376 xla_ae_lines_pkg.BflowUpgEntry
45377 (p_business_method_code => l_bflow_method_code
45378 ,p_business_class_code => l_bflow_class_code
45379 ,p_balance_type => l_balance_type_code);
45380 ELSE
45381 NULL;
45382 -- No business flow processing for business flow method of NONE.
45383 END IF;
45384
45385 --
45386 -- call analytical criteria
45387 --
45388
45389 --
45390 -- call description
45391 --
45392 -- No description or it is inherited.
45393 --
45394 -- call ADRs
45395 -- Bug 4922099
45396 --
45397 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45398 (NVL(l_actual_upg_option, 'N') = 'O') OR
45399 (NVL(l_enc_upg_option, 'N') = 'O')
45400 )
45401 THEN
45402 NULL;
45403 --
45404 --
45405
45406 l_ccid := AcctDerRule_11(
45407 p_application_id => p_application_id
45408 , p_ae_header_id => l_ae_header_id
45409 , p_source_10 => p_source_10
45410 , x_transaction_coa_id => l_adr_transaction_coa_id
45411 , x_accounting_coa_id => l_adr_accounting_coa_id
45412 , x_value_type_code => l_adr_value_type_code
45413 , p_side => 'NA'
45414 );
45415
45416 xla_ae_lines_pkg.set_ccid(
45417 p_code_combination_id => l_ccid
45418 , p_value_type_code => l_adr_value_type_code
45419 , p_transaction_coa_id => l_adr_transaction_coa_id
45420 , p_accounting_coa_id => l_adr_accounting_coa_id
45421 , p_adr_code => 'DIST_CCID'
45422 , p_adr_type_code => 'S'
45423 , p_component_type => l_component_type
45424 , p_component_code => l_component_code
45425 , p_component_type_code => l_component_type_code
45426 , p_component_appl_id => l_component_appl_id
45427 , p_amb_context_code => l_amb_context_code
45428 , p_side => 'NA'
45429 );
45430
45431
45432 --
45433 --
45434 END IF;
45435 --
45436 -- Bug 4922099
45437 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
45438 (NVL(l_enc_upg_option, 'N') = 'O')
45439 ) AND
45440 (l_bflow_method_code = 'PRIOR_ENTRY')
45441 )
45442 THEN
45443 IF
45444 --
45445 1 = 2
45446 --
45447 THEN
45448 xla_accounting_err_pkg.build_message
45449 (p_appli_s_name => 'XLA'
45450 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45451 ,p_token_1 => 'LINE_NUMBER'
45452 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
45453 ,p_token_2 => 'LINE_TYPE_NAME'
45454 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
45455 l_component_type
45456 ,l_component_code
45457 ,l_component_type_code
45458 ,l_component_appl_id
45459 ,l_amb_context_code
45460 ,l_entity_code
45461 ,l_event_class_code
45462 )
45463 ,p_token_3 => 'OWNER'
45467 )
45464 ,p_value_3 => xla_lookups_pkg.get_meaning(
45465 p_lookup_type => 'XLA_OWNER_TYPE'
45466 ,p_lookup_code => l_component_type_code
45468 ,p_token_4 => 'PRODUCT_NAME'
45469 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
45470 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
45471 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
45472 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
45473 ,p_ae_header_id => NULL
45474 );
45475
45476 IF (C_LEVEL_ERROR>= g_log_level) THEN
45477 trace
45478 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45479 ,p_level => C_LEVEL_ERROR
45480 ,p_module => l_log_module);
45481 END IF;
45482 END IF;
45483 END IF;
45484 --
45485 --
45486 ------------------------------------------------------------------------------------------------
45487 -- 4219869 Business Flow
45488 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
45489 -- Prior Entry. Currently, the following code is always generated.
45490 ------------------------------------------------------------------------------------------------
45491 XLA_AE_LINES_PKG.ValidateCurrentLine;
45492
45493 ------------------------------------------------------------------------------------
45494 -- 4219869 Business Flow
45495 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
45496 ------------------------------------------------------------------------------------
45497 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45498
45499 ----------------------------------------------------------------------------------
45500 -- 4219869 Business Flow
45501 -- Update journal entry status -- Need to generate this within IF <condition>
45502 ----------------------------------------------------------------------------------
45503 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45504 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
45505 ,p_balance_type_code => l_balance_type_code
45506 );
45507
45508 -------------------------------------------------------------------------------------------
45509 -- 4262811 - Generate the Accrual Reversal lines
45510 -------------------------------------------------------------------------------------------
45511 BEGIN
45512 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
45513 (g_array_event(p_event_id).array_value_num('header_index'));
45514 IF l_acc_rev_flag IS NULL THEN
45515 l_acc_rev_flag := 'N';
45516 END IF;
45517 EXCEPTION
45518 WHEN OTHERS THEN
45519 l_acc_rev_flag := 'N';
45520 END;
45521 --
45522 IF (l_acc_rev_flag = 'Y') THEN
45523
45524 -- 4645092 ------------------------------------------------------------------------------
45525 -- To allow MPA report to determine if it should generate report process
45526 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
45527 ------------------------------------------------------------------------------------------
45528
45529 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
45530 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
45531 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
45532 -- call ADRs
45533 -- Bug 4922099
45534 --
45535 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45536 (NVL(l_actual_upg_option, 'N') = 'O') OR
45537 (NVL(l_enc_upg_option, 'N') = 'O')
45538 )
45539 THEN
45540 NULL;
45541 --
45542 --
45543
45544 l_ccid := AcctDerRule_11(
45545 p_application_id => p_application_id
45546 , p_ae_header_id => l_ae_header_id
45547 , p_source_10 => p_source_10
45548 , x_transaction_coa_id => l_adr_transaction_coa_id
45549 , x_accounting_coa_id => l_adr_accounting_coa_id
45550 , x_value_type_code => l_adr_value_type_code
45551 , p_side => 'NA'
45552 );
45553
45554 xla_ae_lines_pkg.set_ccid(
45555 p_code_combination_id => l_ccid
45556 , p_value_type_code => l_adr_value_type_code
45557 , p_transaction_coa_id => l_adr_transaction_coa_id
45558 , p_accounting_coa_id => l_adr_accounting_coa_id
45559 , p_adr_code => 'DIST_CCID'
45560 , p_adr_type_code => 'S'
45561 , p_component_type => l_component_type
45562 , p_component_code => l_component_code
45563 , p_component_type_code => l_component_type_code
45564 , p_component_appl_id => l_component_appl_id
45565 , p_amb_context_code => l_amb_context_code
45566 , p_side => 'NA'
45567 );
45568
45569
45570 --
45571 --
45572 END IF;
45573
45574 --
45575 -- Update the line information that should be overwritten
45576 --
45577 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
45581 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
45578 p_header_num => 1);
45579 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
45580
45582
45583 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
45584 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
45585 END IF;
45586
45587 --
45588 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
45589 --
45590 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
45591 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
45592 ELSE
45593 ---------------------------------------------------------------------------------------------------
45594 -- 4262811a Switch Sign
45595 ---------------------------------------------------------------------------------------------------
45596 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
45597 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45598 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45599 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45600 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45601 -- 5132302
45602 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
45603 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45604
45605 END IF;
45606
45607 -- 4955764
45608 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45609 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
45610
45611
45612 XLA_AE_LINES_PKG.ValidateCurrentLine;
45613 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45614
45615 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45616 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
45617 ,p_balance_type_code => l_balance_type_code);
45618
45619 END IF;
45620
45621 -----------------------------------------------------------------------------------------
45622 -- 4262811 Multiperiod Accounting
45623 -----------------------------------------------------------------------------------------
45624 -- No MPA option is assigned.
45625
45626
45627 END IF;
45628 END IF;
45629 --
45630
45631 --
45632 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45633 trace
45634 (p_msg => 'END of AcctLineType_91'
45635 ,p_level => C_LEVEL_PROCEDURE
45636 ,p_module => l_log_module);
45637 END IF;
45638 --
45639 EXCEPTION
45640 WHEN xla_exceptions_pkg.application_exception THEN
45641 RAISE;
45642 WHEN OTHERS THEN
45643 xla_exceptions_pkg.raise_message
45644 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_91');
45645 END AcctLineType_91;
45646 --
45647
45648 ---------------------------------------
45649 --
45650 -- PRIVATE FUNCTION
45651 -- AcctLineType_92
45652 --
45653 ---------------------------------------
45654 PROCEDURE AcctLineType_92 (
45655 p_application_id IN NUMBER
45656 ,p_event_id IN NUMBER
45657 ,p_calculate_acctd_flag IN VARCHAR2
45658 ,p_calculate_g_l_flag IN VARCHAR2
45659 ,p_actual_flag IN OUT VARCHAR2
45660 ,p_balance_type_code OUT VARCHAR2
45661 ,p_gain_or_loss_ref OUT VARCHAR2
45662
45663 --Distribution GL Account
45664 , p_source_10 IN NUMBER
45665 --Distribution Source Type
45666 , p_source_15 IN VARCHAR2
45667 --Receivable Activity Type
45668 , p_source_16 IN VARCHAR2
45669 --Distribution Line Identifier
45670 , p_source_17 IN NUMBER
45671 --Distribution Type
45672 , p_source_18 IN VARCHAR2
45673 --Exchange Date
45674 , p_source_21 IN DATE
45675 --Exchange Rate
45676 , p_source_22 IN NUMBER
45677 --Exchange Rate Type
45678 , p_source_23 IN VARCHAR2
45679 --Applied To Document Accounting Amount
45680 , p_source_24 IN NUMBER
45681 --Transaction Distribution Identifier
45682 , p_source_29 IN NUMBER
45683 --Transaction Distribution Type
45684 , p_source_30 IN VARCHAR2
45685 --Distribution Multi Fund Additional Entry
45686 , p_source_54 IN VARCHAR2
45687 --Receipt Applied To Application Identifier
45688 , p_source_58 IN NUMBER
45689 --Transaction Entity Code
45690 , p_source_59 IN VARCHAR2
45691 --Transaction Identifier
45692 , p_source_60 IN NUMBER
45693 --DIST_ENT_AMT_FROM
45694 , p_source_61 IN NUMBER
45695 --Applying Document Currency Code
45696 , p_source_62 IN VARCHAR2
45697 --Distribution Party Identifier
45698 , p_source_64 IN NUMBER
45699 --Distribution Party Site Id
45700 , p_source_65 IN NUMBER
45701 --Distribution Party Type
45702 , p_source_66 IN VARCHAR2
45703 )
45704 IS
45705
45706 l_component_type VARCHAR2(80);
45707 l_component_code VARCHAR2(30);
45708 l_component_type_code VARCHAR2(1);
45712 l_event_class_code VARCHAR2(30);
45709 l_component_appl_id INTEGER;
45710 l_amb_context_code VARCHAR2(30);
45711 l_entity_code VARCHAR2(30);
45713 l_ae_header_id NUMBER;
45714 l_event_type_code VARCHAR2(30);
45715 l_line_definition_code VARCHAR2(30);
45716 l_line_definition_owner_code VARCHAR2(1);
45717 --
45718 -- adr variables
45719 l_segment VARCHAR2(30);
45720 l_ccid NUMBER;
45721 l_adr_transaction_coa_id NUMBER;
45722 l_adr_accounting_coa_id NUMBER;
45723 l_adr_flexfield_segment_code VARCHAR2(30);
45724 l_adr_flex_value_set_id NUMBER;
45725 l_adr_value_type_code VARCHAR2(30);
45726 l_adr_value_combination_id NUMBER;
45727 l_adr_value_segment_code VARCHAR2(30);
45728
45729 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
45730 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
45731 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
45732 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
45733
45734 -- 4262811 Variables ------------------------------------------------------------------------------------------
45735 l_entered_amt_idx NUMBER;
45736 l_accted_amt_idx NUMBER;
45737 l_acc_rev_flag VARCHAR2(1);
45738 l_accrual_line_num NUMBER;
45739 l_tmp_amt NUMBER;
45740 l_acc_rev_natural_side_code VARCHAR2(1);
45741
45742 l_num_entries NUMBER;
45743 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
45744 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
45745 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
45746 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
45747 l_recog_line_1 NUMBER;
45748 l_recog_line_2 NUMBER;
45749
45750 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
45751 l_bflow_applied_to_amt NUMBER; -- 5132302
45752 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
45753
45754 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
45755
45756 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
45757 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
45758
45759 ---------------------------------------------------------------------------------------------------------------
45760
45761
45762 --
45763 -- bulk performance
45764 --
45765 l_balance_type_code VARCHAR2(1);
45766 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
45767 l_log_module VARCHAR2(240);
45768
45769 --
45770 -- Upgrade strategy
45771 --
45772 l_actual_upg_option VARCHAR2(1);
45773 l_enc_upg_option VARCHAR2(1);
45774
45775 --
45776 BEGIN
45777 --
45778 IF g_log_enabled THEN
45779 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_92';
45780 END IF;
45781 --
45782 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45783
45784 trace
45785 (p_msg => 'BEGIN of AcctLineType_92'
45786 ,p_level => C_LEVEL_PROCEDURE
45787 ,p_module => l_log_module);
45788
45789 END IF;
45790 --
45791 l_component_type := 'AMB_JLT';
45792 l_component_code := 'RCT_PMT_NET';
45793 l_component_type_code := 'S';
45794 l_component_appl_id := 222;
45795 l_amb_context_code := 'DEFAULT';
45796 l_entity_code := 'RECEIPTS';
45797 l_event_class_code := 'RECEIPT';
45798 l_event_type_code := 'RECEIPT_ALL';
45799 l_line_definition_owner_code := 'S';
45800 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
45801 --
45802 l_balance_type_code := 'A';
45803 l_segment := NULL;
45804 l_ccid := NULL;
45805 l_adr_transaction_coa_id := NULL;
45806 l_adr_accounting_coa_id := NULL;
45807 l_adr_flexfield_segment_code := NULL;
45808 l_adr_flex_value_set_id := NULL;
45809 l_adr_value_type_code := NULL;
45810 l_adr_value_combination_id := NULL;
45811 l_adr_value_segment_code := NULL;
45812
45813 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
45814 l_bflow_class_code := ''; -- 4219869 Business Flow
45815 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
45816 l_budgetary_control_flag := 'N';
45817
45818 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45819 l_bflow_applied_to_amt := NULL; -- 5132302
45820 l_entered_amt_idx := NULL; -- 4262811
45821 l_accted_amt_idx := NULL; -- 4262811
45822 l_acc_rev_flag := NULL; -- 4262811
45823 l_accrual_line_num := NULL; -- 4262811
45824 l_tmp_amt := NULL; -- 4262811
45825 --
45826
45827 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
45828 l_balance_type_code <> 'B' THEN
45829 IF (NVL(p_source_15,'
45830 ') = 'OTHER_ACC' OR
45831 NVL(p_source_15,'
45832 ') = 'ACTIVITY') AND
45833 NVL(p_source_16,'
45834 ') = 'NETTING' AND
45835 NVL(p_source_54,'
45836 ') = 'N'
45837 THEN
45838
45839 --
45840 XLA_AE_LINES_PKG.SetNewLine;
45841
45842 p_balance_type_code := l_balance_type_code;
45843 -- set the flag so later we will know whether the gain loss line needs to be created
45844
45848
45845 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
45846 p_actual_flag :='A';
45847 END IF;
45849 --
45850 -- bulk performance
45851 --
45852 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
45853 p_header_num => 0); -- 4262811
45854 --
45855 -- set accounting line options
45856 --
45857 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
45858 p_natural_side_code => 'C'
45859 , p_gain_or_loss_flag => 'N'
45860 , p_gl_transfer_mode_code => 'S'
45861 , p_acct_entry_type_code => 'A'
45862 , p_switch_side_flag => 'Y'
45863 , p_merge_duplicate_code => 'A'
45864 );
45865 --
45866 l_acc_rev_natural_side_code := 'D'; -- 4262811
45867 --
45868 --
45869 -- set accounting line type info
45870 --
45871 xla_ae_lines_pkg.SetAcctLineType
45872 (p_component_type => l_component_type
45873 ,p_event_type_code => l_event_type_code
45874 ,p_line_definition_owner_code => l_line_definition_owner_code
45875 ,p_line_definition_code => l_line_definition_code
45876 ,p_accounting_line_code => l_component_code
45877 ,p_accounting_line_type_code => l_component_type_code
45878 ,p_accounting_line_appl_id => l_component_appl_id
45879 ,p_amb_context_code => l_amb_context_code
45880 ,p_entity_code => l_entity_code
45881 ,p_event_class_code => l_event_class_code);
45882 --
45883 -- set accounting class
45884 --
45885 xla_ae_lines_pkg.SetAcctClass(
45886 p_accounting_class_code => 'PMT_NET'
45887 , p_ae_header_id => l_ae_header_id
45888 );
45889
45890 --
45891 -- set rounding class
45892 --
45893 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
45894 'RECEIVABLE';
45895
45896 --
45897 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
45898 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
45899 --
45900 -- bulk performance
45901 --
45902 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
45903
45904 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
45905 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
45906
45907 -- 4955764
45908 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45909 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
45910
45911 -- 4458381 Public Sector Enh
45912
45913 --
45914 -- set accounting attributes for the line type
45915 --
45916 l_entered_amt_idx := 8;
45917 l_accted_amt_idx := 13;
45918 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45919 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
45920 l_rec_acct_attrs.array_num_value(1) := p_source_58;
45921 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
45922 l_rec_acct_attrs.array_char_value(2) := p_source_30;
45923 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
45924 l_rec_acct_attrs.array_char_value(3) := p_source_59;
45925 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
45926 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
45927 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
45928 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
45929 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
45930 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
45931 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
45932 l_rec_acct_attrs.array_char_value(7) := p_source_18;
45933 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
45934 l_rec_acct_attrs.array_num_value(8) := p_source_61;
45935 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
45936 l_rec_acct_attrs.array_char_value(9) := p_source_62;
45937 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
45938 l_rec_acct_attrs.array_date_value(10) := p_source_21;
45939 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
45940 l_rec_acct_attrs.array_num_value(11) := p_source_22;
45941 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
45942 l_rec_acct_attrs.array_char_value(12) := p_source_23;
45943 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
45944 l_rec_acct_attrs.array_num_value(13) := p_source_24;
45945 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
45946 l_rec_acct_attrs.array_num_value(14) := p_source_64;
45947 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
45948 l_rec_acct_attrs.array_num_value(15) := p_source_65;
45949 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
45950 l_rec_acct_attrs.array_char_value(16) := p_source_66;
45951
45952 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
45953 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
45954
45955 ---------------------------------------------------------------------------------------------------------------
45956 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
45957 ---------------------------------------------------------------------------------------------------------------
45961 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45958 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
45959
45960 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45962
45963 IF xla_accounting_cache_pkg.GetValueChar
45964 (p_source_code => 'LEDGER_CATEGORY_CODE'
45965 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
45966 AND l_bflow_method_code = 'PRIOR_ENTRY'
45967 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
45968 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
45969 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
45970 )
45971 THEN
45972 xla_ae_lines_pkg.BflowUpgEntry
45973 (p_business_method_code => l_bflow_method_code
45974 ,p_business_class_code => l_bflow_class_code
45975 ,p_balance_type => l_balance_type_code);
45976 ELSE
45977 NULL;
45978 -- No business flow processing for business flow method of NONE.
45979 END IF;
45980
45981 --
45982 -- call analytical criteria
45983 --
45984
45985 --
45986 -- call description
45987 --
45988 -- No description or it is inherited.
45989 --
45990 -- call ADRs
45991 -- Bug 4922099
45992 --
45993 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45994 (NVL(l_actual_upg_option, 'N') = 'O') OR
45995 (NVL(l_enc_upg_option, 'N') = 'O')
45996 )
45997 THEN
45998 NULL;
45999 --
46000 --
46001
46002 l_ccid := AcctDerRule_11(
46003 p_application_id => p_application_id
46004 , p_ae_header_id => l_ae_header_id
46005 , p_source_10 => p_source_10
46006 , x_transaction_coa_id => l_adr_transaction_coa_id
46007 , x_accounting_coa_id => l_adr_accounting_coa_id
46008 , x_value_type_code => l_adr_value_type_code
46009 , p_side => 'NA'
46010 );
46011
46012 xla_ae_lines_pkg.set_ccid(
46013 p_code_combination_id => l_ccid
46014 , p_value_type_code => l_adr_value_type_code
46015 , p_transaction_coa_id => l_adr_transaction_coa_id
46016 , p_accounting_coa_id => l_adr_accounting_coa_id
46017 , p_adr_code => 'DIST_CCID'
46018 , p_adr_type_code => 'S'
46019 , p_component_type => l_component_type
46020 , p_component_code => l_component_code
46021 , p_component_type_code => l_component_type_code
46022 , p_component_appl_id => l_component_appl_id
46023 , p_amb_context_code => l_amb_context_code
46024 , p_side => 'NA'
46025 );
46026
46027
46028 --
46029 --
46030 END IF;
46031 --
46032 -- Bug 4922099
46033 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
46034 (NVL(l_enc_upg_option, 'N') = 'O')
46035 ) AND
46036 (l_bflow_method_code = 'PRIOR_ENTRY')
46037 )
46038 THEN
46039 IF
46040 --
46041 1 = 2
46042 --
46043 THEN
46044 xla_accounting_err_pkg.build_message
46045 (p_appli_s_name => 'XLA'
46046 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46047 ,p_token_1 => 'LINE_NUMBER'
46048 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
46049 ,p_token_2 => 'LINE_TYPE_NAME'
46050 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
46051 l_component_type
46052 ,l_component_code
46053 ,l_component_type_code
46054 ,l_component_appl_id
46055 ,l_amb_context_code
46056 ,l_entity_code
46057 ,l_event_class_code
46058 )
46059 ,p_token_3 => 'OWNER'
46060 ,p_value_3 => xla_lookups_pkg.get_meaning(
46061 p_lookup_type => 'XLA_OWNER_TYPE'
46062 ,p_lookup_code => l_component_type_code
46063 )
46064 ,p_token_4 => 'PRODUCT_NAME'
46065 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
46066 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
46067 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
46068 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
46069 ,p_ae_header_id => NULL
46070 );
46071
46075 ,p_level => C_LEVEL_ERROR
46072 IF (C_LEVEL_ERROR>= g_log_level) THEN
46073 trace
46074 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46076 ,p_module => l_log_module);
46077 END IF;
46078 END IF;
46079 END IF;
46080 --
46081 --
46082 ------------------------------------------------------------------------------------------------
46083 -- 4219869 Business Flow
46084 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
46085 -- Prior Entry. Currently, the following code is always generated.
46086 ------------------------------------------------------------------------------------------------
46087 XLA_AE_LINES_PKG.ValidateCurrentLine;
46088
46089 ------------------------------------------------------------------------------------
46090 -- 4219869 Business Flow
46091 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
46092 ------------------------------------------------------------------------------------
46093 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46094
46095 ----------------------------------------------------------------------------------
46096 -- 4219869 Business Flow
46097 -- Update journal entry status -- Need to generate this within IF <condition>
46098 ----------------------------------------------------------------------------------
46099 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46100 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
46101 ,p_balance_type_code => l_balance_type_code
46102 );
46103
46104 -------------------------------------------------------------------------------------------
46105 -- 4262811 - Generate the Accrual Reversal lines
46106 -------------------------------------------------------------------------------------------
46107 BEGIN
46108 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
46109 (g_array_event(p_event_id).array_value_num('header_index'));
46110 IF l_acc_rev_flag IS NULL THEN
46111 l_acc_rev_flag := 'N';
46112 END IF;
46113 EXCEPTION
46114 WHEN OTHERS THEN
46115 l_acc_rev_flag := 'N';
46116 END;
46117 --
46118 IF (l_acc_rev_flag = 'Y') THEN
46119
46120 -- 4645092 ------------------------------------------------------------------------------
46121 -- To allow MPA report to determine if it should generate report process
46122 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
46123 ------------------------------------------------------------------------------------------
46124
46125 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
46126 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
46127 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
46128 -- call ADRs
46129 -- Bug 4922099
46130 --
46131 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46132 (NVL(l_actual_upg_option, 'N') = 'O') OR
46133 (NVL(l_enc_upg_option, 'N') = 'O')
46134 )
46135 THEN
46136 NULL;
46137 --
46138 --
46139
46140 l_ccid := AcctDerRule_11(
46141 p_application_id => p_application_id
46142 , p_ae_header_id => l_ae_header_id
46143 , p_source_10 => p_source_10
46144 , x_transaction_coa_id => l_adr_transaction_coa_id
46145 , x_accounting_coa_id => l_adr_accounting_coa_id
46146 , x_value_type_code => l_adr_value_type_code
46147 , p_side => 'NA'
46148 );
46149
46150 xla_ae_lines_pkg.set_ccid(
46151 p_code_combination_id => l_ccid
46152 , p_value_type_code => l_adr_value_type_code
46153 , p_transaction_coa_id => l_adr_transaction_coa_id
46154 , p_accounting_coa_id => l_adr_accounting_coa_id
46155 , p_adr_code => 'DIST_CCID'
46156 , p_adr_type_code => 'S'
46157 , p_component_type => l_component_type
46158 , p_component_code => l_component_code
46159 , p_component_type_code => l_component_type_code
46160 , p_component_appl_id => l_component_appl_id
46161 , p_amb_context_code => l_amb_context_code
46162 , p_side => 'NA'
46163 );
46164
46165
46166 --
46167 --
46168 END IF;
46169
46170 --
46171 -- Update the line information that should be overwritten
46172 --
46173 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
46174 p_header_num => 1);
46175 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
46176
46177 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
46178
46179 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
46180 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
46181 END IF;
46182
46183 --
46184 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
46185 --
46186 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
46187 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
46188 ELSE
46189 ---------------------------------------------------------------------------------------------------
46193 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46190 -- 4262811a Switch Sign
46191 ---------------------------------------------------------------------------------------------------
46192 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
46194 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46195 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46196 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46197 -- 5132302
46198 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
46199 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46200
46201 END IF;
46202
46203 -- 4955764
46204 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46205 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
46206
46207
46208 XLA_AE_LINES_PKG.ValidateCurrentLine;
46209 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46210
46211 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46212 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
46213 ,p_balance_type_code => l_balance_type_code);
46214
46215 END IF;
46216
46217 -----------------------------------------------------------------------------------------
46218 -- 4262811 Multiperiod Accounting
46219 -----------------------------------------------------------------------------------------
46220 -- No MPA option is assigned.
46221
46222
46223 END IF;
46224 END IF;
46225 --
46226
46227 --
46228 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46229 trace
46230 (p_msg => 'END of AcctLineType_92'
46231 ,p_level => C_LEVEL_PROCEDURE
46232 ,p_module => l_log_module);
46233 END IF;
46234 --
46235 EXCEPTION
46236 WHEN xla_exceptions_pkg.application_exception THEN
46237 RAISE;
46238 WHEN OTHERS THEN
46239 xla_exceptions_pkg.raise_message
46240 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_92');
46241 END AcctLineType_92;
46242 --
46243
46244 ---------------------------------------
46245 --
46246 -- PRIVATE FUNCTION
46247 -- AcctLineType_93
46248 --
46249 ---------------------------------------
46250 PROCEDURE AcctLineType_93 (
46251 p_application_id IN NUMBER
46252 ,p_event_id IN NUMBER
46253 ,p_calculate_acctd_flag IN VARCHAR2
46254 ,p_calculate_g_l_flag IN VARCHAR2
46255 ,p_actual_flag IN OUT VARCHAR2
46256 ,p_balance_type_code OUT VARCHAR2
46257 ,p_gain_or_loss_ref OUT VARCHAR2
46258
46259 --Distribution GL Account
46260 , p_source_10 IN NUMBER
46261 --Distribution Source Type
46262 , p_source_15 IN VARCHAR2
46263 --Receivable Activity Type
46264 , p_source_16 IN VARCHAR2
46265 --Distribution Line Identifier
46266 , p_source_17 IN NUMBER
46267 --Distribution Type
46268 , p_source_18 IN VARCHAR2
46269 --Exchange Date
46270 , p_source_21 IN DATE
46271 --Exchange Rate
46272 , p_source_22 IN NUMBER
46273 --Exchange Rate Type
46274 , p_source_23 IN VARCHAR2
46275 --Transaction Distribution Identifier
46276 , p_source_29 IN NUMBER
46277 --Transaction Distribution Type
46278 , p_source_30 IN VARCHAR2
46279 --Distribution Multi Fund Additional Entry
46280 , p_source_54 IN VARCHAR2
46281 --Receipt Applied To Application Identifier
46282 , p_source_58 IN NUMBER
46283 --Transaction Entity Code
46284 , p_source_59 IN VARCHAR2
46285 --Transaction Identifier
46286 , p_source_60 IN NUMBER
46287 --DIST_ENT_AMT_FROM
46288 , p_source_61 IN NUMBER
46289 --Applying Document Currency Code
46290 , p_source_62 IN VARCHAR2
46291 --Accounting Amount
46292 , p_source_63 IN NUMBER
46293 --Distribution Party Identifier
46294 , p_source_64 IN NUMBER
46295 --Distribution Party Site Id
46296 , p_source_65 IN NUMBER
46297 --Distribution Party Type
46298 , p_source_66 IN VARCHAR2
46299 )
46300 IS
46301
46302 l_component_type VARCHAR2(80);
46303 l_component_code VARCHAR2(30);
46304 l_component_type_code VARCHAR2(1);
46305 l_component_appl_id INTEGER;
46306 l_amb_context_code VARCHAR2(30);
46307 l_entity_code VARCHAR2(30);
46308 l_event_class_code VARCHAR2(30);
46309 l_ae_header_id NUMBER;
46310 l_event_type_code VARCHAR2(30);
46311 l_line_definition_code VARCHAR2(30);
46312 l_line_definition_owner_code VARCHAR2(1);
46313 --
46314 -- adr variables
46315 l_segment VARCHAR2(30);
46316 l_ccid NUMBER;
46317 l_adr_transaction_coa_id NUMBER;
46318 l_adr_accounting_coa_id NUMBER;
46319 l_adr_flexfield_segment_code VARCHAR2(30);
46320 l_adr_flex_value_set_id NUMBER;
46321 l_adr_value_type_code VARCHAR2(30);
46322 l_adr_value_combination_id NUMBER;
46323 l_adr_value_segment_code VARCHAR2(30);
46324
46325 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
46326 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
46330 -- 4262811 Variables ------------------------------------------------------------------------------------------
46327 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
46328 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
46329
46331 l_entered_amt_idx NUMBER;
46332 l_accted_amt_idx NUMBER;
46333 l_acc_rev_flag VARCHAR2(1);
46334 l_accrual_line_num NUMBER;
46335 l_tmp_amt NUMBER;
46336 l_acc_rev_natural_side_code VARCHAR2(1);
46337
46338 l_num_entries NUMBER;
46339 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
46340 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
46341 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
46342 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
46343 l_recog_line_1 NUMBER;
46344 l_recog_line_2 NUMBER;
46345
46346 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
46347 l_bflow_applied_to_amt NUMBER; -- 5132302
46348 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
46349
46350 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
46351
46352 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
46353 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
46354
46355 ---------------------------------------------------------------------------------------------------------------
46356
46357
46358 --
46359 -- bulk performance
46360 --
46361 l_balance_type_code VARCHAR2(1);
46362 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
46363 l_log_module VARCHAR2(240);
46364
46365 --
46366 -- Upgrade strategy
46367 --
46368 l_actual_upg_option VARCHAR2(1);
46369 l_enc_upg_option VARCHAR2(1);
46370
46371 --
46372 BEGIN
46373 --
46374 IF g_log_enabled THEN
46375 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_93';
46376 END IF;
46377 --
46378 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46379
46380 trace
46381 (p_msg => 'BEGIN of AcctLineType_93'
46382 ,p_level => C_LEVEL_PROCEDURE
46383 ,p_module => l_log_module);
46384
46385 END IF;
46386 --
46387 l_component_type := 'AMB_JLT';
46388 l_component_code := 'RCT_PREPAYMENT';
46389 l_component_type_code := 'S';
46390 l_component_appl_id := 222;
46391 l_amb_context_code := 'DEFAULT';
46392 l_entity_code := 'RECEIPTS';
46393 l_event_class_code := 'RECEIPT';
46394 l_event_type_code := 'RECEIPT_ALL';
46395 l_line_definition_owner_code := 'S';
46396 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
46397 --
46398 l_balance_type_code := 'A';
46399 l_segment := NULL;
46400 l_ccid := NULL;
46401 l_adr_transaction_coa_id := NULL;
46402 l_adr_accounting_coa_id := NULL;
46403 l_adr_flexfield_segment_code := NULL;
46404 l_adr_flex_value_set_id := NULL;
46405 l_adr_value_type_code := NULL;
46406 l_adr_value_combination_id := NULL;
46407 l_adr_value_segment_code := NULL;
46408
46409 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
46410 l_bflow_class_code := ''; -- 4219869 Business Flow
46411 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
46412 l_budgetary_control_flag := 'N';
46413
46414 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46415 l_bflow_applied_to_amt := NULL; -- 5132302
46416 l_entered_amt_idx := NULL; -- 4262811
46417 l_accted_amt_idx := NULL; -- 4262811
46418 l_acc_rev_flag := NULL; -- 4262811
46419 l_accrual_line_num := NULL; -- 4262811
46420 l_tmp_amt := NULL; -- 4262811
46421 --
46422
46423 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
46424 l_balance_type_code <> 'B' THEN
46425 IF NVL(p_source_15,'
46426 ') = 'OTHER ACC' AND
46427 NVL(p_source_16,'
46428 ') = 'PREPAYMENT' AND
46429 NVL(p_source_54,'
46430 ') = 'N'
46431 THEN
46432
46433 --
46434 XLA_AE_LINES_PKG.SetNewLine;
46435
46436 p_balance_type_code := l_balance_type_code;
46437 -- set the flag so later we will know whether the gain loss line needs to be created
46438
46439 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
46440 p_actual_flag :='A';
46441 END IF;
46442
46443 --
46444 -- bulk performance
46445 --
46446 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
46447 p_header_num => 0); -- 4262811
46448 --
46449 -- set accounting line options
46450 --
46451 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
46452 p_natural_side_code => 'C'
46453 , p_gain_or_loss_flag => 'N'
46454 , p_gl_transfer_mode_code => 'S'
46455 , p_acct_entry_type_code => 'A'
46456 , p_switch_side_flag => 'Y'
46457 , p_merge_duplicate_code => 'A'
46458 );
46459 --
46460 l_acc_rev_natural_side_code := 'D'; -- 4262811
46461 --
46462 --
46463 -- set accounting line type info
46464 --
46465 xla_ae_lines_pkg.SetAcctLineType
46466 (p_component_type => l_component_type
46470 ,p_accounting_line_code => l_component_code
46467 ,p_event_type_code => l_event_type_code
46468 ,p_line_definition_owner_code => l_line_definition_owner_code
46469 ,p_line_definition_code => l_line_definition_code
46471 ,p_accounting_line_type_code => l_component_type_code
46472 ,p_accounting_line_appl_id => l_component_appl_id
46473 ,p_amb_context_code => l_amb_context_code
46474 ,p_entity_code => l_entity_code
46475 ,p_event_class_code => l_event_class_code);
46476 --
46477 -- set accounting class
46478 --
46479 xla_ae_lines_pkg.SetAcctClass(
46480 p_accounting_class_code => 'PREPAY'
46481 , p_ae_header_id => l_ae_header_id
46482 );
46483
46484 --
46485 -- set rounding class
46486 --
46487 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
46488 'RECEIVABLE';
46489
46490 --
46491 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
46492 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
46493 --
46494 -- bulk performance
46495 --
46496 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
46497
46498 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
46499 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
46500
46501 -- 4955764
46502 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46503 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
46504
46505 -- 4458381 Public Sector Enh
46506
46507 --
46508 -- set accounting attributes for the line type
46509 --
46510 l_entered_amt_idx := 8;
46511 l_accted_amt_idx := 13;
46512 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46513 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
46514 l_rec_acct_attrs.array_num_value(1) := p_source_58;
46515 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
46516 l_rec_acct_attrs.array_char_value(2) := p_source_30;
46517 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
46518 l_rec_acct_attrs.array_char_value(3) := p_source_59;
46519 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
46520 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
46521 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
46522 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
46523 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
46524 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
46525 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
46526 l_rec_acct_attrs.array_char_value(7) := p_source_18;
46527 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
46528 l_rec_acct_attrs.array_num_value(8) := p_source_61;
46529 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
46530 l_rec_acct_attrs.array_char_value(9) := p_source_62;
46531 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
46532 l_rec_acct_attrs.array_date_value(10) := p_source_21;
46533 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
46534 l_rec_acct_attrs.array_num_value(11) := p_source_22;
46535 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
46536 l_rec_acct_attrs.array_char_value(12) := p_source_23;
46537 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
46538 l_rec_acct_attrs.array_num_value(13) := p_source_63;
46539 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
46540 l_rec_acct_attrs.array_num_value(14) := p_source_64;
46541 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
46542 l_rec_acct_attrs.array_num_value(15) := p_source_65;
46543 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
46544 l_rec_acct_attrs.array_char_value(16) := p_source_66;
46545
46546 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
46547 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
46548
46549 ---------------------------------------------------------------------------------------------------------------
46550 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
46551 ---------------------------------------------------------------------------------------------------------------
46552 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
46553
46554 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46555 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46556
46557 IF xla_accounting_cache_pkg.GetValueChar
46558 (p_source_code => 'LEDGER_CATEGORY_CODE'
46559 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
46560 AND l_bflow_method_code = 'PRIOR_ENTRY'
46561 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
46562 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
46563 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
46564 )
46565 THEN
46566 xla_ae_lines_pkg.BflowUpgEntry
46567 (p_business_method_code => l_bflow_method_code
46568 ,p_business_class_code => l_bflow_class_code
46569 ,p_balance_type => l_balance_type_code);
46570 ELSE
46571 NULL;
46575 --
46572 -- No business flow processing for business flow method of NONE.
46573 END IF;
46574
46576 -- call analytical criteria
46577 --
46578
46579 --
46580 -- call description
46581 --
46582 -- No description or it is inherited.
46583 --
46584 -- call ADRs
46585 -- Bug 4922099
46586 --
46587 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46588 (NVL(l_actual_upg_option, 'N') = 'O') OR
46589 (NVL(l_enc_upg_option, 'N') = 'O')
46590 )
46591 THEN
46592 NULL;
46593 --
46594 --
46595
46596 l_ccid := AcctDerRule_11(
46597 p_application_id => p_application_id
46598 , p_ae_header_id => l_ae_header_id
46599 , p_source_10 => p_source_10
46600 , x_transaction_coa_id => l_adr_transaction_coa_id
46601 , x_accounting_coa_id => l_adr_accounting_coa_id
46602 , x_value_type_code => l_adr_value_type_code
46603 , p_side => 'NA'
46604 );
46605
46606 xla_ae_lines_pkg.set_ccid(
46607 p_code_combination_id => l_ccid
46608 , p_value_type_code => l_adr_value_type_code
46609 , p_transaction_coa_id => l_adr_transaction_coa_id
46610 , p_accounting_coa_id => l_adr_accounting_coa_id
46611 , p_adr_code => 'DIST_CCID'
46612 , p_adr_type_code => 'S'
46613 , p_component_type => l_component_type
46614 , p_component_code => l_component_code
46615 , p_component_type_code => l_component_type_code
46616 , p_component_appl_id => l_component_appl_id
46617 , p_amb_context_code => l_amb_context_code
46618 , p_side => 'NA'
46619 );
46620
46621
46622 --
46623 --
46624 END IF;
46625 --
46626 -- Bug 4922099
46627 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
46628 (NVL(l_enc_upg_option, 'N') = 'O')
46629 ) AND
46630 (l_bflow_method_code = 'PRIOR_ENTRY')
46631 )
46632 THEN
46633 IF
46634 --
46635 1 = 2
46636 --
46637 THEN
46638 xla_accounting_err_pkg.build_message
46639 (p_appli_s_name => 'XLA'
46640 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46641 ,p_token_1 => 'LINE_NUMBER'
46642 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
46643 ,p_token_2 => 'LINE_TYPE_NAME'
46644 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
46645 l_component_type
46646 ,l_component_code
46647 ,l_component_type_code
46648 ,l_component_appl_id
46649 ,l_amb_context_code
46650 ,l_entity_code
46651 ,l_event_class_code
46652 )
46653 ,p_token_3 => 'OWNER'
46654 ,p_value_3 => xla_lookups_pkg.get_meaning(
46655 p_lookup_type => 'XLA_OWNER_TYPE'
46656 ,p_lookup_code => l_component_type_code
46657 )
46658 ,p_token_4 => 'PRODUCT_NAME'
46659 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
46660 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
46661 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
46662 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
46663 ,p_ae_header_id => NULL
46664 );
46665
46666 IF (C_LEVEL_ERROR>= g_log_level) THEN
46667 trace
46668 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46669 ,p_level => C_LEVEL_ERROR
46670 ,p_module => l_log_module);
46671 END IF;
46672 END IF;
46673 END IF;
46674 --
46675 --
46676 ------------------------------------------------------------------------------------------------
46677 -- 4219869 Business Flow
46678 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
46679 -- Prior Entry. Currently, the following code is always generated.
46680 ------------------------------------------------------------------------------------------------
46681 XLA_AE_LINES_PKG.ValidateCurrentLine;
46682
46683 ------------------------------------------------------------------------------------
46684 -- 4219869 Business Flow
46685 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
46686 ------------------------------------------------------------------------------------
46690 -- 4219869 Business Flow
46687 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46688
46689 ----------------------------------------------------------------------------------
46691 -- Update journal entry status -- Need to generate this within IF <condition>
46692 ----------------------------------------------------------------------------------
46693 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46694 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
46695 ,p_balance_type_code => l_balance_type_code
46696 );
46697
46698 -------------------------------------------------------------------------------------------
46699 -- 4262811 - Generate the Accrual Reversal lines
46700 -------------------------------------------------------------------------------------------
46701 BEGIN
46702 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
46703 (g_array_event(p_event_id).array_value_num('header_index'));
46704 IF l_acc_rev_flag IS NULL THEN
46705 l_acc_rev_flag := 'N';
46706 END IF;
46707 EXCEPTION
46708 WHEN OTHERS THEN
46709 l_acc_rev_flag := 'N';
46710 END;
46711 --
46712 IF (l_acc_rev_flag = 'Y') THEN
46713
46714 -- 4645092 ------------------------------------------------------------------------------
46715 -- To allow MPA report to determine if it should generate report process
46716 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
46717 ------------------------------------------------------------------------------------------
46718
46719 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
46720 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
46721 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
46722 -- call ADRs
46723 -- Bug 4922099
46724 --
46725 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46726 (NVL(l_actual_upg_option, 'N') = 'O') OR
46727 (NVL(l_enc_upg_option, 'N') = 'O')
46728 )
46729 THEN
46730 NULL;
46731 --
46732 --
46733
46734 l_ccid := AcctDerRule_11(
46735 p_application_id => p_application_id
46736 , p_ae_header_id => l_ae_header_id
46737 , p_source_10 => p_source_10
46738 , x_transaction_coa_id => l_adr_transaction_coa_id
46739 , x_accounting_coa_id => l_adr_accounting_coa_id
46740 , x_value_type_code => l_adr_value_type_code
46741 , p_side => 'NA'
46742 );
46743
46744 xla_ae_lines_pkg.set_ccid(
46745 p_code_combination_id => l_ccid
46746 , p_value_type_code => l_adr_value_type_code
46747 , p_transaction_coa_id => l_adr_transaction_coa_id
46748 , p_accounting_coa_id => l_adr_accounting_coa_id
46749 , p_adr_code => 'DIST_CCID'
46750 , p_adr_type_code => 'S'
46751 , p_component_type => l_component_type
46752 , p_component_code => l_component_code
46753 , p_component_type_code => l_component_type_code
46754 , p_component_appl_id => l_component_appl_id
46755 , p_amb_context_code => l_amb_context_code
46756 , p_side => 'NA'
46757 );
46758
46759
46760 --
46761 --
46762 END IF;
46763
46764 --
46765 -- Update the line information that should be overwritten
46766 --
46767 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
46768 p_header_num => 1);
46769 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
46770
46771 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
46772
46773 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
46774 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
46775 END IF;
46776
46777 --
46778 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
46779 --
46780 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
46781 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
46782 ELSE
46783 ---------------------------------------------------------------------------------------------------
46784 -- 4262811a Switch Sign
46785 ---------------------------------------------------------------------------------------------------
46786 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
46787 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46788 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46789 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46790 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46791 -- 5132302
46792 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
46793 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46794
46795 END IF;
46796
46797 -- 4955764
46798 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46799 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
46800
46801
46805 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46802 XLA_AE_LINES_PKG.ValidateCurrentLine;
46803 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46804
46806 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
46807 ,p_balance_type_code => l_balance_type_code);
46808
46809 END IF;
46810
46811 -----------------------------------------------------------------------------------------
46812 -- 4262811 Multiperiod Accounting
46813 -----------------------------------------------------------------------------------------
46814 -- No MPA option is assigned.
46815
46816
46817 END IF;
46818 END IF;
46819 --
46820
46821 --
46822 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46823 trace
46824 (p_msg => 'END of AcctLineType_93'
46825 ,p_level => C_LEVEL_PROCEDURE
46826 ,p_module => l_log_module);
46827 END IF;
46828 --
46829 EXCEPTION
46830 WHEN xla_exceptions_pkg.application_exception THEN
46831 RAISE;
46832 WHEN OTHERS THEN
46833 xla_exceptions_pkg.raise_message
46834 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_93');
46835 END AcctLineType_93;
46836 --
46837
46838 ---------------------------------------
46839 --
46840 -- PRIVATE FUNCTION
46841 -- AcctLineType_94
46842 --
46843 ---------------------------------------
46844 PROCEDURE AcctLineType_94 (
46845 p_application_id IN NUMBER
46846 ,p_event_id IN NUMBER
46847 ,p_calculate_acctd_flag IN VARCHAR2
46848 ,p_calculate_g_l_flag IN VARCHAR2
46849 ,p_actual_flag IN OUT VARCHAR2
46850 ,p_balance_type_code OUT VARCHAR2
46851 ,p_gain_or_loss_ref OUT VARCHAR2
46852
46853 --Distribution GL Account
46854 , p_source_10 IN NUMBER
46855 --Distribution Source Type
46856 , p_source_15 IN VARCHAR2
46857 --Receivable Activity Type
46858 , p_source_16 IN VARCHAR2
46859 --Distribution Line Identifier
46860 , p_source_17 IN NUMBER
46861 --Distribution Type
46862 , p_source_18 IN VARCHAR2
46863 --Exchange Date
46864 , p_source_21 IN DATE
46865 --Exchange Rate
46866 , p_source_22 IN NUMBER
46867 --Exchange Rate Type
46868 , p_source_23 IN VARCHAR2
46869 --Transaction Distribution Identifier
46870 , p_source_29 IN NUMBER
46871 --Transaction Distribution Type
46872 , p_source_30 IN VARCHAR2
46873 --Distribution Multi Fund Additional Entry
46874 , p_source_54 IN VARCHAR2
46875 --Receipt Applied To Application Identifier
46876 , p_source_58 IN NUMBER
46877 --Transaction Entity Code
46878 , p_source_59 IN VARCHAR2
46879 --Transaction Identifier
46880 , p_source_60 IN NUMBER
46881 --DIST_ENT_AMT_FROM
46882 , p_source_61 IN NUMBER
46883 --Applying Document Currency Code
46884 , p_source_62 IN VARCHAR2
46885 --Accounting Amount
46886 , p_source_63 IN NUMBER
46887 --Distribution Party Identifier
46888 , p_source_64 IN NUMBER
46889 --Distribution Party Site Id
46890 , p_source_65 IN NUMBER
46891 --Distribution Party Type
46892 , p_source_66 IN VARCHAR2
46893 )
46894 IS
46895
46896 l_component_type VARCHAR2(80);
46897 l_component_code VARCHAR2(30);
46898 l_component_type_code VARCHAR2(1);
46899 l_component_appl_id INTEGER;
46900 l_amb_context_code VARCHAR2(30);
46901 l_entity_code VARCHAR2(30);
46902 l_event_class_code VARCHAR2(30);
46903 l_ae_header_id NUMBER;
46904 l_event_type_code VARCHAR2(30);
46905 l_line_definition_code VARCHAR2(30);
46906 l_line_definition_owner_code VARCHAR2(1);
46907 --
46908 -- adr variables
46909 l_segment VARCHAR2(30);
46910 l_ccid NUMBER;
46911 l_adr_transaction_coa_id NUMBER;
46912 l_adr_accounting_coa_id NUMBER;
46913 l_adr_flexfield_segment_code VARCHAR2(30);
46914 l_adr_flex_value_set_id NUMBER;
46915 l_adr_value_type_code VARCHAR2(30);
46916 l_adr_value_combination_id NUMBER;
46917 l_adr_value_segment_code VARCHAR2(30);
46918
46919 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
46920 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
46921 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
46922 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
46923
46924 -- 4262811 Variables ------------------------------------------------------------------------------------------
46925 l_entered_amt_idx NUMBER;
46926 l_accted_amt_idx NUMBER;
46927 l_acc_rev_flag VARCHAR2(1);
46928 l_accrual_line_num NUMBER;
46929 l_tmp_amt NUMBER;
46930 l_acc_rev_natural_side_code VARCHAR2(1);
46931
46932 l_num_entries NUMBER;
46933 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
46934 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
46935 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
46936 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
46937 l_recog_line_1 NUMBER;
46938 l_recog_line_2 NUMBER;
46939
46943
46940 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
46941 l_bflow_applied_to_amt NUMBER; -- 5132302
46942 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
46944 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
46945
46946 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
46947 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
46948
46949 ---------------------------------------------------------------------------------------------------------------
46950
46951
46952 --
46953 -- bulk performance
46954 --
46955 l_balance_type_code VARCHAR2(1);
46956 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
46957 l_log_module VARCHAR2(240);
46958
46959 --
46960 -- Upgrade strategy
46961 --
46962 l_actual_upg_option VARCHAR2(1);
46963 l_enc_upg_option VARCHAR2(1);
46964
46965 --
46966 BEGIN
46967 --
46968 IF g_log_enabled THEN
46969 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_94';
46970 END IF;
46971 --
46972 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46973
46974 trace
46975 (p_msg => 'BEGIN of AcctLineType_94'
46976 ,p_level => C_LEVEL_PROCEDURE
46977 ,p_module => l_log_module);
46978
46979 END IF;
46980 --
46981 l_component_type := 'AMB_JLT';
46982 l_component_code := 'RCT_REFUND';
46983 l_component_type_code := 'S';
46984 l_component_appl_id := 222;
46985 l_amb_context_code := 'DEFAULT';
46986 l_entity_code := 'RECEIPTS';
46987 l_event_class_code := 'RECEIPT';
46988 l_event_type_code := 'RECEIPT_ALL';
46989 l_line_definition_owner_code := 'S';
46990 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
46991 --
46992 l_balance_type_code := 'A';
46993 l_segment := NULL;
46994 l_ccid := NULL;
46995 l_adr_transaction_coa_id := NULL;
46996 l_adr_accounting_coa_id := NULL;
46997 l_adr_flexfield_segment_code := NULL;
46998 l_adr_flex_value_set_id := NULL;
46999 l_adr_value_type_code := NULL;
47000 l_adr_value_combination_id := NULL;
47001 l_adr_value_segment_code := NULL;
47002
47003 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
47004 l_bflow_class_code := ''; -- 4219869 Business Flow
47005 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
47006 l_budgetary_control_flag := 'N';
47007
47008 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47009 l_bflow_applied_to_amt := NULL; -- 5132302
47010 l_entered_amt_idx := NULL; -- 4262811
47011 l_accted_amt_idx := NULL; -- 4262811
47012 l_acc_rev_flag := NULL; -- 4262811
47013 l_accrual_line_num := NULL; -- 4262811
47014 l_tmp_amt := NULL; -- 4262811
47015 --
47016
47017 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
47018 l_balance_type_code <> 'B' THEN
47019 IF (NVL(p_source_15,'
47020 ') = 'ACTIVITY' AND
47021 NVL(p_source_16,'
47022 ') = 'CCREFUND' AND
47023 NVL(p_source_54,'
47024 ') = 'N') OR
47025 (NVL(p_source_15,'
47026 ') = 'ACTIVITY' AND
47027 NVL(p_source_16,'
47028 ') = 'CM_REFUND' AND
47029 NVL(p_source_54,'
47030 ') = 'N')
47031 THEN
47032
47033 --
47034 XLA_AE_LINES_PKG.SetNewLine;
47035
47036 p_balance_type_code := l_balance_type_code;
47037 -- set the flag so later we will know whether the gain loss line needs to be created
47038
47039 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
47040 p_actual_flag :='A';
47041 END IF;
47042
47043 --
47044 -- bulk performance
47045 --
47046 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
47047 p_header_num => 0); -- 4262811
47048 --
47049 -- set accounting line options
47050 --
47051 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
47052 p_natural_side_code => 'C'
47053 , p_gain_or_loss_flag => 'N'
47054 , p_gl_transfer_mode_code => 'S'
47055 , p_acct_entry_type_code => 'A'
47056 , p_switch_side_flag => 'Y'
47057 , p_merge_duplicate_code => 'A'
47058 );
47059 --
47060 l_acc_rev_natural_side_code := 'D'; -- 4262811
47061 --
47062 --
47063 -- set accounting line type info
47064 --
47065 xla_ae_lines_pkg.SetAcctLineType
47066 (p_component_type => l_component_type
47067 ,p_event_type_code => l_event_type_code
47068 ,p_line_definition_owner_code => l_line_definition_owner_code
47069 ,p_line_definition_code => l_line_definition_code
47070 ,p_accounting_line_code => l_component_code
47071 ,p_accounting_line_type_code => l_component_type_code
47072 ,p_accounting_line_appl_id => l_component_appl_id
47073 ,p_amb_context_code => l_amb_context_code
47074 ,p_entity_code => l_entity_code
47075 ,p_event_class_code => l_event_class_code);
47076 --
47077 -- set accounting class
47078 --
47079 xla_ae_lines_pkg.SetAcctClass(
47080 p_accounting_class_code => 'REFUND'
47081 , p_ae_header_id => l_ae_header_id
47082 );
47086 --
47083
47084 --
47085 -- set rounding class
47087 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
47088 'RECEIVABLE';
47089
47090 --
47091 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
47092 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
47093 --
47094 -- bulk performance
47095 --
47096 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
47097
47098 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
47099 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
47100
47101 -- 4955764
47102 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47103 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
47104
47105 -- 4458381 Public Sector Enh
47106
47107 --
47108 -- set accounting attributes for the line type
47109 --
47110 l_entered_amt_idx := 8;
47111 l_accted_amt_idx := 13;
47112 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47113 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
47114 l_rec_acct_attrs.array_num_value(1) := p_source_58;
47115 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
47116 l_rec_acct_attrs.array_char_value(2) := p_source_30;
47117 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
47118 l_rec_acct_attrs.array_char_value(3) := p_source_59;
47119 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
47120 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
47121 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
47122 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
47123 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
47124 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
47125 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
47126 l_rec_acct_attrs.array_char_value(7) := p_source_18;
47127 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
47128 l_rec_acct_attrs.array_num_value(8) := p_source_61;
47129 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
47130 l_rec_acct_attrs.array_char_value(9) := p_source_62;
47131 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
47132 l_rec_acct_attrs.array_date_value(10) := p_source_21;
47133 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
47134 l_rec_acct_attrs.array_num_value(11) := p_source_22;
47135 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
47136 l_rec_acct_attrs.array_char_value(12) := p_source_23;
47137 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
47138 l_rec_acct_attrs.array_num_value(13) := p_source_63;
47139 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
47140 l_rec_acct_attrs.array_num_value(14) := p_source_64;
47141 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
47142 l_rec_acct_attrs.array_num_value(15) := p_source_65;
47143 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
47144 l_rec_acct_attrs.array_char_value(16) := p_source_66;
47145
47146 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
47147 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
47148
47149 ---------------------------------------------------------------------------------------------------------------
47150 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
47151 ---------------------------------------------------------------------------------------------------------------
47152 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
47153
47154 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47155 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47156
47157 IF xla_accounting_cache_pkg.GetValueChar
47158 (p_source_code => 'LEDGER_CATEGORY_CODE'
47159 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
47160 AND l_bflow_method_code = 'PRIOR_ENTRY'
47161 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
47162 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
47163 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
47164 )
47165 THEN
47166 xla_ae_lines_pkg.BflowUpgEntry
47167 (p_business_method_code => l_bflow_method_code
47168 ,p_business_class_code => l_bflow_class_code
47169 ,p_balance_type => l_balance_type_code);
47170 ELSE
47171 NULL;
47172 -- No business flow processing for business flow method of NONE.
47173 END IF;
47174
47175 --
47176 -- call analytical criteria
47177 --
47178
47179 --
47180 -- call description
47181 --
47182 -- No description or it is inherited.
47183 --
47184 -- call ADRs
47185 -- Bug 4922099
47186 --
47187 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47188 (NVL(l_actual_upg_option, 'N') = 'O') OR
47189 (NVL(l_enc_upg_option, 'N') = 'O')
47190 )
47191 THEN
47192 NULL;
47193 --
47194 --
47195
47196 l_ccid := AcctDerRule_11(
47197 p_application_id => p_application_id
47198 , p_ae_header_id => l_ae_header_id
47202 , x_value_type_code => l_adr_value_type_code
47199 , p_source_10 => p_source_10
47200 , x_transaction_coa_id => l_adr_transaction_coa_id
47201 , x_accounting_coa_id => l_adr_accounting_coa_id
47203 , p_side => 'NA'
47204 );
47205
47206 xla_ae_lines_pkg.set_ccid(
47207 p_code_combination_id => l_ccid
47208 , p_value_type_code => l_adr_value_type_code
47209 , p_transaction_coa_id => l_adr_transaction_coa_id
47210 , p_accounting_coa_id => l_adr_accounting_coa_id
47211 , p_adr_code => 'DIST_CCID'
47212 , p_adr_type_code => 'S'
47213 , p_component_type => l_component_type
47214 , p_component_code => l_component_code
47215 , p_component_type_code => l_component_type_code
47216 , p_component_appl_id => l_component_appl_id
47217 , p_amb_context_code => l_amb_context_code
47218 , p_side => 'NA'
47219 );
47220
47221
47222 --
47223 --
47224 END IF;
47225 --
47226 -- Bug 4922099
47227 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
47228 (NVL(l_enc_upg_option, 'N') = 'O')
47229 ) AND
47230 (l_bflow_method_code = 'PRIOR_ENTRY')
47231 )
47232 THEN
47233 IF
47234 --
47235 1 = 2
47236 --
47237 THEN
47238 xla_accounting_err_pkg.build_message
47239 (p_appli_s_name => 'XLA'
47240 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47241 ,p_token_1 => 'LINE_NUMBER'
47242 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
47243 ,p_token_2 => 'LINE_TYPE_NAME'
47244 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
47245 l_component_type
47246 ,l_component_code
47247 ,l_component_type_code
47248 ,l_component_appl_id
47249 ,l_amb_context_code
47250 ,l_entity_code
47251 ,l_event_class_code
47252 )
47253 ,p_token_3 => 'OWNER'
47254 ,p_value_3 => xla_lookups_pkg.get_meaning(
47255 p_lookup_type => 'XLA_OWNER_TYPE'
47256 ,p_lookup_code => l_component_type_code
47257 )
47258 ,p_token_4 => 'PRODUCT_NAME'
47259 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
47260 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
47261 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
47262 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
47263 ,p_ae_header_id => NULL
47264 );
47265
47266 IF (C_LEVEL_ERROR>= g_log_level) THEN
47267 trace
47268 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47269 ,p_level => C_LEVEL_ERROR
47270 ,p_module => l_log_module);
47271 END IF;
47272 END IF;
47273 END IF;
47274 --
47275 --
47276 ------------------------------------------------------------------------------------------------
47277 -- 4219869 Business Flow
47278 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
47279 -- Prior Entry. Currently, the following code is always generated.
47280 ------------------------------------------------------------------------------------------------
47281 XLA_AE_LINES_PKG.ValidateCurrentLine;
47282
47283 ------------------------------------------------------------------------------------
47284 -- 4219869 Business Flow
47285 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
47286 ------------------------------------------------------------------------------------
47287 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47288
47289 ----------------------------------------------------------------------------------
47290 -- 4219869 Business Flow
47291 -- Update journal entry status -- Need to generate this within IF <condition>
47292 ----------------------------------------------------------------------------------
47293 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47294 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
47295 ,p_balance_type_code => l_balance_type_code
47296 );
47297
47298 -------------------------------------------------------------------------------------------
47299 -- 4262811 - Generate the Accrual Reversal lines
47300 -------------------------------------------------------------------------------------------
47301 BEGIN
47305 l_acc_rev_flag := 'N';
47302 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
47303 (g_array_event(p_event_id).array_value_num('header_index'));
47304 IF l_acc_rev_flag IS NULL THEN
47306 END IF;
47307 EXCEPTION
47308 WHEN OTHERS THEN
47309 l_acc_rev_flag := 'N';
47310 END;
47311 --
47312 IF (l_acc_rev_flag = 'Y') THEN
47313
47314 -- 4645092 ------------------------------------------------------------------------------
47315 -- To allow MPA report to determine if it should generate report process
47316 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
47317 ------------------------------------------------------------------------------------------
47318
47319 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
47320 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
47321 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
47322 -- call ADRs
47323 -- Bug 4922099
47324 --
47325 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47326 (NVL(l_actual_upg_option, 'N') = 'O') OR
47327 (NVL(l_enc_upg_option, 'N') = 'O')
47328 )
47329 THEN
47330 NULL;
47331 --
47332 --
47333
47334 l_ccid := AcctDerRule_11(
47335 p_application_id => p_application_id
47336 , p_ae_header_id => l_ae_header_id
47337 , p_source_10 => p_source_10
47338 , x_transaction_coa_id => l_adr_transaction_coa_id
47339 , x_accounting_coa_id => l_adr_accounting_coa_id
47340 , x_value_type_code => l_adr_value_type_code
47341 , p_side => 'NA'
47342 );
47343
47344 xla_ae_lines_pkg.set_ccid(
47345 p_code_combination_id => l_ccid
47346 , p_value_type_code => l_adr_value_type_code
47347 , p_transaction_coa_id => l_adr_transaction_coa_id
47348 , p_accounting_coa_id => l_adr_accounting_coa_id
47349 , p_adr_code => 'DIST_CCID'
47350 , p_adr_type_code => 'S'
47351 , p_component_type => l_component_type
47352 , p_component_code => l_component_code
47353 , p_component_type_code => l_component_type_code
47354 , p_component_appl_id => l_component_appl_id
47355 , p_amb_context_code => l_amb_context_code
47356 , p_side => 'NA'
47357 );
47358
47359
47360 --
47361 --
47362 END IF;
47363
47364 --
47365 -- Update the line information that should be overwritten
47366 --
47367 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
47368 p_header_num => 1);
47369 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
47370
47371 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
47372
47373 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
47374 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
47375 END IF;
47376
47377 --
47378 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
47379 --
47380 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
47381 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
47382 ELSE
47383 ---------------------------------------------------------------------------------------------------
47384 -- 4262811a Switch Sign
47385 ---------------------------------------------------------------------------------------------------
47386 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
47387 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
47388 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47389 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
47390 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47391 -- 5132302
47392 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
47393 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47394
47395 END IF;
47396
47397 -- 4955764
47398 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47399 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
47400
47401
47402 XLA_AE_LINES_PKG.ValidateCurrentLine;
47403 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47404
47405 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47406 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
47407 ,p_balance_type_code => l_balance_type_code);
47408
47409 END IF;
47410
47411 -----------------------------------------------------------------------------------------
47412 -- 4262811 Multiperiod Accounting
47413 -----------------------------------------------------------------------------------------
47414 -- No MPA option is assigned.
47415
47416
47417 END IF;
47418 END IF;
47419 --
47420
47421 --
47422 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
47423 trace
47427 END IF;
47424 (p_msg => 'END of AcctLineType_94'
47425 ,p_level => C_LEVEL_PROCEDURE
47426 ,p_module => l_log_module);
47428 --
47429 EXCEPTION
47430 WHEN xla_exceptions_pkg.application_exception THEN
47431 RAISE;
47432 WHEN OTHERS THEN
47433 xla_exceptions_pkg.raise_message
47434 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_94');
47435 END AcctLineType_94;
47436 --
47437
47438 ---------------------------------------
47439 --
47440 -- PRIVATE FUNCTION
47441 -- AcctLineType_95
47442 --
47443 ---------------------------------------
47444 PROCEDURE AcctLineType_95 (
47445 p_application_id IN NUMBER
47446 ,p_event_id IN NUMBER
47447 ,p_calculate_acctd_flag IN VARCHAR2
47448 ,p_calculate_g_l_flag IN VARCHAR2
47449 ,p_actual_flag IN OUT VARCHAR2
47450 ,p_balance_type_code OUT VARCHAR2
47451 ,p_gain_or_loss_ref OUT VARCHAR2
47452
47453 --Distribution GL Account
47454 , p_source_10 IN NUMBER
47455 --Distribution Source Type
47456 , p_source_15 IN VARCHAR2
47457 --Distribution Line Identifier
47458 , p_source_17 IN NUMBER
47459 --Distribution Type
47460 , p_source_18 IN VARCHAR2
47461 --Exchange Date
47462 , p_source_21 IN DATE
47463 --Exchange Rate
47464 , p_source_22 IN NUMBER
47465 --Exchange Rate Type
47466 , p_source_23 IN VARCHAR2
47467 --Transaction Distribution Identifier
47468 , p_source_29 IN NUMBER
47469 --Transaction Distribution Type
47470 , p_source_30 IN VARCHAR2
47471 --Distribution Multi Fund Additional Entry
47472 , p_source_54 IN VARCHAR2
47473 --Receipt Applied To Application Identifier
47474 , p_source_58 IN NUMBER
47475 --Transaction Entity Code
47476 , p_source_59 IN VARCHAR2
47477 --Transaction Identifier
47478 , p_source_60 IN NUMBER
47479 --DIST_ENT_AMT_FROM
47480 , p_source_61 IN NUMBER
47481 --Applying Document Currency Code
47482 , p_source_62 IN VARCHAR2
47483 --Accounting Amount
47484 , p_source_63 IN NUMBER
47485 --Distribution Party Identifier
47486 , p_source_64 IN NUMBER
47487 --Distribution Party Site Id
47488 , p_source_65 IN NUMBER
47489 --Distribution Party Type
47490 , p_source_66 IN VARCHAR2
47491 --Distribution Source Table
47492 , p_source_69 IN VARCHAR2
47493 )
47494 IS
47495
47496 l_component_type VARCHAR2(80);
47497 l_component_code VARCHAR2(30);
47498 l_component_type_code VARCHAR2(1);
47499 l_component_appl_id INTEGER;
47500 l_amb_context_code VARCHAR2(30);
47501 l_entity_code VARCHAR2(30);
47502 l_event_class_code VARCHAR2(30);
47503 l_ae_header_id NUMBER;
47504 l_event_type_code VARCHAR2(30);
47505 l_line_definition_code VARCHAR2(30);
47506 l_line_definition_owner_code VARCHAR2(1);
47507 --
47508 -- adr variables
47509 l_segment VARCHAR2(30);
47510 l_ccid NUMBER;
47511 l_adr_transaction_coa_id NUMBER;
47512 l_adr_accounting_coa_id NUMBER;
47513 l_adr_flexfield_segment_code VARCHAR2(30);
47514 l_adr_flex_value_set_id NUMBER;
47515 l_adr_value_type_code VARCHAR2(30);
47516 l_adr_value_combination_id NUMBER;
47517 l_adr_value_segment_code VARCHAR2(30);
47518
47519 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
47520 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
47521 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
47522 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
47523
47524 -- 4262811 Variables ------------------------------------------------------------------------------------------
47525 l_entered_amt_idx NUMBER;
47526 l_accted_amt_idx NUMBER;
47527 l_acc_rev_flag VARCHAR2(1);
47528 l_accrual_line_num NUMBER;
47529 l_tmp_amt NUMBER;
47530 l_acc_rev_natural_side_code VARCHAR2(1);
47531
47532 l_num_entries NUMBER;
47533 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
47534 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
47535 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
47536 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
47537 l_recog_line_1 NUMBER;
47538 l_recog_line_2 NUMBER;
47539
47540 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
47541 l_bflow_applied_to_amt NUMBER; -- 5132302
47542 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
47543
47544 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
47545
47546 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
47547 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
47548
47549 ---------------------------------------------------------------------------------------------------------------
47550
47551
47552 --
47553 -- bulk performance
47554 --
47555 l_balance_type_code VARCHAR2(1);
47556 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
47557 l_log_module VARCHAR2(240);
47558
47559 --
47560 -- Upgrade strategy
47561 --
47562 l_actual_upg_option VARCHAR2(1);
47566 BEGIN
47563 l_enc_upg_option VARCHAR2(1);
47564
47565 --
47567 --
47568 IF g_log_enabled THEN
47569 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_95';
47570 END IF;
47571 --
47572 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
47573
47574 trace
47575 (p_msg => 'BEGIN of AcctLineType_95'
47576 ,p_level => C_LEVEL_PROCEDURE
47577 ,p_module => l_log_module);
47578
47579 END IF;
47580 --
47581 l_component_type := 'AMB_JLT';
47582 l_component_code := 'RCT_REMIT';
47583 l_component_type_code := 'S';
47584 l_component_appl_id := 222;
47585 l_amb_context_code := 'DEFAULT';
47586 l_entity_code := 'RECEIPTS';
47587 l_event_class_code := 'RECEIPT';
47588 l_event_type_code := 'RECEIPT_ALL';
47589 l_line_definition_owner_code := 'S';
47590 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
47591 --
47592 l_balance_type_code := 'A';
47593 l_segment := NULL;
47594 l_ccid := NULL;
47595 l_adr_transaction_coa_id := NULL;
47596 l_adr_accounting_coa_id := NULL;
47597 l_adr_flexfield_segment_code := NULL;
47598 l_adr_flex_value_set_id := NULL;
47599 l_adr_value_type_code := NULL;
47600 l_adr_value_combination_id := NULL;
47601 l_adr_value_segment_code := NULL;
47602
47603 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
47604 l_bflow_class_code := ''; -- 4219869 Business Flow
47605 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
47606 l_budgetary_control_flag := 'N';
47607
47608 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47609 l_bflow_applied_to_amt := NULL; -- 5132302
47610 l_entered_amt_idx := NULL; -- 4262811
47611 l_accted_amt_idx := NULL; -- 4262811
47612 l_acc_rev_flag := NULL; -- 4262811
47613 l_accrual_line_num := NULL; -- 4262811
47614 l_tmp_amt := NULL; -- 4262811
47615 --
47616
47617 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
47618 l_balance_type_code <> 'B' THEN
47619 IF NVL(p_source_15,'
47620 ') = 'REMITTANCE' AND
47621 NVL(p_source_69,'
47622 ') = 'CRH' AND
47623 NVL(p_source_54,'
47624 ') = 'N'
47625 THEN
47626
47627 --
47628 XLA_AE_LINES_PKG.SetNewLine;
47629
47630 p_balance_type_code := l_balance_type_code;
47631 -- set the flag so later we will know whether the gain loss line needs to be created
47632
47633 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
47634 p_actual_flag :='A';
47635 END IF;
47636
47637 --
47638 -- bulk performance
47639 --
47640 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
47641 p_header_num => 0); -- 4262811
47642 --
47643 -- set accounting line options
47644 --
47645 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
47646 p_natural_side_code => 'C'
47647 , p_gain_or_loss_flag => 'N'
47648 , p_gl_transfer_mode_code => 'S'
47649 , p_acct_entry_type_code => 'A'
47650 , p_switch_side_flag => 'Y'
47651 , p_merge_duplicate_code => 'A'
47652 );
47653 --
47654 l_acc_rev_natural_side_code := 'D'; -- 4262811
47655 --
47656 --
47657 -- set accounting line type info
47658 --
47659 xla_ae_lines_pkg.SetAcctLineType
47660 (p_component_type => l_component_type
47661 ,p_event_type_code => l_event_type_code
47662 ,p_line_definition_owner_code => l_line_definition_owner_code
47663 ,p_line_definition_code => l_line_definition_code
47664 ,p_accounting_line_code => l_component_code
47665 ,p_accounting_line_type_code => l_component_type_code
47666 ,p_accounting_line_appl_id => l_component_appl_id
47667 ,p_amb_context_code => l_amb_context_code
47668 ,p_entity_code => l_entity_code
47669 ,p_event_class_code => l_event_class_code);
47670 --
47671 -- set accounting class
47672 --
47673 xla_ae_lines_pkg.SetAcctClass(
47674 p_accounting_class_code => 'REMITTANCE'
47675 , p_ae_header_id => l_ae_header_id
47676 );
47677
47678 --
47679 -- set rounding class
47680 --
47681 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
47682 'RECEIVABLE';
47683
47684 --
47685 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
47686 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
47687 --
47688 -- bulk performance
47689 --
47690 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
47691
47692 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
47693 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
47694
47695 -- 4955764
47696 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47700
47697 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
47698
47699 -- 4458381 Public Sector Enh
47701 --
47702 -- set accounting attributes for the line type
47703 --
47704 l_entered_amt_idx := 8;
47705 l_accted_amt_idx := 13;
47706 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47707 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
47708 l_rec_acct_attrs.array_num_value(1) := p_source_58;
47709 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
47710 l_rec_acct_attrs.array_char_value(2) := p_source_30;
47711 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
47712 l_rec_acct_attrs.array_char_value(3) := p_source_59;
47713 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
47714 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
47715 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
47716 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
47717 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
47718 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
47719 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
47720 l_rec_acct_attrs.array_char_value(7) := p_source_18;
47721 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
47722 l_rec_acct_attrs.array_num_value(8) := p_source_61;
47723 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
47724 l_rec_acct_attrs.array_char_value(9) := p_source_62;
47725 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
47726 l_rec_acct_attrs.array_date_value(10) := p_source_21;
47727 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
47728 l_rec_acct_attrs.array_num_value(11) := p_source_22;
47729 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
47730 l_rec_acct_attrs.array_char_value(12) := p_source_23;
47731 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
47732 l_rec_acct_attrs.array_num_value(13) := p_source_63;
47733 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
47734 l_rec_acct_attrs.array_num_value(14) := p_source_64;
47735 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
47736 l_rec_acct_attrs.array_num_value(15) := p_source_65;
47737 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
47738 l_rec_acct_attrs.array_char_value(16) := p_source_66;
47739
47740 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
47741 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
47742
47743 ---------------------------------------------------------------------------------------------------------------
47744 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
47745 ---------------------------------------------------------------------------------------------------------------
47746 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
47747
47748 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47749 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47750
47751 IF xla_accounting_cache_pkg.GetValueChar
47752 (p_source_code => 'LEDGER_CATEGORY_CODE'
47753 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
47754 AND l_bflow_method_code = 'PRIOR_ENTRY'
47755 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
47756 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
47757 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
47758 )
47759 THEN
47760 xla_ae_lines_pkg.BflowUpgEntry
47761 (p_business_method_code => l_bflow_method_code
47762 ,p_business_class_code => l_bflow_class_code
47763 ,p_balance_type => l_balance_type_code);
47764 ELSE
47765 NULL;
47766 -- No business flow processing for business flow method of NONE.
47767 END IF;
47768
47769 --
47770 -- call analytical criteria
47771 --
47772
47773 --
47774 -- call description
47775 --
47776 -- No description or it is inherited.
47777 --
47778 -- call ADRs
47779 -- Bug 4922099
47780 --
47781 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47782 (NVL(l_actual_upg_option, 'N') = 'O') OR
47783 (NVL(l_enc_upg_option, 'N') = 'O')
47784 )
47785 THEN
47786 NULL;
47787 --
47788 --
47789
47790 l_ccid := AcctDerRule_11(
47791 p_application_id => p_application_id
47792 , p_ae_header_id => l_ae_header_id
47793 , p_source_10 => p_source_10
47794 , x_transaction_coa_id => l_adr_transaction_coa_id
47795 , x_accounting_coa_id => l_adr_accounting_coa_id
47796 , x_value_type_code => l_adr_value_type_code
47797 , p_side => 'NA'
47798 );
47799
47800 xla_ae_lines_pkg.set_ccid(
47801 p_code_combination_id => l_ccid
47802 , p_value_type_code => l_adr_value_type_code
47803 , p_transaction_coa_id => l_adr_transaction_coa_id
47804 , p_accounting_coa_id => l_adr_accounting_coa_id
47805 , p_adr_code => 'DIST_CCID'
47806 , p_adr_type_code => 'S'
47810 , p_component_appl_id => l_component_appl_id
47807 , p_component_type => l_component_type
47808 , p_component_code => l_component_code
47809 , p_component_type_code => l_component_type_code
47811 , p_amb_context_code => l_amb_context_code
47812 , p_side => 'NA'
47813 );
47814
47815
47816 --
47817 --
47818 END IF;
47819 --
47820 -- Bug 4922099
47821 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
47822 (NVL(l_enc_upg_option, 'N') = 'O')
47823 ) AND
47824 (l_bflow_method_code = 'PRIOR_ENTRY')
47825 )
47826 THEN
47827 IF
47828 --
47829 1 = 2
47830 --
47831 THEN
47832 xla_accounting_err_pkg.build_message
47833 (p_appli_s_name => 'XLA'
47834 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47835 ,p_token_1 => 'LINE_NUMBER'
47836 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
47837 ,p_token_2 => 'LINE_TYPE_NAME'
47838 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
47839 l_component_type
47840 ,l_component_code
47841 ,l_component_type_code
47842 ,l_component_appl_id
47843 ,l_amb_context_code
47844 ,l_entity_code
47845 ,l_event_class_code
47846 )
47847 ,p_token_3 => 'OWNER'
47848 ,p_value_3 => xla_lookups_pkg.get_meaning(
47849 p_lookup_type => 'XLA_OWNER_TYPE'
47850 ,p_lookup_code => l_component_type_code
47851 )
47852 ,p_token_4 => 'PRODUCT_NAME'
47853 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
47854 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
47855 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
47856 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
47857 ,p_ae_header_id => NULL
47858 );
47859
47860 IF (C_LEVEL_ERROR>= g_log_level) THEN
47861 trace
47862 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47863 ,p_level => C_LEVEL_ERROR
47864 ,p_module => l_log_module);
47865 END IF;
47866 END IF;
47867 END IF;
47868 --
47869 --
47870 ------------------------------------------------------------------------------------------------
47871 -- 4219869 Business Flow
47872 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
47873 -- Prior Entry. Currently, the following code is always generated.
47874 ------------------------------------------------------------------------------------------------
47875 XLA_AE_LINES_PKG.ValidateCurrentLine;
47876
47877 ------------------------------------------------------------------------------------
47878 -- 4219869 Business Flow
47879 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
47880 ------------------------------------------------------------------------------------
47881 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47882
47883 ----------------------------------------------------------------------------------
47884 -- 4219869 Business Flow
47885 -- Update journal entry status -- Need to generate this within IF <condition>
47886 ----------------------------------------------------------------------------------
47887 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47888 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
47889 ,p_balance_type_code => l_balance_type_code
47890 );
47891
47892 -------------------------------------------------------------------------------------------
47893 -- 4262811 - Generate the Accrual Reversal lines
47894 -------------------------------------------------------------------------------------------
47895 BEGIN
47896 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
47897 (g_array_event(p_event_id).array_value_num('header_index'));
47898 IF l_acc_rev_flag IS NULL THEN
47899 l_acc_rev_flag := 'N';
47900 END IF;
47901 EXCEPTION
47902 WHEN OTHERS THEN
47903 l_acc_rev_flag := 'N';
47904 END;
47905 --
47906 IF (l_acc_rev_flag = 'Y') THEN
47907
47908 -- 4645092 ------------------------------------------------------------------------------
47909 -- To allow MPA report to determine if it should generate report process
47910 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
47914 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
47911 ------------------------------------------------------------------------------------------
47912
47913 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
47915 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
47916 -- call ADRs
47917 -- Bug 4922099
47918 --
47919 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47920 (NVL(l_actual_upg_option, 'N') = 'O') OR
47921 (NVL(l_enc_upg_option, 'N') = 'O')
47922 )
47923 THEN
47924 NULL;
47925 --
47926 --
47927
47928 l_ccid := AcctDerRule_11(
47929 p_application_id => p_application_id
47930 , p_ae_header_id => l_ae_header_id
47931 , p_source_10 => p_source_10
47932 , x_transaction_coa_id => l_adr_transaction_coa_id
47933 , x_accounting_coa_id => l_adr_accounting_coa_id
47934 , x_value_type_code => l_adr_value_type_code
47935 , p_side => 'NA'
47936 );
47937
47938 xla_ae_lines_pkg.set_ccid(
47939 p_code_combination_id => l_ccid
47940 , p_value_type_code => l_adr_value_type_code
47941 , p_transaction_coa_id => l_adr_transaction_coa_id
47942 , p_accounting_coa_id => l_adr_accounting_coa_id
47943 , p_adr_code => 'DIST_CCID'
47944 , p_adr_type_code => 'S'
47945 , p_component_type => l_component_type
47946 , p_component_code => l_component_code
47947 , p_component_type_code => l_component_type_code
47948 , p_component_appl_id => l_component_appl_id
47949 , p_amb_context_code => l_amb_context_code
47950 , p_side => 'NA'
47951 );
47952
47953
47954 --
47955 --
47956 END IF;
47957
47958 --
47959 -- Update the line information that should be overwritten
47960 --
47961 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
47962 p_header_num => 1);
47963 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
47964
47965 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
47966
47967 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
47968 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
47969 END IF;
47970
47971 --
47972 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
47973 --
47974 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
47975 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
47976 ELSE
47977 ---------------------------------------------------------------------------------------------------
47978 -- 4262811a Switch Sign
47979 ---------------------------------------------------------------------------------------------------
47980 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
47981 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
47982 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47983 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
47984 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47985 -- 5132302
47986 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
47987 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47988
47989 END IF;
47990
47991 -- 4955764
47992 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47993 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
47994
47995
47996 XLA_AE_LINES_PKG.ValidateCurrentLine;
47997 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47998
47999 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48000 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
48001 ,p_balance_type_code => l_balance_type_code);
48002
48003 END IF;
48004
48005 -----------------------------------------------------------------------------------------
48006 -- 4262811 Multiperiod Accounting
48007 -----------------------------------------------------------------------------------------
48008 -- No MPA option is assigned.
48009
48010
48011 END IF;
48012 END IF;
48013 --
48014
48015 --
48016 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48017 trace
48018 (p_msg => 'END of AcctLineType_95'
48019 ,p_level => C_LEVEL_PROCEDURE
48020 ,p_module => l_log_module);
48021 END IF;
48022 --
48023 EXCEPTION
48024 WHEN xla_exceptions_pkg.application_exception THEN
48025 RAISE;
48026 WHEN OTHERS THEN
48027 xla_exceptions_pkg.raise_message
48028 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_95');
48029 END AcctLineType_95;
48030 --
48031
48032 ---------------------------------------
48033 --
48034 -- PRIVATE FUNCTION
48035 -- AcctLineType_96
48036 --
48037 ---------------------------------------
48038 PROCEDURE AcctLineType_96 (
48042 ,p_calculate_g_l_flag IN VARCHAR2
48039 p_application_id IN NUMBER
48040 ,p_event_id IN NUMBER
48041 ,p_calculate_acctd_flag IN VARCHAR2
48043 ,p_actual_flag IN OUT VARCHAR2
48044 ,p_balance_type_code OUT VARCHAR2
48045 ,p_gain_or_loss_ref OUT VARCHAR2
48046
48047 --Distribution GL Account
48048 , p_source_10 IN NUMBER
48049 --Distribution Source Type
48050 , p_source_15 IN VARCHAR2
48051 --Distribution Line Identifier
48052 , p_source_17 IN NUMBER
48053 --Distribution Type
48054 , p_source_18 IN VARCHAR2
48055 --Exchange Date
48056 , p_source_21 IN DATE
48057 --Exchange Rate
48058 , p_source_22 IN NUMBER
48059 --Exchange Rate Type
48060 , p_source_23 IN VARCHAR2
48061 --Transaction Distribution Identifier
48062 , p_source_29 IN NUMBER
48063 --Transaction Distribution Type
48064 , p_source_30 IN VARCHAR2
48065 --Distribution Multi Fund Additional Entry
48066 , p_source_54 IN VARCHAR2
48067 --Receipt Applied To Application Identifier
48068 , p_source_58 IN NUMBER
48069 --Transaction Entity Code
48070 , p_source_59 IN VARCHAR2
48071 --Transaction Identifier
48072 , p_source_60 IN NUMBER
48073 --DIST_ENT_AMT_FROM
48074 , p_source_61 IN NUMBER
48075 --Applying Document Currency Code
48076 , p_source_62 IN VARCHAR2
48077 --Accounting Amount
48078 , p_source_63 IN NUMBER
48079 --Distribution Party Identifier
48080 , p_source_64 IN NUMBER
48081 --Distribution Party Site Id
48082 , p_source_65 IN NUMBER
48083 --Distribution Party Type
48084 , p_source_66 IN VARCHAR2
48085 --Distribution Source Table
48086 , p_source_69 IN VARCHAR2
48087 )
48088 IS
48089
48090 l_component_type VARCHAR2(80);
48091 l_component_code VARCHAR2(30);
48092 l_component_type_code VARCHAR2(1);
48093 l_component_appl_id INTEGER;
48094 l_amb_context_code VARCHAR2(30);
48095 l_entity_code VARCHAR2(30);
48096 l_event_class_code VARCHAR2(30);
48097 l_ae_header_id NUMBER;
48098 l_event_type_code VARCHAR2(30);
48099 l_line_definition_code VARCHAR2(30);
48100 l_line_definition_owner_code VARCHAR2(1);
48101 --
48102 -- adr variables
48103 l_segment VARCHAR2(30);
48104 l_ccid NUMBER;
48105 l_adr_transaction_coa_id NUMBER;
48106 l_adr_accounting_coa_id NUMBER;
48107 l_adr_flexfield_segment_code VARCHAR2(30);
48108 l_adr_flex_value_set_id NUMBER;
48109 l_adr_value_type_code VARCHAR2(30);
48110 l_adr_value_combination_id NUMBER;
48111 l_adr_value_segment_code VARCHAR2(30);
48112
48113 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
48114 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
48115 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
48116 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
48117
48118 -- 4262811 Variables ------------------------------------------------------------------------------------------
48119 l_entered_amt_idx NUMBER;
48120 l_accted_amt_idx NUMBER;
48121 l_acc_rev_flag VARCHAR2(1);
48122 l_accrual_line_num NUMBER;
48123 l_tmp_amt NUMBER;
48124 l_acc_rev_natural_side_code VARCHAR2(1);
48125
48126 l_num_entries NUMBER;
48127 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
48128 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
48129 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
48130 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
48131 l_recog_line_1 NUMBER;
48132 l_recog_line_2 NUMBER;
48133
48134 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
48135 l_bflow_applied_to_amt NUMBER; -- 5132302
48136 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
48137
48138 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
48139
48140 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
48141 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
48142
48143 ---------------------------------------------------------------------------------------------------------------
48144
48145
48146 --
48147 -- bulk performance
48148 --
48149 l_balance_type_code VARCHAR2(1);
48150 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
48151 l_log_module VARCHAR2(240);
48152
48153 --
48154 -- Upgrade strategy
48155 --
48156 l_actual_upg_option VARCHAR2(1);
48157 l_enc_upg_option VARCHAR2(1);
48158
48159 --
48160 BEGIN
48161 --
48162 IF g_log_enabled THEN
48163 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_96';
48164 END IF;
48165 --
48166 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48167
48168 trace
48169 (p_msg => 'BEGIN of AcctLineType_96'
48170 ,p_level => C_LEVEL_PROCEDURE
48171 ,p_module => l_log_module);
48172
48173 END IF;
48174 --
48175 l_component_type := 'AMB_JLT';
48176 l_component_code := 'RCT_REMIT_BR';
48177 l_component_type_code := 'S';
48181 l_event_class_code := 'RECEIPT';
48178 l_component_appl_id := 222;
48179 l_amb_context_code := 'DEFAULT';
48180 l_entity_code := 'RECEIPTS';
48182 l_event_type_code := 'RECEIPT_ALL';
48183 l_line_definition_owner_code := 'S';
48184 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
48185 --
48186 l_balance_type_code := 'A';
48187 l_segment := NULL;
48188 l_ccid := NULL;
48189 l_adr_transaction_coa_id := NULL;
48190 l_adr_accounting_coa_id := NULL;
48191 l_adr_flexfield_segment_code := NULL;
48192 l_adr_flex_value_set_id := NULL;
48193 l_adr_value_type_code := NULL;
48194 l_adr_value_combination_id := NULL;
48195 l_adr_value_segment_code := NULL;
48196
48197 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
48198 l_bflow_class_code := ''; -- 4219869 Business Flow
48199 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
48200 l_budgetary_control_flag := 'N';
48201
48202 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48203 l_bflow_applied_to_amt := NULL; -- 5132302
48204 l_entered_amt_idx := NULL; -- 4262811
48205 l_accted_amt_idx := NULL; -- 4262811
48206 l_acc_rev_flag := NULL; -- 4262811
48207 l_accrual_line_num := NULL; -- 4262811
48208 l_tmp_amt := NULL; -- 4262811
48209 --
48210
48211 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
48212 l_balance_type_code <> 'B' THEN
48213 IF NVL(p_source_15,'
48214 ') = 'REMITTANCE' AND
48215 NVL(p_source_69,'
48216 ') = 'RA' AND
48217 NVL(p_source_54,'
48218 ') = 'N'
48219 THEN
48220
48221 --
48222 XLA_AE_LINES_PKG.SetNewLine;
48223
48224 p_balance_type_code := l_balance_type_code;
48225 -- set the flag so later we will know whether the gain loss line needs to be created
48226
48227 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
48228 p_actual_flag :='A';
48229 END IF;
48230
48231 --
48232 -- bulk performance
48233 --
48234 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
48235 p_header_num => 0); -- 4262811
48236 --
48237 -- set accounting line options
48238 --
48239 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
48240 p_natural_side_code => 'C'
48241 , p_gain_or_loss_flag => 'N'
48242 , p_gl_transfer_mode_code => 'S'
48243 , p_acct_entry_type_code => 'A'
48244 , p_switch_side_flag => 'Y'
48245 , p_merge_duplicate_code => 'A'
48246 );
48247 --
48248 l_acc_rev_natural_side_code := 'D'; -- 4262811
48249 --
48250 --
48251 -- set accounting line type info
48252 --
48253 xla_ae_lines_pkg.SetAcctLineType
48254 (p_component_type => l_component_type
48255 ,p_event_type_code => l_event_type_code
48256 ,p_line_definition_owner_code => l_line_definition_owner_code
48257 ,p_line_definition_code => l_line_definition_code
48258 ,p_accounting_line_code => l_component_code
48259 ,p_accounting_line_type_code => l_component_type_code
48260 ,p_accounting_line_appl_id => l_component_appl_id
48261 ,p_amb_context_code => l_amb_context_code
48262 ,p_entity_code => l_entity_code
48263 ,p_event_class_code => l_event_class_code);
48264 --
48265 -- set accounting class
48266 --
48267 xla_ae_lines_pkg.SetAcctClass(
48268 p_accounting_class_code => 'REM_BR'
48269 , p_ae_header_id => l_ae_header_id
48270 );
48271
48272 --
48273 -- set rounding class
48274 --
48275 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
48276 'RECEIVABLE';
48277
48278 --
48279 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
48280 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
48281 --
48282 -- bulk performance
48283 --
48284 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
48285
48286 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
48287 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
48288
48289 -- 4955764
48290 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48291 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
48292
48293 -- 4458381 Public Sector Enh
48294
48295 --
48296 -- set accounting attributes for the line type
48297 --
48298 l_entered_amt_idx := 8;
48299 l_accted_amt_idx := 13;
48300 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48301 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
48302 l_rec_acct_attrs.array_num_value(1) := p_source_58;
48303 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
48304 l_rec_acct_attrs.array_char_value(2) := p_source_30;
48305 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
48309 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
48306 l_rec_acct_attrs.array_char_value(3) := p_source_59;
48307 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
48308 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
48310 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
48311 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
48312 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
48313 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
48314 l_rec_acct_attrs.array_char_value(7) := p_source_18;
48315 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
48316 l_rec_acct_attrs.array_num_value(8) := p_source_61;
48317 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
48318 l_rec_acct_attrs.array_char_value(9) := p_source_62;
48319 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
48320 l_rec_acct_attrs.array_date_value(10) := p_source_21;
48321 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
48322 l_rec_acct_attrs.array_num_value(11) := p_source_22;
48323 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
48324 l_rec_acct_attrs.array_char_value(12) := p_source_23;
48325 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
48326 l_rec_acct_attrs.array_num_value(13) := p_source_63;
48327 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
48328 l_rec_acct_attrs.array_num_value(14) := p_source_64;
48329 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
48330 l_rec_acct_attrs.array_num_value(15) := p_source_65;
48331 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
48332 l_rec_acct_attrs.array_char_value(16) := p_source_66;
48333
48334 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
48335 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
48336
48337 ---------------------------------------------------------------------------------------------------------------
48338 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
48339 ---------------------------------------------------------------------------------------------------------------
48340 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
48341
48342 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48343 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48344
48345 IF xla_accounting_cache_pkg.GetValueChar
48346 (p_source_code => 'LEDGER_CATEGORY_CODE'
48347 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
48348 AND l_bflow_method_code = 'PRIOR_ENTRY'
48349 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
48350 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
48351 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
48352 )
48353 THEN
48354 xla_ae_lines_pkg.BflowUpgEntry
48355 (p_business_method_code => l_bflow_method_code
48356 ,p_business_class_code => l_bflow_class_code
48357 ,p_balance_type => l_balance_type_code);
48358 ELSE
48359 NULL;
48360 -- No business flow processing for business flow method of NONE.
48361 END IF;
48362
48363 --
48364 -- call analytical criteria
48365 --
48366
48367 --
48368 -- call description
48369 --
48370 -- No description or it is inherited.
48371 --
48372 -- call ADRs
48373 -- Bug 4922099
48374 --
48375 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48376 (NVL(l_actual_upg_option, 'N') = 'O') OR
48377 (NVL(l_enc_upg_option, 'N') = 'O')
48378 )
48379 THEN
48380 NULL;
48381 --
48382 --
48383
48384 l_ccid := AcctDerRule_11(
48385 p_application_id => p_application_id
48386 , p_ae_header_id => l_ae_header_id
48387 , p_source_10 => p_source_10
48388 , x_transaction_coa_id => l_adr_transaction_coa_id
48389 , x_accounting_coa_id => l_adr_accounting_coa_id
48390 , x_value_type_code => l_adr_value_type_code
48391 , p_side => 'NA'
48392 );
48393
48394 xla_ae_lines_pkg.set_ccid(
48395 p_code_combination_id => l_ccid
48396 , p_value_type_code => l_adr_value_type_code
48397 , p_transaction_coa_id => l_adr_transaction_coa_id
48398 , p_accounting_coa_id => l_adr_accounting_coa_id
48399 , p_adr_code => 'DIST_CCID'
48400 , p_adr_type_code => 'S'
48401 , p_component_type => l_component_type
48402 , p_component_code => l_component_code
48403 , p_component_type_code => l_component_type_code
48404 , p_component_appl_id => l_component_appl_id
48405 , p_amb_context_code => l_amb_context_code
48406 , p_side => 'NA'
48407 );
48408
48409
48410 --
48411 --
48412 END IF;
48413 --
48414 -- Bug 4922099
48415 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
48416 (NVL(l_enc_upg_option, 'N') = 'O')
48417 ) AND
48418 (l_bflow_method_code = 'PRIOR_ENTRY')
48419 )
48420 THEN
48421 IF
48422 --
48423 1 = 2
48424 --
48425 THEN
48426 xla_accounting_err_pkg.build_message
48427 (p_appli_s_name => 'XLA'
48431 ,p_token_2 => 'LINE_TYPE_NAME'
48428 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
48429 ,p_token_1 => 'LINE_NUMBER'
48430 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
48432 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
48433 l_component_type
48434 ,l_component_code
48435 ,l_component_type_code
48436 ,l_component_appl_id
48437 ,l_amb_context_code
48438 ,l_entity_code
48439 ,l_event_class_code
48440 )
48441 ,p_token_3 => 'OWNER'
48442 ,p_value_3 => xla_lookups_pkg.get_meaning(
48443 p_lookup_type => 'XLA_OWNER_TYPE'
48444 ,p_lookup_code => l_component_type_code
48445 )
48446 ,p_token_4 => 'PRODUCT_NAME'
48447 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
48448 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
48449 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
48450 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
48451 ,p_ae_header_id => NULL
48452 );
48453
48454 IF (C_LEVEL_ERROR>= g_log_level) THEN
48455 trace
48456 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
48457 ,p_level => C_LEVEL_ERROR
48458 ,p_module => l_log_module);
48459 END IF;
48460 END IF;
48461 END IF;
48462 --
48463 --
48464 ------------------------------------------------------------------------------------------------
48465 -- 4219869 Business Flow
48466 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
48467 -- Prior Entry. Currently, the following code is always generated.
48468 ------------------------------------------------------------------------------------------------
48469 XLA_AE_LINES_PKG.ValidateCurrentLine;
48470
48471 ------------------------------------------------------------------------------------
48472 -- 4219869 Business Flow
48473 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
48474 ------------------------------------------------------------------------------------
48475 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
48476
48477 ----------------------------------------------------------------------------------
48478 -- 4219869 Business Flow
48479 -- Update journal entry status -- Need to generate this within IF <condition>
48480 ----------------------------------------------------------------------------------
48481 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48482 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
48483 ,p_balance_type_code => l_balance_type_code
48484 );
48485
48486 -------------------------------------------------------------------------------------------
48487 -- 4262811 - Generate the Accrual Reversal lines
48488 -------------------------------------------------------------------------------------------
48489 BEGIN
48490 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
48491 (g_array_event(p_event_id).array_value_num('header_index'));
48492 IF l_acc_rev_flag IS NULL THEN
48493 l_acc_rev_flag := 'N';
48494 END IF;
48495 EXCEPTION
48496 WHEN OTHERS THEN
48497 l_acc_rev_flag := 'N';
48498 END;
48499 --
48500 IF (l_acc_rev_flag = 'Y') THEN
48501
48502 -- 4645092 ------------------------------------------------------------------------------
48503 -- To allow MPA report to determine if it should generate report process
48504 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
48505 ------------------------------------------------------------------------------------------
48506
48507 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
48508 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
48509 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
48510 -- call ADRs
48511 -- Bug 4922099
48512 --
48513 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48514 (NVL(l_actual_upg_option, 'N') = 'O') OR
48515 (NVL(l_enc_upg_option, 'N') = 'O')
48516 )
48517 THEN
48518 NULL;
48519 --
48520 --
48521
48522 l_ccid := AcctDerRule_11(
48523 p_application_id => p_application_id
48524 , p_ae_header_id => l_ae_header_id
48525 , p_source_10 => p_source_10
48526 , x_transaction_coa_id => l_adr_transaction_coa_id
48530 );
48527 , x_accounting_coa_id => l_adr_accounting_coa_id
48528 , x_value_type_code => l_adr_value_type_code
48529 , p_side => 'NA'
48531
48532 xla_ae_lines_pkg.set_ccid(
48533 p_code_combination_id => l_ccid
48534 , p_value_type_code => l_adr_value_type_code
48535 , p_transaction_coa_id => l_adr_transaction_coa_id
48536 , p_accounting_coa_id => l_adr_accounting_coa_id
48537 , p_adr_code => 'DIST_CCID'
48538 , p_adr_type_code => 'S'
48539 , p_component_type => l_component_type
48540 , p_component_code => l_component_code
48541 , p_component_type_code => l_component_type_code
48542 , p_component_appl_id => l_component_appl_id
48543 , p_amb_context_code => l_amb_context_code
48544 , p_side => 'NA'
48545 );
48546
48547
48548 --
48549 --
48550 END IF;
48551
48552 --
48553 -- Update the line information that should be overwritten
48554 --
48555 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
48556 p_header_num => 1);
48557 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
48558
48559 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
48560
48561 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
48562 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
48563 END IF;
48564
48565 --
48566 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
48567 --
48568 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
48569 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
48570 ELSE
48571 ---------------------------------------------------------------------------------------------------
48572 -- 4262811a Switch Sign
48573 ---------------------------------------------------------------------------------------------------
48574 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
48575 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48576 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48577 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48578 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48579 -- 5132302
48580 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
48581 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48582
48583 END IF;
48584
48585 -- 4955764
48586 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48587 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
48588
48589
48590 XLA_AE_LINES_PKG.ValidateCurrentLine;
48591 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
48592
48593 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48594 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
48595 ,p_balance_type_code => l_balance_type_code);
48596
48597 END IF;
48598
48599 -----------------------------------------------------------------------------------------
48600 -- 4262811 Multiperiod Accounting
48601 -----------------------------------------------------------------------------------------
48602 -- No MPA option is assigned.
48603
48604
48605 END IF;
48606 END IF;
48607 --
48608
48609 --
48610 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48611 trace
48612 (p_msg => 'END of AcctLineType_96'
48613 ,p_level => C_LEVEL_PROCEDURE
48614 ,p_module => l_log_module);
48615 END IF;
48616 --
48617 EXCEPTION
48618 WHEN xla_exceptions_pkg.application_exception THEN
48619 RAISE;
48620 WHEN OTHERS THEN
48621 xla_exceptions_pkg.raise_message
48622 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_96');
48623 END AcctLineType_96;
48624 --
48625
48626 ---------------------------------------
48627 --
48628 -- PRIVATE FUNCTION
48629 -- AcctLineType_97
48630 --
48631 ---------------------------------------
48632 PROCEDURE AcctLineType_97 (
48633 p_application_id IN NUMBER
48634 ,p_event_id IN NUMBER
48635 ,p_calculate_acctd_flag IN VARCHAR2
48636 ,p_calculate_g_l_flag IN VARCHAR2
48637 ,p_actual_flag IN OUT VARCHAR2
48638 ,p_balance_type_code OUT VARCHAR2
48639 ,p_gain_or_loss_ref OUT VARCHAR2
48640
48641 --Distribution GL Account
48642 , p_source_10 IN NUMBER
48643 --Distribution Source Type
48644 , p_source_15 IN VARCHAR2
48645 --Distribution Line Identifier
48646 , p_source_17 IN NUMBER
48647 --Distribution Type
48648 , p_source_18 IN VARCHAR2
48649 --Entered Amount
48650 , p_source_19 IN NUMBER
48651 --Currency Code
48652 , p_source_20 IN VARCHAR2
48653 --Applied To Document Accounting Amount
48654 , p_source_24 IN NUMBER
48655 --Transaction Distribution Identifier
48659 --Distribution Multi Fund Additional Entry
48656 , p_source_29 IN NUMBER
48657 --Transaction Distribution Type
48658 , p_source_30 IN VARCHAR2
48660 , p_source_54 IN VARCHAR2
48661 --Applied To Document Exchange Date
48662 , p_source_55 IN DATE
48663 --Receipt Applied To Application Identifier
48664 , p_source_58 IN NUMBER
48665 --Transaction Entity Code
48666 , p_source_59 IN VARCHAR2
48667 --Transaction Identifier
48668 , p_source_60 IN NUMBER
48669 --Distribution Party Identifier
48670 , p_source_64 IN NUMBER
48671 --Distribution Party Site Id
48672 , p_source_65 IN NUMBER
48673 --Distribution Party Type
48674 , p_source_66 IN VARCHAR2
48675 --Applied To Document Exchange Rate Type
48676 , p_source_67 IN VARCHAR2
48677 --Applied To Document Exchange Rate
48678 , p_source_68 IN NUMBER
48679 )
48680 IS
48681
48682 l_component_type VARCHAR2(80);
48683 l_component_code VARCHAR2(30);
48684 l_component_type_code VARCHAR2(1);
48685 l_component_appl_id INTEGER;
48686 l_amb_context_code VARCHAR2(30);
48687 l_entity_code VARCHAR2(30);
48688 l_event_class_code VARCHAR2(30);
48689 l_ae_header_id NUMBER;
48690 l_event_type_code VARCHAR2(30);
48691 l_line_definition_code VARCHAR2(30);
48692 l_line_definition_owner_code VARCHAR2(1);
48693 --
48694 -- adr variables
48695 l_segment VARCHAR2(30);
48696 l_ccid NUMBER;
48697 l_adr_transaction_coa_id NUMBER;
48698 l_adr_accounting_coa_id NUMBER;
48699 l_adr_flexfield_segment_code VARCHAR2(30);
48700 l_adr_flex_value_set_id NUMBER;
48701 l_adr_value_type_code VARCHAR2(30);
48702 l_adr_value_combination_id NUMBER;
48703 l_adr_value_segment_code VARCHAR2(30);
48704
48705 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
48706 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
48707 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
48708 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
48709
48710 -- 4262811 Variables ------------------------------------------------------------------------------------------
48711 l_entered_amt_idx NUMBER;
48712 l_accted_amt_idx NUMBER;
48713 l_acc_rev_flag VARCHAR2(1);
48714 l_accrual_line_num NUMBER;
48715 l_tmp_amt NUMBER;
48716 l_acc_rev_natural_side_code VARCHAR2(1);
48717
48718 l_num_entries NUMBER;
48719 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
48720 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
48721 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
48722 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
48723 l_recog_line_1 NUMBER;
48724 l_recog_line_2 NUMBER;
48725
48726 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
48727 l_bflow_applied_to_amt NUMBER; -- 5132302
48728 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
48729
48730 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
48731
48732 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
48733 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
48734
48735 ---------------------------------------------------------------------------------------------------------------
48736
48737
48738 --
48739 -- bulk performance
48740 --
48741 l_balance_type_code VARCHAR2(1);
48742 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
48743 l_log_module VARCHAR2(240);
48744
48745 --
48746 -- Upgrade strategy
48747 --
48748 l_actual_upg_option VARCHAR2(1);
48749 l_enc_upg_option VARCHAR2(1);
48750
48751 --
48752 BEGIN
48753 --
48754 IF g_log_enabled THEN
48755 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_97';
48756 END IF;
48757 --
48758 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48759
48760 trace
48761 (p_msg => 'BEGIN of AcctLineType_97'
48762 ,p_level => C_LEVEL_PROCEDURE
48763 ,p_module => l_log_module);
48764
48765 END IF;
48766 --
48767 l_component_type := 'AMB_JLT';
48768 l_component_code := 'RCT_TAX';
48769 l_component_type_code := 'S';
48770 l_component_appl_id := 222;
48771 l_amb_context_code := 'DEFAULT';
48772 l_entity_code := 'RECEIPTS';
48773 l_event_class_code := 'RECEIPT';
48774 l_event_type_code := 'RECEIPT_ALL';
48775 l_line_definition_owner_code := 'S';
48776 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
48777 --
48778 l_balance_type_code := 'A';
48779 l_segment := NULL;
48780 l_ccid := NULL;
48781 l_adr_transaction_coa_id := NULL;
48782 l_adr_accounting_coa_id := NULL;
48783 l_adr_flexfield_segment_code := NULL;
48784 l_adr_flex_value_set_id := NULL;
48785 l_adr_value_type_code := NULL;
48786 l_adr_value_combination_id := NULL;
48787 l_adr_value_segment_code := NULL;
48788
48789 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
48790 l_bflow_class_code := ''; -- 4219869 Business Flow
48791 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
48795 l_bflow_applied_to_amt := NULL; -- 5132302
48792 l_budgetary_control_flag := 'N';
48793
48794 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48796 l_entered_amt_idx := NULL; -- 4262811
48797 l_accted_amt_idx := NULL; -- 4262811
48798 l_acc_rev_flag := NULL; -- 4262811
48799 l_accrual_line_num := NULL; -- 4262811
48800 l_tmp_amt := NULL; -- 4262811
48801 --
48802
48803 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
48804 l_balance_type_code <> 'B' THEN
48805 IF NVL(p_source_15,'
48806 ') = 'TAX' AND
48807 NVL(p_source_54,'
48808 ') = 'N'
48809 THEN
48810
48811 --
48812 XLA_AE_LINES_PKG.SetNewLine;
48813
48814 p_balance_type_code := l_balance_type_code;
48815 -- set the flag so later we will know whether the gain loss line needs to be created
48816
48817 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
48818 p_actual_flag :='A';
48819 END IF;
48820
48821 --
48822 -- bulk performance
48823 --
48824 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
48825 p_header_num => 0); -- 4262811
48826 --
48827 -- set accounting line options
48828 --
48829 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
48830 p_natural_side_code => 'C'
48831 , p_gain_or_loss_flag => 'N'
48832 , p_gl_transfer_mode_code => 'S'
48833 , p_acct_entry_type_code => 'A'
48834 , p_switch_side_flag => 'Y'
48835 , p_merge_duplicate_code => 'A'
48836 );
48837 --
48838 l_acc_rev_natural_side_code := 'D'; -- 4262811
48839 --
48840 --
48841 -- set accounting line type info
48842 --
48843 xla_ae_lines_pkg.SetAcctLineType
48844 (p_component_type => l_component_type
48845 ,p_event_type_code => l_event_type_code
48846 ,p_line_definition_owner_code => l_line_definition_owner_code
48847 ,p_line_definition_code => l_line_definition_code
48848 ,p_accounting_line_code => l_component_code
48849 ,p_accounting_line_type_code => l_component_type_code
48850 ,p_accounting_line_appl_id => l_component_appl_id
48851 ,p_amb_context_code => l_amb_context_code
48852 ,p_entity_code => l_entity_code
48853 ,p_event_class_code => l_event_class_code);
48854 --
48855 -- set accounting class
48856 --
48857 xla_ae_lines_pkg.SetAcctClass(
48858 p_accounting_class_code => 'TAX'
48859 , p_ae_header_id => l_ae_header_id
48860 );
48861
48862 --
48863 -- set rounding class
48864 --
48865 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
48866 'RECEIVABLE';
48867
48868 --
48869 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
48870 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
48871 --
48872 -- bulk performance
48873 --
48874 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
48875
48876 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
48877 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
48878
48879 -- 4955764
48880 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48881 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
48882
48883 -- 4458381 Public Sector Enh
48884
48885 --
48886 -- set accounting attributes for the line type
48887 --
48888 l_entered_amt_idx := 8;
48889 l_accted_amt_idx := 13;
48890 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48891 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
48892 l_rec_acct_attrs.array_num_value(1) := p_source_58;
48893 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
48894 l_rec_acct_attrs.array_char_value(2) := p_source_30;
48895 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
48896 l_rec_acct_attrs.array_char_value(3) := p_source_59;
48897 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
48898 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
48899 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
48900 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
48901 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
48902 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
48903 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
48904 l_rec_acct_attrs.array_char_value(7) := p_source_18;
48905 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
48906 l_rec_acct_attrs.array_num_value(8) := p_source_19;
48907 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
48908 l_rec_acct_attrs.array_char_value(9) := p_source_20;
48909 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
48910 l_rec_acct_attrs.array_date_value(10) := p_source_55;
48911 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
48912 l_rec_acct_attrs.array_num_value(11) := p_source_68;
48913 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
48914 l_rec_acct_attrs.array_char_value(12) := p_source_67;
48918 l_rec_acct_attrs.array_num_value(14) := p_source_64;
48915 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
48916 l_rec_acct_attrs.array_num_value(13) := p_source_24;
48917 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
48919 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
48920 l_rec_acct_attrs.array_num_value(15) := p_source_65;
48921 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
48922 l_rec_acct_attrs.array_char_value(16) := p_source_66;
48923
48924 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
48925 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
48926
48927 ---------------------------------------------------------------------------------------------------------------
48928 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
48929 ---------------------------------------------------------------------------------------------------------------
48930 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
48931
48932 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48933 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48934
48935 IF xla_accounting_cache_pkg.GetValueChar
48936 (p_source_code => 'LEDGER_CATEGORY_CODE'
48937 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
48938 AND l_bflow_method_code = 'PRIOR_ENTRY'
48939 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
48940 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
48941 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
48942 )
48943 THEN
48944 xla_ae_lines_pkg.BflowUpgEntry
48945 (p_business_method_code => l_bflow_method_code
48946 ,p_business_class_code => l_bflow_class_code
48947 ,p_balance_type => l_balance_type_code);
48948 ELSE
48949 NULL;
48950 -- No business flow processing for business flow method of NONE.
48951 END IF;
48952
48953 --
48954 -- call analytical criteria
48955 --
48956
48957 --
48958 -- call description
48959 --
48960 -- No description or it is inherited.
48961 --
48962 -- call ADRs
48963 -- Bug 4922099
48964 --
48965 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48966 (NVL(l_actual_upg_option, 'N') = 'O') OR
48967 (NVL(l_enc_upg_option, 'N') = 'O')
48968 )
48969 THEN
48970 NULL;
48971 --
48972 --
48973
48974 l_ccid := AcctDerRule_11(
48975 p_application_id => p_application_id
48976 , p_ae_header_id => l_ae_header_id
48977 , p_source_10 => p_source_10
48978 , x_transaction_coa_id => l_adr_transaction_coa_id
48979 , x_accounting_coa_id => l_adr_accounting_coa_id
48980 , x_value_type_code => l_adr_value_type_code
48981 , p_side => 'NA'
48982 );
48983
48984 xla_ae_lines_pkg.set_ccid(
48985 p_code_combination_id => l_ccid
48986 , p_value_type_code => l_adr_value_type_code
48987 , p_transaction_coa_id => l_adr_transaction_coa_id
48988 , p_accounting_coa_id => l_adr_accounting_coa_id
48989 , p_adr_code => 'DIST_CCID'
48990 , p_adr_type_code => 'S'
48991 , p_component_type => l_component_type
48992 , p_component_code => l_component_code
48993 , p_component_type_code => l_component_type_code
48994 , p_component_appl_id => l_component_appl_id
48995 , p_amb_context_code => l_amb_context_code
48996 , p_side => 'NA'
48997 );
48998
48999
49000 --
49001 --
49002 END IF;
49003 --
49004 -- Bug 4922099
49005 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
49006 (NVL(l_enc_upg_option, 'N') = 'O')
49007 ) AND
49008 (l_bflow_method_code = 'PRIOR_ENTRY')
49009 )
49010 THEN
49011 IF
49012 --
49013 1 = 2
49014 --
49015 THEN
49016 xla_accounting_err_pkg.build_message
49017 (p_appli_s_name => 'XLA'
49018 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49019 ,p_token_1 => 'LINE_NUMBER'
49020 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
49021 ,p_token_2 => 'LINE_TYPE_NAME'
49022 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
49023 l_component_type
49024 ,l_component_code
49025 ,l_component_type_code
49026 ,l_component_appl_id
49027 ,l_amb_context_code
49028 ,l_entity_code
49029 ,l_event_class_code
49030 )
49031 ,p_token_3 => 'OWNER'
49035 )
49032 ,p_value_3 => xla_lookups_pkg.get_meaning(
49033 p_lookup_type => 'XLA_OWNER_TYPE'
49034 ,p_lookup_code => l_component_type_code
49036 ,p_token_4 => 'PRODUCT_NAME'
49037 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
49038 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
49039 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
49040 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
49041 ,p_ae_header_id => NULL
49042 );
49043
49044 IF (C_LEVEL_ERROR>= g_log_level) THEN
49045 trace
49046 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49047 ,p_level => C_LEVEL_ERROR
49048 ,p_module => l_log_module);
49049 END IF;
49050 END IF;
49051 END IF;
49052 --
49053 --
49054 ------------------------------------------------------------------------------------------------
49055 -- 4219869 Business Flow
49056 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
49057 -- Prior Entry. Currently, the following code is always generated.
49058 ------------------------------------------------------------------------------------------------
49059 XLA_AE_LINES_PKG.ValidateCurrentLine;
49060
49061 ------------------------------------------------------------------------------------
49062 -- 4219869 Business Flow
49063 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
49064 ------------------------------------------------------------------------------------
49065 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49066
49067 ----------------------------------------------------------------------------------
49068 -- 4219869 Business Flow
49069 -- Update journal entry status -- Need to generate this within IF <condition>
49070 ----------------------------------------------------------------------------------
49071 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49072 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
49073 ,p_balance_type_code => l_balance_type_code
49074 );
49075
49076 -------------------------------------------------------------------------------------------
49077 -- 4262811 - Generate the Accrual Reversal lines
49078 -------------------------------------------------------------------------------------------
49079 BEGIN
49080 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
49081 (g_array_event(p_event_id).array_value_num('header_index'));
49082 IF l_acc_rev_flag IS NULL THEN
49083 l_acc_rev_flag := 'N';
49084 END IF;
49085 EXCEPTION
49086 WHEN OTHERS THEN
49087 l_acc_rev_flag := 'N';
49088 END;
49089 --
49090 IF (l_acc_rev_flag = 'Y') THEN
49091
49092 -- 4645092 ------------------------------------------------------------------------------
49093 -- To allow MPA report to determine if it should generate report process
49094 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
49095 ------------------------------------------------------------------------------------------
49096
49097 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
49098 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
49099 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
49100 -- call ADRs
49101 -- Bug 4922099
49102 --
49103 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49104 (NVL(l_actual_upg_option, 'N') = 'O') OR
49105 (NVL(l_enc_upg_option, 'N') = 'O')
49106 )
49107 THEN
49108 NULL;
49109 --
49110 --
49111
49112 l_ccid := AcctDerRule_11(
49113 p_application_id => p_application_id
49114 , p_ae_header_id => l_ae_header_id
49115 , p_source_10 => p_source_10
49116 , x_transaction_coa_id => l_adr_transaction_coa_id
49117 , x_accounting_coa_id => l_adr_accounting_coa_id
49118 , x_value_type_code => l_adr_value_type_code
49119 , p_side => 'NA'
49120 );
49121
49122 xla_ae_lines_pkg.set_ccid(
49123 p_code_combination_id => l_ccid
49124 , p_value_type_code => l_adr_value_type_code
49125 , p_transaction_coa_id => l_adr_transaction_coa_id
49126 , p_accounting_coa_id => l_adr_accounting_coa_id
49127 , p_adr_code => 'DIST_CCID'
49128 , p_adr_type_code => 'S'
49129 , p_component_type => l_component_type
49130 , p_component_code => l_component_code
49131 , p_component_type_code => l_component_type_code
49132 , p_component_appl_id => l_component_appl_id
49133 , p_amb_context_code => l_amb_context_code
49134 , p_side => 'NA'
49135 );
49136
49137
49138 --
49139 --
49140 END IF;
49141
49142 --
49143 -- Update the line information that should be overwritten
49144 --
49148
49145 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
49146 p_header_num => 1);
49147 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
49149 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
49150
49151 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
49152 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
49153 END IF;
49154
49155 --
49156 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
49157 --
49158 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
49159 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
49160 ELSE
49161 ---------------------------------------------------------------------------------------------------
49162 -- 4262811a Switch Sign
49163 ---------------------------------------------------------------------------------------------------
49164 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
49165 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49166 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49167 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49168 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49169 -- 5132302
49170 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
49171 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49172
49173 END IF;
49174
49175 -- 4955764
49176 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49177 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
49178
49179
49180 XLA_AE_LINES_PKG.ValidateCurrentLine;
49181 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49182
49183 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49184 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
49185 ,p_balance_type_code => l_balance_type_code);
49186
49187 END IF;
49188
49189 -----------------------------------------------------------------------------------------
49190 -- 4262811 Multiperiod Accounting
49191 -----------------------------------------------------------------------------------------
49192 -- No MPA option is assigned.
49193
49194
49195 END IF;
49196 END IF;
49197 --
49198
49199 --
49200 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49201 trace
49202 (p_msg => 'END of AcctLineType_97'
49203 ,p_level => C_LEVEL_PROCEDURE
49204 ,p_module => l_log_module);
49205 END IF;
49206 --
49207 EXCEPTION
49208 WHEN xla_exceptions_pkg.application_exception THEN
49209 RAISE;
49210 WHEN OTHERS THEN
49211 xla_exceptions_pkg.raise_message
49212 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_97');
49213 END AcctLineType_97;
49214 --
49215
49216 ---------------------------------------
49217 --
49218 -- PRIVATE FUNCTION
49219 -- AcctLineType_98
49220 --
49221 ---------------------------------------
49222 PROCEDURE AcctLineType_98 (
49223 p_application_id IN NUMBER
49224 ,p_event_id IN NUMBER
49225 ,p_calculate_acctd_flag IN VARCHAR2
49226 ,p_calculate_g_l_flag IN VARCHAR2
49227 ,p_actual_flag IN OUT VARCHAR2
49228 ,p_balance_type_code OUT VARCHAR2
49229 ,p_gain_or_loss_ref OUT VARCHAR2
49230
49231 --Remittance Bank Account Unapplied Account
49232 , p_source_11 IN NUMBER
49233 --Distribution Source Type
49234 , p_source_15 IN VARCHAR2
49235 --Receivable Activity Type
49236 , p_source_16 IN VARCHAR2
49237 --Distribution Line Identifier
49238 , p_source_17 IN NUMBER
49239 --Distribution Type
49240 , p_source_18 IN VARCHAR2
49241 --Exchange Date
49242 , p_source_21 IN DATE
49243 --Exchange Rate
49244 , p_source_22 IN NUMBER
49245 --Exchange Rate Type
49246 , p_source_23 IN VARCHAR2
49247 --Transaction Distribution Identifier
49248 , p_source_29 IN NUMBER
49249 --Transaction Distribution Type
49250 , p_source_30 IN VARCHAR2
49251 --Distribution Multi Fund Additional Entry
49252 , p_source_54 IN VARCHAR2
49253 --Receipt Applied To Application Identifier
49254 , p_source_58 IN NUMBER
49255 --Transaction Entity Code
49256 , p_source_59 IN VARCHAR2
49257 --Transaction Identifier
49258 , p_source_60 IN NUMBER
49259 --DIST_ENT_AMT_FROM
49260 , p_source_61 IN NUMBER
49261 --Applying Document Currency Code
49262 , p_source_62 IN VARCHAR2
49263 --Accounting Amount
49264 , p_source_63 IN NUMBER
49265 --Distribution Party Type
49266 , p_source_66 IN VARCHAR2
49267 --Distribution Source Table
49268 , p_source_69 IN VARCHAR2
49269 --Receipt Pay From Customer
49270 , p_source_70 IN NUMBER
49271 --Receipt Customer Site Use Identifier
49272 , p_source_71 IN NUMBER
49273 )
49274 IS
49275
49276 l_component_type VARCHAR2(80);
49280 l_amb_context_code VARCHAR2(30);
49277 l_component_code VARCHAR2(30);
49278 l_component_type_code VARCHAR2(1);
49279 l_component_appl_id INTEGER;
49281 l_entity_code VARCHAR2(30);
49282 l_event_class_code VARCHAR2(30);
49283 l_ae_header_id NUMBER;
49284 l_event_type_code VARCHAR2(30);
49285 l_line_definition_code VARCHAR2(30);
49286 l_line_definition_owner_code VARCHAR2(1);
49287 --
49288 -- adr variables
49289 l_segment VARCHAR2(30);
49290 l_ccid NUMBER;
49291 l_adr_transaction_coa_id NUMBER;
49292 l_adr_accounting_coa_id NUMBER;
49293 l_adr_flexfield_segment_code VARCHAR2(30);
49294 l_adr_flex_value_set_id NUMBER;
49295 l_adr_value_type_code VARCHAR2(30);
49296 l_adr_value_combination_id NUMBER;
49297 l_adr_value_segment_code VARCHAR2(30);
49298
49299 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
49300 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
49301 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
49302 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
49303
49304 -- 4262811 Variables ------------------------------------------------------------------------------------------
49305 l_entered_amt_idx NUMBER;
49306 l_accted_amt_idx NUMBER;
49307 l_acc_rev_flag VARCHAR2(1);
49308 l_accrual_line_num NUMBER;
49309 l_tmp_amt NUMBER;
49310 l_acc_rev_natural_side_code VARCHAR2(1);
49311
49312 l_num_entries NUMBER;
49313 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
49314 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
49315 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
49316 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
49317 l_recog_line_1 NUMBER;
49318 l_recog_line_2 NUMBER;
49319
49320 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
49321 l_bflow_applied_to_amt NUMBER; -- 5132302
49322 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
49323
49324 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
49325
49326 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
49327 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
49328
49329 ---------------------------------------------------------------------------------------------------------------
49330
49331
49332 --
49333 -- bulk performance
49334 --
49335 l_balance_type_code VARCHAR2(1);
49336 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
49337 l_log_module VARCHAR2(240);
49338
49339 --
49340 -- Upgrade strategy
49341 --
49342 l_actual_upg_option VARCHAR2(1);
49343 l_enc_upg_option VARCHAR2(1);
49344
49345 --
49346 BEGIN
49347 --
49348 IF g_log_enabled THEN
49349 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_98';
49350 END IF;
49351 --
49352 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49353
49354 trace
49355 (p_msg => 'BEGIN of AcctLineType_98'
49356 ,p_level => C_LEVEL_PROCEDURE
49357 ,p_module => l_log_module);
49358
49359 END IF;
49360 --
49361 l_component_type := 'AMB_JLT';
49362 l_component_code := 'RCT_UNAPP';
49363 l_component_type_code := 'S';
49364 l_component_appl_id := 222;
49365 l_amb_context_code := 'DEFAULT';
49366 l_entity_code := 'RECEIPTS';
49367 l_event_class_code := 'RECEIPT';
49368 l_event_type_code := 'RECEIPT_ALL';
49369 l_line_definition_owner_code := 'S';
49370 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
49371 --
49372 l_balance_type_code := 'A';
49373 l_segment := NULL;
49374 l_ccid := NULL;
49375 l_adr_transaction_coa_id := NULL;
49376 l_adr_accounting_coa_id := NULL;
49377 l_adr_flexfield_segment_code := NULL;
49378 l_adr_flex_value_set_id := NULL;
49379 l_adr_value_type_code := NULL;
49380 l_adr_value_combination_id := NULL;
49381 l_adr_value_segment_code := NULL;
49382
49383 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
49384 l_bflow_class_code := ''; -- 4219869 Business Flow
49385 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
49386 l_budgetary_control_flag := 'N';
49387
49388 l_bflow_applied_to_amt_idx := NULL; -- 5132302
49389 l_bflow_applied_to_amt := NULL; -- 5132302
49390 l_entered_amt_idx := NULL; -- 4262811
49391 l_accted_amt_idx := NULL; -- 4262811
49392 l_acc_rev_flag := NULL; -- 4262811
49393 l_accrual_line_num := NULL; -- 4262811
49394 l_tmp_amt := NULL; -- 4262811
49395 --
49396
49397 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
49398 l_balance_type_code <> 'B' THEN
49399 IF (NVL(p_source_15,'
49400 ') = 'OTHER ACC' AND
49401 NVL(p_source_16,'
49402 ') = 'CLAIM_INVESTIGATION' AND
49403 NVL(p_source_54,'
49404 ') = 'N') OR
49405 (NVL(p_source_15,'
49406 ') = 'FACTOR' AND
49410 ') = 'N') OR
49407 NVL(p_source_69,'
49408 ') = 'RA' AND
49409 NVL(p_source_54,'
49411 (NVL(p_source_15,'
49412 ') = 'OTHER ACC' AND
49413 NVL(p_source_54,'
49414 ') = 'N' AND
49415 NVL(p_source_16,'
49416 ') = 'NETTING') OR
49417 (NVL(p_source_15,'
49418 ') = 'OTHER ACC' AND
49419 NVL(p_source_54,'
49420 ') = 'N' AND
49421 NVL(p_source_16,'
49422 ') = 'PREPAYMENT') OR
49423 (NVL(p_source_15,'
49424 ') = 'ACTIVITY' AND
49425 NVL(p_source_54,'
49426 ') = 'N' AND
49427 NVL(p_source_16,'
49428 ') = 'CCREFUND') OR
49429 (NVL(p_source_15,'
49430 ') = 'REMITTANCE' AND
49431 NVL(p_source_54,'
49432 ') = 'N' AND
49433 NVL(p_source_69,'
49434 ') = 'RA') OR
49435 (NVL(p_source_15,'
49436 ') = 'ACTIVITY' AND
49437 NVL(p_source_54,'
49438 ') = 'N' AND
49439 NVL(p_source_16,'
49440 ') = 'WRITEOFF') OR
49441 (NVL(p_source_15,'
49442 ') = 'ACTIVITY' AND
49443 NVL(p_source_54,'
49444 ') = 'N' AND
49445 NVL(p_source_16,'
49446 ') = 'CM_REFUND') OR
49447 (NVL(p_source_15,'
49448 ') = 'ACTIVITY' AND
49449 NVL(p_source_16,'
49450 ') = 'ADJUST' AND
49451 NVL(p_source_54,'
49452 ') = 'N') OR
49453 (NVL(p_source_15,'
49454 ') = 'ACTIVITY' AND
49455 NVL(p_source_54,'
49456 ') = 'N' AND
49457 NVL(p_source_16,'
49458 ') = 'CC_CHARGEBACK') OR
49459 (NVL(p_source_15,'
49460 ') = 'ACTIVITY' AND
49461 NVL(p_source_54,'
49462 ') = 'N' AND
49463 NVL(p_source_16,'
49464 ') = 'NETTING')
49465 THEN
49466
49467 --
49468 XLA_AE_LINES_PKG.SetNewLine;
49469
49470 p_balance_type_code := l_balance_type_code;
49471 -- set the flag so later we will know whether the gain loss line needs to be created
49472
49473 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
49474 p_actual_flag :='A';
49475 END IF;
49476
49477 --
49478 -- bulk performance
49479 --
49480 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
49481 p_header_num => 0); -- 4262811
49482 --
49483 -- set accounting line options
49484 --
49485 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
49486 p_natural_side_code => 'D'
49487 , p_gain_or_loss_flag => 'N'
49488 , p_gl_transfer_mode_code => 'S'
49489 , p_acct_entry_type_code => 'A'
49490 , p_switch_side_flag => 'Y'
49491 , p_merge_duplicate_code => 'A'
49492 );
49493 --
49494 l_acc_rev_natural_side_code := 'C'; -- 4262811
49495 --
49496 --
49497 -- set accounting line type info
49498 --
49499 xla_ae_lines_pkg.SetAcctLineType
49500 (p_component_type => l_component_type
49501 ,p_event_type_code => l_event_type_code
49502 ,p_line_definition_owner_code => l_line_definition_owner_code
49503 ,p_line_definition_code => l_line_definition_code
49504 ,p_accounting_line_code => l_component_code
49505 ,p_accounting_line_type_code => l_component_type_code
49506 ,p_accounting_line_appl_id => l_component_appl_id
49507 ,p_amb_context_code => l_amb_context_code
49508 ,p_entity_code => l_entity_code
49509 ,p_event_class_code => l_event_class_code);
49510 --
49511 -- set accounting class
49512 --
49513 xla_ae_lines_pkg.SetAcctClass(
49514 p_accounting_class_code => 'UNAPP'
49515 , p_ae_header_id => l_ae_header_id
49516 );
49517
49518 --
49519 -- set rounding class
49520 --
49521 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
49522 'RECEIVABLE';
49523
49524 --
49525 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
49526 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
49527 --
49528 -- bulk performance
49529 --
49530 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
49531
49532 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
49533 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
49534
49535 -- 4955764
49536 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49537 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
49538
49539 -- 4458381 Public Sector Enh
49540
49541 --
49542 -- set accounting attributes for the line type
49543 --
49544 l_entered_amt_idx := 8;
49545 l_accted_amt_idx := 13;
49546 l_bflow_applied_to_amt_idx := NULL; -- 5132302
49547 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
49548 l_rec_acct_attrs.array_num_value(1) := p_source_58;
49549 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
49550 l_rec_acct_attrs.array_char_value(2) := p_source_30;
49551 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
49552 l_rec_acct_attrs.array_char_value(3) := p_source_59;
49553 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
49554 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
49558 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
49555 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
49556 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
49557 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
49559 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
49560 l_rec_acct_attrs.array_char_value(7) := p_source_18;
49561 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
49562 l_rec_acct_attrs.array_num_value(8) := p_source_61;
49563 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
49564 l_rec_acct_attrs.array_char_value(9) := p_source_62;
49565 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
49566 l_rec_acct_attrs.array_date_value(10) := p_source_21;
49567 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
49568 l_rec_acct_attrs.array_num_value(11) := p_source_22;
49569 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
49570 l_rec_acct_attrs.array_char_value(12) := p_source_23;
49571 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
49572 l_rec_acct_attrs.array_num_value(13) := p_source_63;
49573 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
49574 l_rec_acct_attrs.array_num_value(14) := p_source_70;
49575 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
49576 l_rec_acct_attrs.array_num_value(15) := p_source_71;
49577 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
49578 l_rec_acct_attrs.array_char_value(16) := p_source_66;
49579
49580 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
49581 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
49582
49583 ---------------------------------------------------------------------------------------------------------------
49584 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
49585 ---------------------------------------------------------------------------------------------------------------
49586 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
49587
49588 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
49589 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
49590
49591 IF xla_accounting_cache_pkg.GetValueChar
49592 (p_source_code => 'LEDGER_CATEGORY_CODE'
49593 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
49594 AND l_bflow_method_code = 'PRIOR_ENTRY'
49595 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
49596 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
49597 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
49598 )
49599 THEN
49600 xla_ae_lines_pkg.BflowUpgEntry
49601 (p_business_method_code => l_bflow_method_code
49602 ,p_business_class_code => l_bflow_class_code
49603 ,p_balance_type => l_balance_type_code);
49604 ELSE
49605 NULL;
49606 -- No business flow processing for business flow method of NONE.
49607 END IF;
49608
49609 --
49610 -- call analytical criteria
49611 --
49612
49613 --
49614 -- call description
49615 --
49616 -- No description or it is inherited.
49617 --
49618 -- call ADRs
49619 -- Bug 4922099
49620 --
49621 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49622 (NVL(l_actual_upg_option, 'N') = 'O') OR
49623 (NVL(l_enc_upg_option, 'N') = 'O')
49624 )
49625 THEN
49626 NULL;
49627 --
49628 --
49629
49630 l_ccid := AcctDerRule_15(
49631 p_application_id => p_application_id
49632 , p_ae_header_id => l_ae_header_id
49633 , p_source_11 => p_source_11
49634 , x_transaction_coa_id => l_adr_transaction_coa_id
49635 , x_accounting_coa_id => l_adr_accounting_coa_id
49636 , x_value_type_code => l_adr_value_type_code
49637 , p_side => 'NA'
49638 );
49639
49640 xla_ae_lines_pkg.set_ccid(
49641 p_code_combination_id => l_ccid
49642 , p_value_type_code => l_adr_value_type_code
49643 , p_transaction_coa_id => l_adr_transaction_coa_id
49644 , p_accounting_coa_id => l_adr_accounting_coa_id
49645 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
49646 , p_adr_type_code => 'S'
49647 , p_component_type => l_component_type
49648 , p_component_code => l_component_code
49649 , p_component_type_code => l_component_type_code
49650 , p_component_appl_id => l_component_appl_id
49651 , p_amb_context_code => l_amb_context_code
49652 , p_side => 'NA'
49653 );
49654
49655
49656 --
49657 --
49658 END IF;
49659 --
49660 -- Bug 4922099
49661 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
49662 (NVL(l_enc_upg_option, 'N') = 'O')
49663 ) AND
49664 (l_bflow_method_code = 'PRIOR_ENTRY')
49665 )
49666 THEN
49667 IF
49668 --
49669 1 = 2
49670 --
49671 THEN
49672 xla_accounting_err_pkg.build_message
49673 (p_appli_s_name => 'XLA'
49674 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49675 ,p_token_1 => 'LINE_NUMBER'
49679 l_component_type
49676 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
49677 ,p_token_2 => 'LINE_TYPE_NAME'
49678 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
49680 ,l_component_code
49681 ,l_component_type_code
49682 ,l_component_appl_id
49683 ,l_amb_context_code
49684 ,l_entity_code
49685 ,l_event_class_code
49686 )
49687 ,p_token_3 => 'OWNER'
49688 ,p_value_3 => xla_lookups_pkg.get_meaning(
49689 p_lookup_type => 'XLA_OWNER_TYPE'
49690 ,p_lookup_code => l_component_type_code
49691 )
49692 ,p_token_4 => 'PRODUCT_NAME'
49693 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
49694 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
49695 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
49696 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
49697 ,p_ae_header_id => NULL
49698 );
49699
49700 IF (C_LEVEL_ERROR>= g_log_level) THEN
49701 trace
49702 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49703 ,p_level => C_LEVEL_ERROR
49704 ,p_module => l_log_module);
49705 END IF;
49706 END IF;
49707 END IF;
49708 --
49709 --
49710 ------------------------------------------------------------------------------------------------
49711 -- 4219869 Business Flow
49712 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
49713 -- Prior Entry. Currently, the following code is always generated.
49714 ------------------------------------------------------------------------------------------------
49715 XLA_AE_LINES_PKG.ValidateCurrentLine;
49716
49717 ------------------------------------------------------------------------------------
49718 -- 4219869 Business Flow
49719 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
49720 ------------------------------------------------------------------------------------
49721 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49722
49723 ----------------------------------------------------------------------------------
49724 -- 4219869 Business Flow
49725 -- Update journal entry status -- Need to generate this within IF <condition>
49726 ----------------------------------------------------------------------------------
49727 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49728 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
49729 ,p_balance_type_code => l_balance_type_code
49730 );
49731
49732 -------------------------------------------------------------------------------------------
49733 -- 4262811 - Generate the Accrual Reversal lines
49734 -------------------------------------------------------------------------------------------
49735 BEGIN
49736 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
49737 (g_array_event(p_event_id).array_value_num('header_index'));
49738 IF l_acc_rev_flag IS NULL THEN
49739 l_acc_rev_flag := 'N';
49740 END IF;
49741 EXCEPTION
49742 WHEN OTHERS THEN
49743 l_acc_rev_flag := 'N';
49744 END;
49745 --
49746 IF (l_acc_rev_flag = 'Y') THEN
49747
49748 -- 4645092 ------------------------------------------------------------------------------
49749 -- To allow MPA report to determine if it should generate report process
49750 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
49751 ------------------------------------------------------------------------------------------
49752
49753 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
49754 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
49755 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
49756 -- call ADRs
49757 -- Bug 4922099
49758 --
49759 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49760 (NVL(l_actual_upg_option, 'N') = 'O') OR
49761 (NVL(l_enc_upg_option, 'N') = 'O')
49762 )
49763 THEN
49764 NULL;
49765 --
49766 --
49767
49768 l_ccid := AcctDerRule_15(
49769 p_application_id => p_application_id
49770 , p_ae_header_id => l_ae_header_id
49771 , p_source_11 => p_source_11
49772 , x_transaction_coa_id => l_adr_transaction_coa_id
49773 , x_accounting_coa_id => l_adr_accounting_coa_id
49774 , x_value_type_code => l_adr_value_type_code
49778 xla_ae_lines_pkg.set_ccid(
49775 , p_side => 'NA'
49776 );
49777
49779 p_code_combination_id => l_ccid
49780 , p_value_type_code => l_adr_value_type_code
49781 , p_transaction_coa_id => l_adr_transaction_coa_id
49782 , p_accounting_coa_id => l_adr_accounting_coa_id
49783 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
49784 , p_adr_type_code => 'S'
49785 , p_component_type => l_component_type
49786 , p_component_code => l_component_code
49787 , p_component_type_code => l_component_type_code
49788 , p_component_appl_id => l_component_appl_id
49789 , p_amb_context_code => l_amb_context_code
49790 , p_side => 'NA'
49791 );
49792
49793
49794 --
49795 --
49796 END IF;
49797
49798 --
49799 -- Update the line information that should be overwritten
49800 --
49801 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
49802 p_header_num => 1);
49803 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
49804
49805 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
49806
49807 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
49808 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
49809 END IF;
49810
49811 --
49812 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
49813 --
49814 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
49815 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
49816 ELSE
49817 ---------------------------------------------------------------------------------------------------
49818 -- 4262811a Switch Sign
49819 ---------------------------------------------------------------------------------------------------
49820 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
49821 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49822 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49823 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49824 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49825 -- 5132302
49826 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
49827 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49828
49829 END IF;
49830
49831 -- 4955764
49832 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49833 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
49834
49835
49836 XLA_AE_LINES_PKG.ValidateCurrentLine;
49837 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49838
49839 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49840 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
49841 ,p_balance_type_code => l_balance_type_code);
49842
49843 END IF;
49844
49845 -----------------------------------------------------------------------------------------
49846 -- 4262811 Multiperiod Accounting
49847 -----------------------------------------------------------------------------------------
49848 -- No MPA option is assigned.
49849
49850
49851 END IF;
49852 END IF;
49853 --
49854
49855 --
49856 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49857 trace
49858 (p_msg => 'END of AcctLineType_98'
49859 ,p_level => C_LEVEL_PROCEDURE
49860 ,p_module => l_log_module);
49861 END IF;
49862 --
49863 EXCEPTION
49864 WHEN xla_exceptions_pkg.application_exception THEN
49865 RAISE;
49866 WHEN OTHERS THEN
49867 xla_exceptions_pkg.raise_message
49868 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_98');
49869 END AcctLineType_98;
49870 --
49871
49872 ---------------------------------------
49873 --
49874 -- PRIVATE FUNCTION
49875 -- AcctLineType_99
49876 --
49877 ---------------------------------------
49878 PROCEDURE AcctLineType_99 (
49879 p_application_id IN NUMBER
49880 ,p_event_id IN NUMBER
49881 ,p_calculate_acctd_flag IN VARCHAR2
49882 ,p_calculate_g_l_flag IN VARCHAR2
49883 ,p_actual_flag IN OUT VARCHAR2
49884 ,p_balance_type_code OUT VARCHAR2
49885 ,p_gain_or_loss_ref OUT VARCHAR2
49886
49887 --Remittance Bank Account Unapplied Account
49888 , p_source_11 IN NUMBER
49889 --Distribution Source Type
49890 , p_source_15 IN VARCHAR2
49891 --Distribution Line Identifier
49892 , p_source_17 IN NUMBER
49893 --Distribution Type
49894 , p_source_18 IN VARCHAR2
49895 --Exchange Date
49896 , p_source_21 IN DATE
49897 --Exchange Rate
49898 , p_source_22 IN NUMBER
49899 --Exchange Rate Type
49900 , p_source_23 IN VARCHAR2
49901 --Transaction Distribution Identifier
49902 , p_source_29 IN NUMBER
49903 --Transaction Distribution Type
49904 , p_source_30 IN VARCHAR2
49908 , p_source_58 IN NUMBER
49905 --Distribution Multi Fund Additional Entry
49906 , p_source_54 IN VARCHAR2
49907 --Receipt Applied To Application Identifier
49909 --Transaction Entity Code
49910 , p_source_59 IN VARCHAR2
49911 --Transaction Identifier
49912 , p_source_60 IN NUMBER
49913 --DIST_ENT_AMT_FROM
49914 , p_source_61 IN NUMBER
49915 --Applying Document Currency Code
49916 , p_source_62 IN VARCHAR2
49917 --Accounting Amount
49918 , p_source_63 IN NUMBER
49919 --Distribution Party Type
49920 , p_source_66 IN VARCHAR2
49921 --Distribution Source Table
49922 , p_source_69 IN VARCHAR2
49923 --Receipt Pay From Customer
49924 , p_source_70 IN NUMBER
49925 --Receipt Customer Site Use Identifier
49926 , p_source_71 IN NUMBER
49927 --Receipt Application Status
49928 , p_source_72 IN VARCHAR2
49929 )
49930 IS
49931
49932 l_component_type VARCHAR2(80);
49933 l_component_code VARCHAR2(30);
49934 l_component_type_code VARCHAR2(1);
49935 l_component_appl_id INTEGER;
49936 l_amb_context_code VARCHAR2(30);
49937 l_entity_code VARCHAR2(30);
49938 l_event_class_code VARCHAR2(30);
49939 l_ae_header_id NUMBER;
49940 l_event_type_code VARCHAR2(30);
49941 l_line_definition_code VARCHAR2(30);
49942 l_line_definition_owner_code VARCHAR2(1);
49943 --
49944 -- adr variables
49945 l_segment VARCHAR2(30);
49946 l_ccid NUMBER;
49947 l_adr_transaction_coa_id NUMBER;
49948 l_adr_accounting_coa_id NUMBER;
49949 l_adr_flexfield_segment_code VARCHAR2(30);
49950 l_adr_flex_value_set_id NUMBER;
49951 l_adr_value_type_code VARCHAR2(30);
49952 l_adr_value_combination_id NUMBER;
49953 l_adr_value_segment_code VARCHAR2(30);
49954
49955 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
49956 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
49957 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
49958 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
49959
49960 -- 4262811 Variables ------------------------------------------------------------------------------------------
49961 l_entered_amt_idx NUMBER;
49962 l_accted_amt_idx NUMBER;
49963 l_acc_rev_flag VARCHAR2(1);
49964 l_accrual_line_num NUMBER;
49965 l_tmp_amt NUMBER;
49966 l_acc_rev_natural_side_code VARCHAR2(1);
49967
49968 l_num_entries NUMBER;
49969 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
49970 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
49971 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
49972 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
49973 l_recog_line_1 NUMBER;
49974 l_recog_line_2 NUMBER;
49975
49976 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
49977 l_bflow_applied_to_amt NUMBER; -- 5132302
49978 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
49979
49980 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
49981
49982 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
49983 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
49984
49985 ---------------------------------------------------------------------------------------------------------------
49986
49987
49988 --
49989 -- bulk performance
49990 --
49991 l_balance_type_code VARCHAR2(1);
49992 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
49993 l_log_module VARCHAR2(240);
49994
49995 --
49996 -- Upgrade strategy
49997 --
49998 l_actual_upg_option VARCHAR2(1);
49999 l_enc_upg_option VARCHAR2(1);
50000
50001 --
50002 BEGIN
50003 --
50004 IF g_log_enabled THEN
50005 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_99';
50006 END IF;
50007 --
50008 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
50009
50010 trace
50011 (p_msg => 'BEGIN of AcctLineType_99'
50012 ,p_level => C_LEVEL_PROCEDURE
50013 ,p_module => l_log_module);
50014
50015 END IF;
50016 --
50017 l_component_type := 'AMB_JLT';
50018 l_component_code := 'RCT_UNAPP_DEBIT';
50019 l_component_type_code := 'S';
50020 l_component_appl_id := 222;
50021 l_amb_context_code := 'DEFAULT';
50022 l_entity_code := 'RECEIPTS';
50023 l_event_class_code := 'RECEIPT';
50024 l_event_type_code := 'RECEIPT_ALL';
50025 l_line_definition_owner_code := 'S';
50026 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
50027 --
50028 l_balance_type_code := 'A';
50029 l_segment := NULL;
50030 l_ccid := NULL;
50031 l_adr_transaction_coa_id := NULL;
50032 l_adr_accounting_coa_id := NULL;
50033 l_adr_flexfield_segment_code := NULL;
50034 l_adr_flex_value_set_id := NULL;
50035 l_adr_value_type_code := NULL;
50036 l_adr_value_combination_id := NULL;
50037 l_adr_value_segment_code := NULL;
50038
50039 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
50043
50040 l_bflow_class_code := ''; -- 4219869 Business Flow
50041 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
50042 l_budgetary_control_flag := 'N';
50044 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50045 l_bflow_applied_to_amt := NULL; -- 5132302
50046 l_entered_amt_idx := NULL; -- 4262811
50047 l_accted_amt_idx := NULL; -- 4262811
50048 l_acc_rev_flag := NULL; -- 4262811
50049 l_accrual_line_num := NULL; -- 4262811
50050 l_tmp_amt := NULL; -- 4262811
50051 --
50052
50053 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
50054 l_balance_type_code <> 'B' THEN
50055 IF ((NVL(p_source_15,'
50056 ') = 'REC' AND
50057 NVL(p_source_54,'
50058 ') = 'N') OR
50059 (NVL(p_source_54,'
50060 ') = 'N' AND
50061 NVL(p_source_15,'
50062 ') = 'CASH') OR
50063 (NVL(p_source_54,'
50064 ') = 'N' AND
50065 NVL(p_source_15,'
50066 ') = 'CONFIRMATION') OR
50067 (NVL(p_source_54,'
50068 ') = 'N' AND
50069 NVL(p_source_15,'
50070 ') = 'CURR_ROUND') OR
50071 (NVL(p_source_54,'
50072 ') = 'N' AND
50073 NVL(p_source_15,'
50074 ') = 'DEFERRED_TAX') OR
50075 (NVL(p_source_54,'
50076 ') = 'N' AND
50077 NVL(p_source_69,'
50078 ') = 'CRH' AND
50079 NVL(p_source_15,'
50080 ') = 'FACTOR') OR
50081 (NVL(p_source_54,'
50082 ') = 'N' AND
50083 NVL(p_source_15,'
50084 ') = 'ACC') OR
50085 (NVL(p_source_54,'
50086 ') = 'N' AND
50087 NVL(p_source_15,'
50088 ') = 'REMITTANCE' AND
50089 NVL(p_source_69,'
50090 ') = 'CRH') OR
50091 (NVL(p_source_54,'
50092 ') = 'N' AND
50093 NVL(p_source_15,'
50094 ') = 'SHORT_TERM_DEBT') OR
50095 (NVL(p_source_54,'
50096 ') = 'N' AND
50097 NVL(p_source_15,'
50098 ') = 'TAX') OR
50099 (NVL(p_source_54,'
50100 ') = 'N' AND
50101 NVL(p_source_15,'
50102 ') = 'UNID') OR
50103 (NVL(p_source_54,'
50104 ') = 'N' AND
50105 NVL(p_source_15,'
50106 ') = 'BANK_CHARGES') OR
50107 (NVL(p_source_54,'
50108 ') = 'N' AND
50109 NVL(p_source_15,'
50110 ') = 'EDISC') OR
50111 (NVL(p_source_54,'
50112 ') = 'N' AND
50113 NVL(p_source_15,'
50114 ') = 'UNEDISC')
50115 ) AND NVL(p_source_72,'
50116 ') <> 'UNID'
50117 THEN
50118
50119 --
50120 XLA_AE_LINES_PKG.SetNewLine;
50121
50122 p_balance_type_code := l_balance_type_code;
50123 -- set the flag so later we will know whether the gain loss line needs to be created
50124
50125 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
50126 p_actual_flag :='A';
50127 END IF;
50128
50129 --
50130 -- bulk performance
50131 --
50132 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
50133 p_header_num => 0); -- 4262811
50134 --
50135 -- set accounting line options
50136 --
50137 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
50138 p_natural_side_code => 'D'
50139 , p_gain_or_loss_flag => 'N'
50140 , p_gl_transfer_mode_code => 'S'
50141 , p_acct_entry_type_code => 'A'
50142 , p_switch_side_flag => 'Y'
50143 , p_merge_duplicate_code => 'A'
50144 );
50145 --
50146 l_acc_rev_natural_side_code := 'C'; -- 4262811
50147 --
50148 --
50149 -- set accounting line type info
50150 --
50151 xla_ae_lines_pkg.SetAcctLineType
50152 (p_component_type => l_component_type
50153 ,p_event_type_code => l_event_type_code
50154 ,p_line_definition_owner_code => l_line_definition_owner_code
50155 ,p_line_definition_code => l_line_definition_code
50156 ,p_accounting_line_code => l_component_code
50157 ,p_accounting_line_type_code => l_component_type_code
50158 ,p_accounting_line_appl_id => l_component_appl_id
50159 ,p_amb_context_code => l_amb_context_code
50160 ,p_entity_code => l_entity_code
50161 ,p_event_class_code => l_event_class_code);
50162 --
50163 -- set accounting class
50164 --
50165 xla_ae_lines_pkg.SetAcctClass(
50166 p_accounting_class_code => 'UNAPP'
50167 , p_ae_header_id => l_ae_header_id
50168 );
50169
50170 --
50171 -- set rounding class
50172 --
50173 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
50174 'RECEIVABLE';
50175
50176 --
50177 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
50178 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
50179 --
50180 -- bulk performance
50181 --
50182 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
50183
50184 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
50185 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
50186
50187 -- 4955764
50188 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50189 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
50190
50194 -- set accounting attributes for the line type
50191 -- 4458381 Public Sector Enh
50192
50193 --
50195 --
50196 l_entered_amt_idx := 8;
50197 l_accted_amt_idx := 13;
50198 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50199 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
50200 l_rec_acct_attrs.array_num_value(1) := p_source_58;
50201 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
50202 l_rec_acct_attrs.array_char_value(2) := p_source_30;
50203 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
50204 l_rec_acct_attrs.array_char_value(3) := p_source_59;
50205 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
50206 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
50207 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
50208 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
50209 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
50210 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
50211 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
50212 l_rec_acct_attrs.array_char_value(7) := p_source_18;
50213 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
50214 l_rec_acct_attrs.array_num_value(8) := p_source_61;
50215 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
50216 l_rec_acct_attrs.array_char_value(9) := p_source_62;
50217 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
50218 l_rec_acct_attrs.array_date_value(10) := p_source_21;
50219 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
50220 l_rec_acct_attrs.array_num_value(11) := p_source_22;
50221 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
50222 l_rec_acct_attrs.array_char_value(12) := p_source_23;
50223 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
50224 l_rec_acct_attrs.array_num_value(13) := p_source_63;
50225 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
50226 l_rec_acct_attrs.array_num_value(14) := p_source_70;
50227 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
50228 l_rec_acct_attrs.array_num_value(15) := p_source_71;
50229 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
50230 l_rec_acct_attrs.array_char_value(16) := p_source_66;
50231
50232 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
50233 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
50234
50235 ---------------------------------------------------------------------------------------------------------------
50236 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
50237 ---------------------------------------------------------------------------------------------------------------
50238 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
50239
50240 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50241 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50242
50243 IF xla_accounting_cache_pkg.GetValueChar
50244 (p_source_code => 'LEDGER_CATEGORY_CODE'
50245 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
50246 AND l_bflow_method_code = 'PRIOR_ENTRY'
50247 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
50248 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
50249 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
50250 )
50251 THEN
50252 xla_ae_lines_pkg.BflowUpgEntry
50253 (p_business_method_code => l_bflow_method_code
50254 ,p_business_class_code => l_bflow_class_code
50255 ,p_balance_type => l_balance_type_code);
50256 ELSE
50257 NULL;
50258 -- No business flow processing for business flow method of NONE.
50259 END IF;
50260
50261 --
50262 -- call analytical criteria
50263 --
50264
50265 --
50266 -- call description
50267 --
50268 -- No description or it is inherited.
50269 --
50270 -- call ADRs
50271 -- Bug 4922099
50272 --
50273 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50274 (NVL(l_actual_upg_option, 'N') = 'O') OR
50275 (NVL(l_enc_upg_option, 'N') = 'O')
50276 )
50277 THEN
50278 NULL;
50279 --
50280 --
50281
50282 l_ccid := AcctDerRule_15(
50283 p_application_id => p_application_id
50284 , p_ae_header_id => l_ae_header_id
50285 , p_source_11 => p_source_11
50286 , x_transaction_coa_id => l_adr_transaction_coa_id
50287 , x_accounting_coa_id => l_adr_accounting_coa_id
50288 , x_value_type_code => l_adr_value_type_code
50289 , p_side => 'NA'
50290 );
50291
50292 xla_ae_lines_pkg.set_ccid(
50293 p_code_combination_id => l_ccid
50294 , p_value_type_code => l_adr_value_type_code
50295 , p_transaction_coa_id => l_adr_transaction_coa_id
50296 , p_accounting_coa_id => l_adr_accounting_coa_id
50297 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
50298 , p_adr_type_code => 'S'
50299 , p_component_type => l_component_type
50300 , p_component_code => l_component_code
50301 , p_component_type_code => l_component_type_code
50305 );
50302 , p_component_appl_id => l_component_appl_id
50303 , p_amb_context_code => l_amb_context_code
50304 , p_side => 'NA'
50306
50307
50308 --
50309 --
50310 END IF;
50311 --
50312 -- Bug 4922099
50313 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
50314 (NVL(l_enc_upg_option, 'N') = 'O')
50315 ) AND
50316 (l_bflow_method_code = 'PRIOR_ENTRY')
50317 )
50318 THEN
50319 IF
50320 --
50321 1 = 2
50322 --
50323 THEN
50324 xla_accounting_err_pkg.build_message
50325 (p_appli_s_name => 'XLA'
50326 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50327 ,p_token_1 => 'LINE_NUMBER'
50328 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
50329 ,p_token_2 => 'LINE_TYPE_NAME'
50330 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
50331 l_component_type
50332 ,l_component_code
50333 ,l_component_type_code
50334 ,l_component_appl_id
50335 ,l_amb_context_code
50336 ,l_entity_code
50337 ,l_event_class_code
50338 )
50339 ,p_token_3 => 'OWNER'
50340 ,p_value_3 => xla_lookups_pkg.get_meaning(
50341 p_lookup_type => 'XLA_OWNER_TYPE'
50342 ,p_lookup_code => l_component_type_code
50343 )
50344 ,p_token_4 => 'PRODUCT_NAME'
50345 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
50346 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
50347 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
50348 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
50349 ,p_ae_header_id => NULL
50350 );
50351
50352 IF (C_LEVEL_ERROR>= g_log_level) THEN
50353 trace
50354 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50355 ,p_level => C_LEVEL_ERROR
50356 ,p_module => l_log_module);
50357 END IF;
50358 END IF;
50359 END IF;
50360 --
50361 --
50362 ------------------------------------------------------------------------------------------------
50363 -- 4219869 Business Flow
50364 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
50365 -- Prior Entry. Currently, the following code is always generated.
50366 ------------------------------------------------------------------------------------------------
50367 XLA_AE_LINES_PKG.ValidateCurrentLine;
50368
50369 ------------------------------------------------------------------------------------
50370 -- 4219869 Business Flow
50371 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
50372 ------------------------------------------------------------------------------------
50373 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50374
50375 ----------------------------------------------------------------------------------
50376 -- 4219869 Business Flow
50377 -- Update journal entry status -- Need to generate this within IF <condition>
50378 ----------------------------------------------------------------------------------
50379 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50380 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
50381 ,p_balance_type_code => l_balance_type_code
50382 );
50383
50384 -------------------------------------------------------------------------------------------
50385 -- 4262811 - Generate the Accrual Reversal lines
50386 -------------------------------------------------------------------------------------------
50387 BEGIN
50388 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
50389 (g_array_event(p_event_id).array_value_num('header_index'));
50390 IF l_acc_rev_flag IS NULL THEN
50391 l_acc_rev_flag := 'N';
50392 END IF;
50393 EXCEPTION
50394 WHEN OTHERS THEN
50395 l_acc_rev_flag := 'N';
50396 END;
50397 --
50398 IF (l_acc_rev_flag = 'Y') THEN
50399
50400 -- 4645092 ------------------------------------------------------------------------------
50401 -- To allow MPA report to determine if it should generate report process
50402 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
50403 ------------------------------------------------------------------------------------------
50404
50405 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
50409 -- Bug 4922099
50406 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
50407 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
50408 -- call ADRs
50410 --
50411 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50412 (NVL(l_actual_upg_option, 'N') = 'O') OR
50413 (NVL(l_enc_upg_option, 'N') = 'O')
50414 )
50415 THEN
50416 NULL;
50417 --
50418 --
50419
50420 l_ccid := AcctDerRule_15(
50421 p_application_id => p_application_id
50422 , p_ae_header_id => l_ae_header_id
50423 , p_source_11 => p_source_11
50424 , x_transaction_coa_id => l_adr_transaction_coa_id
50425 , x_accounting_coa_id => l_adr_accounting_coa_id
50426 , x_value_type_code => l_adr_value_type_code
50427 , p_side => 'NA'
50428 );
50429
50430 xla_ae_lines_pkg.set_ccid(
50431 p_code_combination_id => l_ccid
50432 , p_value_type_code => l_adr_value_type_code
50433 , p_transaction_coa_id => l_adr_transaction_coa_id
50434 , p_accounting_coa_id => l_adr_accounting_coa_id
50435 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
50436 , p_adr_type_code => 'S'
50437 , p_component_type => l_component_type
50438 , p_component_code => l_component_code
50439 , p_component_type_code => l_component_type_code
50440 , p_component_appl_id => l_component_appl_id
50441 , p_amb_context_code => l_amb_context_code
50442 , p_side => 'NA'
50443 );
50444
50445
50446 --
50447 --
50448 END IF;
50449
50450 --
50451 -- Update the line information that should be overwritten
50452 --
50453 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
50454 p_header_num => 1);
50455 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
50456
50457 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
50458
50459 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
50460 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
50461 END IF;
50462
50463 --
50464 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
50465 --
50466 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
50467 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
50468 ELSE
50469 ---------------------------------------------------------------------------------------------------
50470 -- 4262811a Switch Sign
50471 ---------------------------------------------------------------------------------------------------
50472 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
50473 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50474 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50475 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50476 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50477 -- 5132302
50478 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
50479 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50480
50481 END IF;
50482
50483 -- 4955764
50484 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50485 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
50486
50487
50488 XLA_AE_LINES_PKG.ValidateCurrentLine;
50489 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50490
50491 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50492 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
50493 ,p_balance_type_code => l_balance_type_code);
50494
50495 END IF;
50496
50497 -----------------------------------------------------------------------------------------
50498 -- 4262811 Multiperiod Accounting
50499 -----------------------------------------------------------------------------------------
50500 -- No MPA option is assigned.
50501
50502
50503 END IF;
50504 END IF;
50505 --
50506
50507 --
50508 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
50509 trace
50510 (p_msg => 'END of AcctLineType_99'
50511 ,p_level => C_LEVEL_PROCEDURE
50512 ,p_module => l_log_module);
50513 END IF;
50514 --
50515 EXCEPTION
50516 WHEN xla_exceptions_pkg.application_exception THEN
50517 RAISE;
50518 WHEN OTHERS THEN
50519 xla_exceptions_pkg.raise_message
50520 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_99');
50521 END AcctLineType_99;
50522 --
50523
50524 ---------------------------------------
50525 --
50526 -- PRIVATE FUNCTION
50527 -- AcctLineType_100
50528 --
50529 ---------------------------------------
50530 PROCEDURE AcctLineType_100 (
50531 p_application_id IN NUMBER
50532 ,p_event_id IN NUMBER
50533 ,p_calculate_acctd_flag IN VARCHAR2
50534 ,p_calculate_g_l_flag IN VARCHAR2
50538
50535 ,p_actual_flag IN OUT VARCHAR2
50536 ,p_balance_type_code OUT VARCHAR2
50537 ,p_gain_or_loss_ref OUT VARCHAR2
50539 --Remittance Bank Account Unapplied Account
50540 , p_source_11 IN NUMBER
50541 --Distribution Source Type
50542 , p_source_15 IN VARCHAR2
50543 --Distribution Line Identifier
50544 , p_source_17 IN NUMBER
50545 --Distribution Type
50546 , p_source_18 IN VARCHAR2
50547 --Exchange Date
50548 , p_source_21 IN DATE
50549 --Exchange Rate
50550 , p_source_22 IN NUMBER
50551 --Exchange Rate Type
50552 , p_source_23 IN VARCHAR2
50553 --Transaction Distribution Identifier
50554 , p_source_29 IN NUMBER
50555 --Transaction Distribution Type
50556 , p_source_30 IN VARCHAR2
50557 --Receipt Applied To Application Identifier
50558 , p_source_58 IN NUMBER
50559 --Transaction Entity Code
50560 , p_source_59 IN VARCHAR2
50561 --Transaction Identifier
50562 , p_source_60 IN NUMBER
50563 --DIST_ENT_AMT_FROM
50564 , p_source_61 IN NUMBER
50565 --Applying Document Currency Code
50566 , p_source_62 IN VARCHAR2
50567 --Accounting Amount
50568 , p_source_63 IN NUMBER
50569 --Distribution Party Identifier
50570 , p_source_64 IN NUMBER
50571 --Distribution Party Site Id
50572 , p_source_65 IN NUMBER
50573 --Distribution Party Type
50574 , p_source_66 IN VARCHAR2
50575 )
50576 IS
50577
50578 l_component_type VARCHAR2(80);
50579 l_component_code VARCHAR2(30);
50580 l_component_type_code VARCHAR2(1);
50581 l_component_appl_id INTEGER;
50582 l_amb_context_code VARCHAR2(30);
50583 l_entity_code VARCHAR2(30);
50584 l_event_class_code VARCHAR2(30);
50585 l_ae_header_id NUMBER;
50586 l_event_type_code VARCHAR2(30);
50587 l_line_definition_code VARCHAR2(30);
50588 l_line_definition_owner_code VARCHAR2(1);
50589 --
50590 -- adr variables
50591 l_segment VARCHAR2(30);
50592 l_ccid NUMBER;
50593 l_adr_transaction_coa_id NUMBER;
50594 l_adr_accounting_coa_id NUMBER;
50595 l_adr_flexfield_segment_code VARCHAR2(30);
50596 l_adr_flex_value_set_id NUMBER;
50597 l_adr_value_type_code VARCHAR2(30);
50598 l_adr_value_combination_id NUMBER;
50599 l_adr_value_segment_code VARCHAR2(30);
50600
50601 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
50602 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
50603 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
50604 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
50605
50606 -- 4262811 Variables ------------------------------------------------------------------------------------------
50607 l_entered_amt_idx NUMBER;
50608 l_accted_amt_idx NUMBER;
50609 l_acc_rev_flag VARCHAR2(1);
50610 l_accrual_line_num NUMBER;
50611 l_tmp_amt NUMBER;
50612 l_acc_rev_natural_side_code VARCHAR2(1);
50613
50614 l_num_entries NUMBER;
50615 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
50616 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
50617 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
50618 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
50619 l_recog_line_1 NUMBER;
50620 l_recog_line_2 NUMBER;
50621
50622 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
50623 l_bflow_applied_to_amt NUMBER; -- 5132302
50624 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
50625
50626 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
50627
50628 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
50629 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
50630
50631 ---------------------------------------------------------------------------------------------------------------
50632
50633
50634 --
50635 -- bulk performance
50636 --
50637 l_balance_type_code VARCHAR2(1);
50638 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
50639 l_log_module VARCHAR2(240);
50640
50641 --
50642 -- Upgrade strategy
50643 --
50644 l_actual_upg_option VARCHAR2(1);
50645 l_enc_upg_option VARCHAR2(1);
50646
50647 --
50648 BEGIN
50649 --
50650 IF g_log_enabled THEN
50651 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_100';
50652 END IF;
50653 --
50654 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
50655
50656 trace
50657 (p_msg => 'BEGIN of AcctLineType_100'
50658 ,p_level => C_LEVEL_PROCEDURE
50659 ,p_module => l_log_module);
50660
50661 END IF;
50662 --
50663 l_component_type := 'AMB_JLT';
50664 l_component_code := 'RCT_UNAPP_GAIN_LOSS_DEBIT';
50665 l_component_type_code := 'S';
50666 l_component_appl_id := 222;
50667 l_amb_context_code := 'DEFAULT';
50668 l_entity_code := 'RECEIPTS';
50669 l_event_class_code := 'RECEIPT';
50670 l_event_type_code := 'RECEIPT_ALL';
50671 l_line_definition_owner_code := 'S';
50672 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
50673 --
50677 l_adr_transaction_coa_id := NULL;
50674 l_balance_type_code := 'A';
50675 l_segment := NULL;
50676 l_ccid := NULL;
50678 l_adr_accounting_coa_id := NULL;
50679 l_adr_flexfield_segment_code := NULL;
50680 l_adr_flex_value_set_id := NULL;
50681 l_adr_value_type_code := NULL;
50682 l_adr_value_combination_id := NULL;
50683 l_adr_value_segment_code := NULL;
50684
50685 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
50686 l_bflow_class_code := ''; -- 4219869 Business Flow
50687 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
50688 l_budgetary_control_flag := 'N';
50689
50690 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50691 l_bflow_applied_to_amt := NULL; -- 5132302
50692 l_entered_amt_idx := NULL; -- 4262811
50693 l_accted_amt_idx := NULL; -- 4262811
50694 l_acc_rev_flag := NULL; -- 4262811
50695 l_accrual_line_num := NULL; -- 4262811
50696 l_tmp_amt := NULL; -- 4262811
50697 --
50698
50699 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
50700 l_balance_type_code <> 'B' THEN
50701 IF (NVL(p_source_15,'
50702 ') = 'EXCH_LOSS') OR
50703 (NVL(p_source_15,'
50704 ') = 'EXCH_GAIN')
50705 THEN
50706
50707 --
50708 XLA_AE_LINES_PKG.SetNewLine;
50709
50710 p_balance_type_code := l_balance_type_code;
50711 -- set the flag so later we will know whether the gain loss line needs to be created
50712
50713 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
50714 p_actual_flag :='A';
50715 END IF;
50716
50717 --
50718 -- bulk performance
50719 --
50720 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
50721 p_header_num => 0); -- 4262811
50722 --
50723 -- set accounting line options
50724 --
50725 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
50726 p_natural_side_code => 'D'
50727 , p_gain_or_loss_flag => 'N'
50728 , p_gl_transfer_mode_code => 'S'
50729 , p_acct_entry_type_code => 'A'
50730 , p_switch_side_flag => 'Y'
50731 , p_merge_duplicate_code => 'A'
50732 );
50733 --
50734 l_acc_rev_natural_side_code := 'C'; -- 4262811
50735 --
50736 --
50737 -- set accounting line type info
50738 --
50739 xla_ae_lines_pkg.SetAcctLineType
50740 (p_component_type => l_component_type
50741 ,p_event_type_code => l_event_type_code
50742 ,p_line_definition_owner_code => l_line_definition_owner_code
50743 ,p_line_definition_code => l_line_definition_code
50744 ,p_accounting_line_code => l_component_code
50745 ,p_accounting_line_type_code => l_component_type_code
50746 ,p_accounting_line_appl_id => l_component_appl_id
50747 ,p_amb_context_code => l_amb_context_code
50748 ,p_entity_code => l_entity_code
50749 ,p_event_class_code => l_event_class_code);
50750 --
50751 -- set accounting class
50752 --
50753 xla_ae_lines_pkg.SetAcctClass(
50754 p_accounting_class_code => 'UNAPP'
50755 , p_ae_header_id => l_ae_header_id
50756 );
50757
50758 --
50759 -- set rounding class
50760 --
50761 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
50762 'RECEIVABLE';
50763
50764 --
50765 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
50766 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
50767 --
50768 -- bulk performance
50769 --
50770 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
50771
50772 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
50773 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
50774
50775 -- 4955764
50776 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50777 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
50778
50779 -- 4458381 Public Sector Enh
50780
50781 --
50782 -- set accounting attributes for the line type
50783 --
50784 l_entered_amt_idx := 8;
50785 l_accted_amt_idx := 13;
50786 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50787 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
50788 l_rec_acct_attrs.array_num_value(1) := p_source_58;
50789 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
50790 l_rec_acct_attrs.array_char_value(2) := p_source_30;
50791 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
50792 l_rec_acct_attrs.array_char_value(3) := p_source_59;
50793 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
50794 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
50795 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
50796 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
50797 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
50798 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
50799 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
50803 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
50800 l_rec_acct_attrs.array_char_value(7) := p_source_18;
50801 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
50802 l_rec_acct_attrs.array_num_value(8) := p_source_61;
50804 l_rec_acct_attrs.array_char_value(9) := p_source_62;
50805 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
50806 l_rec_acct_attrs.array_date_value(10) := p_source_21;
50807 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
50808 l_rec_acct_attrs.array_num_value(11) := p_source_22;
50809 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
50810 l_rec_acct_attrs.array_char_value(12) := p_source_23;
50811 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
50812 l_rec_acct_attrs.array_num_value(13) := p_source_63;
50813 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
50814 l_rec_acct_attrs.array_num_value(14) := p_source_64;
50815 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
50816 l_rec_acct_attrs.array_num_value(15) := p_source_65;
50817 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
50818 l_rec_acct_attrs.array_char_value(16) := p_source_66;
50819
50820 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
50821 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
50822
50823 ---------------------------------------------------------------------------------------------------------------
50824 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
50825 ---------------------------------------------------------------------------------------------------------------
50826 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
50827
50828 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50829 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50830
50831 IF xla_accounting_cache_pkg.GetValueChar
50832 (p_source_code => 'LEDGER_CATEGORY_CODE'
50833 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
50834 AND l_bflow_method_code = 'PRIOR_ENTRY'
50835 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
50836 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
50837 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
50838 )
50839 THEN
50840 xla_ae_lines_pkg.BflowUpgEntry
50841 (p_business_method_code => l_bflow_method_code
50842 ,p_business_class_code => l_bflow_class_code
50843 ,p_balance_type => l_balance_type_code);
50844 ELSE
50845 NULL;
50846 -- No business flow processing for business flow method of NONE.
50847 END IF;
50848
50849 --
50850 -- call analytical criteria
50851 --
50852
50853 --
50854 -- call description
50855 --
50856 -- No description or it is inherited.
50857 --
50858 -- call ADRs
50859 -- Bug 4922099
50860 --
50861 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50862 (NVL(l_actual_upg_option, 'N') = 'O') OR
50863 (NVL(l_enc_upg_option, 'N') = 'O')
50864 )
50865 THEN
50866 NULL;
50867 --
50868 --
50869
50870 l_ccid := AcctDerRule_15(
50871 p_application_id => p_application_id
50872 , p_ae_header_id => l_ae_header_id
50873 , p_source_11 => p_source_11
50874 , x_transaction_coa_id => l_adr_transaction_coa_id
50875 , x_accounting_coa_id => l_adr_accounting_coa_id
50876 , x_value_type_code => l_adr_value_type_code
50877 , p_side => 'NA'
50878 );
50879
50880 xla_ae_lines_pkg.set_ccid(
50881 p_code_combination_id => l_ccid
50882 , p_value_type_code => l_adr_value_type_code
50883 , p_transaction_coa_id => l_adr_transaction_coa_id
50884 , p_accounting_coa_id => l_adr_accounting_coa_id
50885 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
50886 , p_adr_type_code => 'S'
50887 , p_component_type => l_component_type
50888 , p_component_code => l_component_code
50889 , p_component_type_code => l_component_type_code
50890 , p_component_appl_id => l_component_appl_id
50891 , p_amb_context_code => l_amb_context_code
50892 , p_side => 'NA'
50893 );
50894
50895
50896 --
50897 --
50898 END IF;
50899 --
50900 -- Bug 4922099
50901 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
50902 (NVL(l_enc_upg_option, 'N') = 'O')
50903 ) AND
50904 (l_bflow_method_code = 'PRIOR_ENTRY')
50905 )
50906 THEN
50907 IF
50908 --
50909 1 = 2
50910 --
50911 THEN
50912 xla_accounting_err_pkg.build_message
50913 (p_appli_s_name => 'XLA'
50914 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50915 ,p_token_1 => 'LINE_NUMBER'
50916 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
50917 ,p_token_2 => 'LINE_TYPE_NAME'
50918 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
50922 ,l_component_appl_id
50919 l_component_type
50920 ,l_component_code
50921 ,l_component_type_code
50923 ,l_amb_context_code
50924 ,l_entity_code
50925 ,l_event_class_code
50926 )
50927 ,p_token_3 => 'OWNER'
50928 ,p_value_3 => xla_lookups_pkg.get_meaning(
50929 p_lookup_type => 'XLA_OWNER_TYPE'
50930 ,p_lookup_code => l_component_type_code
50931 )
50932 ,p_token_4 => 'PRODUCT_NAME'
50933 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
50934 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
50935 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
50936 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
50937 ,p_ae_header_id => NULL
50938 );
50939
50940 IF (C_LEVEL_ERROR>= g_log_level) THEN
50941 trace
50942 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50943 ,p_level => C_LEVEL_ERROR
50944 ,p_module => l_log_module);
50945 END IF;
50946 END IF;
50947 END IF;
50948 --
50949 --
50950 ------------------------------------------------------------------------------------------------
50951 -- 4219869 Business Flow
50952 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
50953 -- Prior Entry. Currently, the following code is always generated.
50954 ------------------------------------------------------------------------------------------------
50955 XLA_AE_LINES_PKG.ValidateCurrentLine;
50956
50957 ------------------------------------------------------------------------------------
50958 -- 4219869 Business Flow
50959 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
50960 ------------------------------------------------------------------------------------
50961 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50962
50963 ----------------------------------------------------------------------------------
50964 -- 4219869 Business Flow
50965 -- Update journal entry status -- Need to generate this within IF <condition>
50966 ----------------------------------------------------------------------------------
50967 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50968 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
50969 ,p_balance_type_code => l_balance_type_code
50970 );
50971
50972 -------------------------------------------------------------------------------------------
50973 -- 4262811 - Generate the Accrual Reversal lines
50974 -------------------------------------------------------------------------------------------
50975 BEGIN
50976 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
50977 (g_array_event(p_event_id).array_value_num('header_index'));
50978 IF l_acc_rev_flag IS NULL THEN
50979 l_acc_rev_flag := 'N';
50980 END IF;
50981 EXCEPTION
50982 WHEN OTHERS THEN
50983 l_acc_rev_flag := 'N';
50984 END;
50985 --
50986 IF (l_acc_rev_flag = 'Y') THEN
50987
50988 -- 4645092 ------------------------------------------------------------------------------
50989 -- To allow MPA report to determine if it should generate report process
50990 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
50991 ------------------------------------------------------------------------------------------
50992
50993 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
50994 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
50995 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
50996 -- call ADRs
50997 -- Bug 4922099
50998 --
50999 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51000 (NVL(l_actual_upg_option, 'N') = 'O') OR
51001 (NVL(l_enc_upg_option, 'N') = 'O')
51002 )
51003 THEN
51004 NULL;
51005 --
51006 --
51007
51008 l_ccid := AcctDerRule_15(
51009 p_application_id => p_application_id
51010 , p_ae_header_id => l_ae_header_id
51011 , p_source_11 => p_source_11
51012 , x_transaction_coa_id => l_adr_transaction_coa_id
51013 , x_accounting_coa_id => l_adr_accounting_coa_id
51014 , x_value_type_code => l_adr_value_type_code
51015 , p_side => 'NA'
51016 );
51017
51018 xla_ae_lines_pkg.set_ccid(
51019 p_code_combination_id => l_ccid
51023 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
51020 , p_value_type_code => l_adr_value_type_code
51021 , p_transaction_coa_id => l_adr_transaction_coa_id
51022 , p_accounting_coa_id => l_adr_accounting_coa_id
51024 , p_adr_type_code => 'S'
51025 , p_component_type => l_component_type
51026 , p_component_code => l_component_code
51027 , p_component_type_code => l_component_type_code
51028 , p_component_appl_id => l_component_appl_id
51029 , p_amb_context_code => l_amb_context_code
51030 , p_side => 'NA'
51031 );
51032
51033
51034 --
51035 --
51036 END IF;
51037
51038 --
51039 -- Update the line information that should be overwritten
51040 --
51041 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
51042 p_header_num => 1);
51043 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
51044
51045 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
51046
51047 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
51048 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
51049 END IF;
51050
51051 --
51052 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
51053 --
51054 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
51055 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
51056 ELSE
51057 ---------------------------------------------------------------------------------------------------
51058 -- 4262811a Switch Sign
51059 ---------------------------------------------------------------------------------------------------
51060 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
51061 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51062 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51063 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51064 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51065 -- 5132302
51066 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
51067 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51068
51069 END IF;
51070
51071 -- 4955764
51072 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51073 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
51074
51075
51076 XLA_AE_LINES_PKG.ValidateCurrentLine;
51077 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
51078
51079 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
51080 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
51081 ,p_balance_type_code => l_balance_type_code);
51082
51083 END IF;
51084
51085 -----------------------------------------------------------------------------------------
51086 -- 4262811 Multiperiod Accounting
51087 -----------------------------------------------------------------------------------------
51088 -- No MPA option is assigned.
51089
51090
51091 END IF;
51092 END IF;
51093 --
51094
51095 --
51096 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51097 trace
51098 (p_msg => 'END of AcctLineType_100'
51099 ,p_level => C_LEVEL_PROCEDURE
51100 ,p_module => l_log_module);
51101 END IF;
51102 --
51103 EXCEPTION
51104 WHEN xla_exceptions_pkg.application_exception THEN
51105 RAISE;
51106 WHEN OTHERS THEN
51107 xla_exceptions_pkg.raise_message
51108 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_100');
51109 END AcctLineType_100;
51110 --
51111
51112 ---------------------------------------
51113 --
51114 -- PRIVATE FUNCTION
51115 -- AcctLineType_101
51116 --
51117 ---------------------------------------
51118 PROCEDURE AcctLineType_101 (
51119 p_application_id IN NUMBER
51120 ,p_event_id IN NUMBER
51121 ,p_calculate_acctd_flag IN VARCHAR2
51122 ,p_calculate_g_l_flag IN VARCHAR2
51123 ,p_actual_flag IN OUT VARCHAR2
51124 ,p_balance_type_code OUT VARCHAR2
51125 ,p_gain_or_loss_ref OUT VARCHAR2
51126
51127 --Remittance Bank Account Unearned Account
51128 , p_source_7 IN NUMBER
51129 --Transaction Distribution GL Account
51130 , p_source_14 IN NUMBER
51131 --Distribution Source Type
51132 , p_source_15 IN VARCHAR2
51133 --Distribution Line Identifier
51134 , p_source_17 IN NUMBER
51135 --Distribution Type
51136 , p_source_18 IN VARCHAR2
51137 --Entered Amount
51138 , p_source_19 IN NUMBER
51139 --Currency Code
51140 , p_source_20 IN VARCHAR2
51141 --Applied To Document Accounting Amount
51142 , p_source_24 IN NUMBER
51143 --Transaction Distribution Identifier
51144 , p_source_29 IN NUMBER
51148 , p_source_54 IN VARCHAR2
51145 --Transaction Distribution Type
51146 , p_source_30 IN VARCHAR2
51147 --Distribution Multi Fund Additional Entry
51149 --Applied To Document Exchange Date
51150 , p_source_55 IN DATE
51151 --Receipt Applied To Application Identifier
51152 , p_source_58 IN NUMBER
51153 --Transaction Entity Code
51154 , p_source_59 IN VARCHAR2
51155 --Transaction Identifier
51156 , p_source_60 IN NUMBER
51157 --Distribution Party Identifier
51158 , p_source_64 IN NUMBER
51159 --Distribution Party Site Id
51160 , p_source_65 IN NUMBER
51161 --Distribution Party Type
51162 , p_source_66 IN VARCHAR2
51163 --Applied To Document Exchange Rate Type
51164 , p_source_67 IN VARCHAR2
51165 --Applied To Document Exchange Rate
51166 , p_source_68 IN NUMBER
51167 )
51168 IS
51169
51170 l_component_type VARCHAR2(80);
51171 l_component_code VARCHAR2(30);
51172 l_component_type_code VARCHAR2(1);
51173 l_component_appl_id INTEGER;
51174 l_amb_context_code VARCHAR2(30);
51175 l_entity_code VARCHAR2(30);
51176 l_event_class_code VARCHAR2(30);
51177 l_ae_header_id NUMBER;
51178 l_event_type_code VARCHAR2(30);
51179 l_line_definition_code VARCHAR2(30);
51180 l_line_definition_owner_code VARCHAR2(1);
51181 --
51182 -- adr variables
51183 l_segment VARCHAR2(30);
51184 l_ccid NUMBER;
51185 l_adr_transaction_coa_id NUMBER;
51186 l_adr_accounting_coa_id NUMBER;
51187 l_adr_flexfield_segment_code VARCHAR2(30);
51188 l_adr_flex_value_set_id NUMBER;
51189 l_adr_value_type_code VARCHAR2(30);
51190 l_adr_value_combination_id NUMBER;
51191 l_adr_value_segment_code VARCHAR2(30);
51192
51193 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
51194 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
51195 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
51196 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
51197
51198 -- 4262811 Variables ------------------------------------------------------------------------------------------
51199 l_entered_amt_idx NUMBER;
51200 l_accted_amt_idx NUMBER;
51201 l_acc_rev_flag VARCHAR2(1);
51202 l_accrual_line_num NUMBER;
51203 l_tmp_amt NUMBER;
51204 l_acc_rev_natural_side_code VARCHAR2(1);
51205
51206 l_num_entries NUMBER;
51207 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
51208 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
51209 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
51210 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
51211 l_recog_line_1 NUMBER;
51212 l_recog_line_2 NUMBER;
51213
51214 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
51215 l_bflow_applied_to_amt NUMBER; -- 5132302
51216 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
51217
51218 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
51219
51220 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
51221 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
51222
51223 ---------------------------------------------------------------------------------------------------------------
51224
51225
51226 --
51227 -- bulk performance
51228 --
51229 l_balance_type_code VARCHAR2(1);
51230 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
51231 l_log_module VARCHAR2(240);
51232
51233 --
51234 -- Upgrade strategy
51235 --
51236 l_actual_upg_option VARCHAR2(1);
51237 l_enc_upg_option VARCHAR2(1);
51238
51239 --
51240 BEGIN
51241 --
51242 IF g_log_enabled THEN
51243 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_101';
51244 END IF;
51245 --
51246 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51247
51248 trace
51249 (p_msg => 'BEGIN of AcctLineType_101'
51250 ,p_level => C_LEVEL_PROCEDURE
51251 ,p_module => l_log_module);
51252
51253 END IF;
51254 --
51255 l_component_type := 'AMB_JLT';
51256 l_component_code := 'RCT_UNEDISC';
51257 l_component_type_code := 'S';
51258 l_component_appl_id := 222;
51259 l_amb_context_code := 'DEFAULT';
51260 l_entity_code := 'RECEIPTS';
51261 l_event_class_code := 'RECEIPT';
51262 l_event_type_code := 'RECEIPT_ALL';
51263 l_line_definition_owner_code := 'S';
51264 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
51265 --
51266 l_balance_type_code := 'A';
51267 l_segment := NULL;
51268 l_ccid := NULL;
51269 l_adr_transaction_coa_id := NULL;
51270 l_adr_accounting_coa_id := NULL;
51271 l_adr_flexfield_segment_code := NULL;
51272 l_adr_flex_value_set_id := NULL;
51273 l_adr_value_type_code := NULL;
51274 l_adr_value_combination_id := NULL;
51275 l_adr_value_segment_code := NULL;
51276
51277 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
51278 l_bflow_class_code := ''; -- 4219869 Business Flow
51279 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
51280 l_budgetary_control_flag := 'N';
51281
51285 l_accted_amt_idx := NULL; -- 4262811
51282 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51283 l_bflow_applied_to_amt := NULL; -- 5132302
51284 l_entered_amt_idx := NULL; -- 4262811
51286 l_acc_rev_flag := NULL; -- 4262811
51287 l_accrual_line_num := NULL; -- 4262811
51288 l_tmp_amt := NULL; -- 4262811
51289 --
51290
51291 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
51292 l_balance_type_code <> 'B' THEN
51293 IF NVL(p_source_15,'
51294 ') = 'UNEDISC' AND
51295 NVL(p_source_54,'
51296 ') = 'N'
51297 THEN
51298
51299 --
51300 XLA_AE_LINES_PKG.SetNewLine;
51301
51302 p_balance_type_code := l_balance_type_code;
51303 -- set the flag so later we will know whether the gain loss line needs to be created
51304
51305 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
51306 p_actual_flag :='A';
51307 END IF;
51308
51309 --
51310 -- bulk performance
51311 --
51312 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
51313 p_header_num => 0); -- 4262811
51314 --
51315 -- set accounting line options
51316 --
51317 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
51318 p_natural_side_code => 'C'
51319 , p_gain_or_loss_flag => 'N'
51320 , p_gl_transfer_mode_code => 'S'
51321 , p_acct_entry_type_code => 'A'
51322 , p_switch_side_flag => 'Y'
51323 , p_merge_duplicate_code => 'A'
51324 );
51325 --
51326 l_acc_rev_natural_side_code := 'D'; -- 4262811
51327 --
51328 --
51329 -- set accounting line type info
51330 --
51331 xla_ae_lines_pkg.SetAcctLineType
51332 (p_component_type => l_component_type
51333 ,p_event_type_code => l_event_type_code
51334 ,p_line_definition_owner_code => l_line_definition_owner_code
51335 ,p_line_definition_code => l_line_definition_code
51336 ,p_accounting_line_code => l_component_code
51337 ,p_accounting_line_type_code => l_component_type_code
51338 ,p_accounting_line_appl_id => l_component_appl_id
51339 ,p_amb_context_code => l_amb_context_code
51340 ,p_entity_code => l_entity_code
51341 ,p_event_class_code => l_event_class_code);
51342 --
51343 -- set accounting class
51344 --
51345 xla_ae_lines_pkg.SetAcctClass(
51346 p_accounting_class_code => 'UNEDISC'
51347 , p_ae_header_id => l_ae_header_id
51348 );
51349
51350 --
51351 -- set rounding class
51352 --
51353 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
51354 'RECEIVABLE';
51355
51356 --
51357 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
51358 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
51359 --
51360 -- bulk performance
51361 --
51362 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
51363
51364 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
51365 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
51366
51367 -- 4955764
51368 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51369 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
51370
51371 -- 4458381 Public Sector Enh
51372
51373 --
51374 -- set accounting attributes for the line type
51375 --
51376 l_entered_amt_idx := 8;
51377 l_accted_amt_idx := 13;
51378 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51379 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
51380 l_rec_acct_attrs.array_num_value(1) := p_source_58;
51381 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
51382 l_rec_acct_attrs.array_char_value(2) := p_source_30;
51383 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
51384 l_rec_acct_attrs.array_char_value(3) := p_source_59;
51385 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
51386 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
51387 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
51388 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
51389 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
51390 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
51391 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
51392 l_rec_acct_attrs.array_char_value(7) := p_source_18;
51393 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
51394 l_rec_acct_attrs.array_num_value(8) := p_source_19;
51395 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
51396 l_rec_acct_attrs.array_char_value(9) := p_source_20;
51397 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
51398 l_rec_acct_attrs.array_date_value(10) := p_source_55;
51399 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
51400 l_rec_acct_attrs.array_num_value(11) := p_source_68;
51401 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
51402 l_rec_acct_attrs.array_char_value(12) := p_source_67;
51403 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
51407 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
51404 l_rec_acct_attrs.array_num_value(13) := p_source_24;
51405 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
51406 l_rec_acct_attrs.array_num_value(14) := p_source_64;
51408 l_rec_acct_attrs.array_num_value(15) := p_source_65;
51409 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
51410 l_rec_acct_attrs.array_char_value(16) := p_source_66;
51411
51412 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
51413 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
51414
51415 ---------------------------------------------------------------------------------------------------------------
51416 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
51417 ---------------------------------------------------------------------------------------------------------------
51418 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
51419
51420 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51421 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51422
51423 IF xla_accounting_cache_pkg.GetValueChar
51424 (p_source_code => 'LEDGER_CATEGORY_CODE'
51425 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
51426 AND l_bflow_method_code = 'PRIOR_ENTRY'
51427 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
51428 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
51429 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
51430 )
51431 THEN
51432 xla_ae_lines_pkg.BflowUpgEntry
51433 (p_business_method_code => l_bflow_method_code
51434 ,p_business_class_code => l_bflow_class_code
51435 ,p_balance_type => l_balance_type_code);
51436 ELSE
51437 NULL;
51438 -- No business flow processing for business flow method of NONE.
51439 END IF;
51440
51441 --
51442 -- call analytical criteria
51443 --
51444
51445 --
51446 -- call description
51447 --
51448
51449 xla_ae_lines_pkg.SetLineDescription(
51450 p_ae_header_id => l_ae_header_id
51451 ,p_description => Description_1 (
51452 p_application_id => p_application_id
51453 , p_ae_header_id => l_ae_header_id
51454 )
51455 );
51456
51457
51458 --
51459 -- call ADRs
51460 -- Bug 4922099
51461 --
51462 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51463 (NVL(l_actual_upg_option, 'N') = 'O') OR
51464 (NVL(l_enc_upg_option, 'N') = 'O')
51465 )
51466 THEN
51467 NULL;
51468 --
51469 --
51470
51471 l_ccid := AcctDerRule_18(
51472 p_application_id => p_application_id
51473 , p_ae_header_id => l_ae_header_id
51474 , p_source_14 => p_source_14
51475 , x_transaction_coa_id => l_adr_transaction_coa_id
51476 , x_accounting_coa_id => l_adr_accounting_coa_id
51477 , x_value_type_code => l_adr_value_type_code
51478 , p_side => 'NA'
51479 );
51480
51481 xla_ae_lines_pkg.set_ccid(
51482 p_code_combination_id => l_ccid
51483 , p_value_type_code => l_adr_value_type_code
51484 , p_transaction_coa_id => l_adr_transaction_coa_id
51485 , p_accounting_coa_id => l_adr_accounting_coa_id
51486 , p_adr_code => 'TRX_DIST_CCID'
51487 , p_adr_type_code => 'S'
51488 , p_component_type => l_component_type
51489 , p_component_code => l_component_code
51490 , p_component_type_code => l_component_type_code
51491 , p_component_appl_id => l_component_appl_id
51492 , p_amb_context_code => l_amb_context_code
51493 , p_side => 'NA'
51494 );
51495
51496
51497 l_segment := AcctDerRule_8(
51498 p_application_id => p_application_id
51499 , p_ae_header_id => l_ae_header_id
51500 , p_source_7 => p_source_7
51501 , x_transaction_coa_id => l_adr_transaction_coa_id
51502 , x_accounting_coa_id => l_adr_accounting_coa_id
51503 , x_flexfield_segment_code => l_adr_flexfield_segment_code
51504 , x_flex_value_set_id => l_adr_flex_value_set_id
51505 , x_value_type_code => l_adr_value_type_code
51506 , x_value_combination_id => l_adr_value_combination_id
51507 , x_value_segment_code => l_adr_value_segment_code
51508 , p_side => 'NA'
51509 , p_override_seg_flag => 'Y'
51510 );
51511
51512 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
51513
51514 xla_ae_lines_pkg.set_segment(
51515 p_to_segment_code => 'GL_ACCOUNT'
51516 , p_segment_value => l_segment
51517 , p_from_segment_code => l_adr_value_segment_code
51518 , p_from_combination_id => l_adr_value_combination_id
51519 , p_value_type_code => l_adr_value_type_code
51520 , p_transaction_coa_id => l_adr_transaction_coa_id
51521 , p_accounting_coa_id => l_adr_accounting_coa_id
51522 , p_flexfield_segment_code => l_adr_flexfield_segment_code
51523 , p_flex_value_set_id => l_adr_flex_value_set_id
51524 , p_adr_code => 'MFAR_RCT_UNEARNED_NATURAL_SEG'
51525 , p_adr_type_code => 'S'
51529 , p_component_appl_id => l_component_appl_id
51526 , p_component_type => l_component_type
51527 , p_component_code => l_component_code
51528 , p_component_type_code => l_component_type_code
51530 , p_amb_context_code => l_amb_context_code
51531 , p_entity_code => 'RECEIPTS'
51532 , p_event_class_code => 'RECEIPT'
51533 , p_side => 'NA'
51534 );
51535
51536 END IF;
51537
51538 --
51539 --
51540 END IF;
51541 --
51542 -- Bug 4922099
51543 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
51544 (NVL(l_enc_upg_option, 'N') = 'O')
51545 ) AND
51546 (l_bflow_method_code = 'PRIOR_ENTRY')
51547 )
51548 THEN
51549 IF
51550 --
51551 1 = 2
51552 --
51553 THEN
51554 xla_accounting_err_pkg.build_message
51555 (p_appli_s_name => 'XLA'
51556 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
51557 ,p_token_1 => 'LINE_NUMBER'
51558 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
51559 ,p_token_2 => 'LINE_TYPE_NAME'
51560 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
51561 l_component_type
51562 ,l_component_code
51563 ,l_component_type_code
51564 ,l_component_appl_id
51565 ,l_amb_context_code
51566 ,l_entity_code
51567 ,l_event_class_code
51568 )
51569 ,p_token_3 => 'OWNER'
51570 ,p_value_3 => xla_lookups_pkg.get_meaning(
51571 p_lookup_type => 'XLA_OWNER_TYPE'
51572 ,p_lookup_code => l_component_type_code
51573 )
51574 ,p_token_4 => 'PRODUCT_NAME'
51575 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
51576 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
51577 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
51578 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
51579 ,p_ae_header_id => NULL
51580 );
51581
51582 IF (C_LEVEL_ERROR>= g_log_level) THEN
51583 trace
51584 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
51585 ,p_level => C_LEVEL_ERROR
51586 ,p_module => l_log_module);
51587 END IF;
51588 END IF;
51589 END IF;
51590 --
51591 --
51592 ------------------------------------------------------------------------------------------------
51593 -- 4219869 Business Flow
51594 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
51595 -- Prior Entry. Currently, the following code is always generated.
51596 ------------------------------------------------------------------------------------------------
51597 XLA_AE_LINES_PKG.ValidateCurrentLine;
51598
51599 ------------------------------------------------------------------------------------
51600 -- 4219869 Business Flow
51601 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
51602 ------------------------------------------------------------------------------------
51603 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
51604
51605 ----------------------------------------------------------------------------------
51606 -- 4219869 Business Flow
51607 -- Update journal entry status -- Need to generate this within IF <condition>
51608 ----------------------------------------------------------------------------------
51609 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
51610 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
51611 ,p_balance_type_code => l_balance_type_code
51612 );
51613
51614 -------------------------------------------------------------------------------------------
51615 -- 4262811 - Generate the Accrual Reversal lines
51616 -------------------------------------------------------------------------------------------
51617 BEGIN
51618 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
51619 (g_array_event(p_event_id).array_value_num('header_index'));
51620 IF l_acc_rev_flag IS NULL THEN
51621 l_acc_rev_flag := 'N';
51622 END IF;
51623 EXCEPTION
51624 WHEN OTHERS THEN
51625 l_acc_rev_flag := 'N';
51626 END;
51627 --
51628 IF (l_acc_rev_flag = 'Y') THEN
51629
51633 ------------------------------------------------------------------------------------------
51630 -- 4645092 ------------------------------------------------------------------------------
51631 -- To allow MPA report to determine if it should generate report process
51632 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
51634
51635 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
51636 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
51637 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
51638 -- call ADRs
51639 -- Bug 4922099
51640 --
51641 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51642 (NVL(l_actual_upg_option, 'N') = 'O') OR
51643 (NVL(l_enc_upg_option, 'N') = 'O')
51644 )
51645 THEN
51646 NULL;
51647 --
51648 --
51649
51650 l_ccid := AcctDerRule_18(
51651 p_application_id => p_application_id
51652 , p_ae_header_id => l_ae_header_id
51653 , p_source_14 => p_source_14
51654 , x_transaction_coa_id => l_adr_transaction_coa_id
51655 , x_accounting_coa_id => l_adr_accounting_coa_id
51656 , x_value_type_code => l_adr_value_type_code
51657 , p_side => 'NA'
51658 );
51659
51660 xla_ae_lines_pkg.set_ccid(
51661 p_code_combination_id => l_ccid
51662 , p_value_type_code => l_adr_value_type_code
51663 , p_transaction_coa_id => l_adr_transaction_coa_id
51664 , p_accounting_coa_id => l_adr_accounting_coa_id
51665 , p_adr_code => 'TRX_DIST_CCID'
51666 , p_adr_type_code => 'S'
51667 , p_component_type => l_component_type
51668 , p_component_code => l_component_code
51669 , p_component_type_code => l_component_type_code
51670 , p_component_appl_id => l_component_appl_id
51671 , p_amb_context_code => l_amb_context_code
51672 , p_side => 'NA'
51673 );
51674
51675
51676 l_segment := AcctDerRule_8(
51677 p_application_id => p_application_id
51678 , p_ae_header_id => l_ae_header_id
51679 , p_source_7 => p_source_7
51680 , x_transaction_coa_id => l_adr_transaction_coa_id
51681 , x_accounting_coa_id => l_adr_accounting_coa_id
51682 , x_flexfield_segment_code => l_adr_flexfield_segment_code
51683 , x_flex_value_set_id => l_adr_flex_value_set_id
51684 , x_value_type_code => l_adr_value_type_code
51685 , x_value_combination_id => l_adr_value_combination_id
51686 , x_value_segment_code => l_adr_value_segment_code
51687 , p_side => 'NA'
51688 , p_override_seg_flag => 'Y'
51689 );
51690
51691 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
51692
51693 xla_ae_lines_pkg.set_segment(
51694 p_to_segment_code => 'GL_ACCOUNT'
51695 , p_segment_value => l_segment
51696 , p_from_segment_code => l_adr_value_segment_code
51697 , p_from_combination_id => l_adr_value_combination_id
51698 , p_value_type_code => l_adr_value_type_code
51699 , p_transaction_coa_id => l_adr_transaction_coa_id
51700 , p_accounting_coa_id => l_adr_accounting_coa_id
51701 , p_flexfield_segment_code => l_adr_flexfield_segment_code
51702 , p_flex_value_set_id => l_adr_flex_value_set_id
51703 , p_adr_code => 'MFAR_RCT_UNEARNED_NATURAL_SEG'
51704 , p_adr_type_code => 'S'
51705 , p_component_type => l_component_type
51706 , p_component_code => l_component_code
51707 , p_component_type_code => l_component_type_code
51708 , p_component_appl_id => l_component_appl_id
51709 , p_amb_context_code => l_amb_context_code
51710 , p_entity_code => 'RECEIPTS'
51711 , p_event_class_code => 'RECEIPT'
51712 , p_side => 'NA'
51713 );
51714
51715 END IF;
51716
51717 --
51718 --
51719 END IF;
51720
51721 --
51722 -- Update the line information that should be overwritten
51723 --
51724 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
51725 p_header_num => 1);
51726 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
51727
51728 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
51729
51730 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
51731 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
51732 END IF;
51733
51734 --
51735 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
51736 --
51737 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
51738 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
51739 ELSE
51740 ---------------------------------------------------------------------------------------------------
51741 -- 4262811a Switch Sign
51742 ---------------------------------------------------------------------------------------------------
51746 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51743 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
51744 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51745 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51747 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51748 -- 5132302
51749 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
51750 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51751
51752 END IF;
51753
51754 -- 4955764
51755 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51756 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
51757
51758
51759 XLA_AE_LINES_PKG.ValidateCurrentLine;
51760 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
51761
51762 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
51763 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
51764 ,p_balance_type_code => l_balance_type_code);
51765
51766 END IF;
51767
51768 -----------------------------------------------------------------------------------------
51769 -- 4262811 Multiperiod Accounting
51770 -----------------------------------------------------------------------------------------
51771 -- No MPA option is assigned.
51772
51773
51774 END IF;
51775 END IF;
51776 --
51777
51778 --
51779 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51780 trace
51781 (p_msg => 'END of AcctLineType_101'
51782 ,p_level => C_LEVEL_PROCEDURE
51783 ,p_module => l_log_module);
51784 END IF;
51785 --
51786 EXCEPTION
51787 WHEN xla_exceptions_pkg.application_exception THEN
51788 RAISE;
51789 WHEN OTHERS THEN
51790 xla_exceptions_pkg.raise_message
51791 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_101');
51792 END AcctLineType_101;
51793 --
51794
51795 ---------------------------------------
51796 --
51797 -- PRIVATE FUNCTION
51798 -- AcctLineType_102
51799 --
51800 ---------------------------------------
51801 PROCEDURE AcctLineType_102 (
51802 p_application_id IN NUMBER
51803 ,p_event_id IN NUMBER
51804 ,p_calculate_acctd_flag IN VARCHAR2
51805 ,p_calculate_g_l_flag IN VARCHAR2
51806 ,p_actual_flag IN OUT VARCHAR2
51807 ,p_balance_type_code OUT VARCHAR2
51808 ,p_gain_or_loss_ref OUT VARCHAR2
51809
51810 --Distribution GL Account
51811 , p_source_10 IN NUMBER
51812 --Distribution Source Type
51813 , p_source_15 IN VARCHAR2
51814 --Distribution Line Identifier
51815 , p_source_17 IN NUMBER
51816 --Distribution Type
51817 , p_source_18 IN VARCHAR2
51818 --Exchange Date
51819 , p_source_21 IN DATE
51820 --Exchange Rate
51821 , p_source_22 IN NUMBER
51822 --Exchange Rate Type
51823 , p_source_23 IN VARCHAR2
51824 --Transaction Distribution Identifier
51825 , p_source_29 IN NUMBER
51826 --Transaction Distribution Type
51827 , p_source_30 IN VARCHAR2
51828 --Distribution Multi Fund Additional Entry
51829 , p_source_54 IN VARCHAR2
51830 --Receipt Applied To Application Identifier
51831 , p_source_58 IN NUMBER
51832 --Transaction Entity Code
51833 , p_source_59 IN VARCHAR2
51834 --Transaction Identifier
51835 , p_source_60 IN NUMBER
51836 --DIST_ENT_AMT_FROM
51837 , p_source_61 IN NUMBER
51838 --Applying Document Currency Code
51839 , p_source_62 IN VARCHAR2
51840 --Accounting Amount
51841 , p_source_63 IN NUMBER
51842 --Distribution Party Identifier
51843 , p_source_64 IN NUMBER
51844 --Distribution Party Site Id
51845 , p_source_65 IN NUMBER
51846 --Distribution Party Type
51847 , p_source_66 IN VARCHAR2
51848 )
51849 IS
51850
51851 l_component_type VARCHAR2(80);
51852 l_component_code VARCHAR2(30);
51853 l_component_type_code VARCHAR2(1);
51854 l_component_appl_id INTEGER;
51855 l_amb_context_code VARCHAR2(30);
51856 l_entity_code VARCHAR2(30);
51857 l_event_class_code VARCHAR2(30);
51858 l_ae_header_id NUMBER;
51859 l_event_type_code VARCHAR2(30);
51860 l_line_definition_code VARCHAR2(30);
51861 l_line_definition_owner_code VARCHAR2(1);
51862 --
51863 -- adr variables
51864 l_segment VARCHAR2(30);
51865 l_ccid NUMBER;
51866 l_adr_transaction_coa_id NUMBER;
51867 l_adr_accounting_coa_id NUMBER;
51868 l_adr_flexfield_segment_code VARCHAR2(30);
51869 l_adr_flex_value_set_id NUMBER;
51870 l_adr_value_type_code VARCHAR2(30);
51871 l_adr_value_combination_id NUMBER;
51872 l_adr_value_segment_code VARCHAR2(30);
51873
51874 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
51875 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
51876 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
51880 l_entered_amt_idx NUMBER;
51877 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
51878
51879 -- 4262811 Variables ------------------------------------------------------------------------------------------
51881 l_accted_amt_idx NUMBER;
51882 l_acc_rev_flag VARCHAR2(1);
51883 l_accrual_line_num NUMBER;
51884 l_tmp_amt NUMBER;
51885 l_acc_rev_natural_side_code VARCHAR2(1);
51886
51887 l_num_entries NUMBER;
51888 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
51889 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
51890 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
51891 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
51892 l_recog_line_1 NUMBER;
51893 l_recog_line_2 NUMBER;
51894
51895 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
51896 l_bflow_applied_to_amt NUMBER; -- 5132302
51897 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
51898
51899 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
51900
51901 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
51902 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
51903
51904 ---------------------------------------------------------------------------------------------------------------
51905
51906
51907 --
51908 -- bulk performance
51909 --
51910 l_balance_type_code VARCHAR2(1);
51911 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
51912 l_log_module VARCHAR2(240);
51913
51914 --
51915 -- Upgrade strategy
51916 --
51917 l_actual_upg_option VARCHAR2(1);
51918 l_enc_upg_option VARCHAR2(1);
51919
51920 --
51921 BEGIN
51922 --
51923 IF g_log_enabled THEN
51924 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_102';
51925 END IF;
51926 --
51927 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51928
51929 trace
51930 (p_msg => 'BEGIN of AcctLineType_102'
51931 ,p_level => C_LEVEL_PROCEDURE
51932 ,p_module => l_log_module);
51933
51934 END IF;
51935 --
51936 l_component_type := 'AMB_JLT';
51937 l_component_code := 'RCT_UNID';
51938 l_component_type_code := 'S';
51939 l_component_appl_id := 222;
51940 l_amb_context_code := 'DEFAULT';
51941 l_entity_code := 'RECEIPTS';
51942 l_event_class_code := 'RECEIPT';
51943 l_event_type_code := 'RECEIPT_ALL';
51944 l_line_definition_owner_code := 'S';
51945 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
51946 --
51947 l_balance_type_code := 'A';
51948 l_segment := NULL;
51949 l_ccid := NULL;
51950 l_adr_transaction_coa_id := NULL;
51951 l_adr_accounting_coa_id := NULL;
51952 l_adr_flexfield_segment_code := NULL;
51953 l_adr_flex_value_set_id := NULL;
51954 l_adr_value_type_code := NULL;
51955 l_adr_value_combination_id := NULL;
51956 l_adr_value_segment_code := NULL;
51957
51958 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
51959 l_bflow_class_code := ''; -- 4219869 Business Flow
51960 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
51961 l_budgetary_control_flag := 'N';
51962
51963 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51964 l_bflow_applied_to_amt := NULL; -- 5132302
51965 l_entered_amt_idx := NULL; -- 4262811
51966 l_accted_amt_idx := NULL; -- 4262811
51967 l_acc_rev_flag := NULL; -- 4262811
51968 l_accrual_line_num := NULL; -- 4262811
51969 l_tmp_amt := NULL; -- 4262811
51970 --
51971
51972 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
51973 l_balance_type_code <> 'B' THEN
51974 IF NVL(p_source_15,'
51975 ') = 'UNID' AND
51976 NVL(p_source_54,'
51977 ') = 'N'
51978 THEN
51979
51980 --
51981 XLA_AE_LINES_PKG.SetNewLine;
51982
51983 p_balance_type_code := l_balance_type_code;
51984 -- set the flag so later we will know whether the gain loss line needs to be created
51985
51986 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
51987 p_actual_flag :='A';
51988 END IF;
51989
51990 --
51991 -- bulk performance
51992 --
51993 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
51994 p_header_num => 0); -- 4262811
51995 --
51996 -- set accounting line options
51997 --
51998 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
51999 p_natural_side_code => 'C'
52000 , p_gain_or_loss_flag => 'N'
52001 , p_gl_transfer_mode_code => 'S'
52002 , p_acct_entry_type_code => 'A'
52003 , p_switch_side_flag => 'Y'
52004 , p_merge_duplicate_code => 'A'
52005 );
52006 --
52007 l_acc_rev_natural_side_code := 'D'; -- 4262811
52008 --
52009 --
52010 -- set accounting line type info
52011 --
52012 xla_ae_lines_pkg.SetAcctLineType
52016 ,p_line_definition_code => l_line_definition_code
52013 (p_component_type => l_component_type
52014 ,p_event_type_code => l_event_type_code
52015 ,p_line_definition_owner_code => l_line_definition_owner_code
52017 ,p_accounting_line_code => l_component_code
52018 ,p_accounting_line_type_code => l_component_type_code
52019 ,p_accounting_line_appl_id => l_component_appl_id
52020 ,p_amb_context_code => l_amb_context_code
52021 ,p_entity_code => l_entity_code
52022 ,p_event_class_code => l_event_class_code);
52023 --
52024 -- set accounting class
52025 --
52026 xla_ae_lines_pkg.SetAcctClass(
52027 p_accounting_class_code => 'UNID'
52028 , p_ae_header_id => l_ae_header_id
52029 );
52030
52031 --
52032 -- set rounding class
52033 --
52034 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
52035 'RECEIVABLE';
52036
52037 --
52038 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
52039 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
52040 --
52041 -- bulk performance
52042 --
52043 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
52044
52045 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
52046 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
52047
52048 -- 4955764
52049 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52050 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
52051
52052 -- 4458381 Public Sector Enh
52053
52054 --
52055 -- set accounting attributes for the line type
52056 --
52057 l_entered_amt_idx := 8;
52058 l_accted_amt_idx := 13;
52059 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52060 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
52061 l_rec_acct_attrs.array_num_value(1) := p_source_58;
52062 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
52063 l_rec_acct_attrs.array_char_value(2) := p_source_30;
52064 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
52065 l_rec_acct_attrs.array_char_value(3) := p_source_59;
52066 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
52067 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
52068 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
52069 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
52070 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
52071 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
52072 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
52073 l_rec_acct_attrs.array_char_value(7) := p_source_18;
52074 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
52075 l_rec_acct_attrs.array_num_value(8) := p_source_61;
52076 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
52077 l_rec_acct_attrs.array_char_value(9) := p_source_62;
52078 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
52079 l_rec_acct_attrs.array_date_value(10) := p_source_21;
52080 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
52081 l_rec_acct_attrs.array_num_value(11) := p_source_22;
52082 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
52083 l_rec_acct_attrs.array_char_value(12) := p_source_23;
52084 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
52085 l_rec_acct_attrs.array_num_value(13) := p_source_63;
52086 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
52087 l_rec_acct_attrs.array_num_value(14) := p_source_64;
52088 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
52089 l_rec_acct_attrs.array_num_value(15) := p_source_65;
52090 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
52091 l_rec_acct_attrs.array_char_value(16) := p_source_66;
52092
52093 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
52094 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
52095
52096 ---------------------------------------------------------------------------------------------------------------
52097 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
52098 ---------------------------------------------------------------------------------------------------------------
52099 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
52100
52101 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52102 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52103
52104 IF xla_accounting_cache_pkg.GetValueChar
52105 (p_source_code => 'LEDGER_CATEGORY_CODE'
52106 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
52107 AND l_bflow_method_code = 'PRIOR_ENTRY'
52108 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
52109 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
52110 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
52111 )
52112 THEN
52113 xla_ae_lines_pkg.BflowUpgEntry
52114 (p_business_method_code => l_bflow_method_code
52115 ,p_business_class_code => l_bflow_class_code
52116 ,p_balance_type => l_balance_type_code);
52117 ELSE
52121
52118 NULL;
52119 -- No business flow processing for business flow method of NONE.
52120 END IF;
52122 --
52123 -- call analytical criteria
52124 --
52125
52126 --
52127 -- call description
52128 --
52129 -- No description or it is inherited.
52130 --
52131 -- call ADRs
52132 -- Bug 4922099
52133 --
52134 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52135 (NVL(l_actual_upg_option, 'N') = 'O') OR
52136 (NVL(l_enc_upg_option, 'N') = 'O')
52137 )
52138 THEN
52139 NULL;
52140 --
52141 --
52142
52143 l_ccid := AcctDerRule_11(
52144 p_application_id => p_application_id
52145 , p_ae_header_id => l_ae_header_id
52146 , p_source_10 => p_source_10
52147 , x_transaction_coa_id => l_adr_transaction_coa_id
52148 , x_accounting_coa_id => l_adr_accounting_coa_id
52149 , x_value_type_code => l_adr_value_type_code
52150 , p_side => 'NA'
52151 );
52152
52153 xla_ae_lines_pkg.set_ccid(
52154 p_code_combination_id => l_ccid
52155 , p_value_type_code => l_adr_value_type_code
52156 , p_transaction_coa_id => l_adr_transaction_coa_id
52157 , p_accounting_coa_id => l_adr_accounting_coa_id
52158 , p_adr_code => 'DIST_CCID'
52159 , p_adr_type_code => 'S'
52160 , p_component_type => l_component_type
52161 , p_component_code => l_component_code
52162 , p_component_type_code => l_component_type_code
52163 , p_component_appl_id => l_component_appl_id
52164 , p_amb_context_code => l_amb_context_code
52165 , p_side => 'NA'
52166 );
52167
52168
52169 --
52170 --
52171 END IF;
52172 --
52173 -- Bug 4922099
52174 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
52175 (NVL(l_enc_upg_option, 'N') = 'O')
52176 ) AND
52177 (l_bflow_method_code = 'PRIOR_ENTRY')
52178 )
52179 THEN
52180 IF
52181 --
52182 1 = 2
52183 --
52184 THEN
52185 xla_accounting_err_pkg.build_message
52186 (p_appli_s_name => 'XLA'
52187 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52188 ,p_token_1 => 'LINE_NUMBER'
52189 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
52190 ,p_token_2 => 'LINE_TYPE_NAME'
52191 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
52192 l_component_type
52193 ,l_component_code
52194 ,l_component_type_code
52195 ,l_component_appl_id
52196 ,l_amb_context_code
52197 ,l_entity_code
52198 ,l_event_class_code
52199 )
52200 ,p_token_3 => 'OWNER'
52201 ,p_value_3 => xla_lookups_pkg.get_meaning(
52202 p_lookup_type => 'XLA_OWNER_TYPE'
52203 ,p_lookup_code => l_component_type_code
52204 )
52205 ,p_token_4 => 'PRODUCT_NAME'
52206 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
52207 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
52208 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
52209 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
52210 ,p_ae_header_id => NULL
52211 );
52212
52213 IF (C_LEVEL_ERROR>= g_log_level) THEN
52214 trace
52215 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52216 ,p_level => C_LEVEL_ERROR
52217 ,p_module => l_log_module);
52218 END IF;
52219 END IF;
52220 END IF;
52221 --
52222 --
52223 ------------------------------------------------------------------------------------------------
52224 -- 4219869 Business Flow
52225 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
52226 -- Prior Entry. Currently, the following code is always generated.
52227 ------------------------------------------------------------------------------------------------
52228 XLA_AE_LINES_PKG.ValidateCurrentLine;
52229
52230 ------------------------------------------------------------------------------------
52231 -- 4219869 Business Flow
52232 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
52233 ------------------------------------------------------------------------------------
52234 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52235
52236 ----------------------------------------------------------------------------------
52237 -- 4219869 Business Flow
52238 -- Update journal entry status -- Need to generate this within IF <condition>
52239 ----------------------------------------------------------------------------------
52240 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52241 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
52242 ,p_balance_type_code => l_balance_type_code
52243 );
52244
52245 -------------------------------------------------------------------------------------------
52246 -- 4262811 - Generate the Accrual Reversal lines
52247 -------------------------------------------------------------------------------------------
52248 BEGIN
52249 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
52250 (g_array_event(p_event_id).array_value_num('header_index'));
52251 IF l_acc_rev_flag IS NULL THEN
52252 l_acc_rev_flag := 'N';
52253 END IF;
52254 EXCEPTION
52255 WHEN OTHERS THEN
52256 l_acc_rev_flag := 'N';
52257 END;
52258 --
52259 IF (l_acc_rev_flag = 'Y') THEN
52260
52261 -- 4645092 ------------------------------------------------------------------------------
52262 -- To allow MPA report to determine if it should generate report process
52263 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
52264 ------------------------------------------------------------------------------------------
52265
52266 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
52267 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
52268 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
52269 -- call ADRs
52270 -- Bug 4922099
52271 --
52272 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52273 (NVL(l_actual_upg_option, 'N') = 'O') OR
52274 (NVL(l_enc_upg_option, 'N') = 'O')
52275 )
52276 THEN
52277 NULL;
52278 --
52279 --
52280
52281 l_ccid := AcctDerRule_11(
52282 p_application_id => p_application_id
52283 , p_ae_header_id => l_ae_header_id
52284 , p_source_10 => p_source_10
52285 , x_transaction_coa_id => l_adr_transaction_coa_id
52286 , x_accounting_coa_id => l_adr_accounting_coa_id
52287 , x_value_type_code => l_adr_value_type_code
52288 , p_side => 'NA'
52289 );
52290
52291 xla_ae_lines_pkg.set_ccid(
52292 p_code_combination_id => l_ccid
52293 , p_value_type_code => l_adr_value_type_code
52294 , p_transaction_coa_id => l_adr_transaction_coa_id
52295 , p_accounting_coa_id => l_adr_accounting_coa_id
52296 , p_adr_code => 'DIST_CCID'
52297 , p_adr_type_code => 'S'
52298 , p_component_type => l_component_type
52299 , p_component_code => l_component_code
52300 , p_component_type_code => l_component_type_code
52301 , p_component_appl_id => l_component_appl_id
52302 , p_amb_context_code => l_amb_context_code
52303 , p_side => 'NA'
52304 );
52305
52306
52307 --
52308 --
52309 END IF;
52310
52311 --
52312 -- Update the line information that should be overwritten
52313 --
52314 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
52315 p_header_num => 1);
52316 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
52317
52318 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
52319
52320 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
52321 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
52322 END IF;
52323
52324 --
52325 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
52326 --
52327 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
52328 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
52329 ELSE
52330 ---------------------------------------------------------------------------------------------------
52331 -- 4262811a Switch Sign
52332 ---------------------------------------------------------------------------------------------------
52333 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
52334 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52335 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52336 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52337 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52338 -- 5132302
52339 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
52340 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52341
52342 END IF;
52343
52344 -- 4955764
52345 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52346 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
52347
52348
52349 XLA_AE_LINES_PKG.ValidateCurrentLine;
52350 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52351
52352 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52353 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
52354 ,p_balance_type_code => l_balance_type_code);
52355
52356 END IF;
52357
52358 -----------------------------------------------------------------------------------------
52359 -- 4262811 Multiperiod Accounting
52360 -----------------------------------------------------------------------------------------
52361 -- No MPA option is assigned.
52362
52363
52364 END IF;
52365 END IF;
52366 --
52367
52368 --
52369 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52370 trace
52371 (p_msg => 'END of AcctLineType_102'
52372 ,p_level => C_LEVEL_PROCEDURE
52373 ,p_module => l_log_module);
52374 END IF;
52375 --
52376 EXCEPTION
52377 WHEN xla_exceptions_pkg.application_exception THEN
52378 RAISE;
52379 WHEN OTHERS THEN
52380 xla_exceptions_pkg.raise_message
52381 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_102');
52382 END AcctLineType_102;
52383 --
52384
52385 ---------------------------------------
52386 --
52387 -- PRIVATE FUNCTION
52388 -- AcctLineType_103
52389 --
52390 ---------------------------------------
52391 PROCEDURE AcctLineType_103 (
52392 p_application_id IN NUMBER
52393 ,p_event_id IN NUMBER
52394 ,p_calculate_acctd_flag IN VARCHAR2
52395 ,p_calculate_g_l_flag IN VARCHAR2
52396 ,p_actual_flag IN OUT VARCHAR2
52397 ,p_balance_type_code OUT VARCHAR2
52398 ,p_gain_or_loss_ref OUT VARCHAR2
52399
52400 --Distribution GL Account
52401 , p_source_10 IN NUMBER
52402 --Distribution Source Type
52403 , p_source_15 IN VARCHAR2
52404 --Receivable Activity Type
52405 , p_source_16 IN VARCHAR2
52406 --Distribution Line Identifier
52407 , p_source_17 IN NUMBER
52408 --Distribution Type
52409 , p_source_18 IN VARCHAR2
52410 --Exchange Date
52411 , p_source_21 IN DATE
52412 --Exchange Rate
52413 , p_source_22 IN NUMBER
52414 --Exchange Rate Type
52415 , p_source_23 IN VARCHAR2
52416 --Transaction Distribution Identifier
52417 , p_source_29 IN NUMBER
52418 --Transaction Distribution Type
52419 , p_source_30 IN VARCHAR2
52420 --Distribution Multi Fund Additional Entry
52421 , p_source_54 IN VARCHAR2
52422 --Receipt Applied To Application Identifier
52423 , p_source_58 IN NUMBER
52424 --Transaction Entity Code
52425 , p_source_59 IN VARCHAR2
52426 --Transaction Identifier
52427 , p_source_60 IN NUMBER
52428 --DIST_ENT_AMT_FROM
52429 , p_source_61 IN NUMBER
52430 --Applying Document Currency Code
52431 , p_source_62 IN VARCHAR2
52432 --Accounting Amount
52433 , p_source_63 IN NUMBER
52434 --Distribution Party Identifier
52435 , p_source_64 IN NUMBER
52436 --Distribution Party Site Id
52437 , p_source_65 IN NUMBER
52438 --Distribution Party Type
52439 , p_source_66 IN VARCHAR2
52440 )
52441 IS
52442
52443 l_component_type VARCHAR2(80);
52444 l_component_code VARCHAR2(30);
52445 l_component_type_code VARCHAR2(1);
52446 l_component_appl_id INTEGER;
52450 l_ae_header_id NUMBER;
52447 l_amb_context_code VARCHAR2(30);
52448 l_entity_code VARCHAR2(30);
52449 l_event_class_code VARCHAR2(30);
52451 l_event_type_code VARCHAR2(30);
52452 l_line_definition_code VARCHAR2(30);
52453 l_line_definition_owner_code VARCHAR2(1);
52454 --
52455 -- adr variables
52456 l_segment VARCHAR2(30);
52457 l_ccid NUMBER;
52458 l_adr_transaction_coa_id NUMBER;
52459 l_adr_accounting_coa_id NUMBER;
52460 l_adr_flexfield_segment_code VARCHAR2(30);
52461 l_adr_flex_value_set_id NUMBER;
52462 l_adr_value_type_code VARCHAR2(30);
52463 l_adr_value_combination_id NUMBER;
52464 l_adr_value_segment_code VARCHAR2(30);
52465
52466 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
52467 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
52468 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
52469 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
52470
52471 -- 4262811 Variables ------------------------------------------------------------------------------------------
52472 l_entered_amt_idx NUMBER;
52473 l_accted_amt_idx NUMBER;
52474 l_acc_rev_flag VARCHAR2(1);
52475 l_accrual_line_num NUMBER;
52476 l_tmp_amt NUMBER;
52477 l_acc_rev_natural_side_code VARCHAR2(1);
52478
52479 l_num_entries NUMBER;
52480 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
52481 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
52482 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
52483 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
52484 l_recog_line_1 NUMBER;
52485 l_recog_line_2 NUMBER;
52486
52487 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
52488 l_bflow_applied_to_amt NUMBER; -- 5132302
52489 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
52490
52491 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
52492
52493 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
52494 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
52495
52496 ---------------------------------------------------------------------------------------------------------------
52497
52498
52499 --
52500 -- bulk performance
52501 --
52502 l_balance_type_code VARCHAR2(1);
52503 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
52504 l_log_module VARCHAR2(240);
52505
52506 --
52507 -- Upgrade strategy
52508 --
52509 l_actual_upg_option VARCHAR2(1);
52510 l_enc_upg_option VARCHAR2(1);
52511
52512 --
52513 BEGIN
52514 --
52515 IF g_log_enabled THEN
52516 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_103';
52517 END IF;
52518 --
52519 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52520
52521 trace
52522 (p_msg => 'BEGIN of AcctLineType_103'
52523 ,p_level => C_LEVEL_PROCEDURE
52524 ,p_module => l_log_module);
52525
52526 END IF;
52527 --
52528 l_component_type := 'AMB_JLT';
52529 l_component_code := 'RCT_WRITEOFF';
52530 l_component_type_code := 'S';
52531 l_component_appl_id := 222;
52532 l_amb_context_code := 'DEFAULT';
52533 l_entity_code := 'RECEIPTS';
52534 l_event_class_code := 'RECEIPT';
52535 l_event_type_code := 'RECEIPT_ALL';
52536 l_line_definition_owner_code := 'S';
52537 l_line_definition_code := 'MFAR_RCT_ACCRUAL_ACCOUNT';
52538 --
52539 l_balance_type_code := 'A';
52540 l_segment := NULL;
52541 l_ccid := NULL;
52542 l_adr_transaction_coa_id := NULL;
52543 l_adr_accounting_coa_id := NULL;
52544 l_adr_flexfield_segment_code := NULL;
52545 l_adr_flex_value_set_id := NULL;
52546 l_adr_value_type_code := NULL;
52547 l_adr_value_combination_id := NULL;
52548 l_adr_value_segment_code := NULL;
52549
52550 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
52551 l_bflow_class_code := ''; -- 4219869 Business Flow
52552 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
52553 l_budgetary_control_flag := 'N';
52554
52555 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52556 l_bflow_applied_to_amt := NULL; -- 5132302
52557 l_entered_amt_idx := NULL; -- 4262811
52558 l_accted_amt_idx := NULL; -- 4262811
52559 l_acc_rev_flag := NULL; -- 4262811
52560 l_accrual_line_num := NULL; -- 4262811
52561 l_tmp_amt := NULL; -- 4262811
52562 --
52563
52564 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
52565 l_balance_type_code <> 'B' THEN
52566 IF NVL(p_source_15,'
52567 ') = 'ACTIVITY' AND
52568 NVL(p_source_16,'
52569 ') = 'WRITEOFF' AND
52570 NVL(p_source_54,'
52571 ') = 'N'
52572 THEN
52573
52574 --
52575 XLA_AE_LINES_PKG.SetNewLine;
52576
52577 p_balance_type_code := l_balance_type_code;
52578 -- set the flag so later we will know whether the gain loss line needs to be created
52579
52580 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
52581 p_actual_flag :='A';
52582 END IF;
52586 --
52583
52584 --
52585 -- bulk performance
52587 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
52588 p_header_num => 0); -- 4262811
52589 --
52590 -- set accounting line options
52591 --
52592 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
52593 p_natural_side_code => 'C'
52594 , p_gain_or_loss_flag => 'N'
52595 , p_gl_transfer_mode_code => 'S'
52596 , p_acct_entry_type_code => 'A'
52597 , p_switch_side_flag => 'Y'
52598 , p_merge_duplicate_code => 'A'
52599 );
52600 --
52601 l_acc_rev_natural_side_code := 'D'; -- 4262811
52602 --
52603 --
52604 -- set accounting line type info
52605 --
52606 xla_ae_lines_pkg.SetAcctLineType
52607 (p_component_type => l_component_type
52608 ,p_event_type_code => l_event_type_code
52609 ,p_line_definition_owner_code => l_line_definition_owner_code
52610 ,p_line_definition_code => l_line_definition_code
52611 ,p_accounting_line_code => l_component_code
52612 ,p_accounting_line_type_code => l_component_type_code
52613 ,p_accounting_line_appl_id => l_component_appl_id
52614 ,p_amb_context_code => l_amb_context_code
52615 ,p_entity_code => l_entity_code
52616 ,p_event_class_code => l_event_class_code);
52617 --
52618 -- set accounting class
52619 --
52620 xla_ae_lines_pkg.SetAcctClass(
52621 p_accounting_class_code => 'WRITE_OFF'
52622 , p_ae_header_id => l_ae_header_id
52623 );
52624
52625 --
52626 -- set rounding class
52627 --
52628 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
52629 'RECEIVABLE';
52630
52631 --
52632 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
52633 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
52634 --
52635 -- bulk performance
52636 --
52637 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
52638
52639 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
52640 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
52641
52642 -- 4955764
52643 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52644 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
52645
52646 -- 4458381 Public Sector Enh
52647
52648 --
52649 -- set accounting attributes for the line type
52650 --
52651 l_entered_amt_idx := 8;
52652 l_accted_amt_idx := 13;
52653 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52654 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
52655 l_rec_acct_attrs.array_num_value(1) := p_source_58;
52656 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
52657 l_rec_acct_attrs.array_char_value(2) := p_source_30;
52658 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
52659 l_rec_acct_attrs.array_char_value(3) := p_source_59;
52660 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
52661 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_29);
52662 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
52663 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
52664 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
52665 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_17);
52666 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
52667 l_rec_acct_attrs.array_char_value(7) := p_source_18;
52668 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
52669 l_rec_acct_attrs.array_num_value(8) := p_source_61;
52670 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
52671 l_rec_acct_attrs.array_char_value(9) := p_source_62;
52672 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
52673 l_rec_acct_attrs.array_date_value(10) := p_source_21;
52674 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
52675 l_rec_acct_attrs.array_num_value(11) := p_source_22;
52676 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
52677 l_rec_acct_attrs.array_char_value(12) := p_source_23;
52678 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
52679 l_rec_acct_attrs.array_num_value(13) := p_source_63;
52680 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
52681 l_rec_acct_attrs.array_num_value(14) := p_source_64;
52682 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
52683 l_rec_acct_attrs.array_num_value(15) := p_source_65;
52684 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
52685 l_rec_acct_attrs.array_char_value(16) := p_source_66;
52686
52687 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
52688 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
52689
52690 ---------------------------------------------------------------------------------------------------------------
52691 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
52692 ---------------------------------------------------------------------------------------------------------------
52693 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
52694
52698 IF xla_accounting_cache_pkg.GetValueChar
52695 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52696 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52697
52699 (p_source_code => 'LEDGER_CATEGORY_CODE'
52700 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
52701 AND l_bflow_method_code = 'PRIOR_ENTRY'
52702 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
52703 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
52704 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
52705 )
52706 THEN
52707 xla_ae_lines_pkg.BflowUpgEntry
52708 (p_business_method_code => l_bflow_method_code
52709 ,p_business_class_code => l_bflow_class_code
52710 ,p_balance_type => l_balance_type_code);
52711 ELSE
52712 NULL;
52713 -- No business flow processing for business flow method of NONE.
52714 END IF;
52715
52716 --
52717 -- call analytical criteria
52718 --
52719
52720 --
52721 -- call description
52722 --
52723 -- No description or it is inherited.
52724 --
52725 -- call ADRs
52726 -- Bug 4922099
52727 --
52728 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52729 (NVL(l_actual_upg_option, 'N') = 'O') OR
52730 (NVL(l_enc_upg_option, 'N') = 'O')
52731 )
52732 THEN
52733 NULL;
52734 --
52735 --
52736
52737 l_ccid := AcctDerRule_11(
52738 p_application_id => p_application_id
52739 , p_ae_header_id => l_ae_header_id
52740 , p_source_10 => p_source_10
52741 , x_transaction_coa_id => l_adr_transaction_coa_id
52742 , x_accounting_coa_id => l_adr_accounting_coa_id
52743 , x_value_type_code => l_adr_value_type_code
52744 , p_side => 'NA'
52745 );
52746
52747 xla_ae_lines_pkg.set_ccid(
52748 p_code_combination_id => l_ccid
52749 , p_value_type_code => l_adr_value_type_code
52750 , p_transaction_coa_id => l_adr_transaction_coa_id
52751 , p_accounting_coa_id => l_adr_accounting_coa_id
52752 , p_adr_code => 'DIST_CCID'
52753 , p_adr_type_code => 'S'
52754 , p_component_type => l_component_type
52755 , p_component_code => l_component_code
52756 , p_component_type_code => l_component_type_code
52757 , p_component_appl_id => l_component_appl_id
52758 , p_amb_context_code => l_amb_context_code
52759 , p_side => 'NA'
52760 );
52761
52762
52763 --
52764 --
52765 END IF;
52766 --
52767 -- Bug 4922099
52768 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
52769 (NVL(l_enc_upg_option, 'N') = 'O')
52770 ) AND
52771 (l_bflow_method_code = 'PRIOR_ENTRY')
52772 )
52773 THEN
52774 IF
52775 --
52776 1 = 2
52777 --
52778 THEN
52779 xla_accounting_err_pkg.build_message
52780 (p_appli_s_name => 'XLA'
52781 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52782 ,p_token_1 => 'LINE_NUMBER'
52783 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
52784 ,p_token_2 => 'LINE_TYPE_NAME'
52785 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
52786 l_component_type
52787 ,l_component_code
52788 ,l_component_type_code
52789 ,l_component_appl_id
52790 ,l_amb_context_code
52791 ,l_entity_code
52792 ,l_event_class_code
52793 )
52794 ,p_token_3 => 'OWNER'
52795 ,p_value_3 => xla_lookups_pkg.get_meaning(
52796 p_lookup_type => 'XLA_OWNER_TYPE'
52797 ,p_lookup_code => l_component_type_code
52798 )
52799 ,p_token_4 => 'PRODUCT_NAME'
52800 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
52801 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
52802 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
52803 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
52804 ,p_ae_header_id => NULL
52805 );
52806
52807 IF (C_LEVEL_ERROR>= g_log_level) THEN
52808 trace
52809 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52810 ,p_level => C_LEVEL_ERROR
52811 ,p_module => l_log_module);
52812 END IF;
52813 END IF;
52814 END IF;
52815 --
52816 --
52817 ------------------------------------------------------------------------------------------------
52818 -- 4219869 Business Flow
52819 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
52820 -- Prior Entry. Currently, the following code is always generated.
52821 ------------------------------------------------------------------------------------------------
52822 XLA_AE_LINES_PKG.ValidateCurrentLine;
52823
52824 ------------------------------------------------------------------------------------
52825 -- 4219869 Business Flow
52826 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
52827 ------------------------------------------------------------------------------------
52828 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52829
52830 ----------------------------------------------------------------------------------
52831 -- 4219869 Business Flow
52832 -- Update journal entry status -- Need to generate this within IF <condition>
52833 ----------------------------------------------------------------------------------
52834 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52835 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
52836 ,p_balance_type_code => l_balance_type_code
52837 );
52838
52839 -------------------------------------------------------------------------------------------
52840 -- 4262811 - Generate the Accrual Reversal lines
52841 -------------------------------------------------------------------------------------------
52842 BEGIN
52843 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
52844 (g_array_event(p_event_id).array_value_num('header_index'));
52845 IF l_acc_rev_flag IS NULL THEN
52846 l_acc_rev_flag := 'N';
52847 END IF;
52848 EXCEPTION
52849 WHEN OTHERS THEN
52850 l_acc_rev_flag := 'N';
52851 END;
52852 --
52853 IF (l_acc_rev_flag = 'Y') THEN
52854
52855 -- 4645092 ------------------------------------------------------------------------------
52856 -- To allow MPA report to determine if it should generate report process
52857 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
52858 ------------------------------------------------------------------------------------------
52859
52860 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
52861 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
52862 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
52863 -- call ADRs
52864 -- Bug 4922099
52865 --
52866 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52867 (NVL(l_actual_upg_option, 'N') = 'O') OR
52868 (NVL(l_enc_upg_option, 'N') = 'O')
52869 )
52870 THEN
52871 NULL;
52872 --
52873 --
52874
52875 l_ccid := AcctDerRule_11(
52876 p_application_id => p_application_id
52877 , p_ae_header_id => l_ae_header_id
52878 , p_source_10 => p_source_10
52879 , x_transaction_coa_id => l_adr_transaction_coa_id
52880 , x_accounting_coa_id => l_adr_accounting_coa_id
52881 , x_value_type_code => l_adr_value_type_code
52882 , p_side => 'NA'
52883 );
52884
52885 xla_ae_lines_pkg.set_ccid(
52886 p_code_combination_id => l_ccid
52887 , p_value_type_code => l_adr_value_type_code
52888 , p_transaction_coa_id => l_adr_transaction_coa_id
52889 , p_accounting_coa_id => l_adr_accounting_coa_id
52890 , p_adr_code => 'DIST_CCID'
52891 , p_adr_type_code => 'S'
52892 , p_component_type => l_component_type
52893 , p_component_code => l_component_code
52894 , p_component_type_code => l_component_type_code
52895 , p_component_appl_id => l_component_appl_id
52896 , p_amb_context_code => l_amb_context_code
52897 , p_side => 'NA'
52898 );
52899
52900
52901 --
52902 --
52903 END IF;
52904
52905 --
52906 -- Update the line information that should be overwritten
52907 --
52908 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
52909 p_header_num => 1);
52910 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
52911
52912 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
52913
52914 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
52915 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
52916 END IF;
52917
52918 --
52919 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
52920 --
52921 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
52922 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
52923 ELSE
52924 ---------------------------------------------------------------------------------------------------
52925 -- 4262811a Switch Sign
52926 ---------------------------------------------------------------------------------------------------
52927 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
52928 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52929 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52930 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52931 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52932 -- 5132302
52933 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
52934 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52935
52936 END IF;
52937
52938 -- 4955764
52939 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52940 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
52941
52942
52943 XLA_AE_LINES_PKG.ValidateCurrentLine;
52944 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52945
52946 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52947 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
52948 ,p_balance_type_code => l_balance_type_code);
52949
52950 END IF;
52951
52952 -----------------------------------------------------------------------------------------
52953 -- 4262811 Multiperiod Accounting
52954 -----------------------------------------------------------------------------------------
52955 -- No MPA option is assigned.
52956
52957
52958 END IF;
52959 END IF;
52960 --
52961
52962 --
52963 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52964 trace
52965 (p_msg => 'END of AcctLineType_103'
52966 ,p_level => C_LEVEL_PROCEDURE
52967 ,p_module => l_log_module);
52968 END IF;
52969 --
52970 EXCEPTION
52971 WHEN xla_exceptions_pkg.application_exception THEN
52972 RAISE;
52973 WHEN OTHERS THEN
52974 xla_exceptions_pkg.raise_message
52975 (p_location => 'XLA_00222_AAD_S_000007_PKG.AcctLineType_103');
52976 END AcctLineType_103;
52977 --
52978
52979 ---------------------------------------
52980 --
52981 -- PRIVATE PROCEDURE
52982 -- insert_sources_104
52983 --
52984 ----------------------------------------
52985 --
52986 PROCEDURE insert_sources_104(
52987 p_target_ledger_id IN NUMBER
52988 , p_language IN VARCHAR2
52989 , p_sla_ledger_id IN NUMBER
52990 , p_pad_start_date IN DATE
52991 , p_pad_end_date IN DATE
52992 )
52993 IS
52994
52995 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT_ALL';
52996 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT';
52997 p_apps_owner VARCHAR2(30);
52998 l_log_module VARCHAR2(240);
52999 BEGIN
53000 IF g_log_enabled THEN
53001 l_log_module := C_DEFAULT_MODULE||'.insert_sources_104';
53002 END IF;
53003 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53004
53005 trace
53006 (p_msg => 'BEGIN of insert_sources_104'
53007 ,p_level => C_LEVEL_PROCEDURE
53008 ,p_module => l_log_module);
53009
53010 END IF;
53011
53012 -- select APPS owner
53013 SELECT oracle_username
53014 INTO p_apps_owner
53015 FROM fnd_oracle_userid
53016 WHERE read_only_flag = 'U'
53017 ;
53018
53019 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
53020 trace
53024 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
53021 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
53022 ' - p_language = '||p_language||
53023 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
53025 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
53026 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
53027 ,p_level => C_LEVEL_STATEMENT
53028 ,p_module => l_log_module);
53029 END IF;
53030
53031
53032 --
53033 INSERT INTO xla_diag_sources --hdr2
53034 (
53035 event_id
53036 , ledger_id
53037 , sla_ledger_id
53038 , description_language
53039 , object_name
53040 , object_type_code
53041 , line_number
53042 , source_application_id
53043 , source_type_code
53044 , source_code
53045 , source_value
53046 , source_meaning
53047 , created_by
53048 , creation_date
53049 , last_update_date
53050 , last_updated_by
53051 , last_update_login
53052 , program_update_date
53053 , program_application_id
53054 , program_id
53055 , request_id
53056 )
53057 SELECT
53058 event_id
53059 , p_target_ledger_id
53060 , p_sla_ledger_id
53061 , p_language
53062 , object_name
53063 , object_type_code
53064 , line_number
53065 , source_application_id
53066 , source_type_code
53067 , source_code
53068 , SUBSTR(source_value ,1,1996)
53069 , SUBSTR(source_meaning ,1,200)
53070 , xla_environment_pkg.g_Usr_Id
53071 , TRUNC(SYSDATE)
53072 , TRUNC(SYSDATE)
53073 , xla_environment_pkg.g_Usr_Id
53074 , xla_environment_pkg.g_Login_Id
53075 , TRUNC(SYSDATE)
53076 , xla_environment_pkg.g_Prog_Appl_Id
53077 , xla_environment_pkg.g_Prog_Id
53078 , xla_environment_pkg.g_Req_Id
53079 FROM (
53080 SELECT xet.event_id event_id
53081 , 0 line_number
53082 , CASE r
53083 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
53084 WHEN 2 THEN 'AR_RECEIVABLES_TRX_ACT_S_V'
53085 WHEN 3 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
53086 WHEN 4 THEN 'AR_BILL_TO_SITE_USES_S_V'
53087 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
53088 WHEN 6 THEN 'AR_ADJUSTMENTS_H_V'
53089 WHEN 7 THEN 'AR_ADJUSTMENTS_H_V'
53090 WHEN 8 THEN 'AR_ADJUSTMENTS_H_V'
53091
53092 ELSE null
53093 END object_name
53094 , CASE r
53095 WHEN 1 THEN 'HEADER'
53096 WHEN 2 THEN 'HEADER'
53097 WHEN 3 THEN 'HEADER'
53098 WHEN 4 THEN 'HEADER'
53099 WHEN 5 THEN 'HEADER'
53100 WHEN 6 THEN 'HEADER'
53101 WHEN 7 THEN 'HEADER'
53102 WHEN 8 THEN 'HEADER'
53103
53104 ELSE null
53105 END object_type_code
53106 , CASE r
53107 WHEN 1 THEN '222'
53108 WHEN 2 THEN '222'
53109 WHEN 3 THEN '222'
53110 WHEN 4 THEN '222'
53111 WHEN 5 THEN '222'
53112 WHEN 6 THEN '222'
53113 WHEN 7 THEN '222'
53114 WHEN 8 THEN '222'
53115
53116 ELSE null
53117 END source_application_id
53118 , 'S' source_type_code
53119 , CASE r
53120 WHEN 1 THEN 'TRX_RECEIVABLE_CCID'
53121 WHEN 2 THEN 'REC_ACT_TYPE'
53122 WHEN 3 THEN 'BILL_CUST_ACCOUNT_ID'
53123 WHEN 4 THEN 'BILL_USES_SITE_USE_ID'
53124 WHEN 5 THEN 'XLA_PARTY_TYPE'
53125 WHEN 6 THEN 'ADJ_DOC_SEQUENCE_CATEGORY'
53126 WHEN 7 THEN 'ADJ_DOC_SEQUENCE_ID'
53127 WHEN 8 THEN 'ADJ_DOC_SEQUENCE_VALUE'
53128
53129 ELSE null
53130 END source_code
53131 , CASE r
53132 WHEN 1 THEN TO_CHAR(h7.TRX_RECEIVABLE_CCID)
53133 WHEN 2 THEN TO_CHAR(h6.REC_ACT_TYPE)
53134 WHEN 3 THEN TO_CHAR(h2.BILL_CUST_ACCOUNT_ID)
53135 WHEN 4 THEN TO_CHAR(h3.BILL_USES_SITE_USE_ID)
53136 WHEN 5 THEN TO_CHAR(h7.XLA_PARTY_TYPE)
53137 WHEN 6 THEN TO_CHAR(h1.ADJ_DOC_SEQUENCE_CATEGORY)
53138 WHEN 7 THEN TO_CHAR(h1.ADJ_DOC_SEQUENCE_ID)
53139 WHEN 8 THEN TO_CHAR(h1.ADJ_DOC_SEQUENCE_VALUE)
53140
53141 ELSE null
53142 END source_value
53143 , null source_meaning
53144 FROM xla_events_gt xet
53145 , AR_ADJUSTMENTS_H_V h1
53146 , AR_BILL_TO_CUSTOMERS_S_V h2
53147 , AR_BILL_TO_SITE_USES_S_V h3
53148 , AR_RECEIVABLES_TRX_ACT_S_V h6
53149 , AR_TRANSACTIONS_S_V h7
53150 ,(select rownum r from all_objects where rownum <= 8 and owner = p_apps_owner)
53151 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
53152 AND xet.event_class_code = C_EVENT_CLASS_CODE
53153 AND h1.event_id = xet.event_id
53154 AND h2.event_id = h1.event_id
53155 AND h3.event_id = h1.event_id
53156 AND h6.event_id (+) = h1.event_id
53157 AND h7.event_id = h1.event_id
53158
53159 )
53160 ;
53161 --
53162 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
53163
53164 trace
53165 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
53166 ,p_level => C_LEVEL_STATEMENT
53167 ,p_module => l_log_module);
53168
53169 END IF;
53170 --
53171
53172
53173
53174 --
53175 INSERT INTO xla_diag_sources --line2
53176 (
53177 event_id
53178 , ledger_id
53179 , sla_ledger_id
53180 , description_language
53181 , object_name
53182 , object_type_code
53183 , line_number
53184 , source_application_id
53185 , source_type_code
53186 , source_code
53187 , source_value
53188 , source_meaning
53189 , created_by
53190 , creation_date
53191 , last_update_date
53192 , last_updated_by
53193 , last_update_login
53194 , program_update_date
53195 , program_application_id
53196 , program_id
53197 , request_id
53198 )
53199 SELECT event_id
53200 , p_target_ledger_id
53201 , p_sla_ledger_id
53202 , p_language
53203 , object_name
53204 , object_type_code
53205 , line_number
53206 , source_application_id
53207 , source_type_code
53208 , source_code
53209 , SUBSTR(source_value,1,1996)
53210 , SUBSTR(source_meaning ,1,200)
53211 , xla_environment_pkg.g_Usr_Id
53212 , TRUNC(SYSDATE)
53213 , TRUNC(SYSDATE)
53214 , xla_environment_pkg.g_Usr_Id
53215 , xla_environment_pkg.g_Login_Id
53216 , TRUNC(SYSDATE)
53217 , xla_environment_pkg.g_Prog_Appl_Id
53218 , xla_environment_pkg.g_Prog_Id
53219 , xla_environment_pkg.g_Req_Id
53220 FROM (
53221 SELECT xet.event_id event_id
53222 , l5.line_number line_number
53223 , CASE r
53224 WHEN 1 THEN 'AR_DISTRIBUTIONS_L_V'
53225 WHEN 2 THEN 'AR_DISTRIBUTIONS_L_V'
53226 WHEN 3 THEN 'AR_DISTRIBUTIONS_L_V'
53227 WHEN 4 THEN 'AR_DISTRIBUTIONS_L_V'
53228 WHEN 5 THEN 'AR_DISTRIBUTIONS_L_V'
53229 WHEN 6 THEN 'AR_DISTRIBUTIONS_L_V'
53230 WHEN 7 THEN 'AR_DISTRIBUTIONS_BASE_V'
53231 WHEN 8 THEN 'AR_DISTRIBUTIONS_BASE_V'
53232 WHEN 9 THEN 'AR_DISTRIBUTIONS_BASE_V'
53233 WHEN 10 THEN 'AR_DISTRIBUTIONS_BASE_V'
53234
53235 ELSE null
53236 END object_name
53237 , CASE r
53238 WHEN 1 THEN 'LINE'
53239 WHEN 2 THEN 'LINE'
53240 WHEN 3 THEN 'LINE'
53241 WHEN 4 THEN 'LINE'
53242 WHEN 5 THEN 'LINE'
53243 WHEN 6 THEN 'LINE'
53244 WHEN 7 THEN 'LINE'
53245 WHEN 8 THEN 'LINE'
53246 WHEN 9 THEN 'LINE'
53247 WHEN 10 THEN 'LINE'
53248
53249 ELSE null
53250 END object_type_code
53251 , CASE r
53252 WHEN 1 THEN '222'
53253 WHEN 2 THEN '222'
53254 WHEN 3 THEN '222'
53255 WHEN 4 THEN '222'
53256 WHEN 5 THEN '222'
53257 WHEN 6 THEN '222'
53258 WHEN 7 THEN '222'
53259 WHEN 8 THEN '222'
53260 WHEN 9 THEN '222'
53261 WHEN 10 THEN '222'
53262
53263 ELSE null
53264 END source_application_id
53265 , 'S' source_type_code
53266 , CASE r
53267 WHEN 1 THEN 'DIST_CODE_COMBINATION_ID'
53268 WHEN 2 THEN 'DIST_SOURCE_TYPE'
53269 WHEN 3 THEN 'DIST_LINE_ID'
53270 WHEN 4 THEN 'DISTRIBUTION_TYPE'
53271 WHEN 5 THEN 'DIST_ENT_AMT'
53272 WHEN 6 THEN 'DIST_CURRENCY_CODE'
53273 WHEN 7 THEN 'DIST_CUR_CONVERSION_DATE'
53274 WHEN 8 THEN 'DIST_CUR_CONVERSION_RATE'
53275 WHEN 9 THEN 'DIST_CUR_CONVERSION_TYPE'
53276 WHEN 10 THEN 'DIST_TO_ACCTD_AMT'
53277
53278 ELSE null
53279 END source_code
53280 , CASE r
53281 WHEN 1 THEN TO_CHAR(l5.DIST_CODE_COMBINATION_ID)
53285 WHEN 5 THEN TO_CHAR(l5.DIST_ENT_AMT)
53282 WHEN 2 THEN TO_CHAR(l5.DIST_SOURCE_TYPE)
53283 WHEN 3 THEN TO_CHAR(l5.DIST_LINE_ID)
53284 WHEN 4 THEN TO_CHAR(l5.DISTRIBUTION_TYPE)
53286 WHEN 6 THEN TO_CHAR(l5.DIST_CURRENCY_CODE)
53287 WHEN 7 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_DATE)
53288 WHEN 8 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_RATE)
53289 WHEN 9 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_TYPE)
53290 WHEN 10 THEN TO_CHAR(l4.DIST_TO_ACCTD_AMT)
53291
53292 ELSE null
53293 END source_value
53294 , null source_meaning
53295 FROM xla_events_gt xet
53296 , AR_DISTRIBUTIONS_BASE_V l4
53297 , AR_DISTRIBUTIONS_L_V l5
53298 , (select rownum r from all_objects where rownum <= 10 and owner = p_apps_owner)
53299 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
53300 AND xet.event_class_code = C_EVENT_CLASS_CODE
53301 AND l4.event_id = xet.event_id
53302 AND l5.event_id = l4.event_id
53303 AND l5.line_number = l4.line_number
53304
53305 )
53306 ;
53307 --
53308 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
53309
53310 trace
53311 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
53312 ,p_level => C_LEVEL_STATEMENT
53313 ,p_module => l_log_module);
53314
53315 END IF;
53316
53317
53318 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53319 trace
53320 (p_msg => 'END of insert_sources_104'
53321 ,p_level => C_LEVEL_PROCEDURE
53322 ,p_module => l_log_module);
53323 END IF;
53324 EXCEPTION
53325 WHEN xla_exceptions_pkg.application_exception THEN
53326 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
53327 trace
53328 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
53329 ,p_level => C_LEVEL_EXCEPTION
53330 ,p_module => l_log_module);
53331 END IF;
53332 RAISE;
53333 WHEN OTHERS THEN
53334 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
53335 trace
53336 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
53337 ,p_level => C_LEVEL_EXCEPTION
53338 ,p_module => l_log_module);
53339 END IF;
53340 xla_exceptions_pkg.raise_message
53341 (p_location => 'XLA_00222_AAD_S_000007_PKG.insert_sources_104');
53342 END insert_sources_104;
53343 --
53344
53345 ---------------------------------------
53346 --
53347 -- PRIVATE FUNCTION
53348 -- EventClass_104
53349 --
53350 ----------------------------------------
53351 --
53352 FUNCTION EventClass_104
53353 (p_application_id IN NUMBER
53354 ,p_base_ledger_id IN NUMBER
53355 ,p_target_ledger_id IN NUMBER
53356 ,p_language IN VARCHAR2
53357 ,p_currency_code IN VARCHAR2
53358 ,p_sla_ledger_id IN NUMBER
53359 ,p_pad_start_date IN DATE
53360 ,p_pad_end_date IN DATE
53361 ,p_primary_ledger_id IN NUMBER)
53362 RETURN BOOLEAN IS
53363 --
53364 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT_ALL';
53365 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT';
53366
53367 l_calculate_acctd_flag VARCHAR2(1) :='N';
53368 l_calculate_g_l_flag VARCHAR2(1) :='Y';
53369 --
53370 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
53371 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
53372 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
53373 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
53374 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
53375 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
53376 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
53377 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
53378 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
53379 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
53380 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
53381 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
53382 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
53383 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
53384 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
53385 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
53386 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
53387 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
53388 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
53389 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
53390 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
53391 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
53392 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
53393 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
53394 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
53395 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
53396
53397 l_event_id NUMBER;
53398 l_previous_event_id NUMBER;
53399 l_first_event_id NUMBER;
53400 l_last_event_id NUMBER;
53401
53402 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
53403 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
53404 --
53405 --
53406 l_result BOOLEAN := TRUE;
53407 l_rows NUMBER := 1000;
53408 l_event_type_name VARCHAR2(80) := 'All';
53409 l_event_class_name VARCHAR2(80) := 'Adjustment';
53410 l_description VARCHAR2(4000);
53411 l_transaction_reversal NUMBER;
53412 l_ae_header_id NUMBER;
53413 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
53414 l_log_module VARCHAR2(240);
53415 --
53416 l_acct_reversal_source VARCHAR2(30);
53417 l_trx_reversal_source VARCHAR2(30);
53418
53419 l_continue_with_lines BOOLEAN := TRUE;
53420 --
53421 l_acc_rev_gl_date_source DATE; -- 4262811
53422 --
53423 type t_array_event_id is table of number index by binary_integer;
53424
53425 l_rec_array_event t_rec_array_event;
53426 l_null_rec_array_event t_rec_array_event;
53427 l_array_ae_header_id xla_number_array_type;
53428 l_actual_flag VARCHAR2(1) := NULL;
53429 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
53430 l_balance_type_code VARCHAR2(1) :=NULL;
53431 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
53432
53433 --
53434 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
53435 --
53436
53437 TYPE t_array_source_8 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_RECEIVABLE_CCID%TYPE INDEX BY BINARY_INTEGER;
53438 TYPE t_array_source_16 IS TABLE OF AR_RECEIVABLES_TRX_ACT_S_V.REC_ACT_TYPE%TYPE INDEX BY BINARY_INTEGER;
53439 TYPE t_array_source_25 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
53440 TYPE t_array_source_26 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
53441 TYPE t_array_source_27 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
53442 TYPE t_array_source_73 IS TABLE OF AR_ADJUSTMENTS_H_V.ADJ_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
53443 TYPE t_array_source_74 IS TABLE OF AR_ADJUSTMENTS_H_V.ADJ_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
53444 TYPE t_array_source_75 IS TABLE OF AR_ADJUSTMENTS_H_V.ADJ_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
53445
53446 TYPE t_array_source_10 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
53447 TYPE t_array_source_15 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
53448 TYPE t_array_source_17 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
53449 TYPE t_array_source_18 IS TABLE OF AR_DISTRIBUTIONS_L_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
53450 TYPE t_array_source_19 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
53451 TYPE t_array_source_20 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
53452 TYPE t_array_source_21 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
53453 TYPE t_array_source_22 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
53454 TYPE t_array_source_23 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
53455 TYPE t_array_source_24 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
53456
53457 l_array_source_8 t_array_source_8;
53458 l_array_source_16 t_array_source_16;
53459 l_array_source_25 t_array_source_25;
53460 l_array_source_26 t_array_source_26;
53461 l_array_source_27 t_array_source_27;
53462 l_array_source_73 t_array_source_73;
53463 l_array_source_74 t_array_source_74;
53464 l_array_source_75 t_array_source_75;
53465
53466 l_array_source_10 t_array_source_10;
53467 l_array_source_15 t_array_source_15;
53468 l_array_source_17 t_array_source_17;
53469 l_array_source_18 t_array_source_18;
53470 l_array_source_19 t_array_source_19;
53471 l_array_source_20 t_array_source_20;
53472 l_array_source_21 t_array_source_21;
53473 l_array_source_22 t_array_source_22;
53474 l_array_source_23 t_array_source_23;
53475 l_array_source_24 t_array_source_24;
53476
53477 --
53478 CURSOR header_cur
53479 IS
53483 ,xet.legal_entity_id
53480 SELECT /*+ leading(xet) cardinality(xet,1) */
53481 -- Event Class Code: ADJUSTMENT
53482 xet.entity_id
53484 ,xet.entity_code
53485 ,xet.transaction_number
53486 ,xet.event_id
53487 ,xet.event_class_code
53488 ,xet.event_type_code
53489 ,xet.event_number
53490 ,xet.event_date
53491 ,xet.transaction_date
53492 ,xet.reference_num_1
53493 ,xet.reference_num_2
53494 ,xet.reference_num_3
53495 ,xet.reference_num_4
53496 ,xet.reference_char_1
53497 ,xet.reference_char_2
53498 ,xet.reference_char_3
53499 ,xet.reference_char_4
53500 ,xet.reference_date_1
53501 ,xet.reference_date_2
53502 ,xet.reference_date_3
53503 ,xet.reference_date_4
53504 ,xet.event_created_by
53505 ,xet.budgetary_control_flag
53506 , h7.TRX_RECEIVABLE_CCID source_8
53507 , h6.REC_ACT_TYPE source_16
53508 , h2.BILL_CUST_ACCOUNT_ID source_25
53509 , h3.BILL_USES_SITE_USE_ID source_26
53510 , h7.XLA_PARTY_TYPE source_27
53511 , h1.ADJ_DOC_SEQUENCE_CATEGORY source_73
53512 , h1.ADJ_DOC_SEQUENCE_ID source_74
53513 , h1.ADJ_DOC_SEQUENCE_VALUE source_75
53514 FROM xla_events_gt xet
53515 , AR_ADJUSTMENTS_H_V h1
53516 , AR_BILL_TO_CUSTOMERS_S_V h2
53517 , AR_BILL_TO_SITE_USES_S_V h3
53518 , AR_RECEIVABLES_TRX_ACT_S_V h6
53519 , AR_TRANSACTIONS_S_V h7
53520 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
53521 and xet.event_class_code = C_EVENT_CLASS_CODE
53522 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
53523 AND h2.event_id = h1.event_id
53524 AND h3.event_id = h1.event_id
53525 AND h6.event_id (+) = h1.event_id
53526 AND h7.event_id = h1.event_id
53527
53528 ORDER BY event_id
53529 ;
53530
53531
53532 --
53533 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
53534 IS
53535 SELECT /*+ leading(xet) cardinality(xet,1) */
53536 -- Event Class Code: ADJUSTMENT
53537 xet.entity_id
53538 ,xet.legal_entity_id
53539 ,xet.entity_code
53540 ,xet.transaction_number
53541 ,xet.event_id
53542 ,xet.event_class_code
53543 ,xet.event_type_code
53544 ,xet.event_number
53545 ,xet.event_date
53546 ,xet.transaction_date
53547 ,xet.reference_num_1
53548 ,xet.reference_num_2
53549 ,xet.reference_num_3
53550 ,xet.reference_num_4
53551 ,xet.reference_char_1
53552 ,xet.reference_char_2
53553 ,xet.reference_char_3
53554 ,xet.reference_char_4
53555 ,xet.reference_date_1
53556 ,xet.reference_date_2
53557 ,xet.reference_date_3
53558 ,xet.reference_date_4
53559 ,xet.event_created_by
53560 ,xet.budgetary_control_flag
53561 , l4.LINE_NUMBER
53562 , l5.DIST_CODE_COMBINATION_ID source_10
53563 , l5.DIST_SOURCE_TYPE source_15
53564 , l5.DIST_LINE_ID source_17
53565 , l5.DISTRIBUTION_TYPE source_18
53566 , l5.DIST_ENT_AMT source_19
53567 , l5.DIST_CURRENCY_CODE source_20
53568 , l4.DIST_CUR_CONVERSION_DATE source_21
53569 , l4.DIST_CUR_CONVERSION_RATE source_22
53570 , l4.DIST_CUR_CONVERSION_TYPE source_23
53571 , l4.DIST_TO_ACCTD_AMT source_24
53572 FROM xla_events_gt xet
53573 , AR_DISTRIBUTIONS_BASE_V l4
53574 , AR_DISTRIBUTIONS_L_V l5
53575 WHERE xet.event_id between x_first_event_id and x_last_event_id
53576 and xet.event_date between p_pad_start_date and p_pad_end_date
53577 and xet.event_class_code = C_EVENT_CLASS_CODE
53578 and xet.event_status_code <> 'N' AND l4.event_id = xet.event_id
53579 AND l5.event_id = l4.event_id
53580 AND l5.line_number = l4.line_number
53581 ;
53582
53583 --
53584 BEGIN
53585 IF g_log_enabled THEN
53586 l_log_module := C_DEFAULT_MODULE||'.EventClass_104';
53587 END IF;
53588 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53589 trace
53590 (p_msg => 'BEGIN of EventClass_104'
53591 ,p_level => C_LEVEL_PROCEDURE
53592 ,p_module => l_log_module);
53593 END IF;
53594
53595 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
53596 trace
53597 (p_msg => 'p_application_id = '||p_application_id||
53598 ' - p_base_ledger_id = '||p_base_ledger_id||
53599 ' - p_target_ledger_id = '||p_target_ledger_id||
53600 ' - p_language = '||p_language||
53601 ' - p_currency_code = '||p_currency_code||
53602 ' - p_sla_ledger_id = '||p_sla_ledger_id
53603 ,p_level => C_LEVEL_STATEMENT
53604 ,p_module => l_log_module);
53605 END IF;
53606 --
53607 -- initialze arrays
53608 --
53609 g_array_event.DELETE;
53610 l_rec_array_event := l_null_rec_array_event;
53611 --
53612 --------------------------------------
53613 -- 4262811 Initialze MPA Line Number
53614 --------------------------------------
53615 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
53616
53617 --
53618
53619 --
53620 OPEN header_cur;
53621 --
53622 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
53623 trace
53624 (p_msg => 'SQL - FETCH header_cur'
53625 ,p_level => C_LEVEL_STATEMENT
53626 ,p_module => l_log_module);
53627 END IF;
53628 --
53629 LOOP
53630 FETCH header_cur BULK COLLECT INTO
53631 l_array_entity_id
53632 , l_array_legal_entity_id
53633 , l_array_entity_code
53634 , l_array_transaction_num
53635 , l_array_event_id
53636 , l_array_class_code
53637 , l_array_event_type
53638 , l_array_event_number
53639 , l_array_event_date
53640 , l_array_transaction_date
53641 , l_array_reference_num_1
53642 , l_array_reference_num_2
53643 , l_array_reference_num_3
53644 , l_array_reference_num_4
53645 , l_array_reference_char_1
53646 , l_array_reference_char_2
53647 , l_array_reference_char_3
53648 , l_array_reference_char_4
53649 , l_array_reference_date_1
53650 , l_array_reference_date_2
53651 , l_array_reference_date_3
53652 , l_array_reference_date_4
53653 , l_array_event_created_by
53654 , l_array_budgetary_control_flag
53655 , l_array_source_8
53656 , l_array_source_16
53657 , l_array_source_25
53658 , l_array_source_26
53659 , l_array_source_27
53660 , l_array_source_73
53661 , l_array_source_74
53662 , l_array_source_75
53663 LIMIT l_rows;
53664 --
53665 IF (C_LEVEL_EVENT >= g_log_level) THEN
53666 trace
53667 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
53668 ,p_level => C_LEVEL_EVENT
53669 ,p_module => l_log_module);
53670 END IF;
53671 --
53672 EXIT WHEN l_array_entity_id.COUNT = 0;
53673
53674 -- initialize arrays
53675 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
53676 XLA_AE_LINES_PKG.g_rec_lines := NULL;
53677
53678 --
53679 -- Bug 4458708
53680 --
53681 XLA_AE_LINES_PKG.g_LineNumber := 0;
53682
53683
53684 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
53685 g_last_hdr_idx := l_array_event_id.LAST;
53686 --
53687 -- loop for the headers. Each iteration is for each header extract row
53688 -- fetched in header cursor
53689 --
53690 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
53691
53692 --
53693 -- set event info as cache for other routines to refer event attributes
53694 --
53695 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
53696 (p_application_id => p_application_id
53697 ,p_primary_ledger_id => p_primary_ledger_id
53698 ,p_base_ledger_id => p_base_ledger_id
53699 ,p_target_ledger_id => p_target_ledger_id
53700 ,p_entity_id => l_array_entity_id(hdr_idx)
53701 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
53702 ,p_entity_code => l_array_entity_code(hdr_idx)
53703 ,p_transaction_num => l_array_transaction_num(hdr_idx)
53704 ,p_event_id => l_array_event_id(hdr_idx)
53705 ,p_event_class_code => l_array_class_code(hdr_idx)
53706 ,p_event_type_code => l_array_event_type(hdr_idx)
53707 ,p_event_number => l_array_event_number(hdr_idx)
53708 ,p_event_date => l_array_event_date(hdr_idx)
53709 ,p_transaction_date => l_array_transaction_date(hdr_idx)
53710 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
53711 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
53712 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
53713 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
53714 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
53715 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
53716 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
53717 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
53718 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
53719 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
53720 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
53721 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
53722 ,p_event_created_by => l_array_event_created_by(hdr_idx)
53723 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
53724
53725 --
53726 -- set the status of entry to C_VALID (0)
53727 --
53728 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
53729
53730 --
53731 -- initialize a row for ae header
53732 --
53733 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
53734
53735 l_event_id := l_array_event_id(hdr_idx);
53736
53737 --
53738 -- storing the hdr_idx for event. May be used by line cursor.
53739 --
53740 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
53741
53742 --
53743 -- store sources from header extract. This can be improved to
53744 -- store only those sources from header extract that may be used in lines
53745 --
53746
53747 g_array_event(l_event_id).array_value_num('source_8') := l_array_source_8(hdr_idx);
53748 g_array_event(l_event_id).array_value_char('source_16') := l_array_source_16(hdr_idx);
53749 g_array_event(l_event_id).array_value_num('source_25') := l_array_source_25(hdr_idx);
53750 g_array_event(l_event_id).array_value_num('source_26') := l_array_source_26(hdr_idx);
53751 g_array_event(l_event_id).array_value_char('source_27') := l_array_source_27(hdr_idx);
53752 g_array_event(l_event_id).array_value_char('source_73') := l_array_source_73(hdr_idx);
53753 g_array_event(l_event_id).array_value_num('source_74') := l_array_source_74(hdr_idx);
53754 g_array_event(l_event_id).array_value_num('source_75') := l_array_source_75(hdr_idx);
53755
53756 --
53757 -- initilaize the status of ae headers for diffrent balance types
53758 -- the status is initialised to C_NOT_CREATED (2)
53759 --
53760 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
53761 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
53762 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
53763
53764 --
53765 -- call api to validate and store accounting attributes for header
53766 --
53767
53768 ------------------------------------------------------------
53769 -- Accrual Reversal : to get date for Standard Source (NONE)
53770 ------------------------------------------------------------
53771 l_acc_rev_gl_date_source := NULL;
53772
53773 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
53774 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_73');
53775 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
53776 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_74');
53777 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
53778 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_75');
53779 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
53780 l_rec_acct_attrs.array_date_value(4) :=
53781 xla_ae_sources_pkg.GetSystemSourceDate(
53782 p_source_code => 'XLA_EVENT_DATE'
53783 , p_source_type_code => 'Y'
53784 , p_source_application_id => 602
53785 );
53786
53787
53788 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
53789
53790 XLA_AE_HEADER_PKG.SetJeCategoryName;
53791
53792 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
53793 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
53794 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
53795 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
53796 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
53797
53798
53799 -- No header level analytical criteria
53800
53801 --
53802 --accounting attribute enhancement, bug 3612931
53803 --
53804 l_trx_reversal_source := SUBSTR(NULL, 1,30);
53805
53806 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
53807 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
53808
53809 xla_accounting_err_pkg.build_message
53810 (p_appli_s_name => 'XLA'
53811 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
53812 ,p_token_1 => 'ACCT_ATTR_NAME'
53813 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
53814 ,p_token_2 => 'PRODUCT_NAME'
53815 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
53816 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
53817 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
53818 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
53819
53820 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
53821 --
53822 -- following sets the accounting attributes needed to reverse
53823 -- accounting for a distributeion
53824 --
53825 xla_ae_lines_pkg.SetTrxReversalAttrs
53826 (p_event_id => l_event_id
53827 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
53828 ,p_trx_reversal_source => l_trx_reversal_source);
53829
53830 END IF;
53831
53832
53833 ----------------------------------------------------------------
53834 -- 4262811 - update the header statuses to invalid in need be
53835 ----------------------------------------------------------------
53836 --
53837 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
53841 -- No accrual reversal for the event class/type
53838
53839
53840 -----------------------------------------------
53842 -----------------------------------------------
53843 ----------------------------------------------------------------
53844
53845 --
53846 -- this ends the header loop iteration for one bulk fetch
53847 --
53848 END LOOP;
53849
53850 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
53851 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
53852
53853 --
53854 -- insert dummy rows into lines gt table that were created due to
53855 -- transaction reversals
53856 --
53857 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
53858 l_result := XLA_AE_LINES_PKG.InsertLines;
53859 END IF;
53860
53861 --
53862 -- reset the temp_line_num for each set of events fetched from header
53863 -- cursor rather than doing it for each new event in line cursor
53864 -- Bug 3939231
53865 --
53866 xla_ae_lines_pkg.g_temp_line_num := 0;
53867
53868
53869
53870 --
53871 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
53872 --
53873 --
53874 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
53875
53876 trace
53877 (p_msg => 'SQL - FETCH line_cur'
53878 ,p_level => C_LEVEL_STATEMENT
53879 ,p_module => l_log_module);
53880
53881 END IF;
53882 --
53883 --
53884 LOOP
53885 --
53886 FETCH line_cur BULK COLLECT INTO
53887 l_array_entity_id
53888 , l_array_legal_entity_id
53889 , l_array_entity_code
53890 , l_array_transaction_num
53891 , l_array_event_id
53892 , l_array_class_code
53893 , l_array_event_type
53894 , l_array_event_number
53895 , l_array_event_date
53896 , l_array_transaction_date
53897 , l_array_reference_num_1
53898 , l_array_reference_num_2
53899 , l_array_reference_num_3
53900 , l_array_reference_num_4
53901 , l_array_reference_char_1
53902 , l_array_reference_char_2
53903 , l_array_reference_char_3
53904 , l_array_reference_char_4
53905 , l_array_reference_date_1
53906 , l_array_reference_date_2
53907 , l_array_reference_date_3
53908 , l_array_reference_date_4
53909 , l_array_event_created_by
53910 , l_array_budgetary_control_flag
53911 , l_array_extract_line_num
53912 , l_array_source_10
53913 , l_array_source_15
53914 , l_array_source_17
53915 , l_array_source_18
53916 , l_array_source_19
53917 , l_array_source_20
53918 , l_array_source_21
53919 , l_array_source_22
53920 , l_array_source_23
53921 , l_array_source_24
53922 LIMIT l_rows;
53923
53924 --
53925 IF (C_LEVEL_EVENT >= g_log_level) THEN
53926 trace
53927 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
53928 ,p_level => C_LEVEL_EVENT
53929 ,p_module => l_log_module);
53930 END IF;
53931 --
53932 EXIT WHEN l_array_entity_id.count = 0;
53933
53934 XLA_AE_LINES_PKG.g_rec_lines := null;
53935
53936 --
53937 -- Bug 4458708
53938 --
53939 XLA_AE_LINES_PKG.g_LineNumber := 0;
53940 --
53941 --
53942
53943 FOR Idx IN 1..l_array_event_id.count LOOP
53944 --
53945 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
53946 --
53947 l_event_id := l_array_event_id(idx); -- 5648433
53948
53949 --
53950 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
53951 --
53952
53953 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
53954 (g_array_event(l_event_id).array_value_num('header_index'))
53955 ,'N'
53956 ) <> 'Y'
53957 THEN
53958 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
53959 trace
53960 (p_msg => 'Trancaction revesal option is not Y '
53961 ,p_level => C_LEVEL_STATEMENT
53962 ,p_module => l_log_module);
53963 END IF;
53964
53965 --
53966 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
53967 --
53968 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
53969 --
53970 -- set event info as cache for other routines to refer event attributes
53971 --
53972
53973 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
53974 l_previous_event_id := l_event_id;
53975
53976 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
53977 (p_application_id => p_application_id
53978 ,p_primary_ledger_id => p_primary_ledger_id
53979 ,p_base_ledger_id => p_base_ledger_id
53980 ,p_target_ledger_id => p_target_ledger_id
53981 ,p_entity_id => l_array_entity_id(Idx)
53982 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
53983 ,p_entity_code => l_array_entity_code(Idx)
53984 ,p_transaction_num => l_array_transaction_num(Idx)
53985 ,p_event_id => l_array_event_id(Idx)
53986 ,p_event_class_code => l_array_class_code(Idx)
53987 ,p_event_type_code => l_array_event_type(Idx)
53988 ,p_event_number => l_array_event_number(Idx)
53989 ,p_event_date => l_array_event_date(Idx)
53990 ,p_transaction_date => l_array_transaction_date(Idx)
53991 ,p_reference_num_1 => l_array_reference_num_1(Idx)
53992 ,p_reference_num_2 => l_array_reference_num_2(Idx)
53993 ,p_reference_num_3 => l_array_reference_num_3(Idx)
53994 ,p_reference_num_4 => l_array_reference_num_4(Idx)
53995 ,p_reference_char_1 => l_array_reference_char_1(Idx)
53996 ,p_reference_char_2 => l_array_reference_char_2(Idx)
53997 ,p_reference_char_3 => l_array_reference_char_3(Idx)
53998 ,p_reference_char_4 => l_array_reference_char_4(Idx)
53999 ,p_reference_date_1 => l_array_reference_date_1(Idx)
54000 ,p_reference_date_2 => l_array_reference_date_2(Idx)
54001 ,p_reference_date_3 => l_array_reference_date_3(Idx)
54002 ,p_reference_date_4 => l_array_reference_date_4(Idx)
54003 ,p_event_created_by => l_array_event_created_by(Idx)
54004 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
54005 --
54006 END IF;
54007
54008
54009
54010 --
54011 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
54012
54013 l_acct_reversal_source := SUBSTR(NULL, 1,30);
54014
54015 IF l_continue_with_lines THEN
54016 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
54017 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
54018
54019 xla_accounting_err_pkg.build_message
54020 (p_appli_s_name => 'XLA'
54021 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
54022 ,p_token_1 => 'LINE_NUMBER'
54023 ,p_value_1 => l_array_extract_line_num(Idx)
54024 ,p_token_2 => 'PRODUCT_NAME'
54025 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
54026 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
54027 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
54028 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
54029
54030 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
54031 --
54032 -- following sets the accounting attributes needed to reverse
54033 -- accounting for a distributeion
54034 --
54035
54036 --
54037 -- 5217187
54038 --
54039 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
54040 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
54041 g_array_event(l_event_id).array_value_num('header_index'));
54042 --
54043 --
54044
54045 -- No reversal code generated
54046
54047 xla_ae_lines_pkg.SetAcctReversalAttrs
54048 (p_event_id => l_event_id
54049 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
54050 ,p_calculate_acctd_flag => l_calculate_acctd_flag
54051 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
54052 END IF;
54053
54054 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
54055 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
54056
54057 --
54058 AcctLineType_19 (
54059 p_application_id => p_application_id
54060 ,p_event_id => l_event_id
54061 ,p_calculate_acctd_flag => l_calculate_acctd_flag
54062 ,p_calculate_g_l_flag => l_calculate_g_l_flag
54063 ,p_actual_flag => l_actual_flag
54064 ,p_balance_type_code => l_balance_type_code
54065 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
54066
54067 , p_source_10 => l_array_source_10(Idx)
54068 , p_source_15 => l_array_source_15(Idx)
54069 , p_source_16 => g_array_event(l_event_id).array_value_char('source_16')
54070 , p_source_17 => l_array_source_17(Idx)
54071 , p_source_18 => l_array_source_18(Idx)
54072 , p_source_19 => l_array_source_19(Idx)
54073 , p_source_20 => l_array_source_20(Idx)
54074 , p_source_21 => l_array_source_21(Idx)
54075 , p_source_22 => l_array_source_22(Idx)
54076 , p_source_23 => l_array_source_23(Idx)
54077 , p_source_24 => l_array_source_24(Idx)
54078 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
54079 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
54080 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
54081 );
54082 If(l_balance_type_code = 'A') THEN
54083 l_actual_gain_loss_ref := l_gain_or_loss_ref;
54084 END IF;
54085
54086 --
54087
54088
54089 --
54090 AcctLineType_20 (
54091 p_application_id => p_application_id
54092 ,p_event_id => l_event_id
54093 ,p_calculate_acctd_flag => l_calculate_acctd_flag
54094 ,p_calculate_g_l_flag => l_calculate_g_l_flag
54095 ,p_actual_flag => l_actual_flag
54096 ,p_balance_type_code => l_balance_type_code
54097 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
54098
54099 , p_source_10 => l_array_source_10(Idx)
54100 , p_source_15 => l_array_source_15(Idx)
54101 , p_source_16 => g_array_event(l_event_id).array_value_char('source_16')
54102 , p_source_17 => l_array_source_17(Idx)
54103 , p_source_18 => l_array_source_18(Idx)
54104 , p_source_19 => l_array_source_19(Idx)
54105 , p_source_20 => l_array_source_20(Idx)
54106 , p_source_21 => l_array_source_21(Idx)
54107 , p_source_22 => l_array_source_22(Idx)
54108 , p_source_23 => l_array_source_23(Idx)
54109 , p_source_24 => l_array_source_24(Idx)
54110 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
54111 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
54112 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
54113 );
54114 If(l_balance_type_code = 'A') THEN
54115 l_actual_gain_loss_ref := l_gain_or_loss_ref;
54116 END IF;
54117
54118 --
54119
54120
54121 --
54122 AcctLineType_21 (
54123 p_application_id => p_application_id
54124 ,p_event_id => l_event_id
54125 ,p_calculate_acctd_flag => l_calculate_acctd_flag
54126 ,p_calculate_g_l_flag => l_calculate_g_l_flag
54127 ,p_actual_flag => l_actual_flag
54128 ,p_balance_type_code => l_balance_type_code
54129 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
54130
54131 , p_source_10 => l_array_source_10(Idx)
54132 , p_source_15 => l_array_source_15(Idx)
54133 , p_source_17 => l_array_source_17(Idx)
54134 , p_source_18 => l_array_source_18(Idx)
54135 , p_source_19 => l_array_source_19(Idx)
54136 , p_source_20 => l_array_source_20(Idx)
54137 , p_source_21 => l_array_source_21(Idx)
54138 , p_source_22 => l_array_source_22(Idx)
54139 , p_source_23 => l_array_source_23(Idx)
54140 , p_source_24 => l_array_source_24(Idx)
54141 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
54142 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
54143 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
54144 );
54145 If(l_balance_type_code = 'A') THEN
54146 l_actual_gain_loss_ref := l_gain_or_loss_ref;
54147 END IF;
54148
54149 --
54150
54151
54152 --
54153 AcctLineType_22 (
54154 p_application_id => p_application_id
54155 ,p_event_id => l_event_id
54156 ,p_calculate_acctd_flag => l_calculate_acctd_flag
54157 ,p_calculate_g_l_flag => l_calculate_g_l_flag
54158 ,p_actual_flag => l_actual_flag
54159 ,p_balance_type_code => l_balance_type_code
54160 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
54161
54162 , p_source_10 => l_array_source_10(Idx)
54163 , p_source_15 => l_array_source_15(Idx)
54164 , p_source_17 => l_array_source_17(Idx)
54165 , p_source_18 => l_array_source_18(Idx)
54166 , p_source_19 => l_array_source_19(Idx)
54167 , p_source_20 => l_array_source_20(Idx)
54168 , p_source_21 => l_array_source_21(Idx)
54169 , p_source_22 => l_array_source_22(Idx)
54170 , p_source_23 => l_array_source_23(Idx)
54171 , p_source_24 => l_array_source_24(Idx)
54172 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
54173 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
54174 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
54175 );
54176 If(l_balance_type_code = 'A') THEN
54177 l_actual_gain_loss_ref := l_gain_or_loss_ref;
54178 END IF;
54179
54180 --
54181
54182
54183 --
54184 AcctLineType_53 (
54185 p_application_id => p_application_id
54186 ,p_event_id => l_event_id
54187 ,p_calculate_acctd_flag => l_calculate_acctd_flag
54188 ,p_calculate_g_l_flag => l_calculate_g_l_flag
54189 ,p_actual_flag => l_actual_flag
54190 ,p_balance_type_code => l_balance_type_code
54191 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
54192
54193 , p_source_8 => g_array_event(l_event_id).array_value_num('source_8')
54194 , p_source_10 => l_array_source_10(Idx)
54195 , p_source_15 => l_array_source_15(Idx)
54196 , p_source_16 => g_array_event(l_event_id).array_value_char('source_16')
54197 , p_source_17 => l_array_source_17(Idx)
54198 , p_source_18 => l_array_source_18(Idx)
54199 , p_source_19 => l_array_source_19(Idx)
54200 , p_source_20 => l_array_source_20(Idx)
54201 , p_source_21 => l_array_source_21(Idx)
54202 , p_source_22 => l_array_source_22(Idx)
54203 , p_source_23 => l_array_source_23(Idx)
54204 , p_source_24 => l_array_source_24(Idx)
54205 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
54206 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
54207 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
54208 );
54209 If(l_balance_type_code = 'A') THEN
54210 l_actual_gain_loss_ref := l_gain_or_loss_ref;
54211 END IF;
54212
54213 --
54214
54215 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
54216 -- or secondary ledger that has different currency with primary
54217 -- or alc that is calculated by sla
54218 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
54222 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
54219 (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'))
54220
54221 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
54223 AND (l_actual_flag = 'A')) THEN
54224 XLA_AE_LINES_PKG.CreateGainOrLossLines(
54225 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
54226 ,p_application_id => p_application_id
54227 ,p_amb_context_code => 'DEFAULT'
54228 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
54229 ,p_event_class_code => C_EVENT_CLASS_CODE
54230 ,p_event_type_code => C_EVENT_TYPE_CODE
54231
54232 ,p_gain_ccid => -1
54233 ,p_loss_ccid => -1
54234
54235 ,p_actual_flag => l_actual_flag
54236 ,p_enc_flag => null
54237 ,p_actual_g_l_ref => l_actual_gain_loss_ref
54238 ,p_enc_g_l_ref => null
54239 );
54240 END IF;
54241 END IF;
54242 END IF;
54243
54244 ELSE
54245 --
54246 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
54247 --
54248 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
54249 trace
54250 (p_msg => 'Trancaction revesal option is Y'
54251 ,p_level => C_LEVEL_STATEMENT
54252 ,p_module => l_log_module);
54253 END IF;
54254 END IF;
54255
54256 END LOOP;
54257 l_result := XLA_AE_LINES_PKG.InsertLines ;
54258 end loop;
54259 close line_cur;
54260
54261
54262 --
54263 -- insert headers into xla_ae_headers_gt table
54264 --
54265 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
54266
54267 -- insert into errors table here.
54268
54269 END LOOP;
54270
54271 --
54272 -- 4865292
54273 --
54274 -- Compare g_hdr_extract_count with event count in
54275 -- CreateHeadersAndLines.
54276 --
54277 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
54278
54279 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
54280 trace (p_msg => '# rows extracted from header extract objects '
54281 || ' (running total): '
54282 || g_hdr_extract_count
54283 ,p_level => C_LEVEL_STATEMENT
54284 ,p_module => l_log_module);
54285 END IF;
54286
54287 CLOSE header_cur;
54288 --
54289
54290 --
54291 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54292 trace
54293 (p_msg => 'END of EventClass_104'
54294 ,p_level => C_LEVEL_PROCEDURE
54295 ,p_module => l_log_module);
54296 END IF;
54297 --
54298 RETURN l_result;
54299 EXCEPTION
54300 WHEN xla_exceptions_pkg.application_exception THEN
54301
54302 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
54303
54304
54305 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
54306
54307 RAISE;
54308
54309 WHEN NO_DATA_FOUND THEN
54310
54311 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
54312 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
54313
54314 FOR header_record IN header_cur
54315 LOOP
54316 l_array_header_events(header_record.event_id) := header_record.event_id;
54317 END LOOP;
54318
54319 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
54320 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
54321
54322 fnd_file.put_line(fnd_file.LOG, ' ');
54323 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
54324 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
54325 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
54326
54327 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
54328 LOOP
54329 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
54330 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
54331 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
54332 END IF;
54333 END LOOP;
54334
54335 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
54336 fnd_file.put_line(fnd_file.LOG, ' ');
54337
54338
54339 xla_exceptions_pkg.raise_message
54340 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_104');
54341
54342
54343 WHEN OTHERS THEN
54344 xla_exceptions_pkg.raise_message
54345 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_104');
54346 END EventClass_104;
54347 --
54348
54349 ---------------------------------------
54350 --
54351 -- PRIVATE PROCEDURE
54352 -- insert_sources_105
54353 --
54354 ----------------------------------------
54355 --
54356 PROCEDURE insert_sources_105(
54357 p_target_ledger_id IN NUMBER
54358 , p_language IN VARCHAR2
54359 , p_sla_ledger_id IN NUMBER
54360 , p_pad_start_date IN DATE
54361 , p_pad_end_date IN DATE
54362 )
54363 IS
54364
54365 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK_ALL';
54366 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK';
54367 p_apps_owner VARCHAR2(30);
54368 l_log_module VARCHAR2(240);
54369 BEGIN
54370 IF g_log_enabled THEN
54371 l_log_module := C_DEFAULT_MODULE||'.insert_sources_105';
54372 END IF;
54373 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54374
54375 trace
54376 (p_msg => 'BEGIN of insert_sources_105'
54377 ,p_level => C_LEVEL_PROCEDURE
54378 ,p_module => l_log_module);
54379
54380 END IF;
54381
54382 -- select APPS owner
54383 SELECT oracle_username
54384 INTO p_apps_owner
54385 FROM fnd_oracle_userid
54386 WHERE read_only_flag = 'U'
54387 ;
54388
54389 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
54390 trace
54391 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
54392 ' - p_language = '||p_language||
54393 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
54394 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
54395 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
54396 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
54397 ,p_level => C_LEVEL_STATEMENT
54398 ,p_module => l_log_module);
54399 END IF;
54400
54401
54402 --
54403 INSERT INTO xla_diag_sources --hdr2
54404 (
54405 event_id
54406 , ledger_id
54407 , sla_ledger_id
54408 , description_language
54409 , object_name
54410 , object_type_code
54411 , line_number
54412 , source_application_id
54413 , source_type_code
54414 , source_code
54415 , source_value
54416 , source_meaning
54417 , created_by
54418 , creation_date
54419 , last_update_date
54420 , last_updated_by
54421 , last_update_login
54422 , program_update_date
54423 , program_application_id
54424 , program_id
54425 , request_id
54426 )
54427 SELECT
54428 event_id
54429 , p_target_ledger_id
54430 , p_sla_ledger_id
54431 , p_language
54432 , object_name
54433 , object_type_code
54434 , line_number
54435 , source_application_id
54436 , source_type_code
54437 , source_code
54438 , SUBSTR(source_value ,1,1996)
54439 , SUBSTR(source_meaning ,1,200)
54440 , xla_environment_pkg.g_Usr_Id
54441 , TRUNC(SYSDATE)
54442 , TRUNC(SYSDATE)
54443 , xla_environment_pkg.g_Usr_Id
54444 , xla_environment_pkg.g_Login_Id
54445 , TRUNC(SYSDATE)
54446 , xla_environment_pkg.g_Prog_Appl_Id
54447 , xla_environment_pkg.g_Prog_Id
54448 , xla_environment_pkg.g_Req_Id
54449 FROM (
54450 SELECT xet.event_id event_id
54451 , 0 line_number
54452 , CASE r
54453 WHEN 1 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
54454 WHEN 2 THEN 'AR_BILL_TO_SITE_USES_S_V'
54455 WHEN 3 THEN 'AR_TRANSACTIONS_S_V'
54456 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
54457 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
54458 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
54459 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
54460
54461 ELSE null
54462 END object_name
54463 , CASE r
54464 WHEN 1 THEN 'HEADER'
54465 WHEN 2 THEN 'HEADER'
54466 WHEN 3 THEN 'HEADER'
54467 WHEN 4 THEN 'HEADER'
54468 WHEN 5 THEN 'HEADER'
54469 WHEN 6 THEN 'HEADER'
54470 WHEN 7 THEN 'HEADER'
54471
54472 ELSE null
54473 END object_type_code
54474 , CASE r
54475 WHEN 1 THEN '222'
54476 WHEN 2 THEN '222'
54477 WHEN 3 THEN '222'
54478 WHEN 4 THEN '222'
54479 WHEN 5 THEN '222'
54480 WHEN 6 THEN '222'
54481 WHEN 7 THEN '222'
54482
54483 ELSE null
54484 END source_application_id
54485 , 'S' source_type_code
54486 , CASE r
54487 WHEN 1 THEN 'BILL_CUST_ACCOUNT_ID'
54488 WHEN 2 THEN 'BILL_USES_SITE_USE_ID'
54489 WHEN 3 THEN 'XLA_PARTY_TYPE'
54490 WHEN 4 THEN 'TRX_INVOICE_CURRENCY_CODE'
54491 WHEN 5 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
54492 WHEN 6 THEN 'TRX_DOC_SEQUENCE_ID'
54493 WHEN 7 THEN 'TRX_DOC_SEQUENCE_VALUE'
54494
54495 ELSE null
54496 END source_code
54497 , CASE r
54498 WHEN 1 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
54499 WHEN 2 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
54500 WHEN 3 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
54501 WHEN 4 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
54502 WHEN 5 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
54503 WHEN 6 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
54504 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
54505
54506 ELSE null
54507 END source_value
54508 , null source_meaning
54509 FROM xla_events_gt xet
54510 , AR_BILL_TO_CUSTOMERS_S_V h1
54511 , AR_BILL_TO_SITE_USES_S_V h2
54512 , AR_TRANSACTIONS_S_V h5
54513 ,(select rownum r from all_objects where rownum <= 7 and owner = p_apps_owner)
54514 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
54515 AND xet.event_class_code = C_EVENT_CLASS_CODE
54516 AND h1.event_id = xet.event_id
54517 AND h2.event_id = h1.event_id
54518 AND h5.event_id = h1.event_id
54519
54520 )
54521 ;
54522 --
54523 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
54524
54525 trace
54526 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
54527 ,p_level => C_LEVEL_STATEMENT
54528 ,p_module => l_log_module);
54529
54530 END IF;
54531 --
54532
54533
54534
54535 --
54536 INSERT INTO xla_diag_sources --line2
54537 (
54538 event_id
54539 , ledger_id
54540 , sla_ledger_id
54541 , description_language
54542 , object_name
54543 , object_type_code
54544 , line_number
54545 , source_application_id
54546 , source_type_code
54547 , source_code
54548 , source_value
54549 , source_meaning
54550 , created_by
54551 , creation_date
54552 , last_update_date
54553 , last_updated_by
54554 , last_update_login
54555 , program_update_date
54556 , program_application_id
54557 , program_id
54558 , request_id
54559 )
54560 SELECT event_id
54561 , p_target_ledger_id
54562 , p_sla_ledger_id
54563 , p_language
54564 , object_name
54565 , object_type_code
54566 , line_number
54567 , source_application_id
54568 , source_type_code
54569 , source_code
54570 , SUBSTR(source_value,1,1996)
54571 , SUBSTR(source_meaning ,1,200)
54572 , xla_environment_pkg.g_Usr_Id
54573 , TRUNC(SYSDATE)
54574 , TRUNC(SYSDATE)
54575 , xla_environment_pkg.g_Usr_Id
54576 , xla_environment_pkg.g_Login_Id
54577 , TRUNC(SYSDATE)
54578 , xla_environment_pkg.g_Prog_Appl_Id
54579 , xla_environment_pkg.g_Prog_Id
54580 , xla_environment_pkg.g_Req_Id
54581 FROM (
54582 SELECT xet.event_id event_id
54583 , l4.line_number line_number
54584 , CASE r
54585 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
54586 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
54587 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
54588 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
54589 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
54590 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
54591 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
54592 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
54593 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
54594
54595 ELSE null
54596 END object_name
54597 , CASE r
54598 WHEN 1 THEN 'LINE'
54599 WHEN 2 THEN 'LINE'
54600 WHEN 3 THEN 'LINE'
54601 WHEN 4 THEN 'LINE'
54602 WHEN 5 THEN 'LINE'
54603 WHEN 6 THEN 'LINE'
54604 WHEN 7 THEN 'LINE'
54605 WHEN 8 THEN 'LINE'
54606 WHEN 9 THEN 'LINE'
54607
54608 ELSE null
54609 END object_type_code
54610 , CASE r
54611 WHEN 1 THEN '222'
54612 WHEN 2 THEN '222'
54613 WHEN 3 THEN '222'
54614 WHEN 4 THEN '222'
54615 WHEN 5 THEN '222'
54616 WHEN 6 THEN '222'
54617 WHEN 7 THEN '222'
54618 WHEN 8 THEN '222'
54619 WHEN 9 THEN '222'
54620
54621 ELSE null
54622 END source_application_id
54623 , 'S' source_type_code
54624 , CASE r
54625 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
54626 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
54627 WHEN 3 THEN 'TRX_LINE_DIST_ID'
54628 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
54629 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
54630 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
54631 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
54632 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
54633 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
54634
54635 ELSE null
54636 END source_code
54637 , CASE r
54638 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
54639 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
54640 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
54641 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
54642 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
54643 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
54644 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
54645 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
54646 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
54647
54648 ELSE null
54649 END source_value
54650 , null source_meaning
54651 FROM xla_events_gt xet
54652 , AR_CUST_TRX_LINES_BASE_V l3
54653 , AR_CUST_TRX_LINES_L_V l4
54654 , (select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
54655 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
54656 AND xet.event_class_code = C_EVENT_CLASS_CODE
54657 AND l3.event_id = xet.event_id
54658 AND l4.event_id = l3.event_id
54659 AND l4.line_number = l3.line_number
54660
54661 )
54662 ;
54663 --
54664 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
54665
54666 trace
54667 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
54668 ,p_level => C_LEVEL_STATEMENT
54669 ,p_module => l_log_module);
54670
54671 END IF;
54672
54673
54674 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54675 trace
54676 (p_msg => 'END of insert_sources_105'
54677 ,p_level => C_LEVEL_PROCEDURE
54678 ,p_module => l_log_module);
54679 END IF;
54680 EXCEPTION
54681 WHEN xla_exceptions_pkg.application_exception THEN
54682 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
54683 trace
54684 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
54685 ,p_level => C_LEVEL_EXCEPTION
54686 ,p_module => l_log_module);
54687 END IF;
54688 RAISE;
54689 WHEN OTHERS THEN
54690 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
54691 trace
54692 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
54693 ,p_level => C_LEVEL_EXCEPTION
54694 ,p_module => l_log_module);
54695 END IF;
54696 xla_exceptions_pkg.raise_message
54697 (p_location => 'XLA_00222_AAD_S_000007_PKG.insert_sources_105');
54698 END insert_sources_105;
54699 --
54700
54701 ---------------------------------------
54702 --
54703 -- PRIVATE FUNCTION
54704 -- EventClass_105
54705 --
54706 ----------------------------------------
54707 --
54708 FUNCTION EventClass_105
54709 (p_application_id IN NUMBER
54710 ,p_base_ledger_id IN NUMBER
54711 ,p_target_ledger_id IN NUMBER
54712 ,p_language IN VARCHAR2
54713 ,p_currency_code IN VARCHAR2
54714 ,p_sla_ledger_id IN NUMBER
54715 ,p_pad_start_date IN DATE
54716 ,p_pad_end_date IN DATE
54717 ,p_primary_ledger_id IN NUMBER)
54718 RETURN BOOLEAN IS
54719 --
54720 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK_ALL';
54721 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK';
54722
54723 l_calculate_acctd_flag VARCHAR2(1) :='N';
54724 l_calculate_g_l_flag VARCHAR2(1) :='N';
54725 --
54726 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
54727 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
54728 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
54729 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
54730 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
54731 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
54732 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
54733 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
54734 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
54735 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
54736 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
54737 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
54738 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
54739 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
54740 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
54741 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
54742 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
54743 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
54744 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
54745 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
54746 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
54747 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
54748 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
54749 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
54750 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
54751 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
54752
54753 l_event_id NUMBER;
54754 l_previous_event_id NUMBER;
54755 l_first_event_id NUMBER;
54756 l_last_event_id NUMBER;
54757
54758 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
54759 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
54760 --
54761 --
54762 l_result BOOLEAN := TRUE;
54763 l_rows NUMBER := 1000;
54764 l_event_type_name VARCHAR2(80) := 'All';
54765 l_event_class_name VARCHAR2(80) := 'Chargeback';
54766 l_description VARCHAR2(4000);
54767 l_transaction_reversal NUMBER;
54768 l_ae_header_id NUMBER;
54769 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
54770 l_log_module VARCHAR2(240);
54771 --
54772 l_acct_reversal_source VARCHAR2(30);
54773 l_trx_reversal_source VARCHAR2(30);
54774
54775 l_continue_with_lines BOOLEAN := TRUE;
54776 --
54777 l_acc_rev_gl_date_source DATE; -- 4262811
54778 --
54779 type t_array_event_id is table of number index by binary_integer;
54780
54781 l_rec_array_event t_rec_array_event;
54782 l_null_rec_array_event t_rec_array_event;
54783 l_array_ae_header_id xla_number_array_type;
54784 l_actual_flag VARCHAR2(1) := NULL;
54785 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
54786 l_balance_type_code VARCHAR2(1) :=NULL;
54787 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
54788
54789 --
54790 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
54791 --
54792
54793 TYPE t_array_source_25 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
54794 TYPE t_array_source_26 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
54795 TYPE t_array_source_27 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
54796 TYPE t_array_source_32 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
54797 TYPE t_array_source_77 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
54798 TYPE t_array_source_78 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
54799 TYPE t_array_source_79 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
54800
54801 TYPE t_array_source_14 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
54802 TYPE t_array_source_28 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
54803 TYPE t_array_source_29 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
54804 TYPE t_array_source_30 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
54805 TYPE t_array_source_31 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
54806 TYPE t_array_source_33 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
54807 TYPE t_array_source_34 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
54808 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
54809 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
54810
54811 l_array_source_25 t_array_source_25;
54812 l_array_source_26 t_array_source_26;
54813 l_array_source_27 t_array_source_27;
54814 l_array_source_32 t_array_source_32;
54815 l_array_source_77 t_array_source_77;
54816 l_array_source_78 t_array_source_78;
54817 l_array_source_79 t_array_source_79;
54818
54819 l_array_source_14 t_array_source_14;
54820 l_array_source_28 t_array_source_28;
54821 l_array_source_29 t_array_source_29;
54822 l_array_source_30 t_array_source_30;
54823 l_array_source_31 t_array_source_31;
54824 l_array_source_33 t_array_source_33;
54825 l_array_source_34 t_array_source_34;
54826 l_array_source_35 t_array_source_35;
54827 l_array_source_36 t_array_source_36;
54828
54829 --
54830 CURSOR header_cur
54831 IS
54832 SELECT /*+ leading(xet) cardinality(xet,1) */
54833 -- Event Class Code: CHARGEBACK
54834 xet.entity_id
54835 ,xet.legal_entity_id
54836 ,xet.entity_code
54837 ,xet.transaction_number
54838 ,xet.event_id
54839 ,xet.event_class_code
54840 ,xet.event_type_code
54841 ,xet.event_number
54842 ,xet.event_date
54843 ,xet.transaction_date
54844 ,xet.reference_num_1
54845 ,xet.reference_num_2
54846 ,xet.reference_num_3
54847 ,xet.reference_num_4
54848 ,xet.reference_char_1
54849 ,xet.reference_char_2
54850 ,xet.reference_char_3
54851 ,xet.reference_char_4
54852 ,xet.reference_date_1
54853 ,xet.reference_date_2
54854 ,xet.reference_date_3
54855 ,xet.reference_date_4
54856 ,xet.event_created_by
54857 ,xet.budgetary_control_flag
54858 , h1.BILL_CUST_ACCOUNT_ID source_25
54859 , h2.BILL_USES_SITE_USE_ID source_26
54860 , h5.XLA_PARTY_TYPE source_27
54861 , h5.TRX_INVOICE_CURRENCY_CODE source_32
54862 , h5.TRX_DOC_SEQUENCE_CATEGORY source_77
54863 , h5.TRX_DOC_SEQUENCE_ID source_78
54864 , h5.TRX_DOC_SEQUENCE_VALUE source_79
54865 FROM xla_events_gt xet
54866 , AR_BILL_TO_CUSTOMERS_S_V h1
54867 , AR_BILL_TO_SITE_USES_S_V h2
54868 , AR_TRANSACTIONS_S_V h5
54869 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
54870 and xet.event_class_code = C_EVENT_CLASS_CODE
54871 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
54872 AND h2.event_id = h1.event_id
54873 AND h5.event_id = h1.event_id
54874
54875 ORDER BY event_id
54876 ;
54877
54878
54879 --
54880 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
54881 IS
54882 SELECT /*+ leading(xet) cardinality(xet,1) */
54883 -- Event Class Code: CHARGEBACK
54884 xet.entity_id
54885 ,xet.legal_entity_id
54886 ,xet.entity_code
54887 ,xet.transaction_number
54888 ,xet.event_id
54889 ,xet.event_class_code
54890 ,xet.event_type_code
54891 ,xet.event_number
54892 ,xet.event_date
54893 ,xet.transaction_date
54894 ,xet.reference_num_1
54895 ,xet.reference_num_2
54896 ,xet.reference_num_3
54897 ,xet.reference_num_4
54898 ,xet.reference_char_1
54899 ,xet.reference_char_2
54900 ,xet.reference_char_3
54901 ,xet.reference_char_4
54902 ,xet.reference_date_1
54903 ,xet.reference_date_2
54907 ,xet.budgetary_control_flag
54904 ,xet.reference_date_3
54905 ,xet.reference_date_4
54906 ,xet.event_created_by
54908 , l3.LINE_NUMBER
54909 , l4.TRX_LINE_DIST_CCID source_14
54910 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_28
54911 , l4.TRX_LINE_DIST_ID source_29
54912 , l4.TRX_DISTRIBUTION_TYPE source_30
54913 , l4.TRX_LINE_DIST_AMT source_31
54914 , l3.TRX_LINE_CUR_CONVERSION_DATE source_33
54915 , l3.TRX_LINE_CUR_CONVERSION_RATE source_34
54916 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_35
54917 , l3.TRX_LINE_ACCTD_AMT source_36
54918 FROM xla_events_gt xet
54919 , AR_CUST_TRX_LINES_BASE_V l3
54920 , AR_CUST_TRX_LINES_L_V l4
54921 WHERE xet.event_id between x_first_event_id and x_last_event_id
54922 and xet.event_date between p_pad_start_date and p_pad_end_date
54923 and xet.event_class_code = C_EVENT_CLASS_CODE
54924 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
54925 AND l4.event_id = l3.event_id
54926 AND l4.line_number = l3.line_number
54927 ;
54928
54929 --
54930 BEGIN
54931 IF g_log_enabled THEN
54932 l_log_module := C_DEFAULT_MODULE||'.EventClass_105';
54933 END IF;
54934 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54935 trace
54936 (p_msg => 'BEGIN of EventClass_105'
54937 ,p_level => C_LEVEL_PROCEDURE
54938 ,p_module => l_log_module);
54939 END IF;
54940
54941 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
54942 trace
54943 (p_msg => 'p_application_id = '||p_application_id||
54944 ' - p_base_ledger_id = '||p_base_ledger_id||
54945 ' - p_target_ledger_id = '||p_target_ledger_id||
54946 ' - p_language = '||p_language||
54947 ' - p_currency_code = '||p_currency_code||
54948 ' - p_sla_ledger_id = '||p_sla_ledger_id
54949 ,p_level => C_LEVEL_STATEMENT
54950 ,p_module => l_log_module);
54951 END IF;
54952 --
54953 -- initialze arrays
54954 --
54955 g_array_event.DELETE;
54956 l_rec_array_event := l_null_rec_array_event;
54957 --
54958 --------------------------------------
54959 -- 4262811 Initialze MPA Line Number
54960 --------------------------------------
54961 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
54962
54963 --
54964
54965 --
54966 OPEN header_cur;
54967 --
54968 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
54969 trace
54970 (p_msg => 'SQL - FETCH header_cur'
54971 ,p_level => C_LEVEL_STATEMENT
54972 ,p_module => l_log_module);
54973 END IF;
54974 --
54975 LOOP
54976 FETCH header_cur BULK COLLECT INTO
54977 l_array_entity_id
54978 , l_array_legal_entity_id
54979 , l_array_entity_code
54980 , l_array_transaction_num
54981 , l_array_event_id
54982 , l_array_class_code
54983 , l_array_event_type
54984 , l_array_event_number
54985 , l_array_event_date
54986 , l_array_transaction_date
54987 , l_array_reference_num_1
54988 , l_array_reference_num_2
54989 , l_array_reference_num_3
54990 , l_array_reference_num_4
54991 , l_array_reference_char_1
54992 , l_array_reference_char_2
54993 , l_array_reference_char_3
54994 , l_array_reference_char_4
54995 , l_array_reference_date_1
54996 , l_array_reference_date_2
54997 , l_array_reference_date_3
54998 , l_array_reference_date_4
54999 , l_array_event_created_by
55000 , l_array_budgetary_control_flag
55001 , l_array_source_25
55002 , l_array_source_26
55003 , l_array_source_27
55004 , l_array_source_32
55005 , l_array_source_77
55006 , l_array_source_78
55007 , l_array_source_79
55008 LIMIT l_rows;
55009 --
55010 IF (C_LEVEL_EVENT >= g_log_level) THEN
55011 trace
55012 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
55013 ,p_level => C_LEVEL_EVENT
55014 ,p_module => l_log_module);
55015 END IF;
55016 --
55017 EXIT WHEN l_array_entity_id.COUNT = 0;
55018
55019 -- initialize arrays
55020 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
55021 XLA_AE_LINES_PKG.g_rec_lines := NULL;
55022
55023 --
55024 -- Bug 4458708
55025 --
55026 XLA_AE_LINES_PKG.g_LineNumber := 0;
55027
55028
55029 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
55030 g_last_hdr_idx := l_array_event_id.LAST;
55031 --
55032 -- loop for the headers. Each iteration is for each header extract row
55033 -- fetched in header cursor
55034 --
55035 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
55036
55037 --
55038 -- set event info as cache for other routines to refer event attributes
55039 --
55040 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
55041 (p_application_id => p_application_id
55042 ,p_primary_ledger_id => p_primary_ledger_id
55043 ,p_base_ledger_id => p_base_ledger_id
55044 ,p_target_ledger_id => p_target_ledger_id
55045 ,p_entity_id => l_array_entity_id(hdr_idx)
55046 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
55047 ,p_entity_code => l_array_entity_code(hdr_idx)
55048 ,p_transaction_num => l_array_transaction_num(hdr_idx)
55049 ,p_event_id => l_array_event_id(hdr_idx)
55050 ,p_event_class_code => l_array_class_code(hdr_idx)
55051 ,p_event_type_code => l_array_event_type(hdr_idx)
55052 ,p_event_number => l_array_event_number(hdr_idx)
55053 ,p_event_date => l_array_event_date(hdr_idx)
55054 ,p_transaction_date => l_array_transaction_date(hdr_idx)
55055 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
55056 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
55057 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
55058 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
55059 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
55060 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
55061 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
55062 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
55063 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
55064 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
55065 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
55066 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
55067 ,p_event_created_by => l_array_event_created_by(hdr_idx)
55068 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
55069
55070 --
55071 -- set the status of entry to C_VALID (0)
55072 --
55073 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
55074
55075 --
55076 -- initialize a row for ae header
55077 --
55078 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
55079
55080 l_event_id := l_array_event_id(hdr_idx);
55081
55082 --
55083 -- storing the hdr_idx for event. May be used by line cursor.
55084 --
55085 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
55086
55087 --
55088 -- store sources from header extract. This can be improved to
55089 -- store only those sources from header extract that may be used in lines
55090 --
55091
55092 g_array_event(l_event_id).array_value_num('source_25') := l_array_source_25(hdr_idx);
55093 g_array_event(l_event_id).array_value_num('source_26') := l_array_source_26(hdr_idx);
55094 g_array_event(l_event_id).array_value_char('source_27') := l_array_source_27(hdr_idx);
55095 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
55096 g_array_event(l_event_id).array_value_char('source_77') := l_array_source_77(hdr_idx);
55097 g_array_event(l_event_id).array_value_num('source_78') := l_array_source_78(hdr_idx);
55098 g_array_event(l_event_id).array_value_num('source_79') := l_array_source_79(hdr_idx);
55099
55100 --
55101 -- initilaize the status of ae headers for diffrent balance types
55102 -- the status is initialised to C_NOT_CREATED (2)
55103 --
55104 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
55105 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
55106 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
55107
55108 --
55109 -- call api to validate and store accounting attributes for header
55110 --
55111
55112 ------------------------------------------------------------
55113 -- Accrual Reversal : to get date for Standard Source (NONE)
55114 ------------------------------------------------------------
55115 l_acc_rev_gl_date_source := NULL;
55116
55117 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
55118 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_77');
55119 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
55120 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_78');
55121 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
55122 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_79');
55123 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
55124 l_rec_acct_attrs.array_date_value(4) :=
55125 xla_ae_sources_pkg.GetSystemSourceDate(
55126 p_source_code => 'XLA_EVENT_DATE'
55127 , p_source_type_code => 'Y'
55128 , p_source_application_id => 602
55129 );
55130
55131
55132 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
55133
55134 XLA_AE_HEADER_PKG.SetJeCategoryName;
55135
55136 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
55137 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
55138 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
55139 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
55140 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
55141
55142
55143 -- No header level analytical criteria
55144
55145 --
55146 --accounting attribute enhancement, bug 3612931
55147 --
55148 l_trx_reversal_source := SUBSTR(NULL, 1,30);
55149
55150 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
55151 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
55152
55153 xla_accounting_err_pkg.build_message
55154 (p_appli_s_name => 'XLA'
55155 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
55156 ,p_token_1 => 'ACCT_ATTR_NAME'
55157 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
55158 ,p_token_2 => 'PRODUCT_NAME'
55159 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
55160 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
55161 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
55162 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
55163
55164 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
55165 --
55166 -- following sets the accounting attributes needed to reverse
55167 -- accounting for a distributeion
55168 --
55169 xla_ae_lines_pkg.SetTrxReversalAttrs
55170 (p_event_id => l_event_id
55171 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
55172 ,p_trx_reversal_source => l_trx_reversal_source);
55173
55174 END IF;
55175
55176
55177 ----------------------------------------------------------------
55178 -- 4262811 - update the header statuses to invalid in need be
55179 ----------------------------------------------------------------
55180 --
55181 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
55182
55183
55184 -----------------------------------------------
55185 -- No accrual reversal for the event class/type
55186 -----------------------------------------------
55187 ----------------------------------------------------------------
55188
55189 --
55190 -- this ends the header loop iteration for one bulk fetch
55191 --
55192 END LOOP;
55193
55194 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
55195 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
55196
55197 --
55198 -- insert dummy rows into lines gt table that were created due to
55199 -- transaction reversals
55200 --
55201 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
55202 l_result := XLA_AE_LINES_PKG.InsertLines;
55203 END IF;
55204
55205 --
55206 -- reset the temp_line_num for each set of events fetched from header
55207 -- cursor rather than doing it for each new event in line cursor
55208 -- Bug 3939231
55209 --
55210 xla_ae_lines_pkg.g_temp_line_num := 0;
55211
55212
55213
55214 --
55215 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
55216 --
55217 --
55218 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
55219
55220 trace
55221 (p_msg => 'SQL - FETCH line_cur'
55222 ,p_level => C_LEVEL_STATEMENT
55223 ,p_module => l_log_module);
55224
55225 END IF;
55226 --
55227 --
55228 LOOP
55229 --
55230 FETCH line_cur BULK COLLECT INTO
55231 l_array_entity_id
55232 , l_array_legal_entity_id
55233 , l_array_entity_code
55234 , l_array_transaction_num
55235 , l_array_event_id
55236 , l_array_class_code
55237 , l_array_event_type
55238 , l_array_event_number
55239 , l_array_event_date
55240 , l_array_transaction_date
55241 , l_array_reference_num_1
55242 , l_array_reference_num_2
55243 , l_array_reference_num_3
55244 , l_array_reference_num_4
55245 , l_array_reference_char_1
55246 , l_array_reference_char_2
55247 , l_array_reference_char_3
55248 , l_array_reference_char_4
55249 , l_array_reference_date_1
55250 , l_array_reference_date_2
55251 , l_array_reference_date_3
55252 , l_array_reference_date_4
55253 , l_array_event_created_by
55254 , l_array_budgetary_control_flag
55255 , l_array_extract_line_num
55256 , l_array_source_14
55257 , l_array_source_28
55258 , l_array_source_29
55259 , l_array_source_30
55260 , l_array_source_31
55261 , l_array_source_33
55262 , l_array_source_34
55263 , l_array_source_35
55264 , l_array_source_36
55265 LIMIT l_rows;
55266
55267 --
55268 IF (C_LEVEL_EVENT >= g_log_level) THEN
55269 trace
55270 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
55271 ,p_level => C_LEVEL_EVENT
55272 ,p_module => l_log_module);
55273 END IF;
55274 --
55275 EXIT WHEN l_array_entity_id.count = 0;
55276
55277 XLA_AE_LINES_PKG.g_rec_lines := null;
55278
55279 --
55280 -- Bug 4458708
55281 --
55282 XLA_AE_LINES_PKG.g_LineNumber := 0;
55283 --
55284 --
55285
55286 FOR Idx IN 1..l_array_event_id.count LOOP
55287 --
55288 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
55289 --
55290 l_event_id := l_array_event_id(idx); -- 5648433
55291
55292 --
55293 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
55294 --
55295
55296 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
55297 (g_array_event(l_event_id).array_value_num('header_index'))
55298 ,'N'
55299 ) <> 'Y'
55300 THEN
55301 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
55302 trace
55303 (p_msg => 'Trancaction revesal option is not Y '
55304 ,p_level => C_LEVEL_STATEMENT
55305 ,p_module => l_log_module);
55306 END IF;
55307
55308 --
55309 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
55310 --
55311 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
55312 --
55313 -- set event info as cache for other routines to refer event attributes
55314 --
55315
55316 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
55317 l_previous_event_id := l_event_id;
55318
55319 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
55320 (p_application_id => p_application_id
55321 ,p_primary_ledger_id => p_primary_ledger_id
55322 ,p_base_ledger_id => p_base_ledger_id
55323 ,p_target_ledger_id => p_target_ledger_id
55324 ,p_entity_id => l_array_entity_id(Idx)
55325 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
55326 ,p_entity_code => l_array_entity_code(Idx)
55327 ,p_transaction_num => l_array_transaction_num(Idx)
55328 ,p_event_id => l_array_event_id(Idx)
55329 ,p_event_class_code => l_array_class_code(Idx)
55330 ,p_event_type_code => l_array_event_type(Idx)
55331 ,p_event_number => l_array_event_number(Idx)
55332 ,p_event_date => l_array_event_date(Idx)
55333 ,p_transaction_date => l_array_transaction_date(Idx)
55334 ,p_reference_num_1 => l_array_reference_num_1(Idx)
55335 ,p_reference_num_2 => l_array_reference_num_2(Idx)
55336 ,p_reference_num_3 => l_array_reference_num_3(Idx)
55337 ,p_reference_num_4 => l_array_reference_num_4(Idx)
55338 ,p_reference_char_1 => l_array_reference_char_1(Idx)
55339 ,p_reference_char_2 => l_array_reference_char_2(Idx)
55340 ,p_reference_char_3 => l_array_reference_char_3(Idx)
55341 ,p_reference_char_4 => l_array_reference_char_4(Idx)
55342 ,p_reference_date_1 => l_array_reference_date_1(Idx)
55343 ,p_reference_date_2 => l_array_reference_date_2(Idx)
55344 ,p_reference_date_3 => l_array_reference_date_3(Idx)
55345 ,p_reference_date_4 => l_array_reference_date_4(Idx)
55346 ,p_event_created_by => l_array_event_created_by(Idx)
55347 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
55348 --
55349 END IF;
55350
55351
55352
55353 --
55354 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
55355
55356 l_acct_reversal_source := SUBSTR(NULL, 1,30);
55357
55358 IF l_continue_with_lines THEN
55359 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
55360 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
55361
55362 xla_accounting_err_pkg.build_message
55363 (p_appli_s_name => 'XLA'
55364 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
55365 ,p_token_1 => 'LINE_NUMBER'
55366 ,p_value_1 => l_array_extract_line_num(Idx)
55367 ,p_token_2 => 'PRODUCT_NAME'
55368 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
55369 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
55370 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
55371 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
55372
55376 -- accounting for a distributeion
55373 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
55374 --
55375 -- following sets the accounting attributes needed to reverse
55377 --
55378
55379 --
55380 -- 5217187
55381 --
55382 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
55383 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
55384 g_array_event(l_event_id).array_value_num('header_index'));
55385 --
55386 --
55387
55388 -- No reversal code generated
55389
55390 xla_ae_lines_pkg.SetAcctReversalAttrs
55391 (p_event_id => l_event_id
55392 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
55393 ,p_calculate_acctd_flag => l_calculate_acctd_flag
55394 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
55395 END IF;
55396
55397 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
55398 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
55399
55400 --
55401 AcctLineType_23 (
55402 p_application_id => p_application_id
55403 ,p_event_id => l_event_id
55404 ,p_calculate_acctd_flag => l_calculate_acctd_flag
55405 ,p_calculate_g_l_flag => l_calculate_g_l_flag
55406 ,p_actual_flag => l_actual_flag
55407 ,p_balance_type_code => l_balance_type_code
55408 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
55409
55410 , p_source_14 => l_array_source_14(Idx)
55411 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
55412 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
55413 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
55414 , p_source_28 => l_array_source_28(Idx)
55415 , p_source_29 => l_array_source_29(Idx)
55416 , p_source_30 => l_array_source_30(Idx)
55417 , p_source_31 => l_array_source_31(Idx)
55418 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
55419 , p_source_33 => l_array_source_33(Idx)
55420 , p_source_34 => l_array_source_34(Idx)
55421 , p_source_35 => l_array_source_35(Idx)
55422 , p_source_36 => l_array_source_36(Idx)
55423 );
55424 If(l_balance_type_code = 'A') THEN
55425 l_actual_gain_loss_ref := l_gain_or_loss_ref;
55426 END IF;
55427
55428 --
55429
55430
55431 --
55432 AcctLineType_24 (
55433 p_application_id => p_application_id
55434 ,p_event_id => l_event_id
55435 ,p_calculate_acctd_flag => l_calculate_acctd_flag
55436 ,p_calculate_g_l_flag => l_calculate_g_l_flag
55437 ,p_actual_flag => l_actual_flag
55438 ,p_balance_type_code => l_balance_type_code
55439 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
55440
55441 , p_source_14 => l_array_source_14(Idx)
55442 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
55443 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
55444 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
55445 , p_source_28 => l_array_source_28(Idx)
55446 , p_source_29 => l_array_source_29(Idx)
55447 , p_source_30 => l_array_source_30(Idx)
55448 , p_source_31 => l_array_source_31(Idx)
55449 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
55450 , p_source_33 => l_array_source_33(Idx)
55451 , p_source_34 => l_array_source_34(Idx)
55452 , p_source_35 => l_array_source_35(Idx)
55453 , p_source_36 => l_array_source_36(Idx)
55454 );
55455 If(l_balance_type_code = 'A') THEN
55456 l_actual_gain_loss_ref := l_gain_or_loss_ref;
55457 END IF;
55458
55459 --
55460
55461 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
55462 -- or secondary ledger that has different currency with primary
55463 -- or alc that is calculated by sla
55464 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
55465 (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'))
55466
55467 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
55468 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
55469 AND (l_actual_flag = 'A')) THEN
55470 XLA_AE_LINES_PKG.CreateGainOrLossLines(
55471 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
55472 ,p_application_id => p_application_id
55473 ,p_amb_context_code => 'DEFAULT'
55474 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
55475 ,p_event_class_code => C_EVENT_CLASS_CODE
55476 ,p_event_type_code => C_EVENT_TYPE_CODE
55477
55478 ,p_gain_ccid => -1
55479 ,p_loss_ccid => -1
55480
55481 ,p_actual_flag => l_actual_flag
55482 ,p_enc_flag => null
55483 ,p_actual_g_l_ref => l_actual_gain_loss_ref
55484 ,p_enc_g_l_ref => null
55485 );
55486 END IF;
55487 END IF;
55488 END IF;
55489
55490 ELSE
55491 --
55492 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
55493 --
55494 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
55495 trace
55496 (p_msg => 'Trancaction revesal option is Y'
55497 ,p_level => C_LEVEL_STATEMENT
55498 ,p_module => l_log_module);
55499 END IF;
55500 END IF;
55501
55502 END LOOP;
55503 l_result := XLA_AE_LINES_PKG.InsertLines ;
55504 end loop;
55505 close line_cur;
55506
55507
55508 --
55509 -- insert headers into xla_ae_headers_gt table
55510 --
55511 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
55512
55513 -- insert into errors table here.
55514
55515 END LOOP;
55516
55517 --
55518 -- 4865292
55519 --
55520 -- Compare g_hdr_extract_count with event count in
55521 -- CreateHeadersAndLines.
55522 --
55523 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
55524
55525 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
55526 trace (p_msg => '# rows extracted from header extract objects '
55527 || ' (running total): '
55528 || g_hdr_extract_count
55529 ,p_level => C_LEVEL_STATEMENT
55530 ,p_module => l_log_module);
55531 END IF;
55532
55533 CLOSE header_cur;
55534 --
55535
55536 --
55537 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55538 trace
55539 (p_msg => 'END of EventClass_105'
55540 ,p_level => C_LEVEL_PROCEDURE
55541 ,p_module => l_log_module);
55542 END IF;
55543 --
55544 RETURN l_result;
55545 EXCEPTION
55546 WHEN xla_exceptions_pkg.application_exception THEN
55547
55548 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
55549
55550
55551 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
55552
55553 RAISE;
55554
55555 WHEN NO_DATA_FOUND THEN
55556
55557 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
55558 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
55559
55560 FOR header_record IN header_cur
55561 LOOP
55562 l_array_header_events(header_record.event_id) := header_record.event_id;
55563 END LOOP;
55564
55565 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
55566 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
55567
55568 fnd_file.put_line(fnd_file.LOG, ' ');
55569 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
55570 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
55571 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
55572
55573 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
55574 LOOP
55575 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
55576 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
55577 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
55578 END IF;
55579 END LOOP;
55580
55581 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
55582 fnd_file.put_line(fnd_file.LOG, ' ');
55583
55584
55585 xla_exceptions_pkg.raise_message
55586 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_105');
55587
55588
55589 WHEN OTHERS THEN
55590 xla_exceptions_pkg.raise_message
55591 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_105');
55592 END EventClass_105;
55593 --
55594
55595 ---------------------------------------
55596 --
55597 -- PRIVATE PROCEDURE
55598 -- insert_sources_106
55599 --
55600 ----------------------------------------
55601 --
55602 PROCEDURE insert_sources_106(
55603 p_target_ledger_id IN NUMBER
55604 , p_language IN VARCHAR2
55605 , p_sla_ledger_id IN NUMBER
55606 , p_pad_start_date IN DATE
55607 , p_pad_end_date IN DATE
55608 )
55609 IS
55610
55611 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO_ALL';
55612 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO';
55613 p_apps_owner VARCHAR2(30);
55614 l_log_module VARCHAR2(240);
55615 BEGIN
55616 IF g_log_enabled THEN
55617 l_log_module := C_DEFAULT_MODULE||'.insert_sources_106';
55618 END IF;
55619 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55620
55621 trace
55622 (p_msg => 'BEGIN of insert_sources_106'
55623 ,p_level => C_LEVEL_PROCEDURE
55624 ,p_module => l_log_module);
55625
55626 END IF;
55627
55628 -- select APPS owner
55629 SELECT oracle_username
55630 INTO p_apps_owner
55631 FROM fnd_oracle_userid
55632 WHERE read_only_flag = 'U'
55633 ;
55634
55635 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
55636 trace
55637 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
55638 ' - p_language = '||p_language||
55639 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
55640 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
55641 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
55642 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
55643 ,p_level => C_LEVEL_STATEMENT
55644 ,p_module => l_log_module);
55645 END IF;
55646
55647
55648 --
55649 INSERT INTO xla_diag_sources --hdr2
55650 (
55651 event_id
55652 , ledger_id
55653 , sla_ledger_id
55654 , description_language
55655 , object_name
55656 , object_type_code
55657 , line_number
55658 , source_application_id
55659 , source_type_code
55660 , source_code
55661 , source_value
55662 , source_meaning
55663 , created_by
55664 , creation_date
55665 , last_update_date
55666 , last_updated_by
55667 , last_update_login
55668 , program_update_date
55669 , program_application_id
55670 , program_id
55671 , request_id
55672 )
55673 SELECT
55674 event_id
55675 , p_target_ledger_id
55676 , p_sla_ledger_id
55677 , p_language
55678 , object_name
55679 , object_type_code
55680 , line_number
55681 , source_application_id
55682 , source_type_code
55683 , source_code
55684 , SUBSTR(source_value ,1,1996)
55685 , SUBSTR(source_meaning ,1,200)
55686 , xla_environment_pkg.g_Usr_Id
55687 , TRUNC(SYSDATE)
55688 , TRUNC(SYSDATE)
55689 , xla_environment_pkg.g_Usr_Id
55690 , xla_environment_pkg.g_Login_Id
55691 , TRUNC(SYSDATE)
55692 , xla_environment_pkg.g_Prog_Appl_Id
55693 , xla_environment_pkg.g_Prog_Id
55694 , xla_environment_pkg.g_Req_Id
55695 FROM (
55696 SELECT xet.event_id event_id
55697 , 0 line_number
55698 , CASE r
55699 WHEN 1 THEN 'AR_CREDIT_MEMO_H_V'
55700 WHEN 2 THEN 'AR_SYSTEM_PARAM_H_V'
55701 WHEN 3 THEN 'AR_SYSTEM_PARAM_H_V'
55702 WHEN 4 THEN 'AR_CREDIT_MEMO_H_V'
55703 WHEN 5 THEN 'AR_CREDIT_MEMO_H_V'
55704 WHEN 6 THEN 'AR_CM_BILL_TO_CUST_H_V'
55705 WHEN 7 THEN 'AR_CM_BILL_SITE_USES_H_V'
55706 WHEN 8 THEN 'AR_CREDIT_MEMO_H_V'
55707
55708 ELSE null
55709 END object_name
55710 , CASE r
55711 WHEN 1 THEN 'HEADER'
55712 WHEN 2 THEN 'HEADER'
55713 WHEN 3 THEN 'HEADER'
55714 WHEN 4 THEN 'HEADER'
55715 WHEN 5 THEN 'HEADER'
55716 WHEN 6 THEN 'HEADER'
55717 WHEN 7 THEN 'HEADER'
55718 WHEN 8 THEN 'HEADER'
55719
55720 ELSE null
55721 END object_type_code
55722 , CASE r
55723 WHEN 1 THEN '222'
55724 WHEN 2 THEN '222'
55725 WHEN 3 THEN '222'
55726 WHEN 4 THEN '222'
55727 WHEN 5 THEN '222'
55728 WHEN 6 THEN '222'
55729 WHEN 7 THEN '222'
55730 WHEN 8 THEN '222'
55731
55732 ELSE null
55733 END source_application_id
55734 , 'S' source_type_code
55735 , CASE r
55736 WHEN 1 THEN 'CM_RECEIVABLE_CCID'
55737 WHEN 2 THEN 'CODE_COMBINATION_ID_GAIN'
55738 WHEN 3 THEN 'CODE_COMBINATION_ID_LOSS'
55739 WHEN 4 THEN 'XLA_PARTY_TYPE'
55740 WHEN 5 THEN 'CM_INVOICE_CURRENCY_CODE'
55741 WHEN 6 THEN 'CM_BILL_CUST_ACCOUNT_ID'
55742 WHEN 7 THEN 'CM_BILL_USES_SITE_USE_ID'
55743 WHEN 8 THEN 'CM_INVOICING_RULE_ID'
55744
55745 ELSE null
55746 END source_code
55747 , CASE r
55748 WHEN 1 THEN TO_CHAR(h5.CM_RECEIVABLE_CCID)
55749 WHEN 2 THEN TO_CHAR(h8.CODE_COMBINATION_ID_GAIN)
55750 WHEN 3 THEN TO_CHAR(h8.CODE_COMBINATION_ID_LOSS)
55751 WHEN 4 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
55752 WHEN 5 THEN TO_CHAR(h5.CM_INVOICE_CURRENCY_CODE)
55756
55753 WHEN 6 THEN TO_CHAR(h2.CM_BILL_CUST_ACCOUNT_ID)
55754 WHEN 7 THEN TO_CHAR(h1.CM_BILL_USES_SITE_USE_ID)
55755 WHEN 8 THEN TO_CHAR(h5.CM_INVOICING_RULE_ID)
55757 ELSE null
55758 END source_value
55759 , null source_meaning
55760 FROM xla_events_gt xet
55761 , AR_CM_BILL_SITE_USES_H_V h1
55762 , AR_CM_BILL_TO_CUST_H_V h2
55763 , AR_CREDIT_MEMO_H_V h5
55764 , AR_SYSTEM_PARAM_H_V h8
55765 ,(select rownum r from all_objects where rownum <= 8 and owner = p_apps_owner)
55766 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
55767 AND xet.event_class_code = C_EVENT_CLASS_CODE
55768 AND h1.event_id = xet.event_id
55769 AND h2.event_id = h1.event_id
55770 AND h5.event_id = h1.event_id
55771 AND h8.event_id (+) = h1.event_id
55772
55773 )
55774 ;
55775 --
55776 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
55777
55778 trace
55779 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
55780 ,p_level => C_LEVEL_STATEMENT
55781 ,p_module => l_log_module);
55782
55783 END IF;
55784 --
55785
55786
55787
55788 --
55789 INSERT INTO xla_diag_sources --line2
55790 (
55791 event_id
55792 , ledger_id
55793 , sla_ledger_id
55794 , description_language
55795 , object_name
55796 , object_type_code
55797 , line_number
55798 , source_application_id
55799 , source_type_code
55800 , source_code
55801 , source_value
55802 , source_meaning
55803 , created_by
55804 , creation_date
55805 , last_update_date
55806 , last_updated_by
55807 , last_update_login
55808 , program_update_date
55809 , program_application_id
55810 , program_id
55811 , request_id
55812 )
55813 SELECT event_id
55814 , p_target_ledger_id
55815 , p_sla_ledger_id
55816 , p_language
55817 , object_name
55818 , object_type_code
55819 , line_number
55820 , source_application_id
55821 , source_type_code
55822 , source_code
55823 , SUBSTR(source_value,1,1996)
55824 , SUBSTR(source_meaning ,1,200)
55825 , xla_environment_pkg.g_Usr_Id
55826 , TRUNC(SYSDATE)
55827 , TRUNC(SYSDATE)
55828 , xla_environment_pkg.g_Usr_Id
55829 , xla_environment_pkg.g_Login_Id
55830 , TRUNC(SYSDATE)
55831 , xla_environment_pkg.g_Prog_Appl_Id
55832 , xla_environment_pkg.g_Prog_Id
55833 , xla_environment_pkg.g_Req_Id
55834 FROM (
55835 SELECT xet.event_id event_id
55836 , l3.line_number line_number
55837 , CASE r
55838 WHEN 1 THEN 'AR_CM_LINES_L_V'
55839 WHEN 2 THEN 'AR_DISTRIBUTIONS_L_V'
55840 WHEN 3 THEN 'AR_DISTRIBUTIONS_L_V'
55841 WHEN 4 THEN 'AR_RECEIVABLES_TRX_ACT_S_V'
55842 WHEN 5 THEN 'AR_DISTRIBUTIONS_L_V'
55843 WHEN 6 THEN 'AR_CM_LINES_BASE_V'
55844 WHEN 7 THEN 'AR_CM_LINES_BASE_V'
55845 WHEN 8 THEN 'AR_CM_LINES_BASE_V'
55846 WHEN 9 THEN 'AR_CM_LINES_BASE_V'
55847 WHEN 10 THEN 'AR_CM_LINES_BASE_V'
55848 WHEN 11 THEN 'AR_CM_LINES_BASE_V'
55849 WHEN 12 THEN 'AR_CM_LINES_BASE_V'
55850 WHEN 13 THEN 'AR_CM_LINES_L_V'
55851 WHEN 14 THEN 'AR_CM_LINES_L_V'
55852 WHEN 15 THEN 'AR_CM_LINES_L_V'
55853
55854 ELSE null
55855 END object_name
55856 , CASE r
55857 WHEN 1 THEN 'LINE'
55858 WHEN 2 THEN 'LINE'
55859 WHEN 3 THEN 'LINE'
55860 WHEN 4 THEN 'LINE'
55861 WHEN 5 THEN 'LINE'
55862 WHEN 6 THEN 'LINE'
55863 WHEN 7 THEN 'LINE'
55864 WHEN 8 THEN 'LINE'
55865 WHEN 9 THEN 'LINE'
55866 WHEN 10 THEN 'LINE'
55867 WHEN 11 THEN 'LINE'
55868 WHEN 12 THEN 'LINE'
55869 WHEN 13 THEN 'LINE'
55870 WHEN 14 THEN 'LINE'
55871 WHEN 15 THEN 'LINE'
55872
55873 ELSE null
55874 END object_type_code
55875 , CASE r
55876 WHEN 1 THEN '222'
55877 WHEN 2 THEN '222'
55878 WHEN 3 THEN '222'
55879 WHEN 4 THEN '222'
55880 WHEN 5 THEN '222'
55881 WHEN 6 THEN '222'
55882 WHEN 7 THEN '222'
55883 WHEN 8 THEN '222'
55884 WHEN 9 THEN '222'
55885 WHEN 10 THEN '222'
55886 WHEN 11 THEN '222'
55887 WHEN 12 THEN '222'
55888 WHEN 13 THEN '222'
55889 WHEN 14 THEN '222'
55890 WHEN 15 THEN '222'
55891
55892 ELSE null
55893 END source_application_id
55894 , 'S' source_type_code
55895 , CASE r
55896 WHEN 1 THEN 'CM_LINE_DIST_CCID'
55897 WHEN 2 THEN 'DIST_CODE_COMBINATION_ID'
55898 WHEN 3 THEN 'DIST_SOURCE_TYPE'
55899 WHEN 4 THEN 'REC_ACT_TYPE'
55900 WHEN 5 THEN 'DIST_ENT_AMT'
55901 WHEN 6 THEN 'CM_DIST_IDENTIFER'
55902 WHEN 7 THEN 'CM_DIST_TYPE'
55903 WHEN 8 THEN 'CM_LINE_CUR_CONVERSION_DATE'
55904 WHEN 9 THEN 'CM_LINE_CUR_CONVERSION_RATE'
55905 WHEN 10 THEN 'CM_LINE_CUR_CONVERSION_TYPE'
55906 WHEN 11 THEN 'GAIN_LOSS_REF'
55907 WHEN 12 THEN 'CM_LINE_ACCTD_AMT'
55908 WHEN 13 THEN 'CM_TAX_LINE_ID'
55909 WHEN 14 THEN 'CM_LINE_DIST_ACCOUNT_CLASS'
55910 WHEN 15 THEN 'CM_LINE_DIST_AMT'
55911
55912 ELSE null
55913 END source_code
55914 , CASE r
55915 WHEN 1 THEN TO_CHAR(l4.CM_LINE_DIST_CCID)
55916 WHEN 2 THEN TO_CHAR(l6.DIST_CODE_COMBINATION_ID)
55917 WHEN 3 THEN TO_CHAR(l6.DIST_SOURCE_TYPE)
55918 WHEN 4 THEN TO_CHAR(l7.REC_ACT_TYPE)
55919 WHEN 5 THEN TO_CHAR(l6.DIST_ENT_AMT)
55920 WHEN 6 THEN TO_CHAR(l3.CM_DIST_IDENTIFER)
55921 WHEN 7 THEN TO_CHAR(l3.CM_DIST_TYPE)
55922 WHEN 8 THEN TO_CHAR(l3.CM_LINE_CUR_CONVERSION_DATE)
55923 WHEN 9 THEN TO_CHAR(l3.CM_LINE_CUR_CONVERSION_RATE)
55924 WHEN 10 THEN TO_CHAR(l3.CM_LINE_CUR_CONVERSION_TYPE)
55925 WHEN 11 THEN TO_CHAR(l3.GAIN_LOSS_REF)
55926 WHEN 12 THEN TO_CHAR(l3.CM_LINE_ACCTD_AMT)
55927 WHEN 13 THEN TO_CHAR(l4.CM_TAX_LINE_ID)
55928 WHEN 14 THEN TO_CHAR(l4.CM_LINE_DIST_ACCOUNT_CLASS)
55929 WHEN 15 THEN TO_CHAR(l4.CM_LINE_DIST_AMT)
55930
55931 ELSE null
55932 END source_value
55933 , null source_meaning
55934 FROM xla_events_gt xet
55935 , AR_CM_LINES_BASE_V l3
55936 , AR_CM_LINES_L_V l4
55937 , AR_DISTRIBUTIONS_L_V l6
55938 , AR_RECEIVABLES_TRX_ACT_S_V l7
55939 , (select rownum r from all_objects where rownum <= 15 and owner = p_apps_owner)
55940 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
55941 AND xet.event_class_code = C_EVENT_CLASS_CODE
55942 AND l3.event_id = xet.event_id
55943 AND l4.event_id (+) = l3.event_id
55944 AND l4.line_number (+) = l3.line_number
55945 AND l6.event_id (+) = l3.event_id
55946 AND l6.line_number (+) = l3.line_number
55947 AND l7.event_id (+) = l3.event_id
55948 AND l7.line_number (+) = l3.line_number
55949
55950 )
55951 ;
55952 --
55953 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
55954
55955 trace
55956 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
55957 ,p_level => C_LEVEL_STATEMENT
55958 ,p_module => l_log_module);
55959
55960 END IF;
55961
55962
55963 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55964 trace
55965 (p_msg => 'END of insert_sources_106'
55966 ,p_level => C_LEVEL_PROCEDURE
55967 ,p_module => l_log_module);
55968 END IF;
55969 EXCEPTION
55970 WHEN xla_exceptions_pkg.application_exception THEN
55971 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
55972 trace
55973 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
55974 ,p_level => C_LEVEL_EXCEPTION
55975 ,p_module => l_log_module);
55976 END IF;
55977 RAISE;
55978 WHEN OTHERS THEN
55979 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
55980 trace
55981 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
55982 ,p_level => C_LEVEL_EXCEPTION
55983 ,p_module => l_log_module);
55984 END IF;
55985 xla_exceptions_pkg.raise_message
55986 (p_location => 'XLA_00222_AAD_S_000007_PKG.insert_sources_106');
55987 END insert_sources_106;
55988 --
55989
55990 ---------------------------------------
55991 --
55992 -- PRIVATE FUNCTION
55993 -- EventClass_106
55994 --
55995 ----------------------------------------
55996 --
55997 FUNCTION EventClass_106
55998 (p_application_id IN NUMBER
55999 ,p_base_ledger_id IN NUMBER
56000 ,p_target_ledger_id IN NUMBER
56001 ,p_language IN VARCHAR2
56002 ,p_currency_code IN VARCHAR2
56003 ,p_sla_ledger_id IN NUMBER
56004 ,p_pad_start_date IN DATE
56005 ,p_pad_end_date IN DATE
56006 ,p_primary_ledger_id IN NUMBER)
56007 RETURN BOOLEAN IS
56008 --
56009 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO_ALL';
56010 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO';
56011
56012 l_calculate_acctd_flag VARCHAR2(1) :='N';
56013 l_calculate_g_l_flag VARCHAR2(1) :='Y';
56014 --
56015 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
56016 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
56017 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
56018 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
56019 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
56020 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
56021 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
56022 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
56023 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
56024 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
56025 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
56026 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
56027 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
56028 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
56029 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
56030 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
56031 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
56032 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
56033 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
56034 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
56035 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
56036 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
56037 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
56038 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
56039 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
56040 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
56041
56042 l_event_id NUMBER;
56043 l_previous_event_id NUMBER;
56044 l_first_event_id NUMBER;
56045 l_last_event_id NUMBER;
56046
56047 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
56048 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
56049 --
56050 --
56051 l_result BOOLEAN := TRUE;
56052 l_rows NUMBER := 1000;
56053 l_event_type_name VARCHAR2(80) := 'All';
56054 l_event_class_name VARCHAR2(80) := 'Credit Memo';
56055 l_description VARCHAR2(4000);
56056 l_transaction_reversal NUMBER;
56057 l_ae_header_id NUMBER;
56058 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
56059 l_log_module VARCHAR2(240);
56060 --
56061 l_acct_reversal_source VARCHAR2(30);
56062 l_trx_reversal_source VARCHAR2(30);
56063
56064 l_continue_with_lines BOOLEAN := TRUE;
56065 --
56066 l_acc_rev_gl_date_source DATE; -- 4262811
56067 --
56068 type t_array_event_id is table of number index by binary_integer;
56069
56070 l_rec_array_event t_rec_array_event;
56071 l_null_rec_array_event t_rec_array_event;
56072 l_array_ae_header_id xla_number_array_type;
56073 l_actual_flag VARCHAR2(1) := NULL;
56074 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
56078 --
56075 l_balance_type_code VARCHAR2(1) :=NULL;
56076 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
56077
56079 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
56080 --
56081
56082 TYPE t_array_source_2 IS TABLE OF AR_CREDIT_MEMO_H_V.CM_RECEIVABLE_CCID%TYPE INDEX BY BINARY_INTEGER;
56083 TYPE t_array_source_12 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_GAIN%TYPE INDEX BY BINARY_INTEGER;
56084 TYPE t_array_source_13 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_LOSS%TYPE INDEX BY BINARY_INTEGER;
56085 TYPE t_array_source_27 IS TABLE OF AR_CREDIT_MEMO_H_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
56086 TYPE t_array_source_39 IS TABLE OF AR_CREDIT_MEMO_H_V.CM_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
56087 TYPE t_array_source_45 IS TABLE OF AR_CM_BILL_TO_CUST_H_V.CM_BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
56088 TYPE t_array_source_46 IS TABLE OF AR_CM_BILL_SITE_USES_H_V.CM_BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
56089 TYPE t_array_source_52 IS TABLE OF AR_CREDIT_MEMO_H_V.CM_INVOICING_RULE_ID%TYPE INDEX BY BINARY_INTEGER;
56090
56091 TYPE t_array_source_9 IS TABLE OF AR_CM_LINES_L_V.CM_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
56092 TYPE t_array_source_10 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
56093 TYPE t_array_source_15 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
56094 TYPE t_array_source_16 IS TABLE OF AR_RECEIVABLES_TRX_ACT_S_V.REC_ACT_TYPE%TYPE INDEX BY BINARY_INTEGER;
56095 TYPE t_array_source_19 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
56096 TYPE t_array_source_37 IS TABLE OF AR_CM_LINES_BASE_V.CM_DIST_IDENTIFER%TYPE INDEX BY BINARY_INTEGER;
56097 TYPE t_array_source_38 IS TABLE OF AR_CM_LINES_BASE_V.CM_DIST_TYPE%TYPE INDEX BY BINARY_INTEGER;
56098 TYPE t_array_source_40 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
56099 TYPE t_array_source_41 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
56100 TYPE t_array_source_42 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
56101 TYPE t_array_source_43 IS TABLE OF AR_CM_LINES_BASE_V.GAIN_LOSS_REF%TYPE INDEX BY BINARY_INTEGER;
56102 TYPE t_array_source_44 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
56103 TYPE t_array_source_47 IS TABLE OF AR_CM_LINES_L_V.CM_TAX_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
56104 TYPE t_array_source_48 IS TABLE OF AR_CM_LINES_L_V.CM_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
56105 TYPE t_array_source_49 IS TABLE OF AR_CM_LINES_L_V.CM_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
56106
56107 l_array_source_2 t_array_source_2;
56108 l_array_source_12 t_array_source_12;
56109 l_array_source_13 t_array_source_13;
56110 l_array_source_27 t_array_source_27;
56111 l_array_source_39 t_array_source_39;
56112 l_array_source_45 t_array_source_45;
56113 l_array_source_46 t_array_source_46;
56114 l_array_source_52 t_array_source_52;
56115
56116 l_array_source_9 t_array_source_9;
56117 l_array_source_10 t_array_source_10;
56118 l_array_source_15 t_array_source_15;
56119 l_array_source_16 t_array_source_16;
56120 l_array_source_19 t_array_source_19;
56121 l_array_source_37 t_array_source_37;
56122 l_array_source_38 t_array_source_38;
56123 l_array_source_40 t_array_source_40;
56124 l_array_source_41 t_array_source_41;
56125 l_array_source_42 t_array_source_42;
56126 l_array_source_43 t_array_source_43;
56127 l_array_source_44 t_array_source_44;
56128 l_array_source_47 t_array_source_47;
56129 l_array_source_48 t_array_source_48;
56130 l_array_source_49 t_array_source_49;
56131
56132 --
56133 CURSOR header_cur
56134 IS
56135 SELECT /*+ leading(xet) cardinality(xet,1) */
56136 -- Event Class Code: CREDIT_MEMO
56137 xet.entity_id
56138 ,xet.legal_entity_id
56139 ,xet.entity_code
56140 ,xet.transaction_number
56141 ,xet.event_id
56142 ,xet.event_class_code
56143 ,xet.event_type_code
56144 ,xet.event_number
56145 ,xet.event_date
56146 ,xet.transaction_date
56147 ,xet.reference_num_1
56148 ,xet.reference_num_2
56149 ,xet.reference_num_3
56150 ,xet.reference_num_4
56151 ,xet.reference_char_1
56152 ,xet.reference_char_2
56153 ,xet.reference_char_3
56154 ,xet.reference_char_4
56155 ,xet.reference_date_1
56156 ,xet.reference_date_2
56157 ,xet.reference_date_3
56158 ,xet.reference_date_4
56159 ,xet.event_created_by
56160 ,xet.budgetary_control_flag
56161 , h5.CM_RECEIVABLE_CCID source_2
56162 , h8.CODE_COMBINATION_ID_GAIN source_12
56163 , h8.CODE_COMBINATION_ID_LOSS source_13
56164 , h5.XLA_PARTY_TYPE source_27
56165 , h5.CM_INVOICE_CURRENCY_CODE source_39
56166 , h2.CM_BILL_CUST_ACCOUNT_ID source_45
56167 , h1.CM_BILL_USES_SITE_USE_ID source_46
56168 , h5.CM_INVOICING_RULE_ID source_52
56169 FROM xla_events_gt xet
56170 , AR_CM_BILL_SITE_USES_H_V h1
56171 , AR_CM_BILL_TO_CUST_H_V h2
56172 , AR_CREDIT_MEMO_H_V h5
56173 , AR_SYSTEM_PARAM_H_V h8
56174 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
56175 and xet.event_class_code = C_EVENT_CLASS_CODE
56176 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
56177 AND h2.event_id = h1.event_id
56178 AND h5.event_id = h1.event_id
56179 AND h8.event_id (+) = h1.event_id
56180
56181 ORDER BY event_id
56182 ;
56183
56184
56185 --
56186 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
56187 IS
56188 SELECT /*+ leading(xet) cardinality(xet,1) */
56189 -- Event Class Code: CREDIT_MEMO
56190 xet.entity_id
56191 ,xet.legal_entity_id
56192 ,xet.entity_code
56193 ,xet.transaction_number
56194 ,xet.event_id
56195 ,xet.event_class_code
56196 ,xet.event_type_code
56197 ,xet.event_number
56198 ,xet.event_date
56199 ,xet.transaction_date
56200 ,xet.reference_num_1
56201 ,xet.reference_num_2
56202 ,xet.reference_num_3
56203 ,xet.reference_num_4
56204 ,xet.reference_char_1
56205 ,xet.reference_char_2
56206 ,xet.reference_char_3
56207 ,xet.reference_char_4
56208 ,xet.reference_date_1
56209 ,xet.reference_date_2
56210 ,xet.reference_date_3
56211 ,xet.reference_date_4
56212 ,xet.event_created_by
56213 ,xet.budgetary_control_flag
56214 , l3.LINE_NUMBER
56215 , l4.CM_LINE_DIST_CCID source_9
56216 , l6.DIST_CODE_COMBINATION_ID source_10
56217 , l6.DIST_SOURCE_TYPE source_15
56218 , l7.REC_ACT_TYPE source_16
56219 , l6.DIST_ENT_AMT source_19
56220 , l3.CM_DIST_IDENTIFER source_37
56221 , l3.CM_DIST_TYPE source_38
56222 , l3.CM_LINE_CUR_CONVERSION_DATE source_40
56223 , l3.CM_LINE_CUR_CONVERSION_RATE source_41
56224 , l3.CM_LINE_CUR_CONVERSION_TYPE source_42
56225 , l3.GAIN_LOSS_REF source_43
56226 , l3.CM_LINE_ACCTD_AMT source_44
56227 , l4.CM_TAX_LINE_ID source_47
56228 , l4.CM_LINE_DIST_ACCOUNT_CLASS source_48
56229 , l4.CM_LINE_DIST_AMT source_49
56230 FROM xla_events_gt xet
56231 , AR_CM_LINES_BASE_V l3
56232 , AR_CM_LINES_L_V l4
56233 , AR_DISTRIBUTIONS_L_V l6
56234 , AR_RECEIVABLES_TRX_ACT_S_V l7
56235 WHERE xet.event_id between x_first_event_id and x_last_event_id
56236 and xet.event_date between p_pad_start_date and p_pad_end_date
56237 and xet.event_class_code = C_EVENT_CLASS_CODE
56238 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
56239 AND l4.event_id (+) = l3.event_id
56240 AND l4.line_number (+) = l3.line_number
56241 AND l6.event_id (+) = l3.event_id
56242 AND l6.line_number (+) = l3.line_number
56243 AND l7.event_id (+) = l3.event_id
56244 AND l7.line_number (+) = l3.line_number
56245 ;
56246
56247 --
56248 BEGIN
56249 IF g_log_enabled THEN
56250 l_log_module := C_DEFAULT_MODULE||'.EventClass_106';
56251 END IF;
56252 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56253 trace
56254 (p_msg => 'BEGIN of EventClass_106'
56255 ,p_level => C_LEVEL_PROCEDURE
56256 ,p_module => l_log_module);
56257 END IF;
56258
56259 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
56260 trace
56261 (p_msg => 'p_application_id = '||p_application_id||
56262 ' - p_base_ledger_id = '||p_base_ledger_id||
56263 ' - p_target_ledger_id = '||p_target_ledger_id||
56264 ' - p_language = '||p_language||
56265 ' - p_currency_code = '||p_currency_code||
56266 ' - p_sla_ledger_id = '||p_sla_ledger_id
56267 ,p_level => C_LEVEL_STATEMENT
56268 ,p_module => l_log_module);
56269 END IF;
56270 --
56271 -- initialze arrays
56272 --
56273 g_array_event.DELETE;
56274 l_rec_array_event := l_null_rec_array_event;
56275 --
56276 --------------------------------------
56277 -- 4262811 Initialze MPA Line Number
56278 --------------------------------------
56279 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
56280
56281 --
56282
56283 --
56284 OPEN header_cur;
56285 --
56286 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
56287 trace
56288 (p_msg => 'SQL - FETCH header_cur'
56289 ,p_level => C_LEVEL_STATEMENT
56290 ,p_module => l_log_module);
56291 END IF;
56292 --
56293 LOOP
56294 FETCH header_cur BULK COLLECT INTO
56295 l_array_entity_id
56296 , l_array_legal_entity_id
56297 , l_array_entity_code
56298 , l_array_transaction_num
56299 , l_array_event_id
56300 , l_array_class_code
56301 , l_array_event_type
56302 , l_array_event_number
56303 , l_array_event_date
56304 , l_array_transaction_date
56305 , l_array_reference_num_1
56306 , l_array_reference_num_2
56307 , l_array_reference_num_3
56308 , l_array_reference_num_4
56309 , l_array_reference_char_1
56310 , l_array_reference_char_2
56311 , l_array_reference_char_3
56312 , l_array_reference_char_4
56313 , l_array_reference_date_1
56314 , l_array_reference_date_2
56315 , l_array_reference_date_3
56316 , l_array_reference_date_4
56317 , l_array_event_created_by
56318 , l_array_budgetary_control_flag
56319 , l_array_source_2
56320 , l_array_source_12
56321 , l_array_source_13
56322 , l_array_source_27
56323 , l_array_source_39
56324 , l_array_source_45
56325 , l_array_source_46
56326 , l_array_source_52
56327 LIMIT l_rows;
56328 --
56329 IF (C_LEVEL_EVENT >= g_log_level) THEN
56330 trace
56331 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
56332 ,p_level => C_LEVEL_EVENT
56333 ,p_module => l_log_module);
56334 END IF;
56335 --
56336 EXIT WHEN l_array_entity_id.COUNT = 0;
56337
56338 -- initialize arrays
56339 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
56340 XLA_AE_LINES_PKG.g_rec_lines := NULL;
56341
56342 --
56343 -- Bug 4458708
56344 --
56345 XLA_AE_LINES_PKG.g_LineNumber := 0;
56346
56347
56348 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
56349 g_last_hdr_idx := l_array_event_id.LAST;
56350 --
56351 -- loop for the headers. Each iteration is for each header extract row
56352 -- fetched in header cursor
56353 --
56354 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
56355
56356 --
56357 -- set event info as cache for other routines to refer event attributes
56358 --
56359 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
56360 (p_application_id => p_application_id
56361 ,p_primary_ledger_id => p_primary_ledger_id
56362 ,p_base_ledger_id => p_base_ledger_id
56363 ,p_target_ledger_id => p_target_ledger_id
56364 ,p_entity_id => l_array_entity_id(hdr_idx)
56365 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
56366 ,p_entity_code => l_array_entity_code(hdr_idx)
56367 ,p_transaction_num => l_array_transaction_num(hdr_idx)
56368 ,p_event_id => l_array_event_id(hdr_idx)
56369 ,p_event_class_code => l_array_class_code(hdr_idx)
56370 ,p_event_type_code => l_array_event_type(hdr_idx)
56371 ,p_event_number => l_array_event_number(hdr_idx)
56372 ,p_event_date => l_array_event_date(hdr_idx)
56373 ,p_transaction_date => l_array_transaction_date(hdr_idx)
56374 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
56375 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
56376 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
56377 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
56378 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
56379 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
56380 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
56381 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
56382 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
56383 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
56384 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
56385 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
56386 ,p_event_created_by => l_array_event_created_by(hdr_idx)
56387 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
56388
56389 --
56390 -- set the status of entry to C_VALID (0)
56391 --
56392 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
56393
56394 --
56395 -- initialize a row for ae header
56396 --
56397 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
56398
56399 l_event_id := l_array_event_id(hdr_idx);
56400
56401 --
56402 -- storing the hdr_idx for event. May be used by line cursor.
56403 --
56404 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
56405
56406 --
56407 -- store sources from header extract. This can be improved to
56408 -- store only those sources from header extract that may be used in lines
56409 --
56410
56411 g_array_event(l_event_id).array_value_num('source_2') := l_array_source_2(hdr_idx);
56412 g_array_event(l_event_id).array_value_num('source_12') := l_array_source_12(hdr_idx);
56413 g_array_event(l_event_id).array_value_num('source_13') := l_array_source_13(hdr_idx);
56414 g_array_event(l_event_id).array_value_char('source_27') := l_array_source_27(hdr_idx);
56415 g_array_event(l_event_id).array_value_char('source_39') := l_array_source_39(hdr_idx);
56416 g_array_event(l_event_id).array_value_num('source_45') := l_array_source_45(hdr_idx);
56417 g_array_event(l_event_id).array_value_num('source_46') := l_array_source_46(hdr_idx);
56418 g_array_event(l_event_id).array_value_num('source_52') := l_array_source_52(hdr_idx);
56419
56420 --
56421 -- initilaize the status of ae headers for diffrent balance types
56422 -- the status is initialised to C_NOT_CREATED (2)
56423 --
56424 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
56425 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
56426 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
56427
56428 --
56429 -- call api to validate and store accounting attributes for header
56430 --
56431
56432 ------------------------------------------------------------
56433 -- Accrual Reversal : to get date for Standard Source (NONE)
56434 ------------------------------------------------------------
56435 l_acc_rev_gl_date_source := NULL;
56436
56437 l_rec_acct_attrs.array_acct_attr_code(1) := 'GL_DATE';
56438 l_rec_acct_attrs.array_date_value(1) :=
56439 xla_ae_sources_pkg.GetSystemSourceDate(
56440 p_source_code => 'XLA_EVENT_DATE'
56441 , p_source_type_code => 'Y'
56442 , p_source_application_id => 602
56443 );
56444
56445
56446 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
56447
56448 XLA_AE_HEADER_PKG.SetJeCategoryName;
56449
56450 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
56451 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
56452 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
56453 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
56454 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
56455
56456
56457 -- No header level analytical criteria
56458
56459 --
56460 --accounting attribute enhancement, bug 3612931
56461 --
56462 l_trx_reversal_source := SUBSTR(NULL, 1,30);
56463
56464 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
56465 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
56466
56467 xla_accounting_err_pkg.build_message
56468 (p_appli_s_name => 'XLA'
56469 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
56470 ,p_token_1 => 'ACCT_ATTR_NAME'
56471 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
56472 ,p_token_2 => 'PRODUCT_NAME'
56476 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
56473 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
56474 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
56475 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
56477
56478 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
56479 --
56480 -- following sets the accounting attributes needed to reverse
56481 -- accounting for a distributeion
56482 --
56483 xla_ae_lines_pkg.SetTrxReversalAttrs
56484 (p_event_id => l_event_id
56485 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
56486 ,p_trx_reversal_source => l_trx_reversal_source);
56487
56488 END IF;
56489
56490
56491 ----------------------------------------------------------------
56492 -- 4262811 - update the header statuses to invalid in need be
56493 ----------------------------------------------------------------
56494 --
56495 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
56496
56497
56498 -----------------------------------------------
56499 -- No accrual reversal for the event class/type
56500 -----------------------------------------------
56501 ----------------------------------------------------------------
56502
56503 --
56504 -- this ends the header loop iteration for one bulk fetch
56505 --
56506 END LOOP;
56507
56508 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
56509 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
56510
56511 --
56512 -- insert dummy rows into lines gt table that were created due to
56513 -- transaction reversals
56514 --
56515 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
56516 l_result := XLA_AE_LINES_PKG.InsertLines;
56517 END IF;
56518
56519 --
56520 -- reset the temp_line_num for each set of events fetched from header
56521 -- cursor rather than doing it for each new event in line cursor
56522 -- Bug 3939231
56523 --
56524 xla_ae_lines_pkg.g_temp_line_num := 0;
56525
56526
56527
56528 --
56529 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
56530 --
56531 --
56532 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
56533
56534 trace
56535 (p_msg => 'SQL - FETCH line_cur'
56536 ,p_level => C_LEVEL_STATEMENT
56537 ,p_module => l_log_module);
56538
56539 END IF;
56540 --
56541 --
56542 LOOP
56543 --
56544 FETCH line_cur BULK COLLECT INTO
56545 l_array_entity_id
56546 , l_array_legal_entity_id
56547 , l_array_entity_code
56548 , l_array_transaction_num
56549 , l_array_event_id
56550 , l_array_class_code
56551 , l_array_event_type
56552 , l_array_event_number
56553 , l_array_event_date
56554 , l_array_transaction_date
56555 , l_array_reference_num_1
56556 , l_array_reference_num_2
56557 , l_array_reference_num_3
56558 , l_array_reference_num_4
56559 , l_array_reference_char_1
56560 , l_array_reference_char_2
56561 , l_array_reference_char_3
56562 , l_array_reference_char_4
56563 , l_array_reference_date_1
56564 , l_array_reference_date_2
56565 , l_array_reference_date_3
56566 , l_array_reference_date_4
56567 , l_array_event_created_by
56568 , l_array_budgetary_control_flag
56569 , l_array_extract_line_num
56570 , l_array_source_9
56571 , l_array_source_10
56572 , l_array_source_15
56573 , l_array_source_16
56574 , l_array_source_19
56575 , l_array_source_37
56576 , l_array_source_38
56577 , l_array_source_40
56578 , l_array_source_41
56579 , l_array_source_42
56580 , l_array_source_43
56581 , l_array_source_44
56582 , l_array_source_47
56583 , l_array_source_48
56584 , l_array_source_49
56585 LIMIT l_rows;
56586
56587 --
56588 IF (C_LEVEL_EVENT >= g_log_level) THEN
56589 trace
56590 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
56591 ,p_level => C_LEVEL_EVENT
56592 ,p_module => l_log_module);
56593 END IF;
56594 --
56595 EXIT WHEN l_array_entity_id.count = 0;
56596
56597 XLA_AE_LINES_PKG.g_rec_lines := null;
56598
56599 --
56600 -- Bug 4458708
56601 --
56602 XLA_AE_LINES_PKG.g_LineNumber := 0;
56603 --
56604 --
56605
56606 FOR Idx IN 1..l_array_event_id.count LOOP
56607 --
56608 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
56609 --
56610 l_event_id := l_array_event_id(idx); -- 5648433
56611
56612 --
56613 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
56614 --
56615
56616 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
56617 (g_array_event(l_event_id).array_value_num('header_index'))
56618 ,'N'
56619 ) <> 'Y'
56620 THEN
56621 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
56622 trace
56623 (p_msg => 'Trancaction revesal option is not Y '
56624 ,p_level => C_LEVEL_STATEMENT
56625 ,p_module => l_log_module);
56626 END IF;
56627
56628 --
56629 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
56630 --
56631 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
56632 --
56633 -- set event info as cache for other routines to refer event attributes
56634 --
56635
56636 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
56637 l_previous_event_id := l_event_id;
56638
56639 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
56640 (p_application_id => p_application_id
56641 ,p_primary_ledger_id => p_primary_ledger_id
56642 ,p_base_ledger_id => p_base_ledger_id
56643 ,p_target_ledger_id => p_target_ledger_id
56644 ,p_entity_id => l_array_entity_id(Idx)
56645 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
56646 ,p_entity_code => l_array_entity_code(Idx)
56647 ,p_transaction_num => l_array_transaction_num(Idx)
56648 ,p_event_id => l_array_event_id(Idx)
56649 ,p_event_class_code => l_array_class_code(Idx)
56650 ,p_event_type_code => l_array_event_type(Idx)
56651 ,p_event_number => l_array_event_number(Idx)
56652 ,p_event_date => l_array_event_date(Idx)
56653 ,p_transaction_date => l_array_transaction_date(Idx)
56654 ,p_reference_num_1 => l_array_reference_num_1(Idx)
56655 ,p_reference_num_2 => l_array_reference_num_2(Idx)
56656 ,p_reference_num_3 => l_array_reference_num_3(Idx)
56657 ,p_reference_num_4 => l_array_reference_num_4(Idx)
56658 ,p_reference_char_1 => l_array_reference_char_1(Idx)
56659 ,p_reference_char_2 => l_array_reference_char_2(Idx)
56660 ,p_reference_char_3 => l_array_reference_char_3(Idx)
56661 ,p_reference_char_4 => l_array_reference_char_4(Idx)
56662 ,p_reference_date_1 => l_array_reference_date_1(Idx)
56663 ,p_reference_date_2 => l_array_reference_date_2(Idx)
56664 ,p_reference_date_3 => l_array_reference_date_3(Idx)
56665 ,p_reference_date_4 => l_array_reference_date_4(Idx)
56666 ,p_event_created_by => l_array_event_created_by(Idx)
56667 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
56668 --
56669 END IF;
56670
56671
56672
56673 --
56674 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
56675
56676 l_acct_reversal_source := SUBSTR(NULL, 1,30);
56677
56678 IF l_continue_with_lines THEN
56679 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
56680 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
56681
56682 xla_accounting_err_pkg.build_message
56683 (p_appli_s_name => 'XLA'
56684 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
56685 ,p_token_1 => 'LINE_NUMBER'
56686 ,p_value_1 => l_array_extract_line_num(Idx)
56687 ,p_token_2 => 'PRODUCT_NAME'
56688 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
56689 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
56690 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
56691 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
56692
56693 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
56694 --
56695 -- following sets the accounting attributes needed to reverse
56696 -- accounting for a distributeion
56697 --
56698
56699 --
56700 -- 5217187
56701 --
56702 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
56703 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
56704 g_array_event(l_event_id).array_value_num('header_index'));
56705 --
56706 --
56707
56708 -- No reversal code generated
56709
56710 xla_ae_lines_pkg.SetAcctReversalAttrs
56711 (p_event_id => l_event_id
56712 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
56713 ,p_calculate_acctd_flag => l_calculate_acctd_flag
56714 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
56715 END IF;
56716
56717 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
56718 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
56719
56720 --
56721 AcctLineType_25 (
56722 p_application_id => p_application_id
56723 ,p_event_id => l_event_id
56724 ,p_calculate_acctd_flag => l_calculate_acctd_flag
56725 ,p_calculate_g_l_flag => l_calculate_g_l_flag
56726 ,p_actual_flag => l_actual_flag
56727 ,p_balance_type_code => l_balance_type_code
56728 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
56729
56730 , p_source_10 => l_array_source_10(Idx)
56731 , p_source_15 => l_array_source_15(Idx)
56732 , p_source_19 => l_array_source_19(Idx)
56733 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
56734 , p_source_37 => l_array_source_37(Idx)
56735 , p_source_38 => l_array_source_38(Idx)
56736 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
56737 , p_source_40 => l_array_source_40(Idx)
56738 , p_source_41 => l_array_source_41(Idx)
56739 , p_source_42 => l_array_source_42(Idx)
56740 , p_source_43 => l_array_source_43(Idx)
56741 , p_source_44 => l_array_source_44(Idx)
56742 , p_source_45 => g_array_event(l_event_id).array_value_num('source_45')
56743 , p_source_46 => g_array_event(l_event_id).array_value_num('source_46')
56744 , p_source_47 => l_array_source_47(Idx)
56745 );
56746 If(l_balance_type_code = 'A') THEN
56747 l_actual_gain_loss_ref := l_gain_or_loss_ref;
56748 END IF;
56749
56750 --
56751
56752
56753 --
56754 AcctLineType_26 (
56755 p_application_id => p_application_id
56756 ,p_event_id => l_event_id
56757 ,p_calculate_acctd_flag => l_calculate_acctd_flag
56758 ,p_calculate_g_l_flag => l_calculate_g_l_flag
56759 ,p_actual_flag => l_actual_flag
56760 ,p_balance_type_code => l_balance_type_code
56761 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
56762
56763 , p_source_10 => l_array_source_10(Idx)
56764 , p_source_15 => l_array_source_15(Idx)
56765 , p_source_16 => l_array_source_16(Idx)
56766 , p_source_19 => l_array_source_19(Idx)
56767 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
56768 , p_source_37 => l_array_source_37(Idx)
56769 , p_source_38 => l_array_source_38(Idx)
56770 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
56771 , p_source_40 => l_array_source_40(Idx)
56772 , p_source_41 => l_array_source_41(Idx)
56773 , p_source_42 => l_array_source_42(Idx)
56774 , p_source_43 => l_array_source_43(Idx)
56775 , p_source_44 => l_array_source_44(Idx)
56776 , p_source_45 => g_array_event(l_event_id).array_value_num('source_45')
56777 , p_source_46 => g_array_event(l_event_id).array_value_num('source_46')
56778 , p_source_47 => l_array_source_47(Idx)
56779 );
56780 If(l_balance_type_code = 'A') THEN
56781 l_actual_gain_loss_ref := l_gain_or_loss_ref;
56782 END IF;
56783
56784 --
56785
56786
56787 --
56788 AcctLineType_27 (
56789 p_application_id => p_application_id
56790 ,p_event_id => l_event_id
56791 ,p_calculate_acctd_flag => l_calculate_acctd_flag
56792 ,p_calculate_g_l_flag => l_calculate_g_l_flag
56793 ,p_actual_flag => l_actual_flag
56794 ,p_balance_type_code => l_balance_type_code
56795 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
56796
56797 , p_source_9 => l_array_source_9(Idx)
56798 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
56799 , p_source_37 => l_array_source_37(Idx)
56800 , p_source_38 => l_array_source_38(Idx)
56801 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
56802 , p_source_40 => l_array_source_40(Idx)
56803 , p_source_41 => l_array_source_41(Idx)
56804 , p_source_42 => l_array_source_42(Idx)
56805 , p_source_43 => l_array_source_43(Idx)
56806 , p_source_44 => l_array_source_44(Idx)
56810 , p_source_48 => l_array_source_48(Idx)
56807 , p_source_45 => g_array_event(l_event_id).array_value_num('source_45')
56808 , p_source_46 => g_array_event(l_event_id).array_value_num('source_46')
56809 , p_source_47 => l_array_source_47(Idx)
56811 , p_source_49 => l_array_source_49(Idx)
56812 );
56813 If(l_balance_type_code = 'A') THEN
56814 l_actual_gain_loss_ref := l_gain_or_loss_ref;
56815 END IF;
56816
56817 --
56818
56819
56820 --
56821 AcctLineType_28 (
56822 p_application_id => p_application_id
56823 ,p_event_id => l_event_id
56824 ,p_calculate_acctd_flag => l_calculate_acctd_flag
56825 ,p_calculate_g_l_flag => l_calculate_g_l_flag
56826 ,p_actual_flag => l_actual_flag
56827 ,p_balance_type_code => l_balance_type_code
56828 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
56829
56830 , p_source_9 => l_array_source_9(Idx)
56831 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
56832 , p_source_37 => l_array_source_37(Idx)
56833 , p_source_38 => l_array_source_38(Idx)
56834 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
56835 , p_source_40 => l_array_source_40(Idx)
56836 , p_source_41 => l_array_source_41(Idx)
56837 , p_source_42 => l_array_source_42(Idx)
56838 , p_source_43 => l_array_source_43(Idx)
56839 , p_source_44 => l_array_source_44(Idx)
56840 , p_source_45 => g_array_event(l_event_id).array_value_num('source_45')
56841 , p_source_46 => g_array_event(l_event_id).array_value_num('source_46')
56842 , p_source_47 => l_array_source_47(Idx)
56843 , p_source_48 => l_array_source_48(Idx)
56844 , p_source_49 => l_array_source_49(Idx)
56845 );
56846 If(l_balance_type_code = 'A') THEN
56847 l_actual_gain_loss_ref := l_gain_or_loss_ref;
56848 END IF;
56849
56850 --
56851
56852
56853 --
56854 AcctLineType_29 (
56855 p_application_id => p_application_id
56856 ,p_event_id => l_event_id
56857 ,p_calculate_acctd_flag => l_calculate_acctd_flag
56858 ,p_calculate_g_l_flag => l_calculate_g_l_flag
56859 ,p_actual_flag => l_actual_flag
56860 ,p_balance_type_code => l_balance_type_code
56861 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
56862
56863 , p_source_9 => l_array_source_9(Idx)
56864 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
56865 , p_source_37 => l_array_source_37(Idx)
56866 , p_source_38 => l_array_source_38(Idx)
56867 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
56868 , p_source_40 => l_array_source_40(Idx)
56869 , p_source_41 => l_array_source_41(Idx)
56870 , p_source_42 => l_array_source_42(Idx)
56871 , p_source_43 => l_array_source_43(Idx)
56872 , p_source_44 => l_array_source_44(Idx)
56873 , p_source_45 => g_array_event(l_event_id).array_value_num('source_45')
56874 , p_source_46 => g_array_event(l_event_id).array_value_num('source_46')
56875 , p_source_47 => l_array_source_47(Idx)
56876 , p_source_48 => l_array_source_48(Idx)
56877 , p_source_49 => l_array_source_49(Idx)
56878 );
56879 If(l_balance_type_code = 'A') THEN
56880 l_actual_gain_loss_ref := l_gain_or_loss_ref;
56881 END IF;
56882
56883 --
56884
56885
56886 --
56887 AcctLineType_30 (
56888 p_application_id => p_application_id
56889 ,p_event_id => l_event_id
56890 ,p_calculate_acctd_flag => l_calculate_acctd_flag
56891 ,p_calculate_g_l_flag => l_calculate_g_l_flag
56892 ,p_actual_flag => l_actual_flag
56893 ,p_balance_type_code => l_balance_type_code
56894 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
56895
56896 , p_source_9 => l_array_source_9(Idx)
56897 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
56898 , p_source_37 => l_array_source_37(Idx)
56899 , p_source_38 => l_array_source_38(Idx)
56900 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
56901 , p_source_40 => l_array_source_40(Idx)
56902 , p_source_41 => l_array_source_41(Idx)
56903 , p_source_42 => l_array_source_42(Idx)
56904 , p_source_43 => l_array_source_43(Idx)
56905 , p_source_44 => l_array_source_44(Idx)
56906 , p_source_45 => g_array_event(l_event_id).array_value_num('source_45')
56907 , p_source_46 => g_array_event(l_event_id).array_value_num('source_46')
56908 , p_source_47 => l_array_source_47(Idx)
56909 , p_source_48 => l_array_source_48(Idx)
56910 , p_source_49 => l_array_source_49(Idx)
56911 );
56912 If(l_balance_type_code = 'A') THEN
56913 l_actual_gain_loss_ref := l_gain_or_loss_ref;
56914 END IF;
56915
56916 --
56917
56918
56919 --
56920 AcctLineType_31 (
56921 p_application_id => p_application_id
56922 ,p_event_id => l_event_id
56923 ,p_calculate_acctd_flag => l_calculate_acctd_flag
56924 ,p_calculate_g_l_flag => l_calculate_g_l_flag
56925 ,p_actual_flag => l_actual_flag
56926 ,p_balance_type_code => l_balance_type_code
56927 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
56928
56929 , p_source_12 => g_array_event(l_event_id).array_value_num('source_12')
56930 , p_source_13 => g_array_event(l_event_id).array_value_num('source_13')
56931 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
56932 , p_source_37 => l_array_source_37(Idx)
56933 , p_source_38 => l_array_source_38(Idx)
56934 , p_source_43 => l_array_source_43(Idx)
56935 , p_source_44 => l_array_source_44(Idx)
56936 , p_source_45 => g_array_event(l_event_id).array_value_num('source_45')
56937 , p_source_46 => g_array_event(l_event_id).array_value_num('source_46')
56938 , p_source_47 => l_array_source_47(Idx)
56939 );
56940 If(l_balance_type_code = 'A') THEN
56941 l_actual_gain_loss_ref := l_gain_or_loss_ref;
56942 END IF;
56943
56944 --
56945
56946
56947 --
56948 AcctLineType_32 (
56949 p_application_id => p_application_id
56950 ,p_event_id => l_event_id
56951 ,p_calculate_acctd_flag => l_calculate_acctd_flag
56952 ,p_calculate_g_l_flag => l_calculate_g_l_flag
56953 ,p_actual_flag => l_actual_flag
56954 ,p_balance_type_code => l_balance_type_code
56955 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
56956
56957 , p_source_9 => l_array_source_9(Idx)
56958 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
56959 , p_source_37 => l_array_source_37(Idx)
56960 , p_source_38 => l_array_source_38(Idx)
56961 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
56962 , p_source_40 => l_array_source_40(Idx)
56963 , p_source_41 => l_array_source_41(Idx)
56964 , p_source_42 => l_array_source_42(Idx)
56965 , p_source_43 => l_array_source_43(Idx)
56966 , p_source_44 => l_array_source_44(Idx)
56967 , p_source_45 => g_array_event(l_event_id).array_value_num('source_45')
56968 , p_source_46 => g_array_event(l_event_id).array_value_num('source_46')
56969 , p_source_47 => l_array_source_47(Idx)
56970 , p_source_48 => l_array_source_48(Idx)
56971 , p_source_49 => l_array_source_49(Idx)
56972 );
56973 If(l_balance_type_code = 'A') THEN
56974 l_actual_gain_loss_ref := l_gain_or_loss_ref;
56975 END IF;
56976
56977 --
56978
56979
56980 --
56981 AcctLineType_33 (
56982 p_application_id => p_application_id
56983 ,p_event_id => l_event_id
56984 ,p_calculate_acctd_flag => l_calculate_acctd_flag
56985 ,p_calculate_g_l_flag => l_calculate_g_l_flag
56986 ,p_actual_flag => l_actual_flag
56987 ,p_balance_type_code => l_balance_type_code
56988 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
56989
56990 , p_source_9 => l_array_source_9(Idx)
56991 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
56992 , p_source_37 => l_array_source_37(Idx)
56993 , p_source_38 => l_array_source_38(Idx)
56994 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
56995 , p_source_40 => l_array_source_40(Idx)
56996 , p_source_41 => l_array_source_41(Idx)
56997 , p_source_42 => l_array_source_42(Idx)
56998 , p_source_43 => l_array_source_43(Idx)
56999 , p_source_44 => l_array_source_44(Idx)
57000 , p_source_45 => g_array_event(l_event_id).array_value_num('source_45')
57001 , p_source_46 => g_array_event(l_event_id).array_value_num('source_46')
57002 , p_source_47 => l_array_source_47(Idx)
57003 , p_source_48 => l_array_source_48(Idx)
57004 , p_source_49 => l_array_source_49(Idx)
57005 );
57006 If(l_balance_type_code = 'A') THEN
57007 l_actual_gain_loss_ref := l_gain_or_loss_ref;
57008 END IF;
57009
57010 --
57011
57012
57013 --
57014 AcctLineType_34 (
57015 p_application_id => p_application_id
57016 ,p_event_id => l_event_id
57017 ,p_calculate_acctd_flag => l_calculate_acctd_flag
57018 ,p_calculate_g_l_flag => l_calculate_g_l_flag
57019 ,p_actual_flag => l_actual_flag
57020 ,p_balance_type_code => l_balance_type_code
57021 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
57022
57023 , p_source_9 => l_array_source_9(Idx)
57024 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
57025 , p_source_37 => l_array_source_37(Idx)
57026 , p_source_38 => l_array_source_38(Idx)
57027 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
57028 , p_source_40 => l_array_source_40(Idx)
57029 , p_source_41 => l_array_source_41(Idx)
57030 , p_source_42 => l_array_source_42(Idx)
57031 , p_source_43 => l_array_source_43(Idx)
57032 , p_source_44 => l_array_source_44(Idx)
57033 , p_source_45 => g_array_event(l_event_id).array_value_num('source_45')
57034 , p_source_46 => g_array_event(l_event_id).array_value_num('source_46')
57035 , p_source_47 => l_array_source_47(Idx)
57036 , p_source_48 => l_array_source_48(Idx)
57037 , p_source_49 => l_array_source_49(Idx)
57038 );
57039 If(l_balance_type_code = 'A') THEN
57040 l_actual_gain_loss_ref := l_gain_or_loss_ref;
57041 END IF;
57042
57043 --
57044
57045
57046 --
57047 AcctLineType_54 (
57048 p_application_id => p_application_id
57049 ,p_event_id => l_event_id
57050 ,p_calculate_acctd_flag => l_calculate_acctd_flag
57051 ,p_calculate_g_l_flag => l_calculate_g_l_flag
57052 ,p_actual_flag => l_actual_flag
57053 ,p_balance_type_code => l_balance_type_code
57054 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
57055
57056 , p_source_2 => g_array_event(l_event_id).array_value_num('source_2')
57057 , p_source_9 => l_array_source_9(Idx)
57058 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
57059 , p_source_37 => l_array_source_37(Idx)
57060 , p_source_38 => l_array_source_38(Idx)
57061 , p_source_39 => g_array_event(l_event_id).array_value_char('source_39')
57062 , p_source_40 => l_array_source_40(Idx)
57063 , p_source_41 => l_array_source_41(Idx)
57064 , p_source_42 => l_array_source_42(Idx)
57065 , p_source_43 => l_array_source_43(Idx)
57066 , p_source_44 => l_array_source_44(Idx)
57067 , p_source_45 => g_array_event(l_event_id).array_value_num('source_45')
57068 , p_source_46 => g_array_event(l_event_id).array_value_num('source_46')
57069 , p_source_47 => l_array_source_47(Idx)
57070 , p_source_48 => l_array_source_48(Idx)
57071 , p_source_49 => l_array_source_49(Idx)
57072 , p_source_52 => g_array_event(l_event_id).array_value_num('source_52')
57073 );
57074 If(l_balance_type_code = 'A') THEN
57075 l_actual_gain_loss_ref := l_gain_or_loss_ref;
57076 END IF;
57077
57078 --
57079
57080 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
57081 -- or secondary ledger that has different currency with primary
57082 -- or alc that is calculated by sla
57083 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
57084 (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'))
57085
57086 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
57087 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
57088 AND (l_actual_flag = 'A')) THEN
57089 XLA_AE_LINES_PKG.CreateGainOrLossLines(
57090 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
57091 ,p_application_id => p_application_id
57092 ,p_amb_context_code => 'DEFAULT'
57093 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
57094 ,p_event_class_code => C_EVENT_CLASS_CODE
57095 ,p_event_type_code => C_EVENT_TYPE_CODE
57096
57097 ,p_gain_ccid => -1
57098 ,p_loss_ccid => -1
57099
57100 ,p_actual_flag => l_actual_flag
57101 ,p_enc_flag => null
57102 ,p_actual_g_l_ref => l_actual_gain_loss_ref
57103 ,p_enc_g_l_ref => null
57104 );
57105 END IF;
57106 END IF;
57107 END IF;
57108
57109 ELSE
57110 --
57111 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
57112 --
57113 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
57114 trace
57115 (p_msg => 'Trancaction revesal option is Y'
57116 ,p_level => C_LEVEL_STATEMENT
57117 ,p_module => l_log_module);
57118 END IF;
57119 END IF;
57120
57121 END LOOP;
57122 l_result := XLA_AE_LINES_PKG.InsertLines ;
57123 end loop;
57124 close line_cur;
57125
57126
57127 --
57128 -- insert headers into xla_ae_headers_gt table
57129 --
57130 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
57131
57132 -- insert into errors table here.
57133
57134 END LOOP;
57135
57136 --
57137 -- 4865292
57138 --
57139 -- Compare g_hdr_extract_count with event count in
57140 -- CreateHeadersAndLines.
57141 --
57142 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
57143
57144 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
57145 trace (p_msg => '# rows extracted from header extract objects '
57146 || ' (running total): '
57147 || g_hdr_extract_count
57148 ,p_level => C_LEVEL_STATEMENT
57149 ,p_module => l_log_module);
57150 END IF;
57151
57152 CLOSE header_cur;
57153 --
57154
57155 --
57156 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57157 trace
57158 (p_msg => 'END of EventClass_106'
57159 ,p_level => C_LEVEL_PROCEDURE
57160 ,p_module => l_log_module);
57161 END IF;
57162 --
57163 RETURN l_result;
57164 EXCEPTION
57165 WHEN xla_exceptions_pkg.application_exception THEN
57166
57167 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
57168
57169
57170 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
57171
57172 RAISE;
57173
57174 WHEN NO_DATA_FOUND THEN
57175
57176 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
57177 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
57178
57179 FOR header_record IN header_cur
57180 LOOP
57181 l_array_header_events(header_record.event_id) := header_record.event_id;
57182 END LOOP;
57183
57184 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
57185 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
57186
57187 fnd_file.put_line(fnd_file.LOG, ' ');
57188 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
57189 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
57190 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
57191
57192 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
57193 LOOP
57194 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
57195 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
57196 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
57197 END IF;
57198 END LOOP;
57199
57200 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
57201 fnd_file.put_line(fnd_file.LOG, ' ');
57202
57203
57204 xla_exceptions_pkg.raise_message
57205 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_106');
57206
57207
57208 WHEN OTHERS THEN
57209 xla_exceptions_pkg.raise_message
57210 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_106');
57211 END EventClass_106;
57212 --
57213
57214 ---------------------------------------
57215 --
57216 -- PRIVATE PROCEDURE
57217 -- insert_sources_107
57218 --
57219 ----------------------------------------
57220 --
57221 PROCEDURE insert_sources_107(
57222 p_target_ledger_id IN NUMBER
57223 , p_language IN VARCHAR2
57224 , p_sla_ledger_id IN NUMBER
57225 , p_pad_start_date IN DATE
57226 , p_pad_end_date IN DATE
57227 )
57228 IS
57229
57230 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO_ALL';
57231 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO';
57232 p_apps_owner VARCHAR2(30);
57233 l_log_module VARCHAR2(240);
57234 BEGIN
57235 IF g_log_enabled THEN
57236 l_log_module := C_DEFAULT_MODULE||'.insert_sources_107';
57237 END IF;
57238 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57239
57240 trace
57241 (p_msg => 'BEGIN of insert_sources_107'
57242 ,p_level => C_LEVEL_PROCEDURE
57243 ,p_module => l_log_module);
57244
57245 END IF;
57246
57247 -- select APPS owner
57248 SELECT oracle_username
57249 INTO p_apps_owner
57250 FROM fnd_oracle_userid
57251 WHERE read_only_flag = 'U'
57252 ;
57253
57254 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
57255 trace
57256 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
57257 ' - p_language = '||p_language||
57258 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
57259 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
57260 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
57261 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
57262 ,p_level => C_LEVEL_STATEMENT
57263 ,p_module => l_log_module);
57264 END IF;
57265
57266
57267 --
57268 INSERT INTO xla_diag_sources --hdr2
57269 (
57270 event_id
57271 , ledger_id
57272 , sla_ledger_id
57273 , description_language
57274 , object_name
57275 , object_type_code
57276 , line_number
57277 , source_application_id
57278 , source_type_code
57279 , source_code
57280 , source_value
57281 , source_meaning
57282 , created_by
57283 , creation_date
57284 , last_update_date
57285 , last_updated_by
57286 , last_update_login
57287 , program_update_date
57288 , program_application_id
57289 , program_id
57290 , request_id
57291 )
57292 SELECT
57293 event_id
57294 , p_target_ledger_id
57295 , p_sla_ledger_id
57296 , p_language
57297 , object_name
57301 , source_type_code
57298 , object_type_code
57299 , line_number
57300 , source_application_id
57302 , source_code
57303 , SUBSTR(source_value ,1,1996)
57304 , SUBSTR(source_meaning ,1,200)
57305 , xla_environment_pkg.g_Usr_Id
57306 , TRUNC(SYSDATE)
57307 , TRUNC(SYSDATE)
57308 , xla_environment_pkg.g_Usr_Id
57309 , xla_environment_pkg.g_Login_Id
57310 , TRUNC(SYSDATE)
57311 , xla_environment_pkg.g_Prog_Appl_Id
57312 , xla_environment_pkg.g_Prog_Id
57313 , xla_environment_pkg.g_Req_Id
57314 FROM (
57315 SELECT xet.event_id event_id
57316 , 0 line_number
57317 , CASE r
57318 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
57319 WHEN 2 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
57320 WHEN 3 THEN 'AR_BILL_TO_SITE_USES_S_V'
57321 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
57322 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
57323 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
57324 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
57325 WHEN 8 THEN 'AR_TRANSACTIONS_S_V'
57326 WHEN 9 THEN 'AR_TRANSACTIONS_S_V'
57327
57328 ELSE null
57329 END object_name
57330 , CASE r
57331 WHEN 1 THEN 'HEADER'
57332 WHEN 2 THEN 'HEADER'
57333 WHEN 3 THEN 'HEADER'
57334 WHEN 4 THEN 'HEADER'
57335 WHEN 5 THEN 'HEADER'
57336 WHEN 6 THEN 'HEADER'
57337 WHEN 7 THEN 'HEADER'
57338 WHEN 8 THEN 'HEADER'
57339 WHEN 9 THEN 'HEADER'
57340
57341 ELSE null
57342 END object_type_code
57343 , CASE r
57344 WHEN 1 THEN '222'
57345 WHEN 2 THEN '222'
57346 WHEN 3 THEN '222'
57347 WHEN 4 THEN '222'
57348 WHEN 5 THEN '222'
57349 WHEN 6 THEN '222'
57350 WHEN 7 THEN '222'
57351 WHEN 8 THEN '222'
57352 WHEN 9 THEN '222'
57353
57354 ELSE null
57355 END source_application_id
57356 , 'S' source_type_code
57357 , CASE r
57358 WHEN 1 THEN 'TRX_RECEIVABLE_CCID'
57359 WHEN 2 THEN 'BILL_CUST_ACCOUNT_ID'
57360 WHEN 3 THEN 'BILL_USES_SITE_USE_ID'
57361 WHEN 4 THEN 'XLA_PARTY_TYPE'
57362 WHEN 5 THEN 'TRX_INVOICE_CURRENCY_CODE'
57363 WHEN 6 THEN 'TRX_INVOICING_RULE_ID'
57364 WHEN 7 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
57365 WHEN 8 THEN 'TRX_DOC_SEQUENCE_ID'
57366 WHEN 9 THEN 'TRX_DOC_SEQUENCE_VALUE'
57367
57368 ELSE null
57369 END source_code
57370 , CASE r
57371 WHEN 1 THEN TO_CHAR(h5.TRX_RECEIVABLE_CCID)
57372 WHEN 2 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
57373 WHEN 3 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
57374 WHEN 4 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
57375 WHEN 5 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
57376 WHEN 6 THEN TO_CHAR(h5.TRX_INVOICING_RULE_ID)
57377 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
57378 WHEN 8 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
57379 WHEN 9 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
57380
57381 ELSE null
57382 END source_value
57383 , null source_meaning
57384 FROM xla_events_gt xet
57385 , AR_BILL_TO_CUSTOMERS_S_V h1
57386 , AR_BILL_TO_SITE_USES_S_V h2
57387 , AR_TRANSACTIONS_S_V h5
57388 ,(select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
57389 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
57390 AND xet.event_class_code = C_EVENT_CLASS_CODE
57391 AND h1.event_id = xet.event_id
57392 AND h2.event_id = h1.event_id
57393 AND h5.event_id = h1.event_id
57394
57395 )
57396 ;
57397 --
57398 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
57399
57400 trace
57401 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
57402 ,p_level => C_LEVEL_STATEMENT
57403 ,p_module => l_log_module);
57404
57405 END IF;
57406 --
57407
57408
57409
57410 --
57411 INSERT INTO xla_diag_sources --line2
57412 (
57413 event_id
57414 , ledger_id
57415 , sla_ledger_id
57416 , description_language
57417 , object_name
57418 , object_type_code
57419 , line_number
57420 , source_application_id
57421 , source_type_code
57422 , source_code
57423 , source_value
57424 , source_meaning
57425 , created_by
57426 , creation_date
57427 , last_update_date
57428 , last_updated_by
57429 , last_update_login
57430 , program_update_date
57431 , program_application_id
57432 , program_id
57433 , request_id
57434 )
57435 SELECT event_id
57436 , p_target_ledger_id
57437 , p_sla_ledger_id
57438 , p_language
57439 , object_name
57440 , object_type_code
57441 , line_number
57442 , source_application_id
57443 , source_type_code
57444 , source_code
57445 , SUBSTR(source_value,1,1996)
57446 , SUBSTR(source_meaning ,1,200)
57447 , xla_environment_pkg.g_Usr_Id
57448 , TRUNC(SYSDATE)
57449 , TRUNC(SYSDATE)
57450 , xla_environment_pkg.g_Usr_Id
57451 , xla_environment_pkg.g_Login_Id
57452 , TRUNC(SYSDATE)
57453 , xla_environment_pkg.g_Prog_Appl_Id
57454 , xla_environment_pkg.g_Prog_Id
57455 , xla_environment_pkg.g_Req_Id
57456 FROM (
57457 SELECT xet.event_id event_id
57458 , l4.line_number line_number
57459 , CASE r
57460 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
57461 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
57462 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
57463 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
57464 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
57465 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
57466 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
57467 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
57468 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
57469 WHEN 10 THEN 'AR_CUST_TRX_LINES_L_V'
57470
57471 ELSE null
57472 END object_name
57473 , CASE r
57474 WHEN 1 THEN 'LINE'
57475 WHEN 2 THEN 'LINE'
57476 WHEN 3 THEN 'LINE'
57477 WHEN 4 THEN 'LINE'
57478 WHEN 5 THEN 'LINE'
57479 WHEN 6 THEN 'LINE'
57480 WHEN 7 THEN 'LINE'
57481 WHEN 8 THEN 'LINE'
57482 WHEN 9 THEN 'LINE'
57483 WHEN 10 THEN 'LINE'
57484
57485 ELSE null
57486 END object_type_code
57487 , CASE r
57488 WHEN 1 THEN '222'
57489 WHEN 2 THEN '222'
57490 WHEN 3 THEN '222'
57491 WHEN 4 THEN '222'
57492 WHEN 5 THEN '222'
57493 WHEN 6 THEN '222'
57494 WHEN 7 THEN '222'
57495 WHEN 8 THEN '222'
57496 WHEN 9 THEN '222'
57497 WHEN 10 THEN '222'
57498
57499 ELSE null
57500 END source_application_id
57501 , 'S' source_type_code
57502 , CASE r
57503 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
57504 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
57505 WHEN 3 THEN 'TRX_LINE_DIST_ID'
57506 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
57507 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
57508 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
57509 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
57510 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
57511 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
57512 WHEN 10 THEN 'TRX_TAX_LINE_ID'
57513
57514 ELSE null
57515 END source_code
57516 , CASE r
57517 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
57518 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
57519 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
57520 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
57521 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
57522 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
57523 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
57524 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
57525 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
57526 WHEN 10 THEN TO_CHAR(l4.TRX_TAX_LINE_ID)
57527
57528 ELSE null
57529 END source_value
57530 , null source_meaning
57531 FROM xla_events_gt xet
57532 , AR_CUST_TRX_LINES_BASE_V l3
57533 , AR_CUST_TRX_LINES_L_V l4
57534 , (select rownum r from all_objects where rownum <= 10 and owner = p_apps_owner)
57535 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
57536 AND xet.event_class_code = C_EVENT_CLASS_CODE
57537 AND l3.event_id = xet.event_id
57538 AND l4.event_id = l3.event_id
57539 AND l4.line_number = l3.line_number
57540
57541 )
57542 ;
57543 --
57544 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
57545
57546 trace
57547 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
57548 ,p_level => C_LEVEL_STATEMENT
57549 ,p_module => l_log_module);
57550
57551 END IF;
57552
57553
57554 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57555 trace
57556 (p_msg => 'END of insert_sources_107'
57557 ,p_level => C_LEVEL_PROCEDURE
57558 ,p_module => l_log_module);
57559 END IF;
57560 EXCEPTION
57561 WHEN xla_exceptions_pkg.application_exception THEN
57562 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
57563 trace
57564 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
57565 ,p_level => C_LEVEL_EXCEPTION
57566 ,p_module => l_log_module);
57567 END IF;
57568 RAISE;
57569 WHEN OTHERS THEN
57570 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
57571 trace
57572 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
57573 ,p_level => C_LEVEL_EXCEPTION
57574 ,p_module => l_log_module);
57575 END IF;
57576 xla_exceptions_pkg.raise_message
57577 (p_location => 'XLA_00222_AAD_S_000007_PKG.insert_sources_107');
57578 END insert_sources_107;
57579 --
57580
57581 ---------------------------------------
57582 --
57583 -- PRIVATE FUNCTION
57584 -- EventClass_107
57585 --
57586 ----------------------------------------
57587 --
57588 FUNCTION EventClass_107
57589 (p_application_id IN NUMBER
57590 ,p_base_ledger_id IN NUMBER
57591 ,p_target_ledger_id IN NUMBER
57592 ,p_language IN VARCHAR2
57593 ,p_currency_code IN VARCHAR2
57594 ,p_sla_ledger_id IN NUMBER
57595 ,p_pad_start_date IN DATE
57596 ,p_pad_end_date IN DATE
57597 ,p_primary_ledger_id IN NUMBER)
57598 RETURN BOOLEAN IS
57599 --
57600 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO_ALL';
57601 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO';
57602
57603 l_calculate_acctd_flag VARCHAR2(1) :='N';
57604 l_calculate_g_l_flag VARCHAR2(1) :='N';
57605 --
57606 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
57607 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
57608 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
57609 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
57610 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
57611 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
57612 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
57613 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
57614 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
57615 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
57616 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
57617 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
57618 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
57619 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
57620 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
57621 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
57622 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
57623 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
57624 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
57625 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
57626 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
57627 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
57628 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
57629 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
57630 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
57631 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
57632
57633 l_event_id NUMBER;
57634 l_previous_event_id NUMBER;
57635 l_first_event_id NUMBER;
57636 l_last_event_id NUMBER;
57637
57638 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
57639 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
57640 --
57641 --
57642 l_result BOOLEAN := TRUE;
57643 l_rows NUMBER := 1000;
57644 l_event_type_name VARCHAR2(80) := 'All';
57645 l_event_class_name VARCHAR2(80) := 'Debit Memo';
57646 l_description VARCHAR2(4000);
57647 l_transaction_reversal NUMBER;
57648 l_ae_header_id NUMBER;
57649 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
57650 l_log_module VARCHAR2(240);
57651 --
57652 l_acct_reversal_source VARCHAR2(30);
57653 l_trx_reversal_source VARCHAR2(30);
57654
57655 l_continue_with_lines BOOLEAN := TRUE;
57656 --
57657 l_acc_rev_gl_date_source DATE; -- 4262811
57658 --
57659 type t_array_event_id is table of number index by binary_integer;
57660
57661 l_rec_array_event t_rec_array_event;
57662 l_null_rec_array_event t_rec_array_event;
57663 l_array_ae_header_id xla_number_array_type;
57664 l_actual_flag VARCHAR2(1) := NULL;
57665 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
57666 l_balance_type_code VARCHAR2(1) :=NULL;
57667 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
57668
57669 --
57670 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
57671 --
57672
57673 TYPE t_array_source_8 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_RECEIVABLE_CCID%TYPE INDEX BY BINARY_INTEGER;
57674 TYPE t_array_source_25 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
57675 TYPE t_array_source_26 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
57676 TYPE t_array_source_27 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
57677 TYPE t_array_source_32 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
57678 TYPE t_array_source_53 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICING_RULE_ID%TYPE INDEX BY BINARY_INTEGER;
57679 TYPE t_array_source_77 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
57680 TYPE t_array_source_78 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
57681 TYPE t_array_source_79 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
57682
57683 TYPE t_array_source_14 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
57684 TYPE t_array_source_28 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
57685 TYPE t_array_source_29 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
57686 TYPE t_array_source_30 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
57687 TYPE t_array_source_31 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
57688 TYPE t_array_source_33 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
57689 TYPE t_array_source_34 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
57690 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
57691 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
57692 TYPE t_array_source_50 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_TAX_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
57693
57694 l_array_source_8 t_array_source_8;
57695 l_array_source_25 t_array_source_25;
57696 l_array_source_26 t_array_source_26;
57697 l_array_source_27 t_array_source_27;
57698 l_array_source_32 t_array_source_32;
57699 l_array_source_53 t_array_source_53;
57700 l_array_source_77 t_array_source_77;
57701 l_array_source_78 t_array_source_78;
57702 l_array_source_79 t_array_source_79;
57703
57704 l_array_source_14 t_array_source_14;
57705 l_array_source_28 t_array_source_28;
57706 l_array_source_29 t_array_source_29;
57707 l_array_source_30 t_array_source_30;
57708 l_array_source_31 t_array_source_31;
57709 l_array_source_33 t_array_source_33;
57710 l_array_source_34 t_array_source_34;
57711 l_array_source_35 t_array_source_35;
57712 l_array_source_36 t_array_source_36;
57713 l_array_source_50 t_array_source_50;
57714
57715 --
57716 CURSOR header_cur
57717 IS
57718 SELECT /*+ leading(xet) cardinality(xet,1) */
57719 -- Event Class Code: DEBIT_MEMO
57720 xet.entity_id
57721 ,xet.legal_entity_id
57722 ,xet.entity_code
57723 ,xet.transaction_number
57724 ,xet.event_id
57725 ,xet.event_class_code
57726 ,xet.event_type_code
57727 ,xet.event_number
57728 ,xet.event_date
57729 ,xet.transaction_date
57730 ,xet.reference_num_1
57731 ,xet.reference_num_2
57732 ,xet.reference_num_3
57733 ,xet.reference_num_4
57734 ,xet.reference_char_1
57735 ,xet.reference_char_2
57736 ,xet.reference_char_3
57737 ,xet.reference_char_4
57738 ,xet.reference_date_1
57739 ,xet.reference_date_2
57740 ,xet.reference_date_3
57741 ,xet.reference_date_4
57742 ,xet.event_created_by
57743 ,xet.budgetary_control_flag
57744 , h5.TRX_RECEIVABLE_CCID source_8
57745 , h1.BILL_CUST_ACCOUNT_ID source_25
57746 , h2.BILL_USES_SITE_USE_ID source_26
57747 , h5.XLA_PARTY_TYPE source_27
57748 , h5.TRX_INVOICE_CURRENCY_CODE source_32
57749 , h5.TRX_INVOICING_RULE_ID source_53
57750 , h5.TRX_DOC_SEQUENCE_CATEGORY source_77
57751 , h5.TRX_DOC_SEQUENCE_ID source_78
57752 , h5.TRX_DOC_SEQUENCE_VALUE source_79
57753 FROM xla_events_gt xet
57754 , AR_BILL_TO_CUSTOMERS_S_V h1
57755 , AR_BILL_TO_SITE_USES_S_V h2
57756 , AR_TRANSACTIONS_S_V h5
57757 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
57758 and xet.event_class_code = C_EVENT_CLASS_CODE
57759 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
57760 AND h2.event_id = h1.event_id
57761 AND h5.event_id = h1.event_id
57762
57763 ORDER BY event_id
57764 ;
57765
57766
57767 --
57768 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
57769 IS
57770 SELECT /*+ leading(xet) cardinality(xet,1) */
57771 -- Event Class Code: DEBIT_MEMO
57772 xet.entity_id
57773 ,xet.legal_entity_id
57774 ,xet.entity_code
57775 ,xet.transaction_number
57776 ,xet.event_id
57777 ,xet.event_class_code
57778 ,xet.event_type_code
57779 ,xet.event_number
57780 ,xet.event_date
57781 ,xet.transaction_date
57782 ,xet.reference_num_1
57783 ,xet.reference_num_2
57784 ,xet.reference_num_3
57785 ,xet.reference_num_4
57786 ,xet.reference_char_1
57787 ,xet.reference_char_2
57788 ,xet.reference_char_3
57789 ,xet.reference_char_4
57790 ,xet.reference_date_1
57791 ,xet.reference_date_2
57792 ,xet.reference_date_3
57793 ,xet.reference_date_4
57794 ,xet.event_created_by
57795 ,xet.budgetary_control_flag
57796 , l3.LINE_NUMBER
57797 , l4.TRX_LINE_DIST_CCID source_14
57798 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_28
57799 , l4.TRX_LINE_DIST_ID source_29
57800 , l4.TRX_DISTRIBUTION_TYPE source_30
57801 , l4.TRX_LINE_DIST_AMT source_31
57802 , l3.TRX_LINE_CUR_CONVERSION_DATE source_33
57803 , l3.TRX_LINE_CUR_CONVERSION_RATE source_34
57804 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_35
57805 , l3.TRX_LINE_ACCTD_AMT source_36
57806 , l4.TRX_TAX_LINE_ID source_50
57807 FROM xla_events_gt xet
57808 , AR_CUST_TRX_LINES_BASE_V l3
57809 , AR_CUST_TRX_LINES_L_V l4
57810 WHERE xet.event_id between x_first_event_id and x_last_event_id
57811 and xet.event_date between p_pad_start_date and p_pad_end_date
57812 and xet.event_class_code = C_EVENT_CLASS_CODE
57813 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
57814 AND l4.event_id = l3.event_id
57815 AND l4.line_number = l3.line_number
57816 ;
57817
57818 --
57819 BEGIN
57820 IF g_log_enabled THEN
57821 l_log_module := C_DEFAULT_MODULE||'.EventClass_107';
57822 END IF;
57823 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57824 trace
57825 (p_msg => 'BEGIN of EventClass_107'
57826 ,p_level => C_LEVEL_PROCEDURE
57827 ,p_module => l_log_module);
57828 END IF;
57829
57830 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
57831 trace
57832 (p_msg => 'p_application_id = '||p_application_id||
57833 ' - p_base_ledger_id = '||p_base_ledger_id||
57834 ' - p_target_ledger_id = '||p_target_ledger_id||
57835 ' - p_language = '||p_language||
57836 ' - p_currency_code = '||p_currency_code||
57837 ' - p_sla_ledger_id = '||p_sla_ledger_id
57838 ,p_level => C_LEVEL_STATEMENT
57839 ,p_module => l_log_module);
57840 END IF;
57841 --
57842 -- initialze arrays
57843 --
57844 g_array_event.DELETE;
57845 l_rec_array_event := l_null_rec_array_event;
57846 --
57847 --------------------------------------
57848 -- 4262811 Initialze MPA Line Number
57849 --------------------------------------
57850 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
57851
57852 --
57853
57854 --
57855 OPEN header_cur;
57856 --
57857 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
57858 trace
57859 (p_msg => 'SQL - FETCH header_cur'
57860 ,p_level => C_LEVEL_STATEMENT
57861 ,p_module => l_log_module);
57862 END IF;
57863 --
57864 LOOP
57865 FETCH header_cur BULK COLLECT INTO
57866 l_array_entity_id
57867 , l_array_legal_entity_id
57868 , l_array_entity_code
57869 , l_array_transaction_num
57870 , l_array_event_id
57871 , l_array_class_code
57872 , l_array_event_type
57873 , l_array_event_number
57874 , l_array_event_date
57875 , l_array_transaction_date
57876 , l_array_reference_num_1
57877 , l_array_reference_num_2
57878 , l_array_reference_num_3
57879 , l_array_reference_num_4
57880 , l_array_reference_char_1
57881 , l_array_reference_char_2
57882 , l_array_reference_char_3
57883 , l_array_reference_char_4
57884 , l_array_reference_date_1
57885 , l_array_reference_date_2
57886 , l_array_reference_date_3
57887 , l_array_reference_date_4
57888 , l_array_event_created_by
57889 , l_array_budgetary_control_flag
57890 , l_array_source_8
57891 , l_array_source_25
57892 , l_array_source_26
57893 , l_array_source_27
57894 , l_array_source_32
57895 , l_array_source_53
57896 , l_array_source_77
57897 , l_array_source_78
57898 , l_array_source_79
57899 LIMIT l_rows;
57900 --
57901 IF (C_LEVEL_EVENT >= g_log_level) THEN
57902 trace
57903 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
57904 ,p_level => C_LEVEL_EVENT
57905 ,p_module => l_log_module);
57906 END IF;
57907 --
57908 EXIT WHEN l_array_entity_id.COUNT = 0;
57909
57910 -- initialize arrays
57911 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
57912 XLA_AE_LINES_PKG.g_rec_lines := NULL;
57913
57914 --
57915 -- Bug 4458708
57916 --
57917 XLA_AE_LINES_PKG.g_LineNumber := 0;
57918
57919
57920 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
57921 g_last_hdr_idx := l_array_event_id.LAST;
57922 --
57923 -- loop for the headers. Each iteration is for each header extract row
57924 -- fetched in header cursor
57925 --
57926 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
57927
57928 --
57929 -- set event info as cache for other routines to refer event attributes
57930 --
57931 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
57932 (p_application_id => p_application_id
57933 ,p_primary_ledger_id => p_primary_ledger_id
57934 ,p_base_ledger_id => p_base_ledger_id
57935 ,p_target_ledger_id => p_target_ledger_id
57936 ,p_entity_id => l_array_entity_id(hdr_idx)
57937 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
57938 ,p_entity_code => l_array_entity_code(hdr_idx)
57939 ,p_transaction_num => l_array_transaction_num(hdr_idx)
57940 ,p_event_id => l_array_event_id(hdr_idx)
57941 ,p_event_class_code => l_array_class_code(hdr_idx)
57942 ,p_event_type_code => l_array_event_type(hdr_idx)
57943 ,p_event_number => l_array_event_number(hdr_idx)
57944 ,p_event_date => l_array_event_date(hdr_idx)
57945 ,p_transaction_date => l_array_transaction_date(hdr_idx)
57946 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
57947 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
57948 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
57949 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
57950 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
57951 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
57952 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
57953 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
57954 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
57955 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
57956 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
57957 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
57958 ,p_event_created_by => l_array_event_created_by(hdr_idx)
57959 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
57960
57961 --
57962 -- set the status of entry to C_VALID (0)
57963 --
57964 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
57965
57966 --
57967 -- initialize a row for ae header
57968 --
57969 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
57970
57971 l_event_id := l_array_event_id(hdr_idx);
57972
57973 --
57974 -- storing the hdr_idx for event. May be used by line cursor.
57975 --
57976 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
57977
57978 --
57979 -- store sources from header extract. This can be improved to
57980 -- store only those sources from header extract that may be used in lines
57981 --
57982
57983 g_array_event(l_event_id).array_value_num('source_8') := l_array_source_8(hdr_idx);
57984 g_array_event(l_event_id).array_value_num('source_25') := l_array_source_25(hdr_idx);
57985 g_array_event(l_event_id).array_value_num('source_26') := l_array_source_26(hdr_idx);
57986 g_array_event(l_event_id).array_value_char('source_27') := l_array_source_27(hdr_idx);
57987 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
57988 g_array_event(l_event_id).array_value_num('source_53') := l_array_source_53(hdr_idx);
57989 g_array_event(l_event_id).array_value_char('source_77') := l_array_source_77(hdr_idx);
57990 g_array_event(l_event_id).array_value_num('source_78') := l_array_source_78(hdr_idx);
57991 g_array_event(l_event_id).array_value_num('source_79') := l_array_source_79(hdr_idx);
57992
57993 --
57994 -- initilaize the status of ae headers for diffrent balance types
57995 -- the status is initialised to C_NOT_CREATED (2)
57996 --
57997 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
57998 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
57999 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
58000
58001 --
58002 -- call api to validate and store accounting attributes for header
58003 --
58004
58005 ------------------------------------------------------------
58006 -- Accrual Reversal : to get date for Standard Source (NONE)
58007 ------------------------------------------------------------
58008 l_acc_rev_gl_date_source := NULL;
58009
58010 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
58011 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_77');
58012 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
58013 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_78');
58014 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
58015 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_79');
58016 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
58017 l_rec_acct_attrs.array_date_value(4) :=
58018 xla_ae_sources_pkg.GetSystemSourceDate(
58019 p_source_code => 'XLA_EVENT_DATE'
58020 , p_source_type_code => 'Y'
58021 , p_source_application_id => 602
58022 );
58023
58024
58025 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
58026
58027 XLA_AE_HEADER_PKG.SetJeCategoryName;
58028
58029 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
58030 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
58031 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
58032 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
58033 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
58034
58035
58036 -- No header level analytical criteria
58037
58038 --
58039 --accounting attribute enhancement, bug 3612931
58040 --
58041 l_trx_reversal_source := SUBSTR(NULL, 1,30);
58042
58043 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
58044 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
58045
58046 xla_accounting_err_pkg.build_message
58047 (p_appli_s_name => 'XLA'
58051 ,p_token_2 => 'PRODUCT_NAME'
58048 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
58049 ,p_token_1 => 'ACCT_ATTR_NAME'
58050 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
58052 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
58053 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
58054 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
58055 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
58056
58057 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
58058 --
58059 -- following sets the accounting attributes needed to reverse
58060 -- accounting for a distributeion
58061 --
58062 xla_ae_lines_pkg.SetTrxReversalAttrs
58063 (p_event_id => l_event_id
58064 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
58065 ,p_trx_reversal_source => l_trx_reversal_source);
58066
58067 END IF;
58068
58069
58070 ----------------------------------------------------------------
58071 -- 4262811 - update the header statuses to invalid in need be
58072 ----------------------------------------------------------------
58073 --
58074 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
58075
58076
58077 -----------------------------------------------
58078 -- No accrual reversal for the event class/type
58079 -----------------------------------------------
58080 ----------------------------------------------------------------
58081
58082 --
58083 -- this ends the header loop iteration for one bulk fetch
58084 --
58085 END LOOP;
58086
58087 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
58088 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
58089
58090 --
58091 -- insert dummy rows into lines gt table that were created due to
58092 -- transaction reversals
58093 --
58094 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
58095 l_result := XLA_AE_LINES_PKG.InsertLines;
58096 END IF;
58097
58098 --
58099 -- reset the temp_line_num for each set of events fetched from header
58100 -- cursor rather than doing it for each new event in line cursor
58101 -- Bug 3939231
58102 --
58103 xla_ae_lines_pkg.g_temp_line_num := 0;
58104
58105
58106
58107 --
58108 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
58109 --
58110 --
58111 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
58112
58113 trace
58114 (p_msg => 'SQL - FETCH line_cur'
58115 ,p_level => C_LEVEL_STATEMENT
58116 ,p_module => l_log_module);
58117
58118 END IF;
58119 --
58120 --
58121 LOOP
58122 --
58123 FETCH line_cur BULK COLLECT INTO
58124 l_array_entity_id
58125 , l_array_legal_entity_id
58126 , l_array_entity_code
58127 , l_array_transaction_num
58128 , l_array_event_id
58129 , l_array_class_code
58130 , l_array_event_type
58131 , l_array_event_number
58132 , l_array_event_date
58133 , l_array_transaction_date
58134 , l_array_reference_num_1
58135 , l_array_reference_num_2
58136 , l_array_reference_num_3
58137 , l_array_reference_num_4
58138 , l_array_reference_char_1
58139 , l_array_reference_char_2
58140 , l_array_reference_char_3
58141 , l_array_reference_char_4
58142 , l_array_reference_date_1
58143 , l_array_reference_date_2
58144 , l_array_reference_date_3
58145 , l_array_reference_date_4
58146 , l_array_event_created_by
58147 , l_array_budgetary_control_flag
58148 , l_array_extract_line_num
58149 , l_array_source_14
58150 , l_array_source_28
58151 , l_array_source_29
58152 , l_array_source_30
58153 , l_array_source_31
58154 , l_array_source_33
58155 , l_array_source_34
58156 , l_array_source_35
58157 , l_array_source_36
58158 , l_array_source_50
58159 LIMIT l_rows;
58160
58161 --
58162 IF (C_LEVEL_EVENT >= g_log_level) THEN
58163 trace
58164 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
58165 ,p_level => C_LEVEL_EVENT
58166 ,p_module => l_log_module);
58167 END IF;
58168 --
58169 EXIT WHEN l_array_entity_id.count = 0;
58170
58171 XLA_AE_LINES_PKG.g_rec_lines := null;
58172
58173 --
58174 -- Bug 4458708
58175 --
58176 XLA_AE_LINES_PKG.g_LineNumber := 0;
58177 --
58178 --
58179
58180 FOR Idx IN 1..l_array_event_id.count LOOP
58181 --
58182 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
58183 --
58184 l_event_id := l_array_event_id(idx); -- 5648433
58185
58186 --
58187 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
58188 --
58189
58190 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
58191 (g_array_event(l_event_id).array_value_num('header_index'))
58192 ,'N'
58193 ) <> 'Y'
58194 THEN
58195 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
58196 trace
58197 (p_msg => 'Trancaction revesal option is not Y '
58198 ,p_level => C_LEVEL_STATEMENT
58199 ,p_module => l_log_module);
58200 END IF;
58201
58202 --
58203 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
58204 --
58205 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
58206 --
58207 -- set event info as cache for other routines to refer event attributes
58208 --
58209
58210 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
58211 l_previous_event_id := l_event_id;
58212
58213 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
58214 (p_application_id => p_application_id
58215 ,p_primary_ledger_id => p_primary_ledger_id
58216 ,p_base_ledger_id => p_base_ledger_id
58217 ,p_target_ledger_id => p_target_ledger_id
58218 ,p_entity_id => l_array_entity_id(Idx)
58219 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
58220 ,p_entity_code => l_array_entity_code(Idx)
58221 ,p_transaction_num => l_array_transaction_num(Idx)
58222 ,p_event_id => l_array_event_id(Idx)
58223 ,p_event_class_code => l_array_class_code(Idx)
58224 ,p_event_type_code => l_array_event_type(Idx)
58225 ,p_event_number => l_array_event_number(Idx)
58226 ,p_event_date => l_array_event_date(Idx)
58227 ,p_transaction_date => l_array_transaction_date(Idx)
58228 ,p_reference_num_1 => l_array_reference_num_1(Idx)
58229 ,p_reference_num_2 => l_array_reference_num_2(Idx)
58230 ,p_reference_num_3 => l_array_reference_num_3(Idx)
58231 ,p_reference_num_4 => l_array_reference_num_4(Idx)
58232 ,p_reference_char_1 => l_array_reference_char_1(Idx)
58233 ,p_reference_char_2 => l_array_reference_char_2(Idx)
58234 ,p_reference_char_3 => l_array_reference_char_3(Idx)
58235 ,p_reference_char_4 => l_array_reference_char_4(Idx)
58236 ,p_reference_date_1 => l_array_reference_date_1(Idx)
58237 ,p_reference_date_2 => l_array_reference_date_2(Idx)
58238 ,p_reference_date_3 => l_array_reference_date_3(Idx)
58239 ,p_reference_date_4 => l_array_reference_date_4(Idx)
58240 ,p_event_created_by => l_array_event_created_by(Idx)
58241 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
58242 --
58243 END IF;
58244
58245
58246
58247 --
58248 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
58249
58250 l_acct_reversal_source := SUBSTR(NULL, 1,30);
58251
58252 IF l_continue_with_lines THEN
58253 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
58254 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
58255
58256 xla_accounting_err_pkg.build_message
58257 (p_appli_s_name => 'XLA'
58258 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
58259 ,p_token_1 => 'LINE_NUMBER'
58260 ,p_value_1 => l_array_extract_line_num(Idx)
58261 ,p_token_2 => 'PRODUCT_NAME'
58262 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
58263 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
58264 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
58265 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
58266
58267 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
58268 --
58269 -- following sets the accounting attributes needed to reverse
58270 -- accounting for a distributeion
58271 --
58272
58273 --
58274 -- 5217187
58275 --
58276 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
58277 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
58278 g_array_event(l_event_id).array_value_num('header_index'));
58279 --
58280 --
58281
58282 -- No reversal code generated
58283
58284 xla_ae_lines_pkg.SetAcctReversalAttrs
58285 (p_event_id => l_event_id
58286 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
58287 ,p_calculate_acctd_flag => l_calculate_acctd_flag
58288 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
58289 END IF;
58290
58291 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
58292 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
58293
58294 --
58295 AcctLineType_37 (
58296 p_application_id => p_application_id
58297 ,p_event_id => l_event_id
58298 ,p_calculate_acctd_flag => l_calculate_acctd_flag
58299 ,p_calculate_g_l_flag => l_calculate_g_l_flag
58300 ,p_actual_flag => l_actual_flag
58301 ,p_balance_type_code => l_balance_type_code
58302 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
58303
58304 , p_source_14 => l_array_source_14(Idx)
58305 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
58306 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
58307 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
58308 , p_source_28 => l_array_source_28(Idx)
58309 , p_source_29 => l_array_source_29(Idx)
58310 , p_source_30 => l_array_source_30(Idx)
58311 , p_source_31 => l_array_source_31(Idx)
58312 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
58313 , p_source_33 => l_array_source_33(Idx)
58314 , p_source_34 => l_array_source_34(Idx)
58315 , p_source_35 => l_array_source_35(Idx)
58316 , p_source_36 => l_array_source_36(Idx)
58317 , p_source_50 => l_array_source_50(Idx)
58318 );
58319 If(l_balance_type_code = 'A') THEN
58320 l_actual_gain_loss_ref := l_gain_or_loss_ref;
58321 END IF;
58322
58323 --
58324
58325
58326 --
58327 AcctLineType_38 (
58328 p_application_id => p_application_id
58329 ,p_event_id => l_event_id
58330 ,p_calculate_acctd_flag => l_calculate_acctd_flag
58331 ,p_calculate_g_l_flag => l_calculate_g_l_flag
58332 ,p_actual_flag => l_actual_flag
58333 ,p_balance_type_code => l_balance_type_code
58334 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
58335
58336 , p_source_14 => l_array_source_14(Idx)
58337 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
58338 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
58339 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
58340 , p_source_28 => l_array_source_28(Idx)
58341 , p_source_29 => l_array_source_29(Idx)
58342 , p_source_30 => l_array_source_30(Idx)
58343 , p_source_31 => l_array_source_31(Idx)
58344 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
58345 , p_source_33 => l_array_source_33(Idx)
58346 , p_source_34 => l_array_source_34(Idx)
58347 , p_source_35 => l_array_source_35(Idx)
58348 , p_source_36 => l_array_source_36(Idx)
58349 , p_source_50 => l_array_source_50(Idx)
58350 );
58351 If(l_balance_type_code = 'A') THEN
58352 l_actual_gain_loss_ref := l_gain_or_loss_ref;
58353 END IF;
58354
58355 --
58356
58357
58358 --
58359 AcctLineType_39 (
58360 p_application_id => p_application_id
58361 ,p_event_id => l_event_id
58362 ,p_calculate_acctd_flag => l_calculate_acctd_flag
58363 ,p_calculate_g_l_flag => l_calculate_g_l_flag
58364 ,p_actual_flag => l_actual_flag
58365 ,p_balance_type_code => l_balance_type_code
58366 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
58367
58368 , p_source_14 => l_array_source_14(Idx)
58369 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
58370 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
58371 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
58372 , p_source_28 => l_array_source_28(Idx)
58373 , p_source_29 => l_array_source_29(Idx)
58374 , p_source_30 => l_array_source_30(Idx)
58375 , p_source_31 => l_array_source_31(Idx)
58376 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
58377 , p_source_33 => l_array_source_33(Idx)
58378 , p_source_34 => l_array_source_34(Idx)
58379 , p_source_35 => l_array_source_35(Idx)
58380 , p_source_36 => l_array_source_36(Idx)
58381 , p_source_50 => l_array_source_50(Idx)
58382 );
58383 If(l_balance_type_code = 'A') THEN
58384 l_actual_gain_loss_ref := l_gain_or_loss_ref;
58385 END IF;
58386
58387 --
58388
58389
58390 --
58391 AcctLineType_40 (
58392 p_application_id => p_application_id
58393 ,p_event_id => l_event_id
58394 ,p_calculate_acctd_flag => l_calculate_acctd_flag
58395 ,p_calculate_g_l_flag => l_calculate_g_l_flag
58396 ,p_actual_flag => l_actual_flag
58397 ,p_balance_type_code => l_balance_type_code
58398 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
58399
58400 , p_source_14 => l_array_source_14(Idx)
58401 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
58402 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
58403 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
58404 , p_source_28 => l_array_source_28(Idx)
58405 , p_source_29 => l_array_source_29(Idx)
58406 , p_source_30 => l_array_source_30(Idx)
58407 , p_source_31 => l_array_source_31(Idx)
58408 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
58409 , p_source_33 => l_array_source_33(Idx)
58410 , p_source_34 => l_array_source_34(Idx)
58411 , p_source_35 => l_array_source_35(Idx)
58412 , p_source_36 => l_array_source_36(Idx)
58413 , p_source_50 => l_array_source_50(Idx)
58414 );
58415 If(l_balance_type_code = 'A') THEN
58416 l_actual_gain_loss_ref := l_gain_or_loss_ref;
58417 END IF;
58418
58419 --
58420
58421
58422 --
58423 AcctLineType_41 (
58424 p_application_id => p_application_id
58425 ,p_event_id => l_event_id
58426 ,p_calculate_acctd_flag => l_calculate_acctd_flag
58427 ,p_calculate_g_l_flag => l_calculate_g_l_flag
58428 ,p_actual_flag => l_actual_flag
58429 ,p_balance_type_code => l_balance_type_code
58430 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
58431
58432 , p_source_14 => l_array_source_14(Idx)
58433 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
58434 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
58435 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
58436 , p_source_28 => l_array_source_28(Idx)
58437 , p_source_29 => l_array_source_29(Idx)
58438 , p_source_30 => l_array_source_30(Idx)
58439 , p_source_31 => l_array_source_31(Idx)
58440 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
58441 , p_source_33 => l_array_source_33(Idx)
58442 , p_source_34 => l_array_source_34(Idx)
58443 , p_source_35 => l_array_source_35(Idx)
58444 , p_source_36 => l_array_source_36(Idx)
58445 , p_source_50 => l_array_source_50(Idx)
58446 );
58447 If(l_balance_type_code = 'A') THEN
58448 l_actual_gain_loss_ref := l_gain_or_loss_ref;
58449 END IF;
58450
58451 --
58452
58453
58454 --
58455 AcctLineType_42 (
58456 p_application_id => p_application_id
58457 ,p_event_id => l_event_id
58458 ,p_calculate_acctd_flag => l_calculate_acctd_flag
58459 ,p_calculate_g_l_flag => l_calculate_g_l_flag
58460 ,p_actual_flag => l_actual_flag
58461 ,p_balance_type_code => l_balance_type_code
58462 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
58463
58464 , p_source_14 => l_array_source_14(Idx)
58465 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
58466 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
58467 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
58468 , p_source_28 => l_array_source_28(Idx)
58469 , p_source_29 => l_array_source_29(Idx)
58470 , p_source_30 => l_array_source_30(Idx)
58471 , p_source_31 => l_array_source_31(Idx)
58472 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
58473 , p_source_33 => l_array_source_33(Idx)
58474 , p_source_34 => l_array_source_34(Idx)
58475 , p_source_35 => l_array_source_35(Idx)
58476 , p_source_36 => l_array_source_36(Idx)
58477 , p_source_50 => l_array_source_50(Idx)
58478 );
58479 If(l_balance_type_code = 'A') THEN
58480 l_actual_gain_loss_ref := l_gain_or_loss_ref;
58481 END IF;
58482
58483 --
58484
58485
58486 --
58487 AcctLineType_43 (
58488 p_application_id => p_application_id
58489 ,p_event_id => l_event_id
58490 ,p_calculate_acctd_flag => l_calculate_acctd_flag
58491 ,p_calculate_g_l_flag => l_calculate_g_l_flag
58492 ,p_actual_flag => l_actual_flag
58493 ,p_balance_type_code => l_balance_type_code
58494 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
58495
58496 , p_source_14 => l_array_source_14(Idx)
58497 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
58498 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
58499 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
58500 , p_source_28 => l_array_source_28(Idx)
58501 , p_source_29 => l_array_source_29(Idx)
58502 , p_source_30 => l_array_source_30(Idx)
58503 , p_source_31 => l_array_source_31(Idx)
58504 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
58505 , p_source_33 => l_array_source_33(Idx)
58506 , p_source_34 => l_array_source_34(Idx)
58507 , p_source_35 => l_array_source_35(Idx)
58508 , p_source_36 => l_array_source_36(Idx)
58509 , p_source_50 => l_array_source_50(Idx)
58510 );
58511 If(l_balance_type_code = 'A') THEN
58512 l_actual_gain_loss_ref := l_gain_or_loss_ref;
58513 END IF;
58514
58515 --
58516
58517
58518 --
58519 AcctLineType_55 (
58520 p_application_id => p_application_id
58521 ,p_event_id => l_event_id
58522 ,p_calculate_acctd_flag => l_calculate_acctd_flag
58523 ,p_calculate_g_l_flag => l_calculate_g_l_flag
58524 ,p_actual_flag => l_actual_flag
58525 ,p_balance_type_code => l_balance_type_code
58526 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
58527
58528 , p_source_8 => g_array_event(l_event_id).array_value_num('source_8')
58529 , p_source_14 => l_array_source_14(Idx)
58530 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
58531 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
58532 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
58533 , p_source_28 => l_array_source_28(Idx)
58534 , p_source_29 => l_array_source_29(Idx)
58535 , p_source_30 => l_array_source_30(Idx)
58536 , p_source_31 => l_array_source_31(Idx)
58537 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
58538 , p_source_33 => l_array_source_33(Idx)
58539 , p_source_34 => l_array_source_34(Idx)
58540 , p_source_35 => l_array_source_35(Idx)
58541 , p_source_36 => l_array_source_36(Idx)
58542 , p_source_50 => l_array_source_50(Idx)
58543 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
58544 );
58545 If(l_balance_type_code = 'A') THEN
58546 l_actual_gain_loss_ref := l_gain_or_loss_ref;
58547 END IF;
58548
58549 --
58550
58551 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
58552 -- or secondary ledger that has different currency with primary
58553 -- or alc that is calculated by sla
58554 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
58555 (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'))
58556
58557 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
58558 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
58559 AND (l_actual_flag = 'A')) THEN
58560 XLA_AE_LINES_PKG.CreateGainOrLossLines(
58561 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
58562 ,p_application_id => p_application_id
58563 ,p_amb_context_code => 'DEFAULT'
58564 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
58565 ,p_event_class_code => C_EVENT_CLASS_CODE
58566 ,p_event_type_code => C_EVENT_TYPE_CODE
58567
58568 ,p_gain_ccid => -1
58569 ,p_loss_ccid => -1
58570
58571 ,p_actual_flag => l_actual_flag
58572 ,p_enc_flag => null
58573 ,p_actual_g_l_ref => l_actual_gain_loss_ref
58574 ,p_enc_g_l_ref => null
58575 );
58576 END IF;
58577 END IF;
58578 END IF;
58579
58580 ELSE
58581 --
58582 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
58583 --
58584 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
58585 trace
58586 (p_msg => 'Trancaction revesal option is Y'
58587 ,p_level => C_LEVEL_STATEMENT
58588 ,p_module => l_log_module);
58589 END IF;
58590 END IF;
58591
58592 END LOOP;
58593 l_result := XLA_AE_LINES_PKG.InsertLines ;
58594 end loop;
58595 close line_cur;
58596
58597
58598 --
58599 -- insert headers into xla_ae_headers_gt table
58600 --
58601 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
58602
58603 -- insert into errors table here.
58604
58605 END LOOP;
58606
58607 --
58608 -- 4865292
58609 --
58610 -- Compare g_hdr_extract_count with event count in
58611 -- CreateHeadersAndLines.
58612 --
58613 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
58614
58615 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
58616 trace (p_msg => '# rows extracted from header extract objects '
58617 || ' (running total): '
58618 || g_hdr_extract_count
58619 ,p_level => C_LEVEL_STATEMENT
58620 ,p_module => l_log_module);
58621 END IF;
58622
58623 CLOSE header_cur;
58624 --
58625
58626 --
58627 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58628 trace
58629 (p_msg => 'END of EventClass_107'
58630 ,p_level => C_LEVEL_PROCEDURE
58631 ,p_module => l_log_module);
58632 END IF;
58633 --
58634 RETURN l_result;
58635 EXCEPTION
58636 WHEN xla_exceptions_pkg.application_exception THEN
58637
58638 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
58639
58640
58641 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
58642
58643 RAISE;
58644
58645 WHEN NO_DATA_FOUND THEN
58646
58647 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
58648 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
58649
58650 FOR header_record IN header_cur
58651 LOOP
58652 l_array_header_events(header_record.event_id) := header_record.event_id;
58653 END LOOP;
58654
58655 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
58656 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
58657
58658 fnd_file.put_line(fnd_file.LOG, ' ');
58659 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
58660 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
58661 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
58662
58663 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
58664 LOOP
58665 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
58666 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
58667 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
58668 END IF;
58669 END LOOP;
58670
58671 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
58672 fnd_file.put_line(fnd_file.LOG, ' ');
58673
58674
58675 xla_exceptions_pkg.raise_message
58676 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_107');
58677
58678
58679 WHEN OTHERS THEN
58680 xla_exceptions_pkg.raise_message
58681 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_107');
58682 END EventClass_107;
58683 --
58684
58685 ---------------------------------------
58686 --
58687 -- PRIVATE PROCEDURE
58688 -- insert_sources_108
58689 --
58690 ----------------------------------------
58691 --
58692 PROCEDURE insert_sources_108(
58693 p_target_ledger_id IN NUMBER
58694 , p_language IN VARCHAR2
58695 , p_sla_ledger_id IN NUMBER
58696 , p_pad_start_date IN DATE
58697 , p_pad_end_date IN DATE
58698 )
58699 IS
58700
58701 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT_ALL';
58702 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT';
58703 p_apps_owner VARCHAR2(30);
58704 l_log_module VARCHAR2(240);
58705 BEGIN
58706 IF g_log_enabled THEN
58707 l_log_module := C_DEFAULT_MODULE||'.insert_sources_108';
58708 END IF;
58709 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58710
58711 trace
58712 (p_msg => 'BEGIN of insert_sources_108'
58713 ,p_level => C_LEVEL_PROCEDURE
58714 ,p_module => l_log_module);
58715
58716 END IF;
58717
58718 -- select APPS owner
58719 SELECT oracle_username
58720 INTO p_apps_owner
58721 FROM fnd_oracle_userid
58722 WHERE read_only_flag = 'U'
58723 ;
58724
58725 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
58726 trace
58727 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
58728 ' - p_language = '||p_language||
58729 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
58730 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
58731 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
58732 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
58733 ,p_level => C_LEVEL_STATEMENT
58734 ,p_module => l_log_module);
58735 END IF;
58736
58737
58738 --
58739 INSERT INTO xla_diag_sources --hdr2
58740 (
58741 event_id
58742 , ledger_id
58743 , sla_ledger_id
58744 , description_language
58745 , object_name
58746 , object_type_code
58747 , line_number
58748 , source_application_id
58749 , source_type_code
58750 , source_code
58751 , source_value
58752 , source_meaning
58753 , created_by
58754 , creation_date
58755 , last_update_date
58756 , last_updated_by
58757 , last_update_login
58758 , program_update_date
58759 , program_application_id
58760 , program_id
58761 , request_id
58762 )
58763 SELECT
58764 event_id
58765 , p_target_ledger_id
58766 , p_sla_ledger_id
58767 , p_language
58768 , object_name
58769 , object_type_code
58770 , line_number
58771 , source_application_id
58772 , source_type_code
58773 , source_code
58774 , SUBSTR(source_value ,1,1996)
58775 , SUBSTR(source_meaning ,1,200)
58776 , xla_environment_pkg.g_Usr_Id
58777 , TRUNC(SYSDATE)
58778 , TRUNC(SYSDATE)
58779 , xla_environment_pkg.g_Usr_Id
58780 , xla_environment_pkg.g_Login_Id
58781 , TRUNC(SYSDATE)
58782 , xla_environment_pkg.g_Prog_Appl_Id
58783 , xla_environment_pkg.g_Prog_Id
58784 , xla_environment_pkg.g_Req_Id
58785 FROM (
58786 SELECT xet.event_id event_id
58787 , 0 line_number
58788 , CASE r
58789 WHEN 1 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
58790 WHEN 2 THEN 'AR_BILL_TO_SITE_USES_S_V'
58791 WHEN 3 THEN 'AR_TRANSACTIONS_S_V'
58792 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
58793 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
58794 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
58795 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
58796
58797 ELSE null
58798 END object_name
58799 , CASE r
58800 WHEN 1 THEN 'HEADER'
58801 WHEN 2 THEN 'HEADER'
58802 WHEN 3 THEN 'HEADER'
58803 WHEN 4 THEN 'HEADER'
58804 WHEN 5 THEN 'HEADER'
58805 WHEN 6 THEN 'HEADER'
58806 WHEN 7 THEN 'HEADER'
58807
58808 ELSE null
58809 END object_type_code
58810 , CASE r
58811 WHEN 1 THEN '222'
58812 WHEN 2 THEN '222'
58813 WHEN 3 THEN '222'
58814 WHEN 4 THEN '222'
58815 WHEN 5 THEN '222'
58816 WHEN 6 THEN '222'
58817 WHEN 7 THEN '222'
58818
58819 ELSE null
58820 END source_application_id
58821 , 'S' source_type_code
58822 , CASE r
58823 WHEN 1 THEN 'BILL_CUST_ACCOUNT_ID'
58824 WHEN 2 THEN 'BILL_USES_SITE_USE_ID'
58825 WHEN 3 THEN 'XLA_PARTY_TYPE'
58826 WHEN 4 THEN 'TRX_INVOICE_CURRENCY_CODE'
58827 WHEN 5 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
58828 WHEN 6 THEN 'TRX_DOC_SEQUENCE_ID'
58829 WHEN 7 THEN 'TRX_DOC_SEQUENCE_VALUE'
58830
58831 ELSE null
58832 END source_code
58833 , CASE r
58834 WHEN 1 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
58835 WHEN 2 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
58836 WHEN 3 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
58837 WHEN 4 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
58838 WHEN 5 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
58839 WHEN 6 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
58840 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
58841
58842 ELSE null
58843 END source_value
58844 , null source_meaning
58845 FROM xla_events_gt xet
58846 , AR_BILL_TO_CUSTOMERS_S_V h1
58847 , AR_BILL_TO_SITE_USES_S_V h2
58848 , AR_TRANSACTIONS_S_V h5
58849 ,(select rownum r from all_objects where rownum <= 7 and owner = p_apps_owner)
58850 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
58851 AND xet.event_class_code = C_EVENT_CLASS_CODE
58852 AND h1.event_id = xet.event_id
58853 AND h2.event_id = h1.event_id
58854 AND h5.event_id = h1.event_id
58855
58856 )
58857 ;
58858 --
58859 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
58860
58861 trace
58862 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
58863 ,p_level => C_LEVEL_STATEMENT
58867 --
58864 ,p_module => l_log_module);
58865
58866 END IF;
58868
58869
58870
58871 --
58872 INSERT INTO xla_diag_sources --line2
58873 (
58874 event_id
58875 , ledger_id
58876 , sla_ledger_id
58877 , description_language
58878 , object_name
58879 , object_type_code
58880 , line_number
58881 , source_application_id
58882 , source_type_code
58883 , source_code
58884 , source_value
58885 , source_meaning
58886 , created_by
58887 , creation_date
58888 , last_update_date
58889 , last_updated_by
58890 , last_update_login
58891 , program_update_date
58892 , program_application_id
58893 , program_id
58894 , request_id
58895 )
58896 SELECT event_id
58897 , p_target_ledger_id
58898 , p_sla_ledger_id
58899 , p_language
58900 , object_name
58901 , object_type_code
58902 , line_number
58903 , source_application_id
58904 , source_type_code
58905 , source_code
58906 , SUBSTR(source_value,1,1996)
58907 , SUBSTR(source_meaning ,1,200)
58908 , xla_environment_pkg.g_Usr_Id
58909 , TRUNC(SYSDATE)
58910 , TRUNC(SYSDATE)
58911 , xla_environment_pkg.g_Usr_Id
58912 , xla_environment_pkg.g_Login_Id
58913 , TRUNC(SYSDATE)
58914 , xla_environment_pkg.g_Prog_Appl_Id
58915 , xla_environment_pkg.g_Prog_Id
58916 , xla_environment_pkg.g_Req_Id
58917 FROM (
58918 SELECT xet.event_id event_id
58919 , l4.line_number line_number
58920 , CASE r
58921 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
58922 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
58923 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
58924 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
58925 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
58926 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
58927 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
58928 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
58929 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
58930
58931 ELSE null
58932 END object_name
58933 , CASE r
58934 WHEN 1 THEN 'LINE'
58935 WHEN 2 THEN 'LINE'
58936 WHEN 3 THEN 'LINE'
58937 WHEN 4 THEN 'LINE'
58938 WHEN 5 THEN 'LINE'
58939 WHEN 6 THEN 'LINE'
58940 WHEN 7 THEN 'LINE'
58941 WHEN 8 THEN 'LINE'
58942 WHEN 9 THEN 'LINE'
58943
58944 ELSE null
58945 END object_type_code
58946 , CASE r
58947 WHEN 1 THEN '222'
58948 WHEN 2 THEN '222'
58949 WHEN 3 THEN '222'
58950 WHEN 4 THEN '222'
58951 WHEN 5 THEN '222'
58952 WHEN 6 THEN '222'
58953 WHEN 7 THEN '222'
58954 WHEN 8 THEN '222'
58955 WHEN 9 THEN '222'
58956
58957 ELSE null
58958 END source_application_id
58959 , 'S' source_type_code
58960 , CASE r
58961 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
58962 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
58963 WHEN 3 THEN 'TRX_LINE_DIST_ID'
58964 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
58965 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
58966 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
58967 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
58968 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
58969 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
58970
58971 ELSE null
58972 END source_code
58973 , CASE r
58974 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
58975 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
58976 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
58977 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
58978 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
58979 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
58980 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
58981 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
58982 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
58983
58984 ELSE null
58985 END source_value
58986 , null source_meaning
58987 FROM xla_events_gt xet
58988 , AR_CUST_TRX_LINES_BASE_V l3
58989 , AR_CUST_TRX_LINES_L_V l4
58990 , (select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
58991 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
58992 AND xet.event_class_code = C_EVENT_CLASS_CODE
58993 AND l3.event_id = xet.event_id
58994 AND l4.event_id = l3.event_id
58995 AND l4.line_number = l3.line_number
58996
58997 )
58998 ;
58999 --
59000 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
59001
59002 trace
59003 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
59004 ,p_level => C_LEVEL_STATEMENT
59005 ,p_module => l_log_module);
59006
59007 END IF;
59008
59009
59010 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59011 trace
59012 (p_msg => 'END of insert_sources_108'
59013 ,p_level => C_LEVEL_PROCEDURE
59014 ,p_module => l_log_module);
59015 END IF;
59016 EXCEPTION
59017 WHEN xla_exceptions_pkg.application_exception THEN
59018 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
59019 trace
59020 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
59021 ,p_level => C_LEVEL_EXCEPTION
59022 ,p_module => l_log_module);
59023 END IF;
59024 RAISE;
59025 WHEN OTHERS THEN
59026 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
59027 trace
59028 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
59029 ,p_level => C_LEVEL_EXCEPTION
59030 ,p_module => l_log_module);
59031 END IF;
59032 xla_exceptions_pkg.raise_message
59033 (p_location => 'XLA_00222_AAD_S_000007_PKG.insert_sources_108');
59034 END insert_sources_108;
59035 --
59036
59037 ---------------------------------------
59038 --
59039 -- PRIVATE FUNCTION
59040 -- EventClass_108
59041 --
59042 ----------------------------------------
59043 --
59044 FUNCTION EventClass_108
59045 (p_application_id IN NUMBER
59046 ,p_base_ledger_id IN NUMBER
59047 ,p_target_ledger_id IN NUMBER
59048 ,p_language IN VARCHAR2
59049 ,p_currency_code IN VARCHAR2
59050 ,p_sla_ledger_id IN NUMBER
59051 ,p_pad_start_date IN DATE
59052 ,p_pad_end_date IN DATE
59053 ,p_primary_ledger_id IN NUMBER)
59054 RETURN BOOLEAN IS
59055 --
59056 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT_ALL';
59057 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT';
59058
59059 l_calculate_acctd_flag VARCHAR2(1) :='N';
59060 l_calculate_g_l_flag VARCHAR2(1) :='N';
59061 --
59062 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
59063 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
59064 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
59065 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
59066 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
59067 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
59068 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
59069 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
59070 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
59071 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
59072 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
59073 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
59074 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
59075 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
59076 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
59077 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
59078 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
59079 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
59080 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
59081 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
59082 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
59083 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
59084 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
59085 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
59086 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
59087 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
59088
59089 l_event_id NUMBER;
59090 l_previous_event_id NUMBER;
59091 l_first_event_id NUMBER;
59092 l_last_event_id NUMBER;
59093
59094 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
59095 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
59096 --
59097 --
59098 l_result BOOLEAN := TRUE;
59099 l_rows NUMBER := 1000;
59100 l_event_type_name VARCHAR2(80) := 'All';
59101 l_event_class_name VARCHAR2(80) := 'Deposit';
59102 l_description VARCHAR2(4000);
59103 l_transaction_reversal NUMBER;
59104 l_ae_header_id NUMBER;
59105 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
59106 l_log_module VARCHAR2(240);
59107 --
59108 l_acct_reversal_source VARCHAR2(30);
59109 l_trx_reversal_source VARCHAR2(30);
59110
59111 l_continue_with_lines BOOLEAN := TRUE;
59112 --
59113 l_acc_rev_gl_date_source DATE; -- 4262811
59114 --
59115 type t_array_event_id is table of number index by binary_integer;
59116
59117 l_rec_array_event t_rec_array_event;
59118 l_null_rec_array_event t_rec_array_event;
59119 l_array_ae_header_id xla_number_array_type;
59120 l_actual_flag VARCHAR2(1) := NULL;
59121 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
59122 l_balance_type_code VARCHAR2(1) :=NULL;
59123 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
59124
59125 --
59126 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
59127 --
59128
59129 TYPE t_array_source_25 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
59130 TYPE t_array_source_26 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
59131 TYPE t_array_source_27 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
59132 TYPE t_array_source_32 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
59133 TYPE t_array_source_77 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
59134 TYPE t_array_source_78 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
59135 TYPE t_array_source_79 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
59136
59137 TYPE t_array_source_14 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
59138 TYPE t_array_source_28 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
59139 TYPE t_array_source_29 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
59140 TYPE t_array_source_30 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
59141 TYPE t_array_source_31 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
59142 TYPE t_array_source_33 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
59143 TYPE t_array_source_34 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
59144 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
59145 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
59146
59147 l_array_source_25 t_array_source_25;
59148 l_array_source_26 t_array_source_26;
59149 l_array_source_27 t_array_source_27;
59150 l_array_source_32 t_array_source_32;
59151 l_array_source_77 t_array_source_77;
59152 l_array_source_78 t_array_source_78;
59153 l_array_source_79 t_array_source_79;
59154
59155 l_array_source_14 t_array_source_14;
59156 l_array_source_28 t_array_source_28;
59157 l_array_source_29 t_array_source_29;
59158 l_array_source_30 t_array_source_30;
59159 l_array_source_31 t_array_source_31;
59160 l_array_source_33 t_array_source_33;
59161 l_array_source_34 t_array_source_34;
59162 l_array_source_35 t_array_source_35;
59163 l_array_source_36 t_array_source_36;
59164
59165 --
59166 CURSOR header_cur
59167 IS
59168 SELECT /*+ leading(xet) cardinality(xet,1) */
59169 -- Event Class Code: DEPOSIT
59170 xet.entity_id
59171 ,xet.legal_entity_id
59172 ,xet.entity_code
59173 ,xet.transaction_number
59174 ,xet.event_id
59175 ,xet.event_class_code
59176 ,xet.event_type_code
59177 ,xet.event_number
59178 ,xet.event_date
59179 ,xet.transaction_date
59180 ,xet.reference_num_1
59181 ,xet.reference_num_2
59182 ,xet.reference_num_3
59183 ,xet.reference_num_4
59184 ,xet.reference_char_1
59185 ,xet.reference_char_2
59186 ,xet.reference_char_3
59187 ,xet.reference_char_4
59188 ,xet.reference_date_1
59189 ,xet.reference_date_2
59190 ,xet.reference_date_3
59191 ,xet.reference_date_4
59192 ,xet.event_created_by
59193 ,xet.budgetary_control_flag
59194 , h1.BILL_CUST_ACCOUNT_ID source_25
59195 , h2.BILL_USES_SITE_USE_ID source_26
59196 , h5.XLA_PARTY_TYPE source_27
59197 , h5.TRX_INVOICE_CURRENCY_CODE source_32
59198 , h5.TRX_DOC_SEQUENCE_CATEGORY source_77
59199 , h5.TRX_DOC_SEQUENCE_ID source_78
59200 , h5.TRX_DOC_SEQUENCE_VALUE source_79
59201 FROM xla_events_gt xet
59202 , AR_BILL_TO_CUSTOMERS_S_V h1
59203 , AR_BILL_TO_SITE_USES_S_V h2
59204 , AR_TRANSACTIONS_S_V h5
59205 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
59206 and xet.event_class_code = C_EVENT_CLASS_CODE
59207 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
59208 AND h2.event_id = h1.event_id
59209 AND h5.event_id = h1.event_id
59210
59211 ORDER BY event_id
59212 ;
59213
59214
59215 --
59216 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
59217 IS
59218 SELECT /*+ leading(xet) cardinality(xet,1) */
59219 -- Event Class Code: DEPOSIT
59220 xet.entity_id
59221 ,xet.legal_entity_id
59222 ,xet.entity_code
59223 ,xet.transaction_number
59224 ,xet.event_id
59225 ,xet.event_class_code
59226 ,xet.event_type_code
59227 ,xet.event_number
59228 ,xet.event_date
59229 ,xet.transaction_date
59230 ,xet.reference_num_1
59231 ,xet.reference_num_2
59232 ,xet.reference_num_3
59233 ,xet.reference_num_4
59234 ,xet.reference_char_1
59235 ,xet.reference_char_2
59236 ,xet.reference_char_3
59237 ,xet.reference_char_4
59238 ,xet.reference_date_1
59239 ,xet.reference_date_2
59240 ,xet.reference_date_3
59241 ,xet.reference_date_4
59242 ,xet.event_created_by
59243 ,xet.budgetary_control_flag
59244 , l3.LINE_NUMBER
59245 , l4.TRX_LINE_DIST_CCID source_14
59246 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_28
59247 , l4.TRX_LINE_DIST_ID source_29
59248 , l4.TRX_DISTRIBUTION_TYPE source_30
59249 , l4.TRX_LINE_DIST_AMT source_31
59250 , l3.TRX_LINE_CUR_CONVERSION_DATE source_33
59251 , l3.TRX_LINE_CUR_CONVERSION_RATE source_34
59252 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_35
59253 , l3.TRX_LINE_ACCTD_AMT source_36
59254 FROM xla_events_gt xet
59255 , AR_CUST_TRX_LINES_BASE_V l3
59256 , AR_CUST_TRX_LINES_L_V l4
59257 WHERE xet.event_id between x_first_event_id and x_last_event_id
59258 and xet.event_date between p_pad_start_date and p_pad_end_date
59259 and xet.event_class_code = C_EVENT_CLASS_CODE
59260 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
59261 AND l4.event_id = l3.event_id
59262 AND l4.line_number = l3.line_number
59263 ;
59264
59265 --
59266 BEGIN
59267 IF g_log_enabled THEN
59268 l_log_module := C_DEFAULT_MODULE||'.EventClass_108';
59269 END IF;
59270 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59271 trace
59272 (p_msg => 'BEGIN of EventClass_108'
59273 ,p_level => C_LEVEL_PROCEDURE
59274 ,p_module => l_log_module);
59275 END IF;
59276
59277 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
59278 trace
59279 (p_msg => 'p_application_id = '||p_application_id||
59280 ' - p_base_ledger_id = '||p_base_ledger_id||
59281 ' - p_target_ledger_id = '||p_target_ledger_id||
59282 ' - p_language = '||p_language||
59283 ' - p_currency_code = '||p_currency_code||
59284 ' - p_sla_ledger_id = '||p_sla_ledger_id
59285 ,p_level => C_LEVEL_STATEMENT
59286 ,p_module => l_log_module);
59287 END IF;
59288 --
59289 -- initialze arrays
59290 --
59291 g_array_event.DELETE;
59292 l_rec_array_event := l_null_rec_array_event;
59293 --
59294 --------------------------------------
59295 -- 4262811 Initialze MPA Line Number
59296 --------------------------------------
59297 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
59298
59299 --
59300
59301 --
59302 OPEN header_cur;
59303 --
59304 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
59305 trace
59306 (p_msg => 'SQL - FETCH header_cur'
59307 ,p_level => C_LEVEL_STATEMENT
59308 ,p_module => l_log_module);
59309 END IF;
59310 --
59311 LOOP
59312 FETCH header_cur BULK COLLECT INTO
59313 l_array_entity_id
59314 , l_array_legal_entity_id
59315 , l_array_entity_code
59316 , l_array_transaction_num
59317 , l_array_event_id
59318 , l_array_class_code
59319 , l_array_event_type
59320 , l_array_event_number
59321 , l_array_event_date
59322 , l_array_transaction_date
59323 , l_array_reference_num_1
59324 , l_array_reference_num_2
59325 , l_array_reference_num_3
59326 , l_array_reference_num_4
59327 , l_array_reference_char_1
59328 , l_array_reference_char_2
59329 , l_array_reference_char_3
59330 , l_array_reference_char_4
59331 , l_array_reference_date_1
59332 , l_array_reference_date_2
59333 , l_array_reference_date_3
59334 , l_array_reference_date_4
59335 , l_array_event_created_by
59336 , l_array_budgetary_control_flag
59337 , l_array_source_25
59338 , l_array_source_26
59339 , l_array_source_27
59340 , l_array_source_32
59341 , l_array_source_77
59342 , l_array_source_78
59343 , l_array_source_79
59344 LIMIT l_rows;
59345 --
59346 IF (C_LEVEL_EVENT >= g_log_level) THEN
59347 trace
59348 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
59349 ,p_level => C_LEVEL_EVENT
59350 ,p_module => l_log_module);
59351 END IF;
59352 --
59353 EXIT WHEN l_array_entity_id.COUNT = 0;
59354
59355 -- initialize arrays
59356 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
59357 XLA_AE_LINES_PKG.g_rec_lines := NULL;
59358
59359 --
59360 -- Bug 4458708
59361 --
59362 XLA_AE_LINES_PKG.g_LineNumber := 0;
59363
59364
59365 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
59366 g_last_hdr_idx := l_array_event_id.LAST;
59367 --
59368 -- loop for the headers. Each iteration is for each header extract row
59369 -- fetched in header cursor
59370 --
59371 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
59372
59373 --
59374 -- set event info as cache for other routines to refer event attributes
59375 --
59376 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
59377 (p_application_id => p_application_id
59378 ,p_primary_ledger_id => p_primary_ledger_id
59379 ,p_base_ledger_id => p_base_ledger_id
59380 ,p_target_ledger_id => p_target_ledger_id
59381 ,p_entity_id => l_array_entity_id(hdr_idx)
59382 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
59383 ,p_entity_code => l_array_entity_code(hdr_idx)
59384 ,p_transaction_num => l_array_transaction_num(hdr_idx)
59385 ,p_event_id => l_array_event_id(hdr_idx)
59386 ,p_event_class_code => l_array_class_code(hdr_idx)
59387 ,p_event_type_code => l_array_event_type(hdr_idx)
59388 ,p_event_number => l_array_event_number(hdr_idx)
59389 ,p_event_date => l_array_event_date(hdr_idx)
59390 ,p_transaction_date => l_array_transaction_date(hdr_idx)
59391 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
59392 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
59393 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
59394 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
59395 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
59396 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
59397 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
59398 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
59399 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
59400 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
59401 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
59402 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
59403 ,p_event_created_by => l_array_event_created_by(hdr_idx)
59404 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
59405
59406 --
59407 -- set the status of entry to C_VALID (0)
59408 --
59409 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
59410
59411 --
59412 -- initialize a row for ae header
59413 --
59414 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
59415
59416 l_event_id := l_array_event_id(hdr_idx);
59417
59418 --
59419 -- storing the hdr_idx for event. May be used by line cursor.
59420 --
59421 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
59422
59423 --
59424 -- store sources from header extract. This can be improved to
59425 -- store only those sources from header extract that may be used in lines
59426 --
59427
59428 g_array_event(l_event_id).array_value_num('source_25') := l_array_source_25(hdr_idx);
59429 g_array_event(l_event_id).array_value_num('source_26') := l_array_source_26(hdr_idx);
59430 g_array_event(l_event_id).array_value_char('source_27') := l_array_source_27(hdr_idx);
59431 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
59432 g_array_event(l_event_id).array_value_char('source_77') := l_array_source_77(hdr_idx);
59433 g_array_event(l_event_id).array_value_num('source_78') := l_array_source_78(hdr_idx);
59434 g_array_event(l_event_id).array_value_num('source_79') := l_array_source_79(hdr_idx);
59435
59436 --
59437 -- initilaize the status of ae headers for diffrent balance types
59438 -- the status is initialised to C_NOT_CREATED (2)
59439 --
59443
59440 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
59441 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
59442 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
59444 --
59445 -- call api to validate and store accounting attributes for header
59446 --
59447
59448 ------------------------------------------------------------
59449 -- Accrual Reversal : to get date for Standard Source (NONE)
59450 ------------------------------------------------------------
59451 l_acc_rev_gl_date_source := NULL;
59452
59453 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
59454 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_77');
59455 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
59456 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_78');
59457 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
59458 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_79');
59459 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
59460 l_rec_acct_attrs.array_date_value(4) :=
59461 xla_ae_sources_pkg.GetSystemSourceDate(
59462 p_source_code => 'XLA_EVENT_DATE'
59463 , p_source_type_code => 'Y'
59464 , p_source_application_id => 602
59465 );
59466
59467
59468 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
59469
59470 XLA_AE_HEADER_PKG.SetJeCategoryName;
59471
59472 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
59473 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
59474 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
59475 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
59476 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
59477
59478
59479 -- No header level analytical criteria
59480
59481 --
59482 --accounting attribute enhancement, bug 3612931
59483 --
59484 l_trx_reversal_source := SUBSTR(NULL, 1,30);
59485
59486 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
59487 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
59488
59489 xla_accounting_err_pkg.build_message
59490 (p_appli_s_name => 'XLA'
59491 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
59492 ,p_token_1 => 'ACCT_ATTR_NAME'
59493 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
59494 ,p_token_2 => 'PRODUCT_NAME'
59495 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
59496 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
59497 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
59498 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
59499
59500 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
59501 --
59502 -- following sets the accounting attributes needed to reverse
59503 -- accounting for a distributeion
59504 --
59505 xla_ae_lines_pkg.SetTrxReversalAttrs
59506 (p_event_id => l_event_id
59507 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
59508 ,p_trx_reversal_source => l_trx_reversal_source);
59509
59510 END IF;
59511
59512
59513 ----------------------------------------------------------------
59514 -- 4262811 - update the header statuses to invalid in need be
59515 ----------------------------------------------------------------
59516 --
59517 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
59518
59519
59520 -----------------------------------------------
59521 -- No accrual reversal for the event class/type
59522 -----------------------------------------------
59523 ----------------------------------------------------------------
59524
59525 --
59526 -- this ends the header loop iteration for one bulk fetch
59527 --
59528 END LOOP;
59529
59530 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
59531 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
59532
59533 --
59534 -- insert dummy rows into lines gt table that were created due to
59535 -- transaction reversals
59536 --
59537 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
59538 l_result := XLA_AE_LINES_PKG.InsertLines;
59539 END IF;
59540
59541 --
59542 -- reset the temp_line_num for each set of events fetched from header
59543 -- cursor rather than doing it for each new event in line cursor
59544 -- Bug 3939231
59545 --
59546 xla_ae_lines_pkg.g_temp_line_num := 0;
59547
59548
59549
59550 --
59551 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
59552 --
59553 --
59554 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
59555
59556 trace
59557 (p_msg => 'SQL - FETCH line_cur'
59558 ,p_level => C_LEVEL_STATEMENT
59559 ,p_module => l_log_module);
59560
59561 END IF;
59562 --
59563 --
59564 LOOP
59565 --
59566 FETCH line_cur BULK COLLECT INTO
59567 l_array_entity_id
59568 , l_array_legal_entity_id
59569 , l_array_entity_code
59570 , l_array_transaction_num
59571 , l_array_event_id
59572 , l_array_class_code
59573 , l_array_event_type
59574 , l_array_event_number
59575 , l_array_event_date
59576 , l_array_transaction_date
59577 , l_array_reference_num_1
59578 , l_array_reference_num_2
59579 , l_array_reference_num_3
59580 , l_array_reference_num_4
59581 , l_array_reference_char_1
59582 , l_array_reference_char_2
59583 , l_array_reference_char_3
59584 , l_array_reference_char_4
59585 , l_array_reference_date_1
59586 , l_array_reference_date_2
59587 , l_array_reference_date_3
59588 , l_array_reference_date_4
59589 , l_array_event_created_by
59590 , l_array_budgetary_control_flag
59591 , l_array_extract_line_num
59592 , l_array_source_14
59593 , l_array_source_28
59594 , l_array_source_29
59595 , l_array_source_30
59596 , l_array_source_31
59597 , l_array_source_33
59598 , l_array_source_34
59599 , l_array_source_35
59600 , l_array_source_36
59601 LIMIT l_rows;
59602
59603 --
59604 IF (C_LEVEL_EVENT >= g_log_level) THEN
59605 trace
59606 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
59607 ,p_level => C_LEVEL_EVENT
59608 ,p_module => l_log_module);
59609 END IF;
59610 --
59611 EXIT WHEN l_array_entity_id.count = 0;
59612
59613 XLA_AE_LINES_PKG.g_rec_lines := null;
59614
59615 --
59616 -- Bug 4458708
59617 --
59618 XLA_AE_LINES_PKG.g_LineNumber := 0;
59619 --
59620 --
59621
59622 FOR Idx IN 1..l_array_event_id.count LOOP
59623 --
59624 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
59625 --
59626 l_event_id := l_array_event_id(idx); -- 5648433
59627
59628 --
59629 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
59630 --
59631
59632 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
59633 (g_array_event(l_event_id).array_value_num('header_index'))
59634 ,'N'
59635 ) <> 'Y'
59636 THEN
59637 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
59638 trace
59639 (p_msg => 'Trancaction revesal option is not Y '
59640 ,p_level => C_LEVEL_STATEMENT
59641 ,p_module => l_log_module);
59642 END IF;
59643
59644 --
59645 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
59646 --
59647 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
59648 --
59649 -- set event info as cache for other routines to refer event attributes
59650 --
59651
59652 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
59653 l_previous_event_id := l_event_id;
59654
59655 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
59656 (p_application_id => p_application_id
59657 ,p_primary_ledger_id => p_primary_ledger_id
59658 ,p_base_ledger_id => p_base_ledger_id
59659 ,p_target_ledger_id => p_target_ledger_id
59660 ,p_entity_id => l_array_entity_id(Idx)
59661 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
59662 ,p_entity_code => l_array_entity_code(Idx)
59663 ,p_transaction_num => l_array_transaction_num(Idx)
59664 ,p_event_id => l_array_event_id(Idx)
59665 ,p_event_class_code => l_array_class_code(Idx)
59666 ,p_event_type_code => l_array_event_type(Idx)
59670 ,p_reference_num_1 => l_array_reference_num_1(Idx)
59667 ,p_event_number => l_array_event_number(Idx)
59668 ,p_event_date => l_array_event_date(Idx)
59669 ,p_transaction_date => l_array_transaction_date(Idx)
59671 ,p_reference_num_2 => l_array_reference_num_2(Idx)
59672 ,p_reference_num_3 => l_array_reference_num_3(Idx)
59673 ,p_reference_num_4 => l_array_reference_num_4(Idx)
59674 ,p_reference_char_1 => l_array_reference_char_1(Idx)
59675 ,p_reference_char_2 => l_array_reference_char_2(Idx)
59676 ,p_reference_char_3 => l_array_reference_char_3(Idx)
59677 ,p_reference_char_4 => l_array_reference_char_4(Idx)
59678 ,p_reference_date_1 => l_array_reference_date_1(Idx)
59679 ,p_reference_date_2 => l_array_reference_date_2(Idx)
59680 ,p_reference_date_3 => l_array_reference_date_3(Idx)
59681 ,p_reference_date_4 => l_array_reference_date_4(Idx)
59682 ,p_event_created_by => l_array_event_created_by(Idx)
59683 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
59684 --
59685 END IF;
59686
59687
59688
59689 --
59690 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
59691
59692 l_acct_reversal_source := SUBSTR(NULL, 1,30);
59693
59694 IF l_continue_with_lines THEN
59695 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
59696 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
59697
59698 xla_accounting_err_pkg.build_message
59699 (p_appli_s_name => 'XLA'
59700 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
59701 ,p_token_1 => 'LINE_NUMBER'
59702 ,p_value_1 => l_array_extract_line_num(Idx)
59703 ,p_token_2 => 'PRODUCT_NAME'
59704 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
59705 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
59706 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
59707 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
59708
59709 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
59710 --
59711 -- following sets the accounting attributes needed to reverse
59712 -- accounting for a distributeion
59713 --
59714
59715 --
59716 -- 5217187
59717 --
59718 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
59719 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
59720 g_array_event(l_event_id).array_value_num('header_index'));
59721 --
59722 --
59723
59724 -- No reversal code generated
59725
59726 xla_ae_lines_pkg.SetAcctReversalAttrs
59727 (p_event_id => l_event_id
59728 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
59729 ,p_calculate_acctd_flag => l_calculate_acctd_flag
59730 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
59731 END IF;
59732
59733 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
59734 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
59735
59736 --
59737 AcctLineType_35 (
59738 p_application_id => p_application_id
59739 ,p_event_id => l_event_id
59740 ,p_calculate_acctd_flag => l_calculate_acctd_flag
59741 ,p_calculate_g_l_flag => l_calculate_g_l_flag
59742 ,p_actual_flag => l_actual_flag
59743 ,p_balance_type_code => l_balance_type_code
59744 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
59745
59746 , p_source_14 => l_array_source_14(Idx)
59747 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
59748 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
59749 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
59750 , p_source_28 => l_array_source_28(Idx)
59751 , p_source_29 => l_array_source_29(Idx)
59752 , p_source_30 => l_array_source_30(Idx)
59753 , p_source_31 => l_array_source_31(Idx)
59754 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
59755 , p_source_33 => l_array_source_33(Idx)
59756 , p_source_34 => l_array_source_34(Idx)
59757 , p_source_35 => l_array_source_35(Idx)
59758 , p_source_36 => l_array_source_36(Idx)
59759 );
59760 If(l_balance_type_code = 'A') THEN
59761 l_actual_gain_loss_ref := l_gain_or_loss_ref;
59762 END IF;
59763
59764 --
59765
59766
59767 --
59768 AcctLineType_36 (
59769 p_application_id => p_application_id
59770 ,p_event_id => l_event_id
59771 ,p_calculate_acctd_flag => l_calculate_acctd_flag
59772 ,p_calculate_g_l_flag => l_calculate_g_l_flag
59773 ,p_actual_flag => l_actual_flag
59774 ,p_balance_type_code => l_balance_type_code
59775 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
59776
59777 , p_source_14 => l_array_source_14(Idx)
59778 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
59779 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
59780 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
59781 , p_source_28 => l_array_source_28(Idx)
59782 , p_source_29 => l_array_source_29(Idx)
59783 , p_source_30 => l_array_source_30(Idx)
59784 , p_source_31 => l_array_source_31(Idx)
59785 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
59786 , p_source_33 => l_array_source_33(Idx)
59787 , p_source_34 => l_array_source_34(Idx)
59788 , p_source_35 => l_array_source_35(Idx)
59789 , p_source_36 => l_array_source_36(Idx)
59790 );
59791 If(l_balance_type_code = 'A') THEN
59792 l_actual_gain_loss_ref := l_gain_or_loss_ref;
59793 END IF;
59794
59795 --
59796
59797 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
59798 -- or secondary ledger that has different currency with primary
59799 -- or alc that is calculated by sla
59800 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
59801 (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'))
59802
59803 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
59804 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
59805 AND (l_actual_flag = 'A')) THEN
59806 XLA_AE_LINES_PKG.CreateGainOrLossLines(
59807 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
59808 ,p_application_id => p_application_id
59809 ,p_amb_context_code => 'DEFAULT'
59810 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
59811 ,p_event_class_code => C_EVENT_CLASS_CODE
59812 ,p_event_type_code => C_EVENT_TYPE_CODE
59813
59814 ,p_gain_ccid => -1
59815 ,p_loss_ccid => -1
59816
59817 ,p_actual_flag => l_actual_flag
59818 ,p_enc_flag => null
59819 ,p_actual_g_l_ref => l_actual_gain_loss_ref
59820 ,p_enc_g_l_ref => null
59821 );
59822 END IF;
59823 END IF;
59824 END IF;
59825
59826 ELSE
59827 --
59828 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
59829 --
59830 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
59831 trace
59832 (p_msg => 'Trancaction revesal option is Y'
59833 ,p_level => C_LEVEL_STATEMENT
59834 ,p_module => l_log_module);
59835 END IF;
59836 END IF;
59837
59838 END LOOP;
59839 l_result := XLA_AE_LINES_PKG.InsertLines ;
59840 end loop;
59841 close line_cur;
59842
59843
59844 --
59845 -- insert headers into xla_ae_headers_gt table
59846 --
59847 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
59848
59849 -- insert into errors table here.
59850
59851 END LOOP;
59852
59853 --
59854 -- 4865292
59855 --
59856 -- Compare g_hdr_extract_count with event count in
59857 -- CreateHeadersAndLines.
59858 --
59859 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
59860
59861 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
59862 trace (p_msg => '# rows extracted from header extract objects '
59863 || ' (running total): '
59864 || g_hdr_extract_count
59865 ,p_level => C_LEVEL_STATEMENT
59866 ,p_module => l_log_module);
59867 END IF;
59868
59869 CLOSE header_cur;
59870 --
59871
59872 --
59873 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59874 trace
59875 (p_msg => 'END of EventClass_108'
59876 ,p_level => C_LEVEL_PROCEDURE
59877 ,p_module => l_log_module);
59878 END IF;
59879 --
59880 RETURN l_result;
59881 EXCEPTION
59882 WHEN xla_exceptions_pkg.application_exception THEN
59883
59884 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
59885
59886
59887 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
59888
59889 RAISE;
59890
59891 WHEN NO_DATA_FOUND THEN
59892
59893 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
59894 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
59895
59896 FOR header_record IN header_cur
59897 LOOP
59898 l_array_header_events(header_record.event_id) := header_record.event_id;
59899 END LOOP;
59900
59901 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
59902 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
59903
59904 fnd_file.put_line(fnd_file.LOG, ' ');
59905 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
59906 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
59907 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
59908
59909 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
59910 LOOP
59911 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
59912 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
59913 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
59914 END IF;
59915 END LOOP;
59916
59917 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
59918 fnd_file.put_line(fnd_file.LOG, ' ');
59919
59920
59921 xla_exceptions_pkg.raise_message
59922 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_108');
59923
59924
59925 WHEN OTHERS THEN
59926 xla_exceptions_pkg.raise_message
59927 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_108');
59928 END EventClass_108;
59929 --
59930
59931 ---------------------------------------
59932 --
59933 -- PRIVATE PROCEDURE
59934 -- insert_sources_109
59935 --
59936 ----------------------------------------
59937 --
59938 PROCEDURE insert_sources_109(
59939 p_target_ledger_id IN NUMBER
59940 , p_language IN VARCHAR2
59941 , p_sla_ledger_id IN NUMBER
59942 , p_pad_start_date IN DATE
59943 , p_pad_end_date IN DATE
59944 )
59945 IS
59946
59947 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE_ALL';
59948 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE';
59949 p_apps_owner VARCHAR2(30);
59950 l_log_module VARCHAR2(240);
59951 BEGIN
59952 IF g_log_enabled THEN
59953 l_log_module := C_DEFAULT_MODULE||'.insert_sources_109';
59954 END IF;
59955 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59956
59957 trace
59958 (p_msg => 'BEGIN of insert_sources_109'
59959 ,p_level => C_LEVEL_PROCEDURE
59960 ,p_module => l_log_module);
59961
59962 END IF;
59963
59964 -- select APPS owner
59965 SELECT oracle_username
59966 INTO p_apps_owner
59967 FROM fnd_oracle_userid
59968 WHERE read_only_flag = 'U'
59969 ;
59970
59971 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
59972 trace
59973 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
59974 ' - p_language = '||p_language||
59975 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
59976 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
59977 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
59978 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
59979 ,p_level => C_LEVEL_STATEMENT
59980 ,p_module => l_log_module);
59981 END IF;
59982
59983
59984 --
59985 INSERT INTO xla_diag_sources --hdr2
59986 (
59987 event_id
59988 , ledger_id
59989 , sla_ledger_id
59990 , description_language
59991 , object_name
59992 , object_type_code
59993 , line_number
59994 , source_application_id
59995 , source_type_code
59996 , source_code
59997 , source_value
59998 , source_meaning
59999 , created_by
60000 , creation_date
60001 , last_update_date
60002 , last_updated_by
60003 , last_update_login
60004 , program_update_date
60005 , program_application_id
60006 , program_id
60007 , request_id
60008 )
60009 SELECT
60010 event_id
60011 , p_target_ledger_id
60012 , p_sla_ledger_id
60013 , p_language
60014 , object_name
60015 , object_type_code
60016 , line_number
60017 , source_application_id
60018 , source_type_code
60019 , source_code
60020 , SUBSTR(source_value ,1,1996)
60021 , SUBSTR(source_meaning ,1,200)
60022 , xla_environment_pkg.g_Usr_Id
60023 , TRUNC(SYSDATE)
60024 , TRUNC(SYSDATE)
60025 , xla_environment_pkg.g_Usr_Id
60026 , xla_environment_pkg.g_Login_Id
60027 , TRUNC(SYSDATE)
60028 , xla_environment_pkg.g_Prog_Appl_Id
60029 , xla_environment_pkg.g_Prog_Id
60030 , xla_environment_pkg.g_Req_Id
60031 FROM (
60032 SELECT xet.event_id event_id
60033 , 0 line_number
60034 , CASE r
60035 WHEN 1 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
60036 WHEN 2 THEN 'AR_BILL_TO_SITE_USES_S_V'
60037 WHEN 3 THEN 'AR_TRANSACTIONS_S_V'
60038 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
60039 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
60040 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
60041 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
60042
60043 ELSE null
60044 END object_name
60045 , CASE r
60046 WHEN 1 THEN 'HEADER'
60047 WHEN 2 THEN 'HEADER'
60048 WHEN 3 THEN 'HEADER'
60049 WHEN 4 THEN 'HEADER'
60050 WHEN 5 THEN 'HEADER'
60051 WHEN 6 THEN 'HEADER'
60052 WHEN 7 THEN 'HEADER'
60053
60054 ELSE null
60055 END object_type_code
60056 , CASE r
60057 WHEN 1 THEN '222'
60058 WHEN 2 THEN '222'
60059 WHEN 3 THEN '222'
60060 WHEN 4 THEN '222'
60061 WHEN 5 THEN '222'
60062 WHEN 6 THEN '222'
60063 WHEN 7 THEN '222'
60064
60065 ELSE null
60066 END source_application_id
60067 , 'S' source_type_code
60068 , CASE r
60069 WHEN 1 THEN 'BILL_CUST_ACCOUNT_ID'
60070 WHEN 2 THEN 'BILL_USES_SITE_USE_ID'
60071 WHEN 3 THEN 'XLA_PARTY_TYPE'
60072 WHEN 4 THEN 'TRX_INVOICE_CURRENCY_CODE'
60073 WHEN 5 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
60074 WHEN 6 THEN 'TRX_DOC_SEQUENCE_ID'
60075 WHEN 7 THEN 'TRX_DOC_SEQUENCE_VALUE'
60076
60077 ELSE null
60078 END source_code
60079 , CASE r
60080 WHEN 1 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
60081 WHEN 2 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
60082 WHEN 3 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
60083 WHEN 4 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
60084 WHEN 5 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
60085 WHEN 6 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
60086 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
60087
60088 ELSE null
60089 END source_value
60090 , null source_meaning
60091 FROM xla_events_gt xet
60092 , AR_BILL_TO_CUSTOMERS_S_V h1
60093 , AR_BILL_TO_SITE_USES_S_V h2
60094 , AR_TRANSACTIONS_S_V h5
60095 ,(select rownum r from all_objects where rownum <= 7 and owner = p_apps_owner)
60096 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
60097 AND xet.event_class_code = C_EVENT_CLASS_CODE
60098 AND h1.event_id = xet.event_id
60099 AND h2.event_id = h1.event_id
60100 AND h5.event_id = h1.event_id
60101
60102 )
60103 ;
60104 --
60105 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
60106
60107 trace
60108 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
60109 ,p_level => C_LEVEL_STATEMENT
60110 ,p_module => l_log_module);
60111
60112 END IF;
60113 --
60114
60115
60116
60117 --
60118 INSERT INTO xla_diag_sources --line2
60119 (
60120 event_id
60121 , ledger_id
60122 , sla_ledger_id
60123 , description_language
60124 , object_name
60125 , object_type_code
60126 , line_number
60127 , source_application_id
60128 , source_type_code
60129 , source_code
60130 , source_value
60131 , source_meaning
60132 , created_by
60133 , creation_date
60134 , last_update_date
60135 , last_updated_by
60136 , last_update_login
60137 , program_update_date
60138 , program_application_id
60139 , program_id
60140 , request_id
60141 )
60142 SELECT event_id
60143 , p_target_ledger_id
60144 , p_sla_ledger_id
60145 , p_language
60146 , object_name
60147 , object_type_code
60148 , line_number
60149 , source_application_id
60150 , source_type_code
60151 , source_code
60152 , SUBSTR(source_value,1,1996)
60153 , SUBSTR(source_meaning ,1,200)
60154 , xla_environment_pkg.g_Usr_Id
60155 , TRUNC(SYSDATE)
60156 , TRUNC(SYSDATE)
60157 , xla_environment_pkg.g_Usr_Id
60158 , xla_environment_pkg.g_Login_Id
60159 , TRUNC(SYSDATE)
60160 , xla_environment_pkg.g_Prog_Appl_Id
60161 , xla_environment_pkg.g_Prog_Id
60162 , xla_environment_pkg.g_Req_Id
60163 FROM (
60164 SELECT xet.event_id event_id
60165 , l4.line_number line_number
60166 , CASE r
60167 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
60168 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
60169 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
60170 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
60171 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
60172 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
60173 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
60174 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
60175 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
60176
60177 ELSE null
60178 END object_name
60179 , CASE r
60180 WHEN 1 THEN 'LINE'
60181 WHEN 2 THEN 'LINE'
60182 WHEN 3 THEN 'LINE'
60183 WHEN 4 THEN 'LINE'
60184 WHEN 5 THEN 'LINE'
60185 WHEN 6 THEN 'LINE'
60186 WHEN 7 THEN 'LINE'
60187 WHEN 8 THEN 'LINE'
60188 WHEN 9 THEN 'LINE'
60189
60190 ELSE null
60191 END object_type_code
60192 , CASE r
60193 WHEN 1 THEN '222'
60194 WHEN 2 THEN '222'
60195 WHEN 3 THEN '222'
60196 WHEN 4 THEN '222'
60197 WHEN 5 THEN '222'
60198 WHEN 6 THEN '222'
60199 WHEN 7 THEN '222'
60200 WHEN 8 THEN '222'
60201 WHEN 9 THEN '222'
60202
60203 ELSE null
60204 END source_application_id
60205 , 'S' source_type_code
60206 , CASE r
60207 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
60208 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
60209 WHEN 3 THEN 'TRX_LINE_DIST_ID'
60210 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
60211 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
60212 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
60213 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
60214 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
60215 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
60216
60217 ELSE null
60218 END source_code
60219 , CASE r
60220 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
60221 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
60222 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
60223 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
60224 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
60225 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
60226 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
60227 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
60228 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
60229
60230 ELSE null
60231 END source_value
60232 , null source_meaning
60233 FROM xla_events_gt xet
60234 , AR_CUST_TRX_LINES_BASE_V l3
60235 , AR_CUST_TRX_LINES_L_V l4
60236 , (select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
60237 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
60238 AND xet.event_class_code = C_EVENT_CLASS_CODE
60239 AND l3.event_id = xet.event_id
60240 AND l4.event_id = l3.event_id
60241 AND l4.line_number = l3.line_number
60242
60243 )
60244 ;
60245 --
60246 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
60247
60248 trace
60249 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
60250 ,p_level => C_LEVEL_STATEMENT
60251 ,p_module => l_log_module);
60252
60253 END IF;
60254
60255
60256 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60257 trace
60258 (p_msg => 'END of insert_sources_109'
60259 ,p_level => C_LEVEL_PROCEDURE
60260 ,p_module => l_log_module);
60261 END IF;
60262 EXCEPTION
60263 WHEN xla_exceptions_pkg.application_exception THEN
60264 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
60265 trace
60266 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
60267 ,p_level => C_LEVEL_EXCEPTION
60268 ,p_module => l_log_module);
60269 END IF;
60270 RAISE;
60271 WHEN OTHERS THEN
60272 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
60273 trace
60274 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
60275 ,p_level => C_LEVEL_EXCEPTION
60276 ,p_module => l_log_module);
60277 END IF;
60278 xla_exceptions_pkg.raise_message
60279 (p_location => 'XLA_00222_AAD_S_000007_PKG.insert_sources_109');
60280 END insert_sources_109;
60281 --
60282
60283 ---------------------------------------
60284 --
60285 -- PRIVATE FUNCTION
60286 -- EventClass_109
60287 --
60288 ----------------------------------------
60289 --
60290 FUNCTION EventClass_109
60291 (p_application_id IN NUMBER
60292 ,p_base_ledger_id IN NUMBER
60293 ,p_target_ledger_id IN NUMBER
60294 ,p_language IN VARCHAR2
60295 ,p_currency_code IN VARCHAR2
60296 ,p_sla_ledger_id IN NUMBER
60297 ,p_pad_start_date IN DATE
60298 ,p_pad_end_date IN DATE
60299 ,p_primary_ledger_id IN NUMBER)
60300 RETURN BOOLEAN IS
60301 --
60302 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE_ALL';
60303 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE';
60304
60305 l_calculate_acctd_flag VARCHAR2(1) :='N';
60306 l_calculate_g_l_flag VARCHAR2(1) :='N';
60307 --
60308 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
60309 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
60310 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
60311 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
60312 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
60313 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
60314 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
60315 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
60316 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
60317 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
60318 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
60319 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
60320 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
60321 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
60322 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
60323 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
60324 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
60325 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
60326 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
60327 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
60328 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
60329 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
60330 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
60331 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
60332 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
60333 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
60334
60335 l_event_id NUMBER;
60336 l_previous_event_id NUMBER;
60337 l_first_event_id NUMBER;
60338 l_last_event_id NUMBER;
60339
60340 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
60341 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
60342 --
60343 --
60344 l_result BOOLEAN := TRUE;
60345 l_rows NUMBER := 1000;
60346 l_event_type_name VARCHAR2(80) := 'All';
60347 l_event_class_name VARCHAR2(80) := 'Guarantee';
60348 l_description VARCHAR2(4000);
60349 l_transaction_reversal NUMBER;
60350 l_ae_header_id NUMBER;
60351 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
60352 l_log_module VARCHAR2(240);
60353 --
60354 l_acct_reversal_source VARCHAR2(30);
60355 l_trx_reversal_source VARCHAR2(30);
60356
60357 l_continue_with_lines BOOLEAN := TRUE;
60358 --
60359 l_acc_rev_gl_date_source DATE; -- 4262811
60360 --
60361 type t_array_event_id is table of number index by binary_integer;
60362
60363 l_rec_array_event t_rec_array_event;
60364 l_null_rec_array_event t_rec_array_event;
60365 l_array_ae_header_id xla_number_array_type;
60366 l_actual_flag VARCHAR2(1) := NULL;
60367 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
60368 l_balance_type_code VARCHAR2(1) :=NULL;
60369 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
60370
60371 --
60372 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
60373 --
60374
60375 TYPE t_array_source_25 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
60376 TYPE t_array_source_26 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
60377 TYPE t_array_source_27 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
60378 TYPE t_array_source_32 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
60379 TYPE t_array_source_77 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
60380 TYPE t_array_source_78 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
60381 TYPE t_array_source_79 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
60382
60383 TYPE t_array_source_14 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
60384 TYPE t_array_source_28 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
60385 TYPE t_array_source_29 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
60386 TYPE t_array_source_30 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
60387 TYPE t_array_source_31 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
60388 TYPE t_array_source_33 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
60389 TYPE t_array_source_34 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
60390 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
60391 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
60392
60393 l_array_source_25 t_array_source_25;
60394 l_array_source_26 t_array_source_26;
60395 l_array_source_27 t_array_source_27;
60396 l_array_source_32 t_array_source_32;
60397 l_array_source_77 t_array_source_77;
60398 l_array_source_78 t_array_source_78;
60399 l_array_source_79 t_array_source_79;
60400
60401 l_array_source_14 t_array_source_14;
60402 l_array_source_28 t_array_source_28;
60403 l_array_source_29 t_array_source_29;
60404 l_array_source_30 t_array_source_30;
60405 l_array_source_31 t_array_source_31;
60406 l_array_source_33 t_array_source_33;
60407 l_array_source_34 t_array_source_34;
60408 l_array_source_35 t_array_source_35;
60409 l_array_source_36 t_array_source_36;
60410
60411 --
60412 CURSOR header_cur
60413 IS
60414 SELECT /*+ leading(xet) cardinality(xet,1) */
60415 -- Event Class Code: GUARANTEE
60416 xet.entity_id
60417 ,xet.legal_entity_id
60421 ,xet.event_class_code
60418 ,xet.entity_code
60419 ,xet.transaction_number
60420 ,xet.event_id
60422 ,xet.event_type_code
60423 ,xet.event_number
60424 ,xet.event_date
60425 ,xet.transaction_date
60426 ,xet.reference_num_1
60427 ,xet.reference_num_2
60428 ,xet.reference_num_3
60429 ,xet.reference_num_4
60430 ,xet.reference_char_1
60431 ,xet.reference_char_2
60432 ,xet.reference_char_3
60433 ,xet.reference_char_4
60434 ,xet.reference_date_1
60435 ,xet.reference_date_2
60436 ,xet.reference_date_3
60437 ,xet.reference_date_4
60438 ,xet.event_created_by
60439 ,xet.budgetary_control_flag
60440 , h1.BILL_CUST_ACCOUNT_ID source_25
60441 , h2.BILL_USES_SITE_USE_ID source_26
60442 , h5.XLA_PARTY_TYPE source_27
60443 , h5.TRX_INVOICE_CURRENCY_CODE source_32
60444 , h5.TRX_DOC_SEQUENCE_CATEGORY source_77
60445 , h5.TRX_DOC_SEQUENCE_ID source_78
60446 , h5.TRX_DOC_SEQUENCE_VALUE source_79
60447 FROM xla_events_gt xet
60448 , AR_BILL_TO_CUSTOMERS_S_V h1
60449 , AR_BILL_TO_SITE_USES_S_V h2
60450 , AR_TRANSACTIONS_S_V h5
60451 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
60452 and xet.event_class_code = C_EVENT_CLASS_CODE
60453 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
60454 AND h2.event_id = h1.event_id
60455 AND h5.event_id = h1.event_id
60456
60457 ORDER BY event_id
60458 ;
60459
60460
60461 --
60462 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
60463 IS
60464 SELECT /*+ leading(xet) cardinality(xet,1) */
60465 -- Event Class Code: GUARANTEE
60466 xet.entity_id
60467 ,xet.legal_entity_id
60468 ,xet.entity_code
60469 ,xet.transaction_number
60470 ,xet.event_id
60471 ,xet.event_class_code
60472 ,xet.event_type_code
60473 ,xet.event_number
60474 ,xet.event_date
60475 ,xet.transaction_date
60476 ,xet.reference_num_1
60477 ,xet.reference_num_2
60478 ,xet.reference_num_3
60479 ,xet.reference_num_4
60480 ,xet.reference_char_1
60481 ,xet.reference_char_2
60482 ,xet.reference_char_3
60483 ,xet.reference_char_4
60484 ,xet.reference_date_1
60485 ,xet.reference_date_2
60486 ,xet.reference_date_3
60487 ,xet.reference_date_4
60488 ,xet.event_created_by
60489 ,xet.budgetary_control_flag
60490 , l3.LINE_NUMBER
60491 , l4.TRX_LINE_DIST_CCID source_14
60492 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_28
60493 , l4.TRX_LINE_DIST_ID source_29
60494 , l4.TRX_DISTRIBUTION_TYPE source_30
60495 , l4.TRX_LINE_DIST_AMT source_31
60496 , l3.TRX_LINE_CUR_CONVERSION_DATE source_33
60497 , l3.TRX_LINE_CUR_CONVERSION_RATE source_34
60498 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_35
60499 , l3.TRX_LINE_ACCTD_AMT source_36
60500 FROM xla_events_gt xet
60501 , AR_CUST_TRX_LINES_BASE_V l3
60502 , AR_CUST_TRX_LINES_L_V l4
60503 WHERE xet.event_id between x_first_event_id and x_last_event_id
60504 and xet.event_date between p_pad_start_date and p_pad_end_date
60505 and xet.event_class_code = C_EVENT_CLASS_CODE
60506 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
60507 AND l4.event_id = l3.event_id
60508 AND l4.line_number = l3.line_number
60509 ;
60510
60511 --
60512 BEGIN
60513 IF g_log_enabled THEN
60514 l_log_module := C_DEFAULT_MODULE||'.EventClass_109';
60515 END IF;
60516 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60517 trace
60518 (p_msg => 'BEGIN of EventClass_109'
60519 ,p_level => C_LEVEL_PROCEDURE
60520 ,p_module => l_log_module);
60521 END IF;
60522
60523 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
60524 trace
60525 (p_msg => 'p_application_id = '||p_application_id||
60526 ' - p_base_ledger_id = '||p_base_ledger_id||
60527 ' - p_target_ledger_id = '||p_target_ledger_id||
60528 ' - p_language = '||p_language||
60529 ' - p_currency_code = '||p_currency_code||
60530 ' - p_sla_ledger_id = '||p_sla_ledger_id
60531 ,p_level => C_LEVEL_STATEMENT
60532 ,p_module => l_log_module);
60533 END IF;
60534 --
60535 -- initialze arrays
60536 --
60537 g_array_event.DELETE;
60538 l_rec_array_event := l_null_rec_array_event;
60539 --
60540 --------------------------------------
60541 -- 4262811 Initialze MPA Line Number
60542 --------------------------------------
60543 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
60544
60545 --
60546
60547 --
60548 OPEN header_cur;
60549 --
60550 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
60551 trace
60552 (p_msg => 'SQL - FETCH header_cur'
60553 ,p_level => C_LEVEL_STATEMENT
60554 ,p_module => l_log_module);
60555 END IF;
60556 --
60557 LOOP
60558 FETCH header_cur BULK COLLECT INTO
60559 l_array_entity_id
60560 , l_array_legal_entity_id
60561 , l_array_entity_code
60562 , l_array_transaction_num
60563 , l_array_event_id
60564 , l_array_class_code
60565 , l_array_event_type
60566 , l_array_event_number
60567 , l_array_event_date
60568 , l_array_transaction_date
60569 , l_array_reference_num_1
60570 , l_array_reference_num_2
60571 , l_array_reference_num_3
60572 , l_array_reference_num_4
60573 , l_array_reference_char_1
60574 , l_array_reference_char_2
60575 , l_array_reference_char_3
60576 , l_array_reference_char_4
60577 , l_array_reference_date_1
60578 , l_array_reference_date_2
60579 , l_array_reference_date_3
60580 , l_array_reference_date_4
60581 , l_array_event_created_by
60582 , l_array_budgetary_control_flag
60583 , l_array_source_25
60584 , l_array_source_26
60585 , l_array_source_27
60586 , l_array_source_32
60587 , l_array_source_77
60588 , l_array_source_78
60589 , l_array_source_79
60590 LIMIT l_rows;
60591 --
60592 IF (C_LEVEL_EVENT >= g_log_level) THEN
60593 trace
60594 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
60595 ,p_level => C_LEVEL_EVENT
60596 ,p_module => l_log_module);
60597 END IF;
60598 --
60599 EXIT WHEN l_array_entity_id.COUNT = 0;
60600
60601 -- initialize arrays
60602 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
60603 XLA_AE_LINES_PKG.g_rec_lines := NULL;
60604
60605 --
60606 -- Bug 4458708
60607 --
60608 XLA_AE_LINES_PKG.g_LineNumber := 0;
60609
60610
60611 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
60612 g_last_hdr_idx := l_array_event_id.LAST;
60613 --
60614 -- loop for the headers. Each iteration is for each header extract row
60615 -- fetched in header cursor
60616 --
60617 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
60618
60619 --
60620 -- set event info as cache for other routines to refer event attributes
60621 --
60622 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
60623 (p_application_id => p_application_id
60624 ,p_primary_ledger_id => p_primary_ledger_id
60625 ,p_base_ledger_id => p_base_ledger_id
60626 ,p_target_ledger_id => p_target_ledger_id
60627 ,p_entity_id => l_array_entity_id(hdr_idx)
60628 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
60629 ,p_entity_code => l_array_entity_code(hdr_idx)
60630 ,p_transaction_num => l_array_transaction_num(hdr_idx)
60631 ,p_event_id => l_array_event_id(hdr_idx)
60632 ,p_event_class_code => l_array_class_code(hdr_idx)
60633 ,p_event_type_code => l_array_event_type(hdr_idx)
60634 ,p_event_number => l_array_event_number(hdr_idx)
60635 ,p_event_date => l_array_event_date(hdr_idx)
60636 ,p_transaction_date => l_array_transaction_date(hdr_idx)
60637 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
60638 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
60639 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
60640 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
60641 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
60642 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
60643 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
60644 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
60645 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
60646 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
60647 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
60648 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
60649 ,p_event_created_by => l_array_event_created_by(hdr_idx)
60650 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
60651
60652 --
60653 -- set the status of entry to C_VALID (0)
60654 --
60655 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
60656
60657 --
60658 -- initialize a row for ae header
60659 --
60660 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
60661
60662 l_event_id := l_array_event_id(hdr_idx);
60663
60664 --
60665 -- storing the hdr_idx for event. May be used by line cursor.
60666 --
60667 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
60668
60669 --
60670 -- store sources from header extract. This can be improved to
60671 -- store only those sources from header extract that may be used in lines
60672 --
60673
60674 g_array_event(l_event_id).array_value_num('source_25') := l_array_source_25(hdr_idx);
60675 g_array_event(l_event_id).array_value_num('source_26') := l_array_source_26(hdr_idx);
60676 g_array_event(l_event_id).array_value_char('source_27') := l_array_source_27(hdr_idx);
60677 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
60678 g_array_event(l_event_id).array_value_char('source_77') := l_array_source_77(hdr_idx);
60679 g_array_event(l_event_id).array_value_num('source_78') := l_array_source_78(hdr_idx);
60680 g_array_event(l_event_id).array_value_num('source_79') := l_array_source_79(hdr_idx);
60681
60682 --
60683 -- initilaize the status of ae headers for diffrent balance types
60684 -- the status is initialised to C_NOT_CREATED (2)
60685 --
60686 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
60687 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
60688 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
60689
60690 --
60691 -- call api to validate and store accounting attributes for header
60692 --
60693
60694 ------------------------------------------------------------
60695 -- Accrual Reversal : to get date for Standard Source (NONE)
60696 ------------------------------------------------------------
60697 l_acc_rev_gl_date_source := NULL;
60698
60699 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
60700 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_77');
60701 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
60702 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_78');
60703 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
60704 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_79');
60705 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
60706 l_rec_acct_attrs.array_date_value(4) :=
60707 xla_ae_sources_pkg.GetSystemSourceDate(
60708 p_source_code => 'XLA_EVENT_DATE'
60709 , p_source_type_code => 'Y'
60710 , p_source_application_id => 602
60711 );
60712
60713
60714 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
60715
60716 XLA_AE_HEADER_PKG.SetJeCategoryName;
60717
60718 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
60719 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
60720 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
60721 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
60722 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
60723
60724
60725 -- No header level analytical criteria
60726
60727 --
60728 --accounting attribute enhancement, bug 3612931
60729 --
60730 l_trx_reversal_source := SUBSTR(NULL, 1,30);
60731
60732 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
60733 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
60734
60735 xla_accounting_err_pkg.build_message
60736 (p_appli_s_name => 'XLA'
60737 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
60738 ,p_token_1 => 'ACCT_ATTR_NAME'
60739 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
60740 ,p_token_2 => 'PRODUCT_NAME'
60741 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
60742 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
60743 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
60744 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
60745
60746 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
60747 --
60748 -- following sets the accounting attributes needed to reverse
60749 -- accounting for a distributeion
60750 --
60751 xla_ae_lines_pkg.SetTrxReversalAttrs
60755
60752 (p_event_id => l_event_id
60753 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
60754 ,p_trx_reversal_source => l_trx_reversal_source);
60756 END IF;
60757
60758
60759 ----------------------------------------------------------------
60760 -- 4262811 - update the header statuses to invalid in need be
60761 ----------------------------------------------------------------
60762 --
60763 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
60764
60765
60766 -----------------------------------------------
60767 -- No accrual reversal for the event class/type
60768 -----------------------------------------------
60769 ----------------------------------------------------------------
60770
60771 --
60772 -- this ends the header loop iteration for one bulk fetch
60773 --
60774 END LOOP;
60775
60776 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
60777 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
60778
60779 --
60780 -- insert dummy rows into lines gt table that were created due to
60781 -- transaction reversals
60782 --
60783 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
60784 l_result := XLA_AE_LINES_PKG.InsertLines;
60785 END IF;
60786
60787 --
60788 -- reset the temp_line_num for each set of events fetched from header
60789 -- cursor rather than doing it for each new event in line cursor
60790 -- Bug 3939231
60791 --
60792 xla_ae_lines_pkg.g_temp_line_num := 0;
60793
60794
60795
60796 --
60797 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
60798 --
60799 --
60800 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
60801
60802 trace
60803 (p_msg => 'SQL - FETCH line_cur'
60804 ,p_level => C_LEVEL_STATEMENT
60805 ,p_module => l_log_module);
60806
60807 END IF;
60808 --
60809 --
60810 LOOP
60811 --
60812 FETCH line_cur BULK COLLECT INTO
60813 l_array_entity_id
60814 , l_array_legal_entity_id
60815 , l_array_entity_code
60816 , l_array_transaction_num
60817 , l_array_event_id
60818 , l_array_class_code
60819 , l_array_event_type
60820 , l_array_event_number
60821 , l_array_event_date
60822 , l_array_transaction_date
60823 , l_array_reference_num_1
60824 , l_array_reference_num_2
60825 , l_array_reference_num_3
60826 , l_array_reference_num_4
60827 , l_array_reference_char_1
60828 , l_array_reference_char_2
60829 , l_array_reference_char_3
60830 , l_array_reference_char_4
60831 , l_array_reference_date_1
60832 , l_array_reference_date_2
60833 , l_array_reference_date_3
60834 , l_array_reference_date_4
60835 , l_array_event_created_by
60836 , l_array_budgetary_control_flag
60837 , l_array_extract_line_num
60838 , l_array_source_14
60839 , l_array_source_28
60840 , l_array_source_29
60841 , l_array_source_30
60842 , l_array_source_31
60843 , l_array_source_33
60844 , l_array_source_34
60845 , l_array_source_35
60846 , l_array_source_36
60847 LIMIT l_rows;
60848
60849 --
60850 IF (C_LEVEL_EVENT >= g_log_level) THEN
60851 trace
60852 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
60853 ,p_level => C_LEVEL_EVENT
60854 ,p_module => l_log_module);
60855 END IF;
60856 --
60857 EXIT WHEN l_array_entity_id.count = 0;
60858
60859 XLA_AE_LINES_PKG.g_rec_lines := null;
60860
60861 --
60862 -- Bug 4458708
60863 --
60864 XLA_AE_LINES_PKG.g_LineNumber := 0;
60865 --
60866 --
60867
60868 FOR Idx IN 1..l_array_event_id.count LOOP
60869 --
60870 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
60871 --
60872 l_event_id := l_array_event_id(idx); -- 5648433
60873
60874 --
60875 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
60876 --
60877
60878 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
60879 (g_array_event(l_event_id).array_value_num('header_index'))
60880 ,'N'
60881 ) <> 'Y'
60882 THEN
60883 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
60884 trace
60885 (p_msg => 'Trancaction revesal option is not Y '
60886 ,p_level => C_LEVEL_STATEMENT
60887 ,p_module => l_log_module);
60888 END IF;
60889
60890 --
60891 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
60892 --
60893 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
60894 --
60895 -- set event info as cache for other routines to refer event attributes
60896 --
60897
60898 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
60899 l_previous_event_id := l_event_id;
60900
60901 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
60902 (p_application_id => p_application_id
60903 ,p_primary_ledger_id => p_primary_ledger_id
60904 ,p_base_ledger_id => p_base_ledger_id
60905 ,p_target_ledger_id => p_target_ledger_id
60906 ,p_entity_id => l_array_entity_id(Idx)
60907 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
60908 ,p_entity_code => l_array_entity_code(Idx)
60909 ,p_transaction_num => l_array_transaction_num(Idx)
60910 ,p_event_id => l_array_event_id(Idx)
60911 ,p_event_class_code => l_array_class_code(Idx)
60912 ,p_event_type_code => l_array_event_type(Idx)
60913 ,p_event_number => l_array_event_number(Idx)
60914 ,p_event_date => l_array_event_date(Idx)
60915 ,p_transaction_date => l_array_transaction_date(Idx)
60916 ,p_reference_num_1 => l_array_reference_num_1(Idx)
60917 ,p_reference_num_2 => l_array_reference_num_2(Idx)
60918 ,p_reference_num_3 => l_array_reference_num_3(Idx)
60919 ,p_reference_num_4 => l_array_reference_num_4(Idx)
60920 ,p_reference_char_1 => l_array_reference_char_1(Idx)
60921 ,p_reference_char_2 => l_array_reference_char_2(Idx)
60922 ,p_reference_char_3 => l_array_reference_char_3(Idx)
60923 ,p_reference_char_4 => l_array_reference_char_4(Idx)
60924 ,p_reference_date_1 => l_array_reference_date_1(Idx)
60925 ,p_reference_date_2 => l_array_reference_date_2(Idx)
60926 ,p_reference_date_3 => l_array_reference_date_3(Idx)
60927 ,p_reference_date_4 => l_array_reference_date_4(Idx)
60928 ,p_event_created_by => l_array_event_created_by(Idx)
60929 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
60930 --
60931 END IF;
60932
60933
60934
60935 --
60936 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
60937
60938 l_acct_reversal_source := SUBSTR(NULL, 1,30);
60939
60940 IF l_continue_with_lines THEN
60941 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
60942 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
60943
60944 xla_accounting_err_pkg.build_message
60945 (p_appli_s_name => 'XLA'
60946 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
60947 ,p_token_1 => 'LINE_NUMBER'
60948 ,p_value_1 => l_array_extract_line_num(Idx)
60949 ,p_token_2 => 'PRODUCT_NAME'
60950 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
60951 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
60952 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
60953 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
60954
60955 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
60956 --
60957 -- following sets the accounting attributes needed to reverse
60958 -- accounting for a distributeion
60959 --
60960
60961 --
60962 -- 5217187
60963 --
60964 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
60965 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
60966 g_array_event(l_event_id).array_value_num('header_index'));
60967 --
60968 --
60969
60970 -- No reversal code generated
60971
60972 xla_ae_lines_pkg.SetAcctReversalAttrs
60973 (p_event_id => l_event_id
60974 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
60975 ,p_calculate_acctd_flag => l_calculate_acctd_flag
60976 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
60977 END IF;
60978
60979 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
60980 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
60981
60982 --
60983 AcctLineType_44 (
60984 p_application_id => p_application_id
60985 ,p_event_id => l_event_id
60986 ,p_calculate_acctd_flag => l_calculate_acctd_flag
60987 ,p_calculate_g_l_flag => l_calculate_g_l_flag
60988 ,p_actual_flag => l_actual_flag
60989 ,p_balance_type_code => l_balance_type_code
60990 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
60991
60992 , p_source_14 => l_array_source_14(Idx)
60993 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
60994 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
60995 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
60996 , p_source_28 => l_array_source_28(Idx)
60997 , p_source_29 => l_array_source_29(Idx)
60998 , p_source_30 => l_array_source_30(Idx)
60999 , p_source_31 => l_array_source_31(Idx)
61000 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
61001 , p_source_33 => l_array_source_33(Idx)
61002 , p_source_34 => l_array_source_34(Idx)
61003 , p_source_35 => l_array_source_35(Idx)
61004 , p_source_36 => l_array_source_36(Idx)
61005 );
61006 If(l_balance_type_code = 'A') THEN
61007 l_actual_gain_loss_ref := l_gain_or_loss_ref;
61008 END IF;
61009
61010 --
61011
61012
61013 --
61014 AcctLineType_45 (
61015 p_application_id => p_application_id
61016 ,p_event_id => l_event_id
61017 ,p_calculate_acctd_flag => l_calculate_acctd_flag
61018 ,p_calculate_g_l_flag => l_calculate_g_l_flag
61019 ,p_actual_flag => l_actual_flag
61020 ,p_balance_type_code => l_balance_type_code
61021 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
61022
61023 , p_source_14 => l_array_source_14(Idx)
61024 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
61025 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
61026 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
61027 , p_source_28 => l_array_source_28(Idx)
61028 , p_source_29 => l_array_source_29(Idx)
61029 , p_source_30 => l_array_source_30(Idx)
61030 , p_source_31 => l_array_source_31(Idx)
61031 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
61032 , p_source_33 => l_array_source_33(Idx)
61033 , p_source_34 => l_array_source_34(Idx)
61034 , p_source_35 => l_array_source_35(Idx)
61035 , p_source_36 => l_array_source_36(Idx)
61036 );
61037 If(l_balance_type_code = 'A') THEN
61038 l_actual_gain_loss_ref := l_gain_or_loss_ref;
61039 END IF;
61040
61041 --
61042
61043 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
61044 -- or secondary ledger that has different currency with primary
61045 -- or alc that is calculated by sla
61046 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
61047 (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'))
61048
61049 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
61050 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
61051 AND (l_actual_flag = 'A')) THEN
61052 XLA_AE_LINES_PKG.CreateGainOrLossLines(
61053 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
61054 ,p_application_id => p_application_id
61055 ,p_amb_context_code => 'DEFAULT'
61056 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
61057 ,p_event_class_code => C_EVENT_CLASS_CODE
61058 ,p_event_type_code => C_EVENT_TYPE_CODE
61059
61060 ,p_gain_ccid => -1
61061 ,p_loss_ccid => -1
61062
61063 ,p_actual_flag => l_actual_flag
61064 ,p_enc_flag => null
61065 ,p_actual_g_l_ref => l_actual_gain_loss_ref
61066 ,p_enc_g_l_ref => null
61067 );
61068 END IF;
61069 END IF;
61070 END IF;
61071
61072 ELSE
61073 --
61074 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
61075 --
61076 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
61077 trace
61078 (p_msg => 'Trancaction revesal option is Y'
61079 ,p_level => C_LEVEL_STATEMENT
61080 ,p_module => l_log_module);
61081 END IF;
61082 END IF;
61083
61084 END LOOP;
61085 l_result := XLA_AE_LINES_PKG.InsertLines ;
61086 end loop;
61087 close line_cur;
61088
61089
61090 --
61091 -- insert headers into xla_ae_headers_gt table
61092 --
61093 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
61094
61095 -- insert into errors table here.
61096
61097 END LOOP;
61098
61099 --
61100 -- 4865292
61101 --
61105 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
61102 -- Compare g_hdr_extract_count with event count in
61103 -- CreateHeadersAndLines.
61104 --
61106
61107 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
61108 trace (p_msg => '# rows extracted from header extract objects '
61109 || ' (running total): '
61110 || g_hdr_extract_count
61111 ,p_level => C_LEVEL_STATEMENT
61112 ,p_module => l_log_module);
61113 END IF;
61114
61115 CLOSE header_cur;
61116 --
61117
61118 --
61119 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61120 trace
61121 (p_msg => 'END of EventClass_109'
61122 ,p_level => C_LEVEL_PROCEDURE
61123 ,p_module => l_log_module);
61124 END IF;
61125 --
61126 RETURN l_result;
61127 EXCEPTION
61128 WHEN xla_exceptions_pkg.application_exception THEN
61129
61130 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
61131
61132
61133 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
61134
61135 RAISE;
61136
61137 WHEN NO_DATA_FOUND THEN
61138
61139 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
61140 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
61141
61142 FOR header_record IN header_cur
61143 LOOP
61144 l_array_header_events(header_record.event_id) := header_record.event_id;
61145 END LOOP;
61146
61147 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
61148 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
61149
61150 fnd_file.put_line(fnd_file.LOG, ' ');
61151 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
61152 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
61153 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
61154
61155 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
61156 LOOP
61157 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
61158 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
61159 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
61160 END IF;
61161 END LOOP;
61162
61163 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
61164 fnd_file.put_line(fnd_file.LOG, ' ');
61165
61166
61167 xla_exceptions_pkg.raise_message
61168 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_109');
61169
61170
61171 WHEN OTHERS THEN
61172 xla_exceptions_pkg.raise_message
61173 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_109');
61174 END EventClass_109;
61175 --
61176
61177 ---------------------------------------
61178 --
61179 -- PRIVATE PROCEDURE
61180 -- insert_sources_110
61181 --
61182 ----------------------------------------
61183 --
61184 PROCEDURE insert_sources_110(
61185 p_target_ledger_id IN NUMBER
61186 , p_language IN VARCHAR2
61187 , p_sla_ledger_id IN NUMBER
61188 , p_pad_start_date IN DATE
61189 , p_pad_end_date IN DATE
61190 )
61191 IS
61192
61193 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'INVOICE_ALL';
61194 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'INVOICE';
61195 p_apps_owner VARCHAR2(30);
61196 l_log_module VARCHAR2(240);
61197 BEGIN
61198 IF g_log_enabled THEN
61199 l_log_module := C_DEFAULT_MODULE||'.insert_sources_110';
61200 END IF;
61201 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61202
61203 trace
61204 (p_msg => 'BEGIN of insert_sources_110'
61205 ,p_level => C_LEVEL_PROCEDURE
61206 ,p_module => l_log_module);
61207
61208 END IF;
61209
61210 -- select APPS owner
61211 SELECT oracle_username
61212 INTO p_apps_owner
61213 FROM fnd_oracle_userid
61214 WHERE read_only_flag = 'U'
61215 ;
61216
61217 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
61218 trace
61219 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
61220 ' - p_language = '||p_language||
61221 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
61222 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
61223 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
61224 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
61225 ,p_level => C_LEVEL_STATEMENT
61226 ,p_module => l_log_module);
61227 END IF;
61228
61229
61230 --
61231 INSERT INTO xla_diag_sources --hdr2
61232 (
61233 event_id
61234 , ledger_id
61235 , sla_ledger_id
61236 , description_language
61237 , object_name
61238 , object_type_code
61239 , line_number
61240 , source_application_id
61241 , source_type_code
61242 , source_code
61243 , source_value
61244 , source_meaning
61245 , created_by
61246 , creation_date
61247 , last_update_date
61248 , last_updated_by
61249 , last_update_login
61250 , program_update_date
61254 )
61251 , program_application_id
61252 , program_id
61253 , request_id
61255 SELECT
61256 event_id
61257 , p_target_ledger_id
61258 , p_sla_ledger_id
61259 , p_language
61260 , object_name
61261 , object_type_code
61262 , line_number
61263 , source_application_id
61264 , source_type_code
61265 , source_code
61266 , SUBSTR(source_value ,1,1996)
61267 , SUBSTR(source_meaning ,1,200)
61268 , xla_environment_pkg.g_Usr_Id
61269 , TRUNC(SYSDATE)
61270 , TRUNC(SYSDATE)
61271 , xla_environment_pkg.g_Usr_Id
61272 , xla_environment_pkg.g_Login_Id
61273 , TRUNC(SYSDATE)
61274 , xla_environment_pkg.g_Prog_Appl_Id
61275 , xla_environment_pkg.g_Prog_Id
61276 , xla_environment_pkg.g_Req_Id
61277 FROM (
61278 SELECT xet.event_id event_id
61279 , 0 line_number
61280 , CASE r
61281 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
61282 WHEN 2 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
61283 WHEN 3 THEN 'AR_BILL_TO_SITE_USES_S_V'
61284 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
61285 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
61286 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
61287 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
61288 WHEN 8 THEN 'AR_TRANSACTIONS_S_V'
61289 WHEN 9 THEN 'AR_TRANSACTIONS_S_V'
61290
61291 ELSE null
61292 END object_name
61293 , CASE r
61294 WHEN 1 THEN 'HEADER'
61295 WHEN 2 THEN 'HEADER'
61296 WHEN 3 THEN 'HEADER'
61297 WHEN 4 THEN 'HEADER'
61298 WHEN 5 THEN 'HEADER'
61299 WHEN 6 THEN 'HEADER'
61300 WHEN 7 THEN 'HEADER'
61301 WHEN 8 THEN 'HEADER'
61302 WHEN 9 THEN 'HEADER'
61303
61304 ELSE null
61305 END object_type_code
61306 , CASE r
61307 WHEN 1 THEN '222'
61308 WHEN 2 THEN '222'
61309 WHEN 3 THEN '222'
61310 WHEN 4 THEN '222'
61311 WHEN 5 THEN '222'
61312 WHEN 6 THEN '222'
61313 WHEN 7 THEN '222'
61314 WHEN 8 THEN '222'
61315 WHEN 9 THEN '222'
61316
61317 ELSE null
61318 END source_application_id
61319 , 'S' source_type_code
61320 , CASE r
61321 WHEN 1 THEN 'TRX_RECEIVABLE_CCID'
61322 WHEN 2 THEN 'BILL_CUST_ACCOUNT_ID'
61323 WHEN 3 THEN 'BILL_USES_SITE_USE_ID'
61324 WHEN 4 THEN 'XLA_PARTY_TYPE'
61325 WHEN 5 THEN 'TRX_INVOICE_CURRENCY_CODE'
61326 WHEN 6 THEN 'TRX_INVOICING_RULE_ID'
61327 WHEN 7 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
61328 WHEN 8 THEN 'TRX_DOC_SEQUENCE_ID'
61329 WHEN 9 THEN 'TRX_DOC_SEQUENCE_VALUE'
61330
61331 ELSE null
61332 END source_code
61333 , CASE r
61334 WHEN 1 THEN TO_CHAR(h5.TRX_RECEIVABLE_CCID)
61335 WHEN 2 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
61336 WHEN 3 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
61337 WHEN 4 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
61338 WHEN 5 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
61339 WHEN 6 THEN TO_CHAR(h5.TRX_INVOICING_RULE_ID)
61340 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
61341 WHEN 8 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
61342 WHEN 9 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
61343
61344 ELSE null
61345 END source_value
61346 , null source_meaning
61347 FROM xla_events_gt xet
61348 , AR_BILL_TO_CUSTOMERS_S_V h1
61349 , AR_BILL_TO_SITE_USES_S_V h2
61350 , AR_TRANSACTIONS_S_V h5
61351 ,(select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
61352 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
61353 AND xet.event_class_code = C_EVENT_CLASS_CODE
61354 AND h1.event_id = xet.event_id
61355 AND h2.event_id = h1.event_id
61356 AND h5.event_id = h1.event_id
61357
61358 )
61359 ;
61360 --
61361 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
61362
61363 trace
61364 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
61365 ,p_level => C_LEVEL_STATEMENT
61366 ,p_module => l_log_module);
61367
61368 END IF;
61369 --
61370
61371
61372
61373 --
61374 INSERT INTO xla_diag_sources --line2
61375 (
61376 event_id
61377 , ledger_id
61378 , sla_ledger_id
61379 , description_language
61380 , object_name
61381 , object_type_code
61382 , line_number
61383 , source_application_id
61384 , source_type_code
61385 , source_code
61386 , source_value
61387 , source_meaning
61388 , created_by
61389 , creation_date
61390 , last_update_date
61391 , last_updated_by
61392 , last_update_login
61393 , program_update_date
61394 , program_application_id
61395 , program_id
61396 , request_id
61397 )
61398 SELECT event_id
61399 , p_target_ledger_id
61400 , p_sla_ledger_id
61401 , p_language
61402 , object_name
61403 , object_type_code
61404 , line_number
61405 , source_application_id
61406 , source_type_code
61407 , source_code
61408 , SUBSTR(source_value,1,1996)
61409 , SUBSTR(source_meaning ,1,200)
61410 , xla_environment_pkg.g_Usr_Id
61411 , TRUNC(SYSDATE)
61412 , TRUNC(SYSDATE)
61413 , xla_environment_pkg.g_Usr_Id
61414 , xla_environment_pkg.g_Login_Id
61415 , TRUNC(SYSDATE)
61416 , xla_environment_pkg.g_Prog_Appl_Id
61417 , xla_environment_pkg.g_Prog_Id
61418 , xla_environment_pkg.g_Req_Id
61419 FROM (
61420 SELECT xet.event_id event_id
61421 , l4.line_number line_number
61422 , CASE r
61423 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
61424 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
61425 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
61426 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
61427 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
61428 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
61429 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
61430 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
61431 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
61432 WHEN 10 THEN 'AR_CUST_TRX_LINES_L_V'
61433 WHEN 11 THEN 'AR_CUST_TRX_LINES_BASE_V'
61434
61435 ELSE null
61436 END object_name
61437 , CASE r
61438 WHEN 1 THEN 'LINE'
61439 WHEN 2 THEN 'LINE'
61440 WHEN 3 THEN 'LINE'
61441 WHEN 4 THEN 'LINE'
61442 WHEN 5 THEN 'LINE'
61443 WHEN 6 THEN 'LINE'
61444 WHEN 7 THEN 'LINE'
61445 WHEN 8 THEN 'LINE'
61446 WHEN 9 THEN 'LINE'
61447 WHEN 10 THEN 'LINE'
61448 WHEN 11 THEN 'LINE'
61449
61450 ELSE null
61451 END object_type_code
61452 , CASE r
61453 WHEN 1 THEN '222'
61454 WHEN 2 THEN '222'
61455 WHEN 3 THEN '222'
61456 WHEN 4 THEN '222'
61457 WHEN 5 THEN '222'
61458 WHEN 6 THEN '222'
61459 WHEN 7 THEN '222'
61460 WHEN 8 THEN '222'
61461 WHEN 9 THEN '222'
61462 WHEN 10 THEN '222'
61463 WHEN 11 THEN '222'
61464
61465 ELSE null
61466 END source_application_id
61467 , 'S' source_type_code
61468 , CASE r
61469 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
61470 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
61471 WHEN 3 THEN 'TRX_LINE_DIST_ID'
61472 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
61473 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
61474 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
61475 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
61476 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
61477 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
61478 WHEN 10 THEN 'TRX_TAX_LINE_ID'
61479 WHEN 11 THEN 'ROUNDING_CORRECTION_FLAG'
61480
61481 ELSE null
61482 END source_code
61486 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
61483 , CASE r
61484 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
61485 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
61487 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
61488 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
61489 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
61490 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
61491 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
61492 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
61493 WHEN 10 THEN TO_CHAR(l4.TRX_TAX_LINE_ID)
61494 WHEN 11 THEN TO_CHAR(l3.ROUNDING_CORRECTION_FLAG)
61495
61496 ELSE null
61497 END source_value
61498 , null source_meaning
61499 FROM xla_events_gt xet
61500 , AR_CUST_TRX_LINES_BASE_V l3
61501 , AR_CUST_TRX_LINES_L_V l4
61502 , (select rownum r from all_objects where rownum <= 11 and owner = p_apps_owner)
61503 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
61504 AND xet.event_class_code = C_EVENT_CLASS_CODE
61505 AND l3.event_id = xet.event_id
61506 AND l4.event_id = l3.event_id
61507 AND l4.line_number = l3.line_number
61508
61509 )
61510 ;
61511 --
61512 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
61513
61514 trace
61515 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
61516 ,p_level => C_LEVEL_STATEMENT
61517 ,p_module => l_log_module);
61518
61519 END IF;
61520
61521
61522 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61523 trace
61524 (p_msg => 'END of insert_sources_110'
61525 ,p_level => C_LEVEL_PROCEDURE
61526 ,p_module => l_log_module);
61527 END IF;
61528 EXCEPTION
61529 WHEN xla_exceptions_pkg.application_exception THEN
61530 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
61531 trace
61532 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
61533 ,p_level => C_LEVEL_EXCEPTION
61534 ,p_module => l_log_module);
61535 END IF;
61536 RAISE;
61537 WHEN OTHERS THEN
61538 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
61539 trace
61540 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
61541 ,p_level => C_LEVEL_EXCEPTION
61542 ,p_module => l_log_module);
61543 END IF;
61544 xla_exceptions_pkg.raise_message
61545 (p_location => 'XLA_00222_AAD_S_000007_PKG.insert_sources_110');
61546 END insert_sources_110;
61547 --
61548
61549 ---------------------------------------
61550 --
61551 -- PRIVATE FUNCTION
61552 -- EventClass_110
61553 --
61554 ----------------------------------------
61555 --
61556 FUNCTION EventClass_110
61557 (p_application_id IN NUMBER
61558 ,p_base_ledger_id IN NUMBER
61559 ,p_target_ledger_id IN NUMBER
61560 ,p_language IN VARCHAR2
61561 ,p_currency_code IN VARCHAR2
61562 ,p_sla_ledger_id IN NUMBER
61563 ,p_pad_start_date IN DATE
61564 ,p_pad_end_date IN DATE
61565 ,p_primary_ledger_id IN NUMBER)
61566 RETURN BOOLEAN IS
61567 --
61568 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'INVOICE_ALL';
61569 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'INVOICE';
61570
61571 l_calculate_acctd_flag VARCHAR2(1) :='N';
61572 l_calculate_g_l_flag VARCHAR2(1) :='N';
61573 --
61574 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
61575 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
61576 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
61577 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
61578 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
61579 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
61580 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
61581 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
61582 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
61583 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
61584 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
61585 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
61586 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
61587 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
61588 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
61589 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
61590 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
61591 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
61592 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
61593 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
61594 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
61595 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
61596 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
61597 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
61598 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
61602 l_previous_event_id NUMBER;
61599 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
61600
61601 l_event_id NUMBER;
61603 l_first_event_id NUMBER;
61604 l_last_event_id NUMBER;
61605
61606 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
61607 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
61608 --
61609 --
61610 l_result BOOLEAN := TRUE;
61611 l_rows NUMBER := 1000;
61612 l_event_type_name VARCHAR2(80) := 'All';
61613 l_event_class_name VARCHAR2(80) := 'Invoice';
61614 l_description VARCHAR2(4000);
61615 l_transaction_reversal NUMBER;
61616 l_ae_header_id NUMBER;
61617 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
61618 l_log_module VARCHAR2(240);
61619 --
61620 l_acct_reversal_source VARCHAR2(30);
61621 l_trx_reversal_source VARCHAR2(30);
61622
61623 l_continue_with_lines BOOLEAN := TRUE;
61624 --
61625 l_acc_rev_gl_date_source DATE; -- 4262811
61626 --
61627 type t_array_event_id is table of number index by binary_integer;
61628
61629 l_rec_array_event t_rec_array_event;
61630 l_null_rec_array_event t_rec_array_event;
61631 l_array_ae_header_id xla_number_array_type;
61632 l_actual_flag VARCHAR2(1) := NULL;
61633 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
61634 l_balance_type_code VARCHAR2(1) :=NULL;
61635 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
61636
61637 --
61638 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
61639 --
61640
61641 TYPE t_array_source_8 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_RECEIVABLE_CCID%TYPE INDEX BY BINARY_INTEGER;
61642 TYPE t_array_source_25 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
61643 TYPE t_array_source_26 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
61644 TYPE t_array_source_27 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
61645 TYPE t_array_source_32 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
61646 TYPE t_array_source_53 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICING_RULE_ID%TYPE INDEX BY BINARY_INTEGER;
61647 TYPE t_array_source_77 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
61648 TYPE t_array_source_78 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
61649 TYPE t_array_source_79 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
61650
61651 TYPE t_array_source_14 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
61652 TYPE t_array_source_28 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
61653 TYPE t_array_source_29 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
61654 TYPE t_array_source_30 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
61655 TYPE t_array_source_31 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
61656 TYPE t_array_source_33 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
61657 TYPE t_array_source_34 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
61658 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
61659 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
61660 TYPE t_array_source_50 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_TAX_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
61661 TYPE t_array_source_51 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.ROUNDING_CORRECTION_FLAG%TYPE INDEX BY BINARY_INTEGER;
61662
61663 l_array_source_8 t_array_source_8;
61664 l_array_source_25 t_array_source_25;
61665 l_array_source_26 t_array_source_26;
61666 l_array_source_27 t_array_source_27;
61667 l_array_source_32 t_array_source_32;
61668 l_array_source_53 t_array_source_53;
61669 l_array_source_77 t_array_source_77;
61670 l_array_source_78 t_array_source_78;
61671 l_array_source_79 t_array_source_79;
61672
61673 l_array_source_14 t_array_source_14;
61674 l_array_source_28 t_array_source_28;
61675 l_array_source_29 t_array_source_29;
61676 l_array_source_30 t_array_source_30;
61677 l_array_source_31 t_array_source_31;
61678 l_array_source_33 t_array_source_33;
61679 l_array_source_34 t_array_source_34;
61680 l_array_source_35 t_array_source_35;
61681 l_array_source_36 t_array_source_36;
61682 l_array_source_50 t_array_source_50;
61683 l_array_source_51 t_array_source_51;
61684
61685 --
61686 CURSOR header_cur
61687 IS
61688 SELECT /*+ leading(xet) cardinality(xet,1) */
61689 -- Event Class Code: INVOICE
61690 xet.entity_id
61691 ,xet.legal_entity_id
61692 ,xet.entity_code
61693 ,xet.transaction_number
61694 ,xet.event_id
61695 ,xet.event_class_code
61696 ,xet.event_type_code
61697 ,xet.event_number
61698 ,xet.event_date
61699 ,xet.transaction_date
61700 ,xet.reference_num_1
61701 ,xet.reference_num_2
61702 ,xet.reference_num_3
61703 ,xet.reference_num_4
61704 ,xet.reference_char_1
61705 ,xet.reference_char_2
61706 ,xet.reference_char_3
61707 ,xet.reference_char_4
61708 ,xet.reference_date_1
61709 ,xet.reference_date_2
61710 ,xet.reference_date_3
61711 ,xet.reference_date_4
61712 ,xet.event_created_by
61713 ,xet.budgetary_control_flag
61714 , h5.TRX_RECEIVABLE_CCID source_8
61715 , h1.BILL_CUST_ACCOUNT_ID source_25
61716 , h2.BILL_USES_SITE_USE_ID source_26
61717 , h5.XLA_PARTY_TYPE source_27
61718 , h5.TRX_INVOICE_CURRENCY_CODE source_32
61719 , h5.TRX_INVOICING_RULE_ID source_53
61720 , h5.TRX_DOC_SEQUENCE_CATEGORY source_77
61721 , h5.TRX_DOC_SEQUENCE_ID source_78
61722 , h5.TRX_DOC_SEQUENCE_VALUE source_79
61723 FROM xla_events_gt xet
61724 , AR_BILL_TO_CUSTOMERS_S_V h1
61725 , AR_BILL_TO_SITE_USES_S_V h2
61726 , AR_TRANSACTIONS_S_V h5
61727 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
61728 and xet.event_class_code = C_EVENT_CLASS_CODE
61729 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
61730 AND h2.event_id = h1.event_id
61731 AND h5.event_id = h1.event_id
61732
61733 ORDER BY event_id
61734 ;
61735
61736
61737 --
61738 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
61739 IS
61740 SELECT /*+ leading(xet) cardinality(xet,1) */
61741 -- Event Class Code: INVOICE
61742 xet.entity_id
61743 ,xet.legal_entity_id
61744 ,xet.entity_code
61745 ,xet.transaction_number
61746 ,xet.event_id
61747 ,xet.event_class_code
61748 ,xet.event_type_code
61749 ,xet.event_number
61750 ,xet.event_date
61751 ,xet.transaction_date
61752 ,xet.reference_num_1
61753 ,xet.reference_num_2
61754 ,xet.reference_num_3
61755 ,xet.reference_num_4
61756 ,xet.reference_char_1
61757 ,xet.reference_char_2
61758 ,xet.reference_char_3
61759 ,xet.reference_char_4
61760 ,xet.reference_date_1
61761 ,xet.reference_date_2
61762 ,xet.reference_date_3
61763 ,xet.reference_date_4
61764 ,xet.event_created_by
61765 ,xet.budgetary_control_flag
61766 , l3.LINE_NUMBER
61767 , l4.TRX_LINE_DIST_CCID source_14
61768 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_28
61769 , l4.TRX_LINE_DIST_ID source_29
61770 , l4.TRX_DISTRIBUTION_TYPE source_30
61771 , l4.TRX_LINE_DIST_AMT source_31
61772 , l3.TRX_LINE_CUR_CONVERSION_DATE source_33
61773 , l3.TRX_LINE_CUR_CONVERSION_RATE source_34
61774 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_35
61775 , l3.TRX_LINE_ACCTD_AMT source_36
61776 , l4.TRX_TAX_LINE_ID source_50
61777 , l3.ROUNDING_CORRECTION_FLAG source_51
61778 FROM xla_events_gt xet
61779 , AR_CUST_TRX_LINES_BASE_V l3
61780 , AR_CUST_TRX_LINES_L_V l4
61781 WHERE xet.event_id between x_first_event_id and x_last_event_id
61782 and xet.event_date between p_pad_start_date and p_pad_end_date
61783 and xet.event_class_code = C_EVENT_CLASS_CODE
61784 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
61785 AND l4.event_id = l3.event_id
61786 AND l4.line_number = l3.line_number
61787 ;
61788
61789 --
61790 BEGIN
61791 IF g_log_enabled THEN
61792 l_log_module := C_DEFAULT_MODULE||'.EventClass_110';
61793 END IF;
61794 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61795 trace
61796 (p_msg => 'BEGIN of EventClass_110'
61797 ,p_level => C_LEVEL_PROCEDURE
61798 ,p_module => l_log_module);
61799 END IF;
61800
61801 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
61802 trace
61803 (p_msg => 'p_application_id = '||p_application_id||
61804 ' - p_base_ledger_id = '||p_base_ledger_id||
61805 ' - p_target_ledger_id = '||p_target_ledger_id||
61806 ' - p_language = '||p_language||
61807 ' - p_currency_code = '||p_currency_code||
61808 ' - p_sla_ledger_id = '||p_sla_ledger_id
61809 ,p_level => C_LEVEL_STATEMENT
61810 ,p_module => l_log_module);
61811 END IF;
61812 --
61813 -- initialze arrays
61814 --
61815 g_array_event.DELETE;
61816 l_rec_array_event := l_null_rec_array_event;
61817 --
61818 --------------------------------------
61819 -- 4262811 Initialze MPA Line Number
61820 --------------------------------------
61821 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
61822
61823 --
61824
61825 --
61826 OPEN header_cur;
61827 --
61828 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
61829 trace
61830 (p_msg => 'SQL - FETCH header_cur'
61831 ,p_level => C_LEVEL_STATEMENT
61832 ,p_module => l_log_module);
61833 END IF;
61834 --
61835 LOOP
61836 FETCH header_cur BULK COLLECT INTO
61837 l_array_entity_id
61838 , l_array_legal_entity_id
61839 , l_array_entity_code
61840 , l_array_transaction_num
61841 , l_array_event_id
61842 , l_array_class_code
61843 , l_array_event_type
61844 , l_array_event_number
61845 , l_array_event_date
61846 , l_array_transaction_date
61847 , l_array_reference_num_1
61848 , l_array_reference_num_2
61849 , l_array_reference_num_3
61850 , l_array_reference_num_4
61851 , l_array_reference_char_1
61852 , l_array_reference_char_2
61853 , l_array_reference_char_3
61854 , l_array_reference_char_4
61855 , l_array_reference_date_1
61856 , l_array_reference_date_2
61857 , l_array_reference_date_3
61858 , l_array_reference_date_4
61859 , l_array_event_created_by
61860 , l_array_budgetary_control_flag
61861 , l_array_source_8
61862 , l_array_source_25
61863 , l_array_source_26
61864 , l_array_source_27
61865 , l_array_source_32
61866 , l_array_source_53
61867 , l_array_source_77
61868 , l_array_source_78
61869 , l_array_source_79
61870 LIMIT l_rows;
61871 --
61872 IF (C_LEVEL_EVENT >= g_log_level) THEN
61873 trace
61874 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
61875 ,p_level => C_LEVEL_EVENT
61876 ,p_module => l_log_module);
61877 END IF;
61878 --
61879 EXIT WHEN l_array_entity_id.COUNT = 0;
61880
61881 -- initialize arrays
61882 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
61883 XLA_AE_LINES_PKG.g_rec_lines := NULL;
61884
61885 --
61886 -- Bug 4458708
61887 --
61888 XLA_AE_LINES_PKG.g_LineNumber := 0;
61889
61890
61891 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
61892 g_last_hdr_idx := l_array_event_id.LAST;
61893 --
61894 -- loop for the headers. Each iteration is for each header extract row
61895 -- fetched in header cursor
61896 --
61897 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
61898
61899 --
61900 -- set event info as cache for other routines to refer event attributes
61901 --
61902 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
61903 (p_application_id => p_application_id
61904 ,p_primary_ledger_id => p_primary_ledger_id
61905 ,p_base_ledger_id => p_base_ledger_id
61906 ,p_target_ledger_id => p_target_ledger_id
61907 ,p_entity_id => l_array_entity_id(hdr_idx)
61908 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
61909 ,p_entity_code => l_array_entity_code(hdr_idx)
61910 ,p_transaction_num => l_array_transaction_num(hdr_idx)
61911 ,p_event_id => l_array_event_id(hdr_idx)
61912 ,p_event_class_code => l_array_class_code(hdr_idx)
61913 ,p_event_type_code => l_array_event_type(hdr_idx)
61914 ,p_event_number => l_array_event_number(hdr_idx)
61915 ,p_event_date => l_array_event_date(hdr_idx)
61916 ,p_transaction_date => l_array_transaction_date(hdr_idx)
61917 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
61918 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
61919 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
61920 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
61921 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
61922 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
61923 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
61924 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
61925 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
61926 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
61927 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
61928 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
61929 ,p_event_created_by => l_array_event_created_by(hdr_idx)
61930 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
61931
61932 --
61933 -- set the status of entry to C_VALID (0)
61934 --
61935 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
61936
61937 --
61938 -- initialize a row for ae header
61939 --
61940 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
61941
61942 l_event_id := l_array_event_id(hdr_idx);
61943
61944 --
61945 -- storing the hdr_idx for event. May be used by line cursor.
61946 --
61947 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
61948
61949 --
61950 -- store sources from header extract. This can be improved to
61951 -- store only those sources from header extract that may be used in lines
61952 --
61953
61954 g_array_event(l_event_id).array_value_num('source_8') := l_array_source_8(hdr_idx);
61955 g_array_event(l_event_id).array_value_num('source_25') := l_array_source_25(hdr_idx);
61956 g_array_event(l_event_id).array_value_num('source_26') := l_array_source_26(hdr_idx);
61957 g_array_event(l_event_id).array_value_char('source_27') := l_array_source_27(hdr_idx);
61958 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
61959 g_array_event(l_event_id).array_value_num('source_53') := l_array_source_53(hdr_idx);
61960 g_array_event(l_event_id).array_value_char('source_77') := l_array_source_77(hdr_idx);
61961 g_array_event(l_event_id).array_value_num('source_78') := l_array_source_78(hdr_idx);
61962 g_array_event(l_event_id).array_value_num('source_79') := l_array_source_79(hdr_idx);
61963
61964 --
61965 -- initilaize the status of ae headers for diffrent balance types
61966 -- the status is initialised to C_NOT_CREATED (2)
61967 --
61968 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
61969 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
61970 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
61971
61972 --
61973 -- call api to validate and store accounting attributes for header
61974 --
61975
61976 ------------------------------------------------------------
61977 -- Accrual Reversal : to get date for Standard Source (NONE)
61978 ------------------------------------------------------------
61979 l_acc_rev_gl_date_source := NULL;
61980
61981 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
61982 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_77');
61983 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
61984 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_78');
61985 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
61986 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_79');
61987 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
61988 l_rec_acct_attrs.array_date_value(4) :=
61989 xla_ae_sources_pkg.GetSystemSourceDate(
61990 p_source_code => 'XLA_EVENT_DATE'
61991 , p_source_type_code => 'Y'
61992 , p_source_application_id => 602
61993 );
61994
61995
61996 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
61997
61998 XLA_AE_HEADER_PKG.SetJeCategoryName;
61999
62000 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
62001 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
62002 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
62003 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
62004 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
62005
62006
62007 -- No header level analytical criteria
62008
62009 --
62010 --accounting attribute enhancement, bug 3612931
62011 --
62012 l_trx_reversal_source := SUBSTR(NULL, 1,30);
62013
62014 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
62015 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
62016
62017 xla_accounting_err_pkg.build_message
62018 (p_appli_s_name => 'XLA'
62019 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
62020 ,p_token_1 => 'ACCT_ATTR_NAME'
62021 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
62022 ,p_token_2 => 'PRODUCT_NAME'
62023 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
62024 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
62025 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
62026 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
62027
62028 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
62029 --
62030 -- following sets the accounting attributes needed to reverse
62031 -- accounting for a distributeion
62032 --
62033 xla_ae_lines_pkg.SetTrxReversalAttrs
62034 (p_event_id => l_event_id
62035 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
62036 ,p_trx_reversal_source => l_trx_reversal_source);
62037
62038 END IF;
62039
62040
62041 ----------------------------------------------------------------
62042 -- 4262811 - update the header statuses to invalid in need be
62043 ----------------------------------------------------------------
62044 --
62045 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
62046
62047
62048 -----------------------------------------------
62049 -- No accrual reversal for the event class/type
62050 -----------------------------------------------
62051 ----------------------------------------------------------------
62052
62053 --
62054 -- this ends the header loop iteration for one bulk fetch
62055 --
62056 END LOOP;
62057
62058 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
62059 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
62060
62061 --
62062 -- insert dummy rows into lines gt table that were created due to
62063 -- transaction reversals
62064 --
62065 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
62066 l_result := XLA_AE_LINES_PKG.InsertLines;
62067 END IF;
62068
62069 --
62070 -- reset the temp_line_num for each set of events fetched from header
62071 -- cursor rather than doing it for each new event in line cursor
62072 -- Bug 3939231
62073 --
62074 xla_ae_lines_pkg.g_temp_line_num := 0;
62075
62076
62077
62078 --
62079 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
62080 --
62081 --
62082 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
62083
62084 trace
62085 (p_msg => 'SQL - FETCH line_cur'
62086 ,p_level => C_LEVEL_STATEMENT
62087 ,p_module => l_log_module);
62088
62089 END IF;
62090 --
62091 --
62092 LOOP
62093 --
62094 FETCH line_cur BULK COLLECT INTO
62095 l_array_entity_id
62096 , l_array_legal_entity_id
62097 , l_array_entity_code
62098 , l_array_transaction_num
62099 , l_array_event_id
62100 , l_array_class_code
62101 , l_array_event_type
62102 , l_array_event_number
62103 , l_array_event_date
62104 , l_array_transaction_date
62105 , l_array_reference_num_1
62106 , l_array_reference_num_2
62107 , l_array_reference_num_3
62108 , l_array_reference_num_4
62109 , l_array_reference_char_1
62110 , l_array_reference_char_2
62111 , l_array_reference_char_3
62112 , l_array_reference_char_4
62113 , l_array_reference_date_1
62114 , l_array_reference_date_2
62115 , l_array_reference_date_3
62116 , l_array_reference_date_4
62117 , l_array_event_created_by
62118 , l_array_budgetary_control_flag
62119 , l_array_extract_line_num
62120 , l_array_source_14
62121 , l_array_source_28
62122 , l_array_source_29
62123 , l_array_source_30
62124 , l_array_source_31
62125 , l_array_source_33
62126 , l_array_source_34
62127 , l_array_source_35
62128 , l_array_source_36
62129 , l_array_source_50
62130 , l_array_source_51
62131 LIMIT l_rows;
62132
62133 --
62134 IF (C_LEVEL_EVENT >= g_log_level) THEN
62135 trace
62136 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
62137 ,p_level => C_LEVEL_EVENT
62138 ,p_module => l_log_module);
62139 END IF;
62140 --
62141 EXIT WHEN l_array_entity_id.count = 0;
62142
62143 XLA_AE_LINES_PKG.g_rec_lines := null;
62144
62145 --
62146 -- Bug 4458708
62147 --
62148 XLA_AE_LINES_PKG.g_LineNumber := 0;
62149 --
62150 --
62151
62152 FOR Idx IN 1..l_array_event_id.count LOOP
62153 --
62154 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
62155 --
62156 l_event_id := l_array_event_id(idx); -- 5648433
62157
62158 --
62159 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
62160 --
62161
62162 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
62163 (g_array_event(l_event_id).array_value_num('header_index'))
62164 ,'N'
62165 ) <> 'Y'
62166 THEN
62167 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
62168 trace
62169 (p_msg => 'Trancaction revesal option is not Y '
62170 ,p_level => C_LEVEL_STATEMENT
62171 ,p_module => l_log_module);
62172 END IF;
62173
62174 --
62175 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
62176 --
62177 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
62178 --
62179 -- set event info as cache for other routines to refer event attributes
62180 --
62181
62182 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
62183 l_previous_event_id := l_event_id;
62184
62185 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
62186 (p_application_id => p_application_id
62187 ,p_primary_ledger_id => p_primary_ledger_id
62188 ,p_base_ledger_id => p_base_ledger_id
62189 ,p_target_ledger_id => p_target_ledger_id
62190 ,p_entity_id => l_array_entity_id(Idx)
62191 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
62192 ,p_entity_code => l_array_entity_code(Idx)
62193 ,p_transaction_num => l_array_transaction_num(Idx)
62194 ,p_event_id => l_array_event_id(Idx)
62195 ,p_event_class_code => l_array_class_code(Idx)
62196 ,p_event_type_code => l_array_event_type(Idx)
62197 ,p_event_number => l_array_event_number(Idx)
62198 ,p_event_date => l_array_event_date(Idx)
62199 ,p_transaction_date => l_array_transaction_date(Idx)
62200 ,p_reference_num_1 => l_array_reference_num_1(Idx)
62201 ,p_reference_num_2 => l_array_reference_num_2(Idx)
62202 ,p_reference_num_3 => l_array_reference_num_3(Idx)
62203 ,p_reference_num_4 => l_array_reference_num_4(Idx)
62204 ,p_reference_char_1 => l_array_reference_char_1(Idx)
62205 ,p_reference_char_2 => l_array_reference_char_2(Idx)
62206 ,p_reference_char_3 => l_array_reference_char_3(Idx)
62207 ,p_reference_char_4 => l_array_reference_char_4(Idx)
62208 ,p_reference_date_1 => l_array_reference_date_1(Idx)
62209 ,p_reference_date_2 => l_array_reference_date_2(Idx)
62210 ,p_reference_date_3 => l_array_reference_date_3(Idx)
62211 ,p_reference_date_4 => l_array_reference_date_4(Idx)
62212 ,p_event_created_by => l_array_event_created_by(Idx)
62213 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
62214 --
62215 END IF;
62216
62217
62218
62219 --
62220 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
62221
62222 l_acct_reversal_source := SUBSTR(NULL, 1,30);
62223
62224 IF l_continue_with_lines THEN
62225 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
62226 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
62227
62228 xla_accounting_err_pkg.build_message
62229 (p_appli_s_name => 'XLA'
62230 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
62231 ,p_token_1 => 'LINE_NUMBER'
62232 ,p_value_1 => l_array_extract_line_num(Idx)
62233 ,p_token_2 => 'PRODUCT_NAME'
62234 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
62235 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
62236 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
62237 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
62238
62239 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
62240 --
62241 -- following sets the accounting attributes needed to reverse
62242 -- accounting for a distributeion
62243 --
62244
62245 --
62246 -- 5217187
62247 --
62248 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
62249 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
62250 g_array_event(l_event_id).array_value_num('header_index'));
62251 --
62252 --
62253
62254 -- No reversal code generated
62255
62256 xla_ae_lines_pkg.SetAcctReversalAttrs
62257 (p_event_id => l_event_id
62258 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
62259 ,p_calculate_acctd_flag => l_calculate_acctd_flag
62260 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
62261 END IF;
62262
62263 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
62264 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
62265
62266 --
62267 AcctLineType_46 (
62268 p_application_id => p_application_id
62269 ,p_event_id => l_event_id
62270 ,p_calculate_acctd_flag => l_calculate_acctd_flag
62271 ,p_calculate_g_l_flag => l_calculate_g_l_flag
62272 ,p_actual_flag => l_actual_flag
62273 ,p_balance_type_code => l_balance_type_code
62274 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
62275
62276 , p_source_14 => l_array_source_14(Idx)
62277 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
62278 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
62279 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
62280 , p_source_28 => l_array_source_28(Idx)
62281 , p_source_29 => l_array_source_29(Idx)
62282 , p_source_30 => l_array_source_30(Idx)
62283 , p_source_31 => l_array_source_31(Idx)
62284 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
62285 , p_source_33 => l_array_source_33(Idx)
62286 , p_source_34 => l_array_source_34(Idx)
62287 , p_source_35 => l_array_source_35(Idx)
62288 , p_source_36 => l_array_source_36(Idx)
62289 , p_source_50 => l_array_source_50(Idx)
62290 );
62291 If(l_balance_type_code = 'A') THEN
62292 l_actual_gain_loss_ref := l_gain_or_loss_ref;
62293 END IF;
62294
62295 --
62296
62297
62298 --
62299 AcctLineType_47 (
62300 p_application_id => p_application_id
62301 ,p_event_id => l_event_id
62302 ,p_calculate_acctd_flag => l_calculate_acctd_flag
62303 ,p_calculate_g_l_flag => l_calculate_g_l_flag
62304 ,p_actual_flag => l_actual_flag
62305 ,p_balance_type_code => l_balance_type_code
62306 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
62307
62308 , p_source_14 => l_array_source_14(Idx)
62309 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
62310 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
62311 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
62312 , p_source_28 => l_array_source_28(Idx)
62313 , p_source_29 => l_array_source_29(Idx)
62314 , p_source_30 => l_array_source_30(Idx)
62315 , p_source_31 => l_array_source_31(Idx)
62316 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
62317 , p_source_33 => l_array_source_33(Idx)
62318 , p_source_34 => l_array_source_34(Idx)
62319 , p_source_35 => l_array_source_35(Idx)
62320 , p_source_36 => l_array_source_36(Idx)
62321 , p_source_50 => l_array_source_50(Idx)
62322 );
62323 If(l_balance_type_code = 'A') THEN
62324 l_actual_gain_loss_ref := l_gain_or_loss_ref;
62325 END IF;
62326
62327 --
62328
62329
62330 --
62331 AcctLineType_48 (
62332 p_application_id => p_application_id
62333 ,p_event_id => l_event_id
62334 ,p_calculate_acctd_flag => l_calculate_acctd_flag
62335 ,p_calculate_g_l_flag => l_calculate_g_l_flag
62336 ,p_actual_flag => l_actual_flag
62337 ,p_balance_type_code => l_balance_type_code
62338 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
62339
62340 , p_source_14 => l_array_source_14(Idx)
62341 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
62342 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
62343 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
62344 , p_source_28 => l_array_source_28(Idx)
62345 , p_source_29 => l_array_source_29(Idx)
62346 , p_source_30 => l_array_source_30(Idx)
62347 , p_source_31 => l_array_source_31(Idx)
62348 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
62349 , p_source_33 => l_array_source_33(Idx)
62350 , p_source_34 => l_array_source_34(Idx)
62351 , p_source_35 => l_array_source_35(Idx)
62352 , p_source_36 => l_array_source_36(Idx)
62353 , p_source_50 => l_array_source_50(Idx)
62354 , p_source_51 => l_array_source_51(Idx)
62355 );
62356 If(l_balance_type_code = 'A') THEN
62357 l_actual_gain_loss_ref := l_gain_or_loss_ref;
62358 END IF;
62359
62360 --
62361
62362
62363 --
62364 AcctLineType_49 (
62365 p_application_id => p_application_id
62366 ,p_event_id => l_event_id
62367 ,p_calculate_acctd_flag => l_calculate_acctd_flag
62368 ,p_calculate_g_l_flag => l_calculate_g_l_flag
62369 ,p_actual_flag => l_actual_flag
62370 ,p_balance_type_code => l_balance_type_code
62371 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
62372
62373 , p_source_14 => l_array_source_14(Idx)
62374 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
62375 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
62376 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
62377 , p_source_28 => l_array_source_28(Idx)
62378 , p_source_29 => l_array_source_29(Idx)
62379 , p_source_30 => l_array_source_30(Idx)
62380 , p_source_31 => l_array_source_31(Idx)
62381 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
62382 , p_source_33 => l_array_source_33(Idx)
62383 , p_source_34 => l_array_source_34(Idx)
62384 , p_source_35 => l_array_source_35(Idx)
62385 , p_source_36 => l_array_source_36(Idx)
62386 , p_source_50 => l_array_source_50(Idx)
62387 );
62388 If(l_balance_type_code = 'A') THEN
62389 l_actual_gain_loss_ref := l_gain_or_loss_ref;
62390 END IF;
62391
62392 --
62393
62394
62395 --
62396 AcctLineType_50 (
62397 p_application_id => p_application_id
62398 ,p_event_id => l_event_id
62399 ,p_calculate_acctd_flag => l_calculate_acctd_flag
62400 ,p_calculate_g_l_flag => l_calculate_g_l_flag
62401 ,p_actual_flag => l_actual_flag
62402 ,p_balance_type_code => l_balance_type_code
62403 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
62404
62405 , p_source_14 => l_array_source_14(Idx)
62406 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
62407 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
62408 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
62409 , p_source_28 => l_array_source_28(Idx)
62410 , p_source_29 => l_array_source_29(Idx)
62411 , p_source_30 => l_array_source_30(Idx)
62412 , p_source_31 => l_array_source_31(Idx)
62413 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
62414 , p_source_33 => l_array_source_33(Idx)
62415 , p_source_34 => l_array_source_34(Idx)
62416 , p_source_35 => l_array_source_35(Idx)
62417 , p_source_36 => l_array_source_36(Idx)
62418 , p_source_50 => l_array_source_50(Idx)
62419 );
62420 If(l_balance_type_code = 'A') THEN
62421 l_actual_gain_loss_ref := l_gain_or_loss_ref;
62422 END IF;
62423
62424 --
62425
62426
62427 --
62428 AcctLineType_51 (
62429 p_application_id => p_application_id
62430 ,p_event_id => l_event_id
62431 ,p_calculate_acctd_flag => l_calculate_acctd_flag
62432 ,p_calculate_g_l_flag => l_calculate_g_l_flag
62433 ,p_actual_flag => l_actual_flag
62434 ,p_balance_type_code => l_balance_type_code
62435 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
62436
62437 , p_source_14 => l_array_source_14(Idx)
62438 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
62439 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
62440 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
62441 , p_source_28 => l_array_source_28(Idx)
62442 , p_source_29 => l_array_source_29(Idx)
62443 , p_source_30 => l_array_source_30(Idx)
62444 , p_source_31 => l_array_source_31(Idx)
62445 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
62446 , p_source_33 => l_array_source_33(Idx)
62447 , p_source_34 => l_array_source_34(Idx)
62448 , p_source_35 => l_array_source_35(Idx)
62449 , p_source_36 => l_array_source_36(Idx)
62450 , p_source_50 => l_array_source_50(Idx)
62451 , p_source_51 => l_array_source_51(Idx)
62452 );
62453 If(l_balance_type_code = 'A') THEN
62454 l_actual_gain_loss_ref := l_gain_or_loss_ref;
62455 END IF;
62456
62457 --
62458
62459
62460 --
62461 AcctLineType_52 (
62462 p_application_id => p_application_id
62463 ,p_event_id => l_event_id
62464 ,p_calculate_acctd_flag => l_calculate_acctd_flag
62465 ,p_calculate_g_l_flag => l_calculate_g_l_flag
62466 ,p_actual_flag => l_actual_flag
62467 ,p_balance_type_code => l_balance_type_code
62468 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
62469
62470 , p_source_14 => l_array_source_14(Idx)
62471 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
62472 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
62473 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
62474 , p_source_28 => l_array_source_28(Idx)
62475 , p_source_29 => l_array_source_29(Idx)
62476 , p_source_30 => l_array_source_30(Idx)
62477 , p_source_31 => l_array_source_31(Idx)
62478 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
62479 , p_source_33 => l_array_source_33(Idx)
62480 , p_source_34 => l_array_source_34(Idx)
62481 , p_source_35 => l_array_source_35(Idx)
62482 , p_source_36 => l_array_source_36(Idx)
62483 , p_source_50 => l_array_source_50(Idx)
62484 , p_source_51 => l_array_source_51(Idx)
62485 );
62486 If(l_balance_type_code = 'A') THEN
62487 l_actual_gain_loss_ref := l_gain_or_loss_ref;
62488 END IF;
62489
62490 --
62491
62492
62493 --
62494 AcctLineType_56 (
62495 p_application_id => p_application_id
62496 ,p_event_id => l_event_id
62497 ,p_calculate_acctd_flag => l_calculate_acctd_flag
62498 ,p_calculate_g_l_flag => l_calculate_g_l_flag
62499 ,p_actual_flag => l_actual_flag
62500 ,p_balance_type_code => l_balance_type_code
62501 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
62502
62503 , p_source_8 => g_array_event(l_event_id).array_value_num('source_8')
62504 , p_source_14 => l_array_source_14(Idx)
62505 , p_source_25 => g_array_event(l_event_id).array_value_num('source_25')
62506 , p_source_26 => g_array_event(l_event_id).array_value_num('source_26')
62507 , p_source_27 => g_array_event(l_event_id).array_value_char('source_27')
62508 , p_source_28 => l_array_source_28(Idx)
62509 , p_source_29 => l_array_source_29(Idx)
62510 , p_source_30 => l_array_source_30(Idx)
62511 , p_source_31 => l_array_source_31(Idx)
62512 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
62513 , p_source_33 => l_array_source_33(Idx)
62514 , p_source_34 => l_array_source_34(Idx)
62515 , p_source_35 => l_array_source_35(Idx)
62516 , p_source_36 => l_array_source_36(Idx)
62517 , p_source_50 => l_array_source_50(Idx)
62518 , p_source_53 => g_array_event(l_event_id).array_value_num('source_53')
62519 );
62520 If(l_balance_type_code = 'A') THEN
62521 l_actual_gain_loss_ref := l_gain_or_loss_ref;
62522 END IF;
62523
62524 --
62525
62526 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
62527 -- or secondary ledger that has different currency with primary
62528 -- or alc that is calculated by sla
62529 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
62530 (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'))
62531
62532 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
62533 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
62534 AND (l_actual_flag = 'A')) THEN
62535 XLA_AE_LINES_PKG.CreateGainOrLossLines(
62536 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
62537 ,p_application_id => p_application_id
62538 ,p_amb_context_code => 'DEFAULT'
62539 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
62540 ,p_event_class_code => C_EVENT_CLASS_CODE
62541 ,p_event_type_code => C_EVENT_TYPE_CODE
62542
62543 ,p_gain_ccid => -1
62544 ,p_loss_ccid => -1
62545
62546 ,p_actual_flag => l_actual_flag
62547 ,p_enc_flag => null
62548 ,p_actual_g_l_ref => l_actual_gain_loss_ref
62549 ,p_enc_g_l_ref => null
62550 );
62551 END IF;
62552 END IF;
62553 END IF;
62554
62555 ELSE
62556 --
62557 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
62558 --
62559 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
62560 trace
62561 (p_msg => 'Trancaction revesal option is Y'
62562 ,p_level => C_LEVEL_STATEMENT
62563 ,p_module => l_log_module);
62564 END IF;
62565 END IF;
62566
62567 END LOOP;
62568 l_result := XLA_AE_LINES_PKG.InsertLines ;
62569 end loop;
62570 close line_cur;
62571
62572
62573 --
62574 -- insert headers into xla_ae_headers_gt table
62575 --
62576 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
62577
62578 -- insert into errors table here.
62579
62580 END LOOP;
62581
62582 --
62583 -- 4865292
62584 --
62585 -- Compare g_hdr_extract_count with event count in
62586 -- CreateHeadersAndLines.
62587 --
62588 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
62589
62590 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
62591 trace (p_msg => '# rows extracted from header extract objects '
62592 || ' (running total): '
62593 || g_hdr_extract_count
62594 ,p_level => C_LEVEL_STATEMENT
62595 ,p_module => l_log_module);
62596 END IF;
62597
62598 CLOSE header_cur;
62599 --
62600
62601 --
62602 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62603 trace
62604 (p_msg => 'END of EventClass_110'
62605 ,p_level => C_LEVEL_PROCEDURE
62606 ,p_module => l_log_module);
62607 END IF;
62608 --
62609 RETURN l_result;
62610 EXCEPTION
62611 WHEN xla_exceptions_pkg.application_exception THEN
62612
62613 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
62614
62615
62616 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
62617
62618 RAISE;
62619
62620 WHEN NO_DATA_FOUND THEN
62621
62622 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
62623 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
62624
62625 FOR header_record IN header_cur
62626 LOOP
62627 l_array_header_events(header_record.event_id) := header_record.event_id;
62628 END LOOP;
62629
62630 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
62631 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
62632
62633 fnd_file.put_line(fnd_file.LOG, ' ');
62634 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
62635 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
62636 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
62637
62638 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
62639 LOOP
62640 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
62641 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
62642 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
62643 END IF;
62644 END LOOP;
62645
62646 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
62650 xla_exceptions_pkg.raise_message
62647 fnd_file.put_line(fnd_file.LOG, ' ');
62648
62649
62651 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_110');
62652
62653
62654 WHEN OTHERS THEN
62655 xla_exceptions_pkg.raise_message
62656 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_110');
62657 END EventClass_110;
62658 --
62659
62660 ---------------------------------------
62661 --
62662 -- PRIVATE PROCEDURE
62663 -- insert_sources_111
62664 --
62665 ----------------------------------------
62666 --
62667 PROCEDURE insert_sources_111(
62668 p_target_ledger_id IN NUMBER
62669 , p_language IN VARCHAR2
62670 , p_sla_ledger_id IN NUMBER
62671 , p_pad_start_date IN DATE
62672 , p_pad_end_date IN DATE
62673 )
62674 IS
62675
62676 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT_ALL';
62677 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT';
62678 p_apps_owner VARCHAR2(30);
62679 l_log_module VARCHAR2(240);
62680 BEGIN
62681 IF g_log_enabled THEN
62682 l_log_module := C_DEFAULT_MODULE||'.insert_sources_111';
62683 END IF;
62684 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62685
62686 trace
62687 (p_msg => 'BEGIN of insert_sources_111'
62688 ,p_level => C_LEVEL_PROCEDURE
62689 ,p_module => l_log_module);
62690
62691 END IF;
62692
62693 -- select APPS owner
62694 SELECT oracle_username
62695 INTO p_apps_owner
62696 FROM fnd_oracle_userid
62697 WHERE read_only_flag = 'U'
62698 ;
62699
62700 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
62701 trace
62702 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
62703 ' - p_language = '||p_language||
62704 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
62705 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
62706 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
62707 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
62708 ,p_level => C_LEVEL_STATEMENT
62709 ,p_module => l_log_module);
62710 END IF;
62711
62712
62713 --
62714 INSERT INTO xla_diag_sources --hdr2
62715 (
62716 event_id
62717 , ledger_id
62718 , sla_ledger_id
62719 , description_language
62720 , object_name
62721 , object_type_code
62722 , line_number
62723 , source_application_id
62724 , source_type_code
62725 , source_code
62726 , source_value
62727 , source_meaning
62728 , created_by
62729 , creation_date
62730 , last_update_date
62731 , last_updated_by
62732 , last_update_login
62733 , program_update_date
62734 , program_application_id
62735 , program_id
62736 , request_id
62737 )
62738 SELECT
62739 event_id
62740 , p_target_ledger_id
62741 , p_sla_ledger_id
62742 , p_language
62743 , object_name
62744 , object_type_code
62745 , line_number
62746 , source_application_id
62747 , source_type_code
62748 , source_code
62749 , SUBSTR(source_value ,1,1996)
62750 , SUBSTR(source_meaning ,1,200)
62751 , xla_environment_pkg.g_Usr_Id
62752 , TRUNC(SYSDATE)
62753 , TRUNC(SYSDATE)
62754 , xla_environment_pkg.g_Usr_Id
62755 , xla_environment_pkg.g_Login_Id
62756 , TRUNC(SYSDATE)
62757 , xla_environment_pkg.g_Prog_Appl_Id
62758 , xla_environment_pkg.g_Prog_Id
62759 , xla_environment_pkg.g_Req_Id
62760 FROM (
62761 SELECT xet.event_id event_id
62762 , 0 line_number
62763 , CASE r
62764 WHEN 1 THEN 'AR_REMIT_BANK_ACCT_H_V'
62765 WHEN 2 THEN 'AR_REMIT_BANK_ACCT_H_V'
62766 WHEN 3 THEN 'AR_REMIT_BANK_ACCT_H_V'
62767 WHEN 4 THEN 'AR_REMIT_BANK_ACCT_H_V'
62768 WHEN 5 THEN 'AR_RCT_METHOD_H_V'
62769 WHEN 6 THEN 'AR_RCT_METHOD_H_V'
62770 WHEN 7 THEN 'AR_CASH_RECEIPTS_H_V'
62771 WHEN 8 THEN 'AR_CASH_RECEIPTS_H_V'
62772 WHEN 9 THEN 'AR_CASH_RECEIPTS_H_V'
62773 WHEN 10 THEN 'AR_CASH_RECEIPTS_H_V'
62774
62775 ELSE null
62776 END object_name
62777 , CASE r
62778 WHEN 1 THEN 'HEADER'
62779 WHEN 2 THEN 'HEADER'
62780 WHEN 3 THEN 'HEADER'
62781 WHEN 4 THEN 'HEADER'
62782 WHEN 5 THEN 'HEADER'
62783 WHEN 6 THEN 'HEADER'
62784 WHEN 7 THEN 'HEADER'
62785 WHEN 8 THEN 'HEADER'
62786 WHEN 9 THEN 'HEADER'
62787 WHEN 10 THEN 'HEADER'
62788
62789 ELSE null
62790 END object_type_code
62791 , CASE r
62792 WHEN 1 THEN '222'
62793 WHEN 2 THEN '222'
62794 WHEN 3 THEN '222'
62795 WHEN 4 THEN '222'
62796 WHEN 5 THEN '222'
62797 WHEN 6 THEN '222'
62798 WHEN 7 THEN '222'
62799 WHEN 8 THEN '222'
62800 WHEN 9 THEN '222'
62801 WHEN 10 THEN '222'
62802
62803 ELSE null
62804 END source_application_id
62805 , 'S' source_type_code
62806 , CASE r
62807 WHEN 1 THEN 'RMT_BNK_BANK_CHARGES_CCID'
62808 WHEN 2 THEN 'RMT_BNK_CONFIRMATION_CCID'
62809 WHEN 3 THEN 'RMT_BNK_CASH_CCID'
62810 WHEN 4 THEN 'RMT_BNK_REMITTANCE_CCID'
62811 WHEN 5 THEN 'RCT_CLASS_REMIT_FLAG'
62812 WHEN 6 THEN 'RCT_CLASS_CONFIRM_FLAG'
62813 WHEN 7 THEN 'RCT_DOC_SEQUENCE_CATEGORY'
62814 WHEN 8 THEN 'RCT_DOC_SEQUENCE_ID'
62815 WHEN 9 THEN 'RCT_DOC_SEQUENCE_VALUE'
62816 WHEN 10 THEN 'RCT_TRX_ACCT_REVERSAL'
62817
62818 ELSE null
62819 END source_code
62820 , CASE r
62821 WHEN 1 THEN TO_CHAR(h5.RMT_BNK_BANK_CHARGES_CCID)
62822 WHEN 2 THEN TO_CHAR(h5.RMT_BNK_CONFIRMATION_CCID)
62823 WHEN 3 THEN TO_CHAR(h5.RMT_BNK_CASH_CCID)
62824 WHEN 4 THEN TO_CHAR(h5.RMT_BNK_REMITTANCE_CCID)
62825 WHEN 5 THEN TO_CHAR(h4.RCT_CLASS_REMIT_FLAG)
62826 WHEN 6 THEN TO_CHAR(h4.RCT_CLASS_CONFIRM_FLAG)
62827 WHEN 7 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_CATEGORY)
62828 WHEN 8 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_ID)
62829 WHEN 9 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_VALUE)
62830 WHEN 10 THEN TO_CHAR(h1.RCT_TRX_ACCT_REVERSAL)
62831
62832 ELSE null
62833 END source_value
62834 , null source_meaning
62835 FROM xla_events_gt xet
62836 , AR_CASH_RECEIPTS_H_V h1
62837 , AR_RCT_METHOD_H_V h4
62838 , AR_REMIT_BANK_ACCT_H_V h5
62839 ,(select rownum r from all_objects where rownum <= 10 and owner = p_apps_owner)
62840 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
62841 AND xet.event_class_code = C_EVENT_CLASS_CODE
62842
62843 )
62844 ;
62845 --
62846 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
62847
62848 trace
62849 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
62850 ,p_level => C_LEVEL_STATEMENT
62851 ,p_module => l_log_module);
62852
62853 END IF;
62854 --
62855
62856
62857
62858 --
62859 INSERT INTO xla_diag_sources --line2
62860 (
62861 event_id
62862 , ledger_id
62863 , sla_ledger_id
62864 , description_language
62865 , object_name
62866 , object_type_code
62867 , line_number
62868 , source_application_id
62869 , source_type_code
62870 , source_code
62871 , source_value
62872 , source_meaning
62873 , created_by
62874 , creation_date
62875 , last_update_date
62876 , last_updated_by
62877 , last_update_login
62878 , program_update_date
62879 , program_application_id
62880 , program_id
62881 , request_id
62882 )
62883 SELECT event_id
62884 , p_target_ledger_id
62885 , p_sla_ledger_id
62886 , p_language
62887 , object_name
62888 , object_type_code
62889 , line_number
62890 , source_application_id
62891 , source_type_code
62892 , source_code
62893 , SUBSTR(source_value,1,1996)
62894 , SUBSTR(source_meaning ,1,200)
62895 , xla_environment_pkg.g_Usr_Id
62896 , TRUNC(SYSDATE)
62897 , TRUNC(SYSDATE)
62898 , xla_environment_pkg.g_Usr_Id
62899 , xla_environment_pkg.g_Login_Id
62900 , TRUNC(SYSDATE)
62901 , xla_environment_pkg.g_Prog_Appl_Id
62902 , xla_environment_pkg.g_Prog_Id
62903 , xla_environment_pkg.g_Req_Id
62904 FROM (
62905 SELECT xet.event_id event_id
62906 , l3.line_number line_number
62907 , CASE r
62908 WHEN 1 THEN 'AR_DISTRIBUTIONS_L_V'
62909 WHEN 2 THEN 'AR_DISTRIBUTIONS_L_V'
62910 WHEN 3 THEN 'AR_DISTRIBUTIONS_L_V'
62911 WHEN 4 THEN 'AR_DISTRIBUTIONS_L_V'
62912 WHEN 5 THEN 'AR_DISTRIBUTIONS_L_V'
62913 WHEN 6 THEN 'AR_DISTRIBUTIONS_L_V'
62914 WHEN 7 THEN 'AR_DISTRIBUTIONS_BASE_V'
62915 WHEN 8 THEN 'AR_DISTRIBUTIONS_BASE_V'
62916 WHEN 9 THEN 'AR_DISTRIBUTIONS_BASE_V'
62917 WHEN 10 THEN 'AR_DISTRIBUTIONS_L_V'
62918 WHEN 11 THEN 'AR_DISTRIBUTIONS_BASE_V'
62919
62920 ELSE null
62921 END object_name
62922 , CASE r
62923 WHEN 1 THEN 'LINE'
62924 WHEN 2 THEN 'LINE'
62925 WHEN 3 THEN 'LINE'
62926 WHEN 4 THEN 'LINE'
62927 WHEN 5 THEN 'LINE'
62928 WHEN 6 THEN 'LINE'
62929 WHEN 7 THEN 'LINE'
62930 WHEN 8 THEN 'LINE'
62931 WHEN 9 THEN 'LINE'
62932 WHEN 10 THEN 'LINE'
62933 WHEN 11 THEN 'LINE'
62934
62935 ELSE null
62936 END object_type_code
62937 , CASE r
62938 WHEN 1 THEN '222'
62939 WHEN 2 THEN '222'
62940 WHEN 3 THEN '222'
62941 WHEN 4 THEN '222'
62942 WHEN 5 THEN '222'
62943 WHEN 6 THEN '222'
62944 WHEN 7 THEN '222'
62945 WHEN 8 THEN '222'
62946 WHEN 9 THEN '222'
62947 WHEN 10 THEN '222'
62948 WHEN 11 THEN '222'
62949
62950 ELSE null
62951 END source_application_id
62952 , 'S' source_type_code
62953 , CASE r
62954 WHEN 1 THEN 'DIST_CODE_COMBINATION_ID'
62955 WHEN 2 THEN 'DIST_SOURCE_TYPE'
62956 WHEN 3 THEN 'DIST_LINE_ID'
62957 WHEN 4 THEN 'DISTRIBUTION_TYPE'
62958 WHEN 5 THEN 'DIST_ENT_AMT'
62959 WHEN 6 THEN 'DIST_CURRENCY_CODE'
62960 WHEN 7 THEN 'DIST_CUR_CONVERSION_RATE'
62961 WHEN 8 THEN 'DIST_CUR_CONVERSION_TYPE'
62962 WHEN 9 THEN 'DIST_TO_ACCTD_AMT'
62963 WHEN 10 THEN 'DIST_MFAR_ADDITIONAL_ENTRY'
62964 WHEN 11 THEN 'DIST_TO_CUR_CONVERSION_DATE'
62965
62966 ELSE null
62967 END source_code
62968 , CASE r
62969 WHEN 1 THEN TO_CHAR(l3.DIST_CODE_COMBINATION_ID)
62970 WHEN 2 THEN TO_CHAR(l3.DIST_SOURCE_TYPE)
62971 WHEN 3 THEN TO_CHAR(l3.DIST_LINE_ID)
62972 WHEN 4 THEN TO_CHAR(l3.DISTRIBUTION_TYPE)
62973 WHEN 5 THEN TO_CHAR(l3.DIST_ENT_AMT)
62974 WHEN 6 THEN TO_CHAR(l3.DIST_CURRENCY_CODE)
62975 WHEN 7 THEN TO_CHAR(l2.DIST_CUR_CONVERSION_RATE)
62976 WHEN 8 THEN TO_CHAR(l2.DIST_CUR_CONVERSION_TYPE)
62977 WHEN 9 THEN TO_CHAR(l2.DIST_TO_ACCTD_AMT)
62978 WHEN 10 THEN TO_CHAR(l3.DIST_MFAR_ADDITIONAL_ENTRY)
62979 WHEN 11 THEN TO_CHAR(l2.DIST_TO_CUR_CONVERSION_DATE)
62980
62981 ELSE null
62982 END source_value
62983 , null source_meaning
62984 FROM xla_events_gt xet
62985 , AR_DISTRIBUTIONS_BASE_V l2
62986 , AR_DISTRIBUTIONS_L_V l3
62987 , (select rownum r from all_objects where rownum <= 11 and owner = p_apps_owner)
62988 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
62989 AND xet.event_class_code = C_EVENT_CLASS_CODE
62990 AND l2.event_id = xet.event_id
62991 AND l3.event_id = l2.event_id
62992 AND l3.line_number = l2.line_number
62993
62994 )
62995 ;
62996 --
62997 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
62998
62999 trace
63000 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
63001 ,p_level => C_LEVEL_STATEMENT
63002 ,p_module => l_log_module);
63003
63004 END IF;
63005
63006
63007 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63008 trace
63009 (p_msg => 'END of insert_sources_111'
63010 ,p_level => C_LEVEL_PROCEDURE
63011 ,p_module => l_log_module);
63012 END IF;
63013 EXCEPTION
63014 WHEN xla_exceptions_pkg.application_exception THEN
63015 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
63016 trace
63017 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
63018 ,p_level => C_LEVEL_EXCEPTION
63019 ,p_module => l_log_module);
63020 END IF;
63021 RAISE;
63022 WHEN OTHERS THEN
63023 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
63024 trace
63025 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
63026 ,p_level => C_LEVEL_EXCEPTION
63027 ,p_module => l_log_module);
63028 END IF;
63029 xla_exceptions_pkg.raise_message
63030 (p_location => 'XLA_00222_AAD_S_000007_PKG.insert_sources_111');
63031 END insert_sources_111;
63032 --
63033
63034 ---------------------------------------
63035 --
63036 -- PRIVATE FUNCTION
63037 -- EventClass_111
63038 --
63039 ----------------------------------------
63040 --
63041 FUNCTION EventClass_111
63042 (p_application_id IN NUMBER
63043 ,p_base_ledger_id IN NUMBER
63044 ,p_target_ledger_id IN NUMBER
63045 ,p_language IN VARCHAR2
63046 ,p_currency_code IN VARCHAR2
63047 ,p_sla_ledger_id IN NUMBER
63048 ,p_pad_start_date IN DATE
63049 ,p_pad_end_date IN DATE
63050 ,p_primary_ledger_id IN NUMBER)
63051 RETURN BOOLEAN IS
63052 --
63053 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT_ALL';
63054 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT';
63055
63056 l_calculate_acctd_flag VARCHAR2(1) :='N';
63057 l_calculate_g_l_flag VARCHAR2(1) :='N';
63058 --
63059 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
63060 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
63061 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
63062 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
63063 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
63064 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
63065 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
63066 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
63067 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
63068 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
63069 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
63070 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
63071 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
63072 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
63073 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
63074 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
63075 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
63076 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
63077 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
63078 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
63079 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
63080 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
63081 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
63082 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
63083 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
63084 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
63085
63086 l_event_id NUMBER;
63087 l_previous_event_id NUMBER;
63088 l_first_event_id NUMBER;
63089 l_last_event_id NUMBER;
63090
63091 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
63092 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
63093 --
63094 --
63095 l_result BOOLEAN := TRUE;
63096 l_rows NUMBER := 1000;
63097 l_event_type_name VARCHAR2(80) := 'All';
63098 l_event_class_name VARCHAR2(80) := 'Miscellaneous Receipt';
63099 l_description VARCHAR2(4000);
63100 l_transaction_reversal NUMBER;
63101 l_ae_header_id NUMBER;
63102 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
63103 l_log_module VARCHAR2(240);
63104 --
63105 l_acct_reversal_source VARCHAR2(30);
63106 l_trx_reversal_source VARCHAR2(30);
63107
63108 l_continue_with_lines BOOLEAN := TRUE;
63109 --
63110 l_acc_rev_gl_date_source DATE; -- 4262811
63111 --
63112 type t_array_event_id is table of number index by binary_integer;
63113
63114 l_rec_array_event t_rec_array_event;
63118 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
63115 l_null_rec_array_event t_rec_array_event;
63116 l_array_ae_header_id xla_number_array_type;
63117 l_actual_flag VARCHAR2(1) := NULL;
63119 l_balance_type_code VARCHAR2(1) :=NULL;
63120 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
63121
63122 --
63123 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
63124 --
63125
63126 TYPE t_array_source_1 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_BANK_CHARGES_CCID%TYPE INDEX BY BINARY_INTEGER;
63127 TYPE t_array_source_3 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_CONFIRMATION_CCID%TYPE INDEX BY BINARY_INTEGER;
63128 TYPE t_array_source_5 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_CASH_CCID%TYPE INDEX BY BINARY_INTEGER;
63129 TYPE t_array_source_6 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_REMITTANCE_CCID%TYPE INDEX BY BINARY_INTEGER;
63130 TYPE t_array_source_56 IS TABLE OF AR_RCT_METHOD_H_V.RCT_CLASS_REMIT_FLAG%TYPE INDEX BY BINARY_INTEGER;
63131 TYPE t_array_source_57 IS TABLE OF AR_RCT_METHOD_H_V.RCT_CLASS_CONFIRM_FLAG%TYPE INDEX BY BINARY_INTEGER;
63132 TYPE t_array_source_80 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
63133 TYPE t_array_source_81 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
63134 TYPE t_array_source_82 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
63135 TYPE t_array_source_83 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_TRX_ACCT_REVERSAL%TYPE INDEX BY BINARY_INTEGER;
63136
63137 TYPE t_array_source_10 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
63138 TYPE t_array_source_15 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
63139 TYPE t_array_source_17 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
63140 TYPE t_array_source_18 IS TABLE OF AR_DISTRIBUTIONS_L_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
63141 TYPE t_array_source_19 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
63142 TYPE t_array_source_20 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
63143 TYPE t_array_source_22 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
63144 TYPE t_array_source_23 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
63145 TYPE t_array_source_24 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
63146 TYPE t_array_source_54 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_MFAR_ADDITIONAL_ENTRY%TYPE INDEX BY BINARY_INTEGER;
63147 TYPE t_array_source_55 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
63148
63149 l_array_source_1 t_array_source_1;
63150 l_array_source_3 t_array_source_3;
63151 l_array_source_5 t_array_source_5;
63152 l_array_source_6 t_array_source_6;
63153 l_array_source_56 t_array_source_56;
63154 l_array_source_57 t_array_source_57;
63155 l_array_source_80 t_array_source_80;
63156 l_array_source_81 t_array_source_81;
63157 l_array_source_82 t_array_source_82;
63158 l_array_source_83 t_array_source_83;
63159
63160 l_array_source_10 t_array_source_10;
63161 l_array_source_15 t_array_source_15;
63162 l_array_source_17 t_array_source_17;
63163 l_array_source_18 t_array_source_18;
63164 l_array_source_19 t_array_source_19;
63165 l_array_source_20 t_array_source_20;
63166 l_array_source_22 t_array_source_22;
63167 l_array_source_23 t_array_source_23;
63168 l_array_source_24 t_array_source_24;
63169 l_array_source_54 t_array_source_54;
63170 l_array_source_55 t_array_source_55;
63171
63172 --
63173 CURSOR header_cur
63174 IS
63175 SELECT /*+ leading(xet) cardinality(xet,1) */
63176 -- Event Class Code: MISC_RECEIPT
63177 xet.entity_id
63178 ,xet.legal_entity_id
63179 ,xet.entity_code
63180 ,xet.transaction_number
63181 ,xet.event_id
63182 ,xet.event_class_code
63183 ,xet.event_type_code
63184 ,xet.event_number
63185 ,xet.event_date
63186 ,xet.transaction_date
63187 ,xet.reference_num_1
63188 ,xet.reference_num_2
63189 ,xet.reference_num_3
63190 ,xet.reference_num_4
63191 ,xet.reference_char_1
63192 ,xet.reference_char_2
63193 ,xet.reference_char_3
63194 ,xet.reference_char_4
63195 ,xet.reference_date_1
63196 ,xet.reference_date_2
63197 ,xet.reference_date_3
63198 ,xet.reference_date_4
63199 ,xet.event_created_by
63200 ,xet.budgetary_control_flag
63201 , h5.RMT_BNK_BANK_CHARGES_CCID source_1
63202 , h5.RMT_BNK_CONFIRMATION_CCID source_3
63203 , h5.RMT_BNK_CASH_CCID source_5
63204 , h5.RMT_BNK_REMITTANCE_CCID source_6
63205 , h4.RCT_CLASS_REMIT_FLAG source_56
63206 , h4.RCT_CLASS_CONFIRM_FLAG source_57
63207 , h1.RCT_DOC_SEQUENCE_CATEGORY source_80
63208 , h1.RCT_DOC_SEQUENCE_ID source_81
63209 , h1.RCT_DOC_SEQUENCE_VALUE source_82
63210 , h1.RCT_TRX_ACCT_REVERSAL source_83
63211 FROM xla_events_gt xet
63212 , AR_CASH_RECEIPTS_H_V h1
63213 , AR_RCT_METHOD_H_V h4
63214 , AR_REMIT_BANK_ACCT_H_V h5
63215 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
63216 and xet.event_class_code = C_EVENT_CLASS_CODE
63217 and xet.event_status_code <> 'N' AND h1.event_id (+) = xet.event_id
63218 AND h4.event_id (+) = xet.event_id
63219 AND h5.event_id (+) = xet.event_id
63220
63221 ORDER BY event_id
63222 ;
63223
63224
63225 --
63226 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
63227 IS
63228 SELECT /*+ leading(xet) cardinality(xet,1) */
63232 ,xet.entity_code
63229 -- Event Class Code: MISC_RECEIPT
63230 xet.entity_id
63231 ,xet.legal_entity_id
63233 ,xet.transaction_number
63234 ,xet.event_id
63235 ,xet.event_class_code
63236 ,xet.event_type_code
63237 ,xet.event_number
63238 ,xet.event_date
63239 ,xet.transaction_date
63240 ,xet.reference_num_1
63241 ,xet.reference_num_2
63242 ,xet.reference_num_3
63243 ,xet.reference_num_4
63244 ,xet.reference_char_1
63245 ,xet.reference_char_2
63246 ,xet.reference_char_3
63247 ,xet.reference_char_4
63248 ,xet.reference_date_1
63249 ,xet.reference_date_2
63250 ,xet.reference_date_3
63251 ,xet.reference_date_4
63252 ,xet.event_created_by
63253 ,xet.budgetary_control_flag
63254 , l2.LINE_NUMBER
63255 , l3.DIST_CODE_COMBINATION_ID source_10
63256 , l3.DIST_SOURCE_TYPE source_15
63257 , l3.DIST_LINE_ID source_17
63258 , l3.DISTRIBUTION_TYPE source_18
63259 , l3.DIST_ENT_AMT source_19
63260 , l3.DIST_CURRENCY_CODE source_20
63261 , l2.DIST_CUR_CONVERSION_RATE source_22
63262 , l2.DIST_CUR_CONVERSION_TYPE source_23
63263 , l2.DIST_TO_ACCTD_AMT source_24
63264 , l3.DIST_MFAR_ADDITIONAL_ENTRY source_54
63265 , l2.DIST_TO_CUR_CONVERSION_DATE source_55
63266 FROM xla_events_gt xet
63267 , AR_DISTRIBUTIONS_BASE_V l2
63268 , AR_DISTRIBUTIONS_L_V l3
63269 WHERE xet.event_id between x_first_event_id and x_last_event_id
63270 and xet.event_date between p_pad_start_date and p_pad_end_date
63271 and xet.event_class_code = C_EVENT_CLASS_CODE
63272 and xet.event_status_code <> 'N' AND l2.event_id = xet.event_id
63273 AND l3.event_id = l2.event_id
63274 AND l3.line_number = l2.line_number
63275 ;
63276
63277 --
63278 BEGIN
63279 IF g_log_enabled THEN
63280 l_log_module := C_DEFAULT_MODULE||'.EventClass_111';
63281 END IF;
63282 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63283 trace
63284 (p_msg => 'BEGIN of EventClass_111'
63285 ,p_level => C_LEVEL_PROCEDURE
63286 ,p_module => l_log_module);
63287 END IF;
63288
63289 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
63290 trace
63291 (p_msg => 'p_application_id = '||p_application_id||
63292 ' - p_base_ledger_id = '||p_base_ledger_id||
63293 ' - p_target_ledger_id = '||p_target_ledger_id||
63294 ' - p_language = '||p_language||
63295 ' - p_currency_code = '||p_currency_code||
63296 ' - p_sla_ledger_id = '||p_sla_ledger_id
63297 ,p_level => C_LEVEL_STATEMENT
63298 ,p_module => l_log_module);
63299 END IF;
63300 --
63301 -- initialze arrays
63302 --
63303 g_array_event.DELETE;
63304 l_rec_array_event := l_null_rec_array_event;
63305 --
63306 --------------------------------------
63307 -- 4262811 Initialze MPA Line Number
63308 --------------------------------------
63309 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
63310
63311 --
63312
63313 --
63314 OPEN header_cur;
63315 --
63316 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
63317 trace
63318 (p_msg => 'SQL - FETCH header_cur'
63319 ,p_level => C_LEVEL_STATEMENT
63320 ,p_module => l_log_module);
63321 END IF;
63322 --
63323 LOOP
63324 FETCH header_cur BULK COLLECT INTO
63325 l_array_entity_id
63326 , l_array_legal_entity_id
63327 , l_array_entity_code
63328 , l_array_transaction_num
63329 , l_array_event_id
63330 , l_array_class_code
63331 , l_array_event_type
63332 , l_array_event_number
63333 , l_array_event_date
63334 , l_array_transaction_date
63335 , l_array_reference_num_1
63336 , l_array_reference_num_2
63337 , l_array_reference_num_3
63338 , l_array_reference_num_4
63339 , l_array_reference_char_1
63340 , l_array_reference_char_2
63341 , l_array_reference_char_3
63342 , l_array_reference_char_4
63343 , l_array_reference_date_1
63344 , l_array_reference_date_2
63345 , l_array_reference_date_3
63346 , l_array_reference_date_4
63347 , l_array_event_created_by
63348 , l_array_budgetary_control_flag
63349 , l_array_source_1
63350 , l_array_source_3
63351 , l_array_source_5
63352 , l_array_source_6
63353 , l_array_source_56
63354 , l_array_source_57
63355 , l_array_source_80
63356 , l_array_source_81
63357 , l_array_source_82
63358 , l_array_source_83
63359 LIMIT l_rows;
63360 --
63361 IF (C_LEVEL_EVENT >= g_log_level) THEN
63362 trace
63363 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
63364 ,p_level => C_LEVEL_EVENT
63365 ,p_module => l_log_module);
63366 END IF;
63367 --
63368 EXIT WHEN l_array_entity_id.COUNT = 0;
63369
63370 -- initialize arrays
63371 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
63372 XLA_AE_LINES_PKG.g_rec_lines := NULL;
63373
63374 --
63375 -- Bug 4458708
63376 --
63377 XLA_AE_LINES_PKG.g_LineNumber := 0;
63378
63379
63380 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
63381 g_last_hdr_idx := l_array_event_id.LAST;
63382 --
63383 -- loop for the headers. Each iteration is for each header extract row
63384 -- fetched in header cursor
63385 --
63386 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
63387
63388 --
63389 -- set event info as cache for other routines to refer event attributes
63390 --
63391 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
63392 (p_application_id => p_application_id
63393 ,p_primary_ledger_id => p_primary_ledger_id
63394 ,p_base_ledger_id => p_base_ledger_id
63395 ,p_target_ledger_id => p_target_ledger_id
63396 ,p_entity_id => l_array_entity_id(hdr_idx)
63397 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
63398 ,p_entity_code => l_array_entity_code(hdr_idx)
63399 ,p_transaction_num => l_array_transaction_num(hdr_idx)
63400 ,p_event_id => l_array_event_id(hdr_idx)
63401 ,p_event_class_code => l_array_class_code(hdr_idx)
63402 ,p_event_type_code => l_array_event_type(hdr_idx)
63403 ,p_event_number => l_array_event_number(hdr_idx)
63404 ,p_event_date => l_array_event_date(hdr_idx)
63405 ,p_transaction_date => l_array_transaction_date(hdr_idx)
63406 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
63407 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
63408 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
63409 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
63410 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
63411 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
63412 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
63413 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
63414 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
63415 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
63416 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
63417 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
63418 ,p_event_created_by => l_array_event_created_by(hdr_idx)
63419 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
63420
63421 --
63422 -- set the status of entry to C_VALID (0)
63423 --
63424 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
63425
63426 --
63427 -- initialize a row for ae header
63428 --
63429 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
63430
63431 l_event_id := l_array_event_id(hdr_idx);
63432
63433 --
63434 -- storing the hdr_idx for event. May be used by line cursor.
63435 --
63436 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
63437
63438 --
63439 -- store sources from header extract. This can be improved to
63440 -- store only those sources from header extract that may be used in lines
63441 --
63442
63443 g_array_event(l_event_id).array_value_num('source_1') := l_array_source_1(hdr_idx);
63444 g_array_event(l_event_id).array_value_num('source_3') := l_array_source_3(hdr_idx);
63445 g_array_event(l_event_id).array_value_num('source_5') := l_array_source_5(hdr_idx);
63446 g_array_event(l_event_id).array_value_num('source_6') := l_array_source_6(hdr_idx);
63447 g_array_event(l_event_id).array_value_char('source_56') := l_array_source_56(hdr_idx);
63448 g_array_event(l_event_id).array_value_char('source_57') := l_array_source_57(hdr_idx);
63449 g_array_event(l_event_id).array_value_char('source_80') := l_array_source_80(hdr_idx);
63450 g_array_event(l_event_id).array_value_num('source_81') := l_array_source_81(hdr_idx);
63451 g_array_event(l_event_id).array_value_num('source_82') := l_array_source_82(hdr_idx);
63452 g_array_event(l_event_id).array_value_char('source_83') := l_array_source_83(hdr_idx);
63453
63454 --
63455 -- initilaize the status of ae headers for diffrent balance types
63456 -- the status is initialised to C_NOT_CREATED (2)
63457 --
63458 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
63459 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
63460 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
63461
63462 --
63463 -- call api to validate and store accounting attributes for header
63464 --
63465
63466 ------------------------------------------------------------
63467 -- Accrual Reversal : to get date for Standard Source (NONE)
63468 ------------------------------------------------------------
63469 l_acc_rev_gl_date_source := NULL;
63470
63471 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
63472 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_80');
63473 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
63474 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_81');
63475 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
63476 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_82');
63477 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
63478 l_rec_acct_attrs.array_date_value(4) :=
63479 xla_ae_sources_pkg.GetSystemSourceDate(
63480 p_source_code => 'XLA_EVENT_DATE'
63481 , p_source_type_code => 'Y'
63482 , p_source_application_id => 602
63483 );
63484 l_rec_acct_attrs.array_acct_attr_code(5) := 'TRX_ACCT_REVERSAL_OPTION';
63485 l_rec_acct_attrs.array_char_value(5) := g_array_event(l_event_id).array_value_char('source_83');
63486
63487
63488 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
63489
63490 XLA_AE_HEADER_PKG.SetJeCategoryName;
63491
63492 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
63493 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
63494 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
63495 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
63496 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
63497
63498
63499 -- No header level analytical criteria
63500
63501 --
63502 --accounting attribute enhancement, bug 3612931
63503 --
63504 l_trx_reversal_source := SUBSTR(g_array_event(l_event_id).array_value_char('source_83'), 1,30);
63505
63506 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
63507 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
63508
63509 xla_accounting_err_pkg.build_message
63510 (p_appli_s_name => 'XLA'
63511 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
63512 ,p_token_1 => 'ACCT_ATTR_NAME'
63513 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
63514 ,p_token_2 => 'PRODUCT_NAME'
63515 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
63516 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
63517 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
63518 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
63519
63520 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
63521 --
63522 -- following sets the accounting attributes needed to reverse
63523 -- accounting for a distributeion
63524 --
63525 xla_ae_lines_pkg.SetTrxReversalAttrs
63526 (p_event_id => l_event_id
63527 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
63528 ,p_trx_reversal_source => l_trx_reversal_source);
63529
63530 END IF;
63531
63532
63533 ----------------------------------------------------------------
63534 -- 4262811 - update the header statuses to invalid in need be
63535 ----------------------------------------------------------------
63536 --
63537 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
63538
63539
63540 -----------------------------------------------
63541 -- No accrual reversal for the event class/type
63542 -----------------------------------------------
63543 ----------------------------------------------------------------
63544
63545 --
63546 -- this ends the header loop iteration for one bulk fetch
63547 --
63548 END LOOP;
63549
63550 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
63551 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
63552
63553 --
63554 -- insert dummy rows into lines gt table that were created due to
63555 -- transaction reversals
63556 --
63557 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
63558 l_result := XLA_AE_LINES_PKG.InsertLines;
63559 END IF;
63560
63561 --
63562 -- reset the temp_line_num for each set of events fetched from header
63563 -- cursor rather than doing it for each new event in line cursor
63564 -- Bug 3939231
63565 --
63566 xla_ae_lines_pkg.g_temp_line_num := 0;
63567
63568
63569
63570 --
63571 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
63572 --
63573 --
63574 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
63575
63576 trace
63577 (p_msg => 'SQL - FETCH line_cur'
63578 ,p_level => C_LEVEL_STATEMENT
63579 ,p_module => l_log_module);
63580
63581 END IF;
63582 --
63583 --
63584 LOOP
63585 --
63586 FETCH line_cur BULK COLLECT INTO
63587 l_array_entity_id
63588 , l_array_legal_entity_id
63589 , l_array_entity_code
63590 , l_array_transaction_num
63591 , l_array_event_id
63592 , l_array_class_code
63593 , l_array_event_type
63594 , l_array_event_number
63595 , l_array_event_date
63596 , l_array_transaction_date
63597 , l_array_reference_num_1
63598 , l_array_reference_num_2
63599 , l_array_reference_num_3
63600 , l_array_reference_num_4
63601 , l_array_reference_char_1
63602 , l_array_reference_char_2
63603 , l_array_reference_char_3
63604 , l_array_reference_char_4
63605 , l_array_reference_date_1
63609 , l_array_event_created_by
63606 , l_array_reference_date_2
63607 , l_array_reference_date_3
63608 , l_array_reference_date_4
63610 , l_array_budgetary_control_flag
63611 , l_array_extract_line_num
63612 , l_array_source_10
63613 , l_array_source_15
63614 , l_array_source_17
63615 , l_array_source_18
63616 , l_array_source_19
63617 , l_array_source_20
63618 , l_array_source_22
63619 , l_array_source_23
63620 , l_array_source_24
63621 , l_array_source_54
63622 , l_array_source_55
63623 LIMIT l_rows;
63624
63625 --
63626 IF (C_LEVEL_EVENT >= g_log_level) THEN
63627 trace
63628 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
63629 ,p_level => C_LEVEL_EVENT
63630 ,p_module => l_log_module);
63631 END IF;
63632 --
63633 EXIT WHEN l_array_entity_id.count = 0;
63634
63635 XLA_AE_LINES_PKG.g_rec_lines := null;
63636
63637 --
63638 -- Bug 4458708
63639 --
63640 XLA_AE_LINES_PKG.g_LineNumber := 0;
63641 --
63642 --
63643
63644 FOR Idx IN 1..l_array_event_id.count LOOP
63645 --
63646 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
63647 --
63648 l_event_id := l_array_event_id(idx); -- 5648433
63649
63650 --
63651 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
63652 --
63653
63654 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
63655 (g_array_event(l_event_id).array_value_num('header_index'))
63656 ,'N'
63657 ) <> 'Y'
63658 THEN
63659 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
63660 trace
63661 (p_msg => 'Trancaction revesal option is not Y '
63662 ,p_level => C_LEVEL_STATEMENT
63663 ,p_module => l_log_module);
63664 END IF;
63665
63666 --
63667 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
63668 --
63669 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
63670 --
63671 -- set event info as cache for other routines to refer event attributes
63672 --
63673
63674 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
63675 l_previous_event_id := l_event_id;
63676
63677 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
63678 (p_application_id => p_application_id
63679 ,p_primary_ledger_id => p_primary_ledger_id
63680 ,p_base_ledger_id => p_base_ledger_id
63681 ,p_target_ledger_id => p_target_ledger_id
63682 ,p_entity_id => l_array_entity_id(Idx)
63683 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
63684 ,p_entity_code => l_array_entity_code(Idx)
63685 ,p_transaction_num => l_array_transaction_num(Idx)
63686 ,p_event_id => l_array_event_id(Idx)
63687 ,p_event_class_code => l_array_class_code(Idx)
63688 ,p_event_type_code => l_array_event_type(Idx)
63689 ,p_event_number => l_array_event_number(Idx)
63690 ,p_event_date => l_array_event_date(Idx)
63691 ,p_transaction_date => l_array_transaction_date(Idx)
63692 ,p_reference_num_1 => l_array_reference_num_1(Idx)
63693 ,p_reference_num_2 => l_array_reference_num_2(Idx)
63694 ,p_reference_num_3 => l_array_reference_num_3(Idx)
63695 ,p_reference_num_4 => l_array_reference_num_4(Idx)
63696 ,p_reference_char_1 => l_array_reference_char_1(Idx)
63697 ,p_reference_char_2 => l_array_reference_char_2(Idx)
63698 ,p_reference_char_3 => l_array_reference_char_3(Idx)
63699 ,p_reference_char_4 => l_array_reference_char_4(Idx)
63700 ,p_reference_date_1 => l_array_reference_date_1(Idx)
63701 ,p_reference_date_2 => l_array_reference_date_2(Idx)
63702 ,p_reference_date_3 => l_array_reference_date_3(Idx)
63703 ,p_reference_date_4 => l_array_reference_date_4(Idx)
63704 ,p_event_created_by => l_array_event_created_by(Idx)
63705 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
63706 --
63707 END IF;
63708
63709
63710
63711 --
63712 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
63713
63714 l_acct_reversal_source := SUBSTR(NULL, 1,30);
63715
63716 IF l_continue_with_lines THEN
63717 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
63718 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
63719
63720 xla_accounting_err_pkg.build_message
63721 (p_appli_s_name => 'XLA'
63722 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
63723 ,p_token_1 => 'LINE_NUMBER'
63724 ,p_value_1 => l_array_extract_line_num(Idx)
63725 ,p_token_2 => 'PRODUCT_NAME'
63726 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
63727 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
63728 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
63729 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
63730
63731 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
63732 --
63733 -- following sets the accounting attributes needed to reverse
63734 -- accounting for a distributeion
63735 --
63736
63740 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
63737 --
63738 -- 5217187
63739 --
63741 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
63742 g_array_event(l_event_id).array_value_num('header_index'));
63743 --
63744 --
63745
63746 -- No reversal code generated
63747
63748 xla_ae_lines_pkg.SetAcctReversalAttrs
63749 (p_event_id => l_event_id
63750 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
63751 ,p_calculate_acctd_flag => l_calculate_acctd_flag
63752 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
63753 END IF;
63754
63755 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
63756 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
63757
63758 --
63759 AcctLineType_57 (
63760 p_application_id => p_application_id
63761 ,p_event_id => l_event_id
63762 ,p_calculate_acctd_flag => l_calculate_acctd_flag
63763 ,p_calculate_g_l_flag => l_calculate_g_l_flag
63764 ,p_actual_flag => l_actual_flag
63765 ,p_balance_type_code => l_balance_type_code
63766 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
63767
63768 , p_source_1 => g_array_event(l_event_id).array_value_num('source_1')
63769 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
63770 , p_source_15 => l_array_source_15(Idx)
63771 , p_source_17 => l_array_source_17(Idx)
63772 , p_source_18 => l_array_source_18(Idx)
63773 , p_source_19 => l_array_source_19(Idx)
63774 , p_source_20 => l_array_source_20(Idx)
63775 , p_source_22 => l_array_source_22(Idx)
63776 , p_source_23 => l_array_source_23(Idx)
63777 , p_source_24 => l_array_source_24(Idx)
63778 , p_source_54 => l_array_source_54(Idx)
63779 , p_source_55 => l_array_source_55(Idx)
63780 );
63781 If(l_balance_type_code = 'A') THEN
63782 l_actual_gain_loss_ref := l_gain_or_loss_ref;
63783 END IF;
63784
63785 --
63786
63787
63788 --
63789 AcctLineType_58 (
63790 p_application_id => p_application_id
63791 ,p_event_id => l_event_id
63792 ,p_calculate_acctd_flag => l_calculate_acctd_flag
63793 ,p_calculate_g_l_flag => l_calculate_g_l_flag
63794 ,p_actual_flag => l_actual_flag
63795 ,p_balance_type_code => l_balance_type_code
63796 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
63797
63798 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
63799 , p_source_10 => l_array_source_10(Idx)
63800 , p_source_15 => l_array_source_15(Idx)
63801 , p_source_17 => l_array_source_17(Idx)
63802 , p_source_18 => l_array_source_18(Idx)
63803 , p_source_19 => l_array_source_19(Idx)
63804 , p_source_20 => l_array_source_20(Idx)
63805 , p_source_22 => l_array_source_22(Idx)
63806 , p_source_23 => l_array_source_23(Idx)
63807 , p_source_24 => l_array_source_24(Idx)
63808 , p_source_54 => l_array_source_54(Idx)
63809 , p_source_55 => l_array_source_55(Idx)
63810 , p_source_56 => g_array_event(l_event_id).array_value_char('source_56')
63811 , p_source_57 => g_array_event(l_event_id).array_value_char('source_57')
63812 );
63813 If(l_balance_type_code = 'A') THEN
63814 l_actual_gain_loss_ref := l_gain_or_loss_ref;
63815 END IF;
63816
63817 --
63818
63819
63820 --
63821 AcctLineType_59 (
63822 p_application_id => p_application_id
63823 ,p_event_id => l_event_id
63824 ,p_calculate_acctd_flag => l_calculate_acctd_flag
63825 ,p_calculate_g_l_flag => l_calculate_g_l_flag
63826 ,p_actual_flag => l_actual_flag
63827 ,p_balance_type_code => l_balance_type_code
63828 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
63829
63830 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
63831 , p_source_10 => l_array_source_10(Idx)
63832 , p_source_15 => l_array_source_15(Idx)
63833 , p_source_17 => l_array_source_17(Idx)
63834 , p_source_18 => l_array_source_18(Idx)
63835 , p_source_19 => l_array_source_19(Idx)
63836 , p_source_20 => l_array_source_20(Idx)
63837 , p_source_22 => l_array_source_22(Idx)
63838 , p_source_23 => l_array_source_23(Idx)
63839 , p_source_24 => l_array_source_24(Idx)
63840 , p_source_54 => l_array_source_54(Idx)
63841 , p_source_55 => l_array_source_55(Idx)
63842 , p_source_56 => g_array_event(l_event_id).array_value_char('source_56')
63843 );
63844 If(l_balance_type_code = 'A') THEN
63845 l_actual_gain_loss_ref := l_gain_or_loss_ref;
63846 END IF;
63847
63848 --
63849
63850
63851 --
63852 AcctLineType_60 (
63853 p_application_id => p_application_id
63854 ,p_event_id => l_event_id
63855 ,p_calculate_acctd_flag => l_calculate_acctd_flag
63856 ,p_calculate_g_l_flag => l_calculate_g_l_flag
63857 ,p_actual_flag => l_actual_flag
63858 ,p_balance_type_code => l_balance_type_code
63859 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
63860
63861 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
63862 , p_source_10 => l_array_source_10(Idx)
63863 , p_source_15 => l_array_source_15(Idx)
63864 , p_source_17 => l_array_source_17(Idx)
63865 , p_source_18 => l_array_source_18(Idx)
63866 , p_source_19 => l_array_source_19(Idx)
63867 , p_source_20 => l_array_source_20(Idx)
63868 , p_source_22 => l_array_source_22(Idx)
63869 , p_source_23 => l_array_source_23(Idx)
63870 , p_source_24 => l_array_source_24(Idx)
63871 , p_source_54 => l_array_source_54(Idx)
63872 , p_source_55 => l_array_source_55(Idx)
63873 );
63874 If(l_balance_type_code = 'A') THEN
63878 --
63875 l_actual_gain_loss_ref := l_gain_or_loss_ref;
63876 END IF;
63877
63879
63880
63881 --
63882 AcctLineType_61 (
63883 p_application_id => p_application_id
63884 ,p_event_id => l_event_id
63885 ,p_calculate_acctd_flag => l_calculate_acctd_flag
63886 ,p_calculate_g_l_flag => l_calculate_g_l_flag
63887 ,p_actual_flag => l_actual_flag
63888 ,p_balance_type_code => l_balance_type_code
63889 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
63890
63891 , p_source_6 => g_array_event(l_event_id).array_value_num('source_6')
63892 , p_source_10 => l_array_source_10(Idx)
63893 , p_source_15 => l_array_source_15(Idx)
63894 , p_source_17 => l_array_source_17(Idx)
63895 , p_source_18 => l_array_source_18(Idx)
63896 , p_source_19 => l_array_source_19(Idx)
63897 , p_source_20 => l_array_source_20(Idx)
63898 , p_source_22 => l_array_source_22(Idx)
63899 , p_source_23 => l_array_source_23(Idx)
63900 , p_source_24 => l_array_source_24(Idx)
63901 , p_source_54 => l_array_source_54(Idx)
63902 , p_source_55 => l_array_source_55(Idx)
63903 );
63904 If(l_balance_type_code = 'A') THEN
63905 l_actual_gain_loss_ref := l_gain_or_loss_ref;
63906 END IF;
63907
63908 --
63909
63910
63911 --
63912 AcctLineType_69 (
63913 p_application_id => p_application_id
63914 ,p_event_id => l_event_id
63915 ,p_calculate_acctd_flag => l_calculate_acctd_flag
63916 ,p_calculate_g_l_flag => l_calculate_g_l_flag
63917 ,p_actual_flag => l_actual_flag
63918 ,p_balance_type_code => l_balance_type_code
63919 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
63920
63921 , p_source_10 => l_array_source_10(Idx)
63922 , p_source_15 => l_array_source_15(Idx)
63923 , p_source_17 => l_array_source_17(Idx)
63924 , p_source_18 => l_array_source_18(Idx)
63925 , p_source_19 => l_array_source_19(Idx)
63926 , p_source_20 => l_array_source_20(Idx)
63927 , p_source_22 => l_array_source_22(Idx)
63928 , p_source_23 => l_array_source_23(Idx)
63929 , p_source_24 => l_array_source_24(Idx)
63930 , p_source_54 => l_array_source_54(Idx)
63931 , p_source_55 => l_array_source_55(Idx)
63932 );
63933 If(l_balance_type_code = 'A') THEN
63934 l_actual_gain_loss_ref := l_gain_or_loss_ref;
63935 END IF;
63936
63937 --
63938
63939
63940 --
63941 AcctLineType_70 (
63942 p_application_id => p_application_id
63943 ,p_event_id => l_event_id
63944 ,p_calculate_acctd_flag => l_calculate_acctd_flag
63945 ,p_calculate_g_l_flag => l_calculate_g_l_flag
63946 ,p_actual_flag => l_actual_flag
63947 ,p_balance_type_code => l_balance_type_code
63948 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
63949
63950 , p_source_10 => l_array_source_10(Idx)
63951 , p_source_15 => l_array_source_15(Idx)
63952 , p_source_17 => l_array_source_17(Idx)
63953 , p_source_18 => l_array_source_18(Idx)
63954 , p_source_19 => l_array_source_19(Idx)
63955 , p_source_20 => l_array_source_20(Idx)
63956 , p_source_22 => l_array_source_22(Idx)
63957 , p_source_23 => l_array_source_23(Idx)
63958 , p_source_24 => l_array_source_24(Idx)
63959 , p_source_54 => l_array_source_54(Idx)
63960 , p_source_55 => l_array_source_55(Idx)
63961 );
63962 If(l_balance_type_code = 'A') THEN
63963 l_actual_gain_loss_ref := l_gain_or_loss_ref;
63964 END IF;
63965
63966 --
63967
63968
63969 --
63970 AcctLineType_71 (
63971 p_application_id => p_application_id
63972 ,p_event_id => l_event_id
63973 ,p_calculate_acctd_flag => l_calculate_acctd_flag
63974 ,p_calculate_g_l_flag => l_calculate_g_l_flag
63975 ,p_actual_flag => l_actual_flag
63976 ,p_balance_type_code => l_balance_type_code
63977 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
63978
63979 , p_source_10 => l_array_source_10(Idx)
63980 , p_source_15 => l_array_source_15(Idx)
63981 , p_source_17 => l_array_source_17(Idx)
63982 , p_source_18 => l_array_source_18(Idx)
63983 , p_source_19 => l_array_source_19(Idx)
63984 , p_source_20 => l_array_source_20(Idx)
63985 , p_source_22 => l_array_source_22(Idx)
63986 , p_source_23 => l_array_source_23(Idx)
63987 , p_source_24 => l_array_source_24(Idx)
63988 , p_source_54 => l_array_source_54(Idx)
63989 , p_source_55 => l_array_source_55(Idx)
63990 );
63991 If(l_balance_type_code = 'A') THEN
63992 l_actual_gain_loss_ref := l_gain_or_loss_ref;
63993 END IF;
63994
63995 --
63996
63997
63998 --
63999 AcctLineType_72 (
64000 p_application_id => p_application_id
64001 ,p_event_id => l_event_id
64002 ,p_calculate_acctd_flag => l_calculate_acctd_flag
64003 ,p_calculate_g_l_flag => l_calculate_g_l_flag
64004 ,p_actual_flag => l_actual_flag
64005 ,p_balance_type_code => l_balance_type_code
64006 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
64007
64008 , p_source_10 => l_array_source_10(Idx)
64009 , p_source_15 => l_array_source_15(Idx)
64010 , p_source_17 => l_array_source_17(Idx)
64011 , p_source_18 => l_array_source_18(Idx)
64012 , p_source_19 => l_array_source_19(Idx)
64013 , p_source_20 => l_array_source_20(Idx)
64014 , p_source_22 => l_array_source_22(Idx)
64015 , p_source_23 => l_array_source_23(Idx)
64016 , p_source_24 => l_array_source_24(Idx)
64017 , p_source_54 => l_array_source_54(Idx)
64018 , p_source_55 => l_array_source_55(Idx)
64019 );
64020 If(l_balance_type_code = 'A') THEN
64021 l_actual_gain_loss_ref := l_gain_or_loss_ref;
64022 END IF;
64023
64024 --
64025
64026
64030 ,p_event_id => l_event_id
64027 --
64028 AcctLineType_73 (
64029 p_application_id => p_application_id
64031 ,p_calculate_acctd_flag => l_calculate_acctd_flag
64032 ,p_calculate_g_l_flag => l_calculate_g_l_flag
64033 ,p_actual_flag => l_actual_flag
64034 ,p_balance_type_code => l_balance_type_code
64035 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
64036
64037 , p_source_10 => l_array_source_10(Idx)
64038 , p_source_15 => l_array_source_15(Idx)
64039 , p_source_17 => l_array_source_17(Idx)
64040 , p_source_18 => l_array_source_18(Idx)
64041 , p_source_19 => l_array_source_19(Idx)
64042 , p_source_20 => l_array_source_20(Idx)
64043 , p_source_22 => l_array_source_22(Idx)
64044 , p_source_23 => l_array_source_23(Idx)
64045 , p_source_24 => l_array_source_24(Idx)
64046 , p_source_54 => l_array_source_54(Idx)
64047 , p_source_55 => l_array_source_55(Idx)
64048 );
64049 If(l_balance_type_code = 'A') THEN
64050 l_actual_gain_loss_ref := l_gain_or_loss_ref;
64051 END IF;
64052
64053 --
64054
64055 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
64056 -- or secondary ledger that has different currency with primary
64057 -- or alc that is calculated by sla
64058 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
64059 (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'))
64060
64061 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
64062 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
64063 AND (l_actual_flag = 'A')) THEN
64064 XLA_AE_LINES_PKG.CreateGainOrLossLines(
64065 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
64066 ,p_application_id => p_application_id
64067 ,p_amb_context_code => 'DEFAULT'
64068 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
64069 ,p_event_class_code => C_EVENT_CLASS_CODE
64070 ,p_event_type_code => C_EVENT_TYPE_CODE
64071
64072 ,p_gain_ccid => -1
64073 ,p_loss_ccid => -1
64074
64075 ,p_actual_flag => l_actual_flag
64076 ,p_enc_flag => null
64077 ,p_actual_g_l_ref => l_actual_gain_loss_ref
64078 ,p_enc_g_l_ref => null
64079 );
64080 END IF;
64081 END IF;
64082 END IF;
64083
64084 ELSE
64085 --
64086 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
64087 --
64088 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
64089 trace
64090 (p_msg => 'Trancaction revesal option is Y'
64091 ,p_level => C_LEVEL_STATEMENT
64092 ,p_module => l_log_module);
64093 END IF;
64094 END IF;
64095
64096 END LOOP;
64097 l_result := XLA_AE_LINES_PKG.InsertLines ;
64098 end loop;
64099 close line_cur;
64100
64101
64102 --
64103 -- insert headers into xla_ae_headers_gt table
64104 --
64105 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
64106
64107 -- insert into errors table here.
64108
64109 END LOOP;
64110
64111 --
64112 -- 4865292
64113 --
64114 -- Compare g_hdr_extract_count with event count in
64115 -- CreateHeadersAndLines.
64116 --
64117 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
64118
64119 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
64120 trace (p_msg => '# rows extracted from header extract objects '
64121 || ' (running total): '
64122 || g_hdr_extract_count
64123 ,p_level => C_LEVEL_STATEMENT
64124 ,p_module => l_log_module);
64125 END IF;
64126
64127 CLOSE header_cur;
64128 --
64129
64130 --
64131 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64132 trace
64133 (p_msg => 'END of EventClass_111'
64134 ,p_level => C_LEVEL_PROCEDURE
64135 ,p_module => l_log_module);
64136 END IF;
64137 --
64138 RETURN l_result;
64139 EXCEPTION
64140 WHEN xla_exceptions_pkg.application_exception THEN
64141
64142 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
64143
64144
64145 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
64146
64147 RAISE;
64148
64149 WHEN NO_DATA_FOUND THEN
64150
64151 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
64152 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
64153
64154 FOR header_record IN header_cur
64155 LOOP
64156 l_array_header_events(header_record.event_id) := header_record.event_id;
64157 END LOOP;
64158
64159 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
64160 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
64161
64162 fnd_file.put_line(fnd_file.LOG, ' ');
64163 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
64164 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
64165 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
64166
64167 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
64168 LOOP
64169 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
64170 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
64174
64171 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
64172 END IF;
64173 END LOOP;
64175 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
64176 fnd_file.put_line(fnd_file.LOG, ' ');
64177
64178
64179 xla_exceptions_pkg.raise_message
64180 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_111');
64181
64182
64183 WHEN OTHERS THEN
64184 xla_exceptions_pkg.raise_message
64185 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_111');
64186 END EventClass_111;
64187 --
64188
64189 ---------------------------------------
64190 --
64191 -- PRIVATE PROCEDURE
64192 -- insert_sources_112
64193 --
64194 ----------------------------------------
64195 --
64196 PROCEDURE insert_sources_112(
64197 p_target_ledger_id IN NUMBER
64198 , p_language IN VARCHAR2
64199 , p_sla_ledger_id IN NUMBER
64200 , p_pad_start_date IN DATE
64201 , p_pad_end_date IN DATE
64202 )
64203 IS
64204
64205 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'RECEIPT_ALL';
64206 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'RECEIPT';
64207 p_apps_owner VARCHAR2(30);
64208 l_log_module VARCHAR2(240);
64209 BEGIN
64210 IF g_log_enabled THEN
64211 l_log_module := C_DEFAULT_MODULE||'.insert_sources_112';
64212 END IF;
64213 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64214
64215 trace
64216 (p_msg => 'BEGIN of insert_sources_112'
64217 ,p_level => C_LEVEL_PROCEDURE
64218 ,p_module => l_log_module);
64219
64220 END IF;
64221
64222 -- select APPS owner
64223 SELECT oracle_username
64224 INTO p_apps_owner
64225 FROM fnd_oracle_userid
64226 WHERE read_only_flag = 'U'
64227 ;
64228
64229 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
64230 trace
64231 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
64232 ' - p_language = '||p_language||
64233 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
64234 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
64235 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
64236 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
64237 ,p_level => C_LEVEL_STATEMENT
64238 ,p_module => l_log_module);
64239 END IF;
64240
64241
64242 --
64243 INSERT INTO xla_diag_sources --hdr2
64244 (
64245 event_id
64246 , ledger_id
64247 , sla_ledger_id
64248 , description_language
64249 , object_name
64250 , object_type_code
64251 , line_number
64252 , source_application_id
64253 , source_type_code
64254 , source_code
64255 , source_value
64256 , source_meaning
64257 , created_by
64258 , creation_date
64259 , last_update_date
64260 , last_updated_by
64261 , last_update_login
64262 , program_update_date
64263 , program_application_id
64264 , program_id
64265 , request_id
64266 )
64267 SELECT
64268 event_id
64269 , p_target_ledger_id
64270 , p_sla_ledger_id
64271 , p_language
64272 , object_name
64273 , object_type_code
64274 , line_number
64275 , source_application_id
64276 , source_type_code
64277 , source_code
64278 , SUBSTR(source_value ,1,1996)
64279 , SUBSTR(source_meaning ,1,200)
64280 , xla_environment_pkg.g_Usr_Id
64281 , TRUNC(SYSDATE)
64282 , TRUNC(SYSDATE)
64283 , xla_environment_pkg.g_Usr_Id
64284 , xla_environment_pkg.g_Login_Id
64285 , TRUNC(SYSDATE)
64286 , xla_environment_pkg.g_Prog_Appl_Id
64287 , xla_environment_pkg.g_Prog_Id
64288 , xla_environment_pkg.g_Req_Id
64289 FROM (
64290 SELECT xet.event_id event_id
64291 , 0 line_number
64292 , CASE r
64293 WHEN 1 THEN 'AR_REMIT_BANK_ACCT_H_V'
64294 WHEN 2 THEN 'AR_REMIT_BANK_ACCT_H_V'
64295 WHEN 3 THEN 'AR_REMIT_BANK_ACCT_H_V'
64296 WHEN 4 THEN 'AR_REMIT_BANK_ACCT_H_V'
64297 WHEN 5 THEN 'AR_REMIT_BANK_ACCT_H_V'
64298 WHEN 6 THEN 'AR_REMIT_BANK_ACCT_H_V'
64299 WHEN 7 THEN 'AR_REMIT_BANK_ACCT_H_V'
64300 WHEN 8 THEN 'AR_SYSTEM_PARAM_H_V'
64301 WHEN 9 THEN 'AR_SYSTEM_PARAM_H_V'
64302 WHEN 10 THEN 'AR_RCT_METHOD_H_V'
64303 WHEN 11 THEN 'AR_RCT_METHOD_H_V'
64304 WHEN 12 THEN 'AR_CASH_RECEIPTS_H_V'
64305 WHEN 13 THEN 'AR_CASH_RECEIPTS_H_V'
64306 WHEN 14 THEN 'AR_RCT_SITE_USES_H_V'
64307 WHEN 15 THEN 'AR_CASH_RECEIPTS_H_V'
64308 WHEN 16 THEN 'AR_CASH_RECEIPTS_H_V'
64309 WHEN 17 THEN 'AR_CASH_RECEIPTS_H_V'
64310 WHEN 18 THEN 'AR_CASH_RECEIPTS_H_V'
64311 WHEN 19 THEN 'AR_CASH_RECEIPTS_H_V'
64312
64313 ELSE null
64314 END object_name
64315 , CASE r
64319 WHEN 4 THEN 'HEADER'
64316 WHEN 1 THEN 'HEADER'
64317 WHEN 2 THEN 'HEADER'
64318 WHEN 3 THEN 'HEADER'
64320 WHEN 5 THEN 'HEADER'
64321 WHEN 6 THEN 'HEADER'
64322 WHEN 7 THEN 'HEADER'
64323 WHEN 8 THEN 'HEADER'
64324 WHEN 9 THEN 'HEADER'
64325 WHEN 10 THEN 'HEADER'
64326 WHEN 11 THEN 'HEADER'
64327 WHEN 12 THEN 'HEADER'
64328 WHEN 13 THEN 'HEADER'
64329 WHEN 14 THEN 'HEADER'
64330 WHEN 15 THEN 'HEADER'
64331 WHEN 16 THEN 'HEADER'
64332 WHEN 17 THEN 'HEADER'
64333 WHEN 18 THEN 'HEADER'
64334 WHEN 19 THEN 'HEADER'
64335
64336 ELSE null
64337 END object_type_code
64338 , CASE r
64339 WHEN 1 THEN '222'
64340 WHEN 2 THEN '222'
64341 WHEN 3 THEN '222'
64342 WHEN 4 THEN '222'
64343 WHEN 5 THEN '222'
64344 WHEN 6 THEN '222'
64345 WHEN 7 THEN '222'
64346 WHEN 8 THEN '222'
64347 WHEN 9 THEN '222'
64348 WHEN 10 THEN '222'
64349 WHEN 11 THEN '222'
64350 WHEN 12 THEN '222'
64351 WHEN 13 THEN '222'
64352 WHEN 14 THEN '222'
64353 WHEN 15 THEN '222'
64354 WHEN 16 THEN '222'
64355 WHEN 17 THEN '222'
64356 WHEN 18 THEN '222'
64357 WHEN 19 THEN '222'
64358
64359 ELSE null
64360 END source_application_id
64361 , 'S' source_type_code
64362 , CASE r
64363 WHEN 1 THEN 'RMT_BNK_BANK_CHARGES_CCID'
64364 WHEN 2 THEN 'RMT_BNK_CONFIRMATION_CCID'
64365 WHEN 3 THEN 'RMT_BNK_EARNED_CCID'
64366 WHEN 4 THEN 'RMT_BNK_CASH_CCID'
64367 WHEN 5 THEN 'RMT_BNK_REMITTANCE_CCID'
64368 WHEN 6 THEN 'RMT_BNK_UNEARNED_CCID'
64369 WHEN 7 THEN 'RMT_BNK_UNAPPLIED_CCID'
64370 WHEN 8 THEN 'CODE_COMBINATION_ID_GAIN'
64371 WHEN 9 THEN 'CODE_COMBINATION_ID_LOSS'
64372 WHEN 10 THEN 'RCT_CLASS_REMIT_FLAG'
64373 WHEN 11 THEN 'RCT_CLASS_CONFIRM_FLAG'
64374 WHEN 12 THEN 'RCT_XLA_APPLIED_TO_APP_ID'
64375 WHEN 13 THEN 'RCT_PAY_FROM_CUSTOMER'
64376 WHEN 14 THEN 'RCT_SITE_SITE_USE_ID'
64377 WHEN 15 THEN 'RCT_APP_STATUS'
64378 WHEN 16 THEN 'RCT_DOC_SEQUENCE_CATEGORY'
64379 WHEN 17 THEN 'RCT_DOC_SEQUENCE_ID'
64380 WHEN 18 THEN 'RCT_DOC_SEQUENCE_VALUE'
64381 WHEN 19 THEN 'RCT_TRX_ACCT_REVERSAL'
64382
64383 ELSE null
64384 END source_code
64385 , CASE r
64386 WHEN 1 THEN TO_CHAR(h8.RMT_BNK_BANK_CHARGES_CCID)
64387 WHEN 2 THEN TO_CHAR(h8.RMT_BNK_CONFIRMATION_CCID)
64388 WHEN 3 THEN TO_CHAR(h8.RMT_BNK_EARNED_CCID)
64389 WHEN 4 THEN TO_CHAR(h8.RMT_BNK_CASH_CCID)
64390 WHEN 5 THEN TO_CHAR(h8.RMT_BNK_REMITTANCE_CCID)
64391 WHEN 6 THEN TO_CHAR(h8.RMT_BNK_UNEARNED_CCID)
64392 WHEN 7 THEN TO_CHAR(h8.RMT_BNK_UNAPPLIED_CCID)
64393 WHEN 8 THEN TO_CHAR(h9.CODE_COMBINATION_ID_GAIN)
64394 WHEN 9 THEN TO_CHAR(h9.CODE_COMBINATION_ID_LOSS)
64395 WHEN 10 THEN TO_CHAR(h5.RCT_CLASS_REMIT_FLAG)
64396 WHEN 11 THEN TO_CHAR(h5.RCT_CLASS_CONFIRM_FLAG)
64397 WHEN 12 THEN TO_CHAR(h1.RCT_XLA_APPLIED_TO_APP_ID)
64398 WHEN 13 THEN TO_CHAR(h1.RCT_PAY_FROM_CUSTOMER)
64399 WHEN 14 THEN TO_CHAR(h6.RCT_SITE_SITE_USE_ID)
64400 WHEN 15 THEN TO_CHAR(h1.RCT_APP_STATUS)
64401 WHEN 16 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_CATEGORY)
64402 WHEN 17 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_ID)
64403 WHEN 18 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_VALUE)
64404 WHEN 19 THEN TO_CHAR(h1.RCT_TRX_ACCT_REVERSAL)
64405
64406 ELSE null
64407 END source_value
64408 , null source_meaning
64409 FROM xla_events_gt xet
64410 , AR_CASH_RECEIPTS_H_V h1
64411 , AR_RCT_METHOD_H_V h5
64412 , AR_RCT_SITE_USES_H_V h6
64413 , AR_REMIT_BANK_ACCT_H_V h8
64414 , AR_SYSTEM_PARAM_H_V h9
64415 ,(select rownum r from all_objects where rownum <= 19 and owner = p_apps_owner)
64416 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
64417 AND xet.event_class_code = C_EVENT_CLASS_CODE
64418 AND h1.event_id = xet.event_id
64419 AND h5.event_id (+) = h1.event_id
64420 AND h6.event_id (+) = h1.event_id
64421 AND h8.event_id (+) = h1.event_id
64422 AND h9.event_id (+) = h1.event_id
64423
64424 )
64425 ;
64426 --
64427 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
64428
64429 trace
64430 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
64431 ,p_level => C_LEVEL_STATEMENT
64432 ,p_module => l_log_module);
64433
64434 END IF;
64435 --
64436
64437
64438
64439 --
64440 INSERT INTO xla_diag_sources --line2
64441 (
64445 , description_language
64442 event_id
64443 , ledger_id
64444 , sla_ledger_id
64446 , object_name
64447 , object_type_code
64448 , line_number
64449 , source_application_id
64450 , source_type_code
64451 , source_code
64452 , source_value
64453 , source_meaning
64454 , created_by
64455 , creation_date
64456 , last_update_date
64457 , last_updated_by
64458 , last_update_login
64459 , program_update_date
64460 , program_application_id
64461 , program_id
64462 , request_id
64463 )
64464 SELECT event_id
64465 , p_target_ledger_id
64466 , p_sla_ledger_id
64467 , p_language
64468 , object_name
64469 , object_type_code
64470 , line_number
64471 , source_application_id
64472 , source_type_code
64473 , source_code
64474 , SUBSTR(source_value,1,1996)
64475 , SUBSTR(source_meaning ,1,200)
64476 , xla_environment_pkg.g_Usr_Id
64477 , TRUNC(SYSDATE)
64478 , TRUNC(SYSDATE)
64479 , xla_environment_pkg.g_Usr_Id
64480 , xla_environment_pkg.g_Login_Id
64481 , TRUNC(SYSDATE)
64482 , xla_environment_pkg.g_Prog_Appl_Id
64483 , xla_environment_pkg.g_Prog_Id
64484 , xla_environment_pkg.g_Req_Id
64485 FROM (
64486 SELECT xet.event_id event_id
64487 , l4.line_number line_number
64488 , CASE r
64489 WHEN 1 THEN 'AR_DISTRIBUTIONS_L_V'
64490 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
64491 WHEN 3 THEN 'AR_DISTRIBUTIONS_L_V'
64492 WHEN 4 THEN 'AR_RECEIVABLES_TRX_ACT_S_V'
64493 WHEN 5 THEN 'AR_DISTRIBUTIONS_L_V'
64494 WHEN 6 THEN 'AR_DISTRIBUTIONS_L_V'
64495 WHEN 7 THEN 'AR_DISTRIBUTIONS_L_V'
64496 WHEN 8 THEN 'AR_DISTRIBUTIONS_L_V'
64497 WHEN 9 THEN 'AR_DISTRIBUTIONS_BASE_V'
64498 WHEN 10 THEN 'AR_DISTRIBUTIONS_BASE_V'
64499 WHEN 11 THEN 'AR_DISTRIBUTIONS_BASE_V'
64500 WHEN 12 THEN 'AR_DISTRIBUTIONS_BASE_V'
64501 WHEN 13 THEN 'AR_CUST_TRX_LINES_L_V'
64502 WHEN 14 THEN 'AR_CUST_TRX_LINES_L_V'
64503 WHEN 15 THEN 'AR_CUST_TRX_LINES_L_V'
64504 WHEN 16 THEN 'AR_DISTRIBUTIONS_L_V'
64505 WHEN 17 THEN 'AR_DISTRIBUTIONS_BASE_V'
64506 WHEN 18 THEN 'AR_TRANSACTIONS_S_V'
64507 WHEN 19 THEN 'AR_TRANSACTIONS_S_V'
64508 WHEN 20 THEN 'AR_DISTRIBUTIONS_L_V'
64509 WHEN 21 THEN 'AR_DISTRIBUTIONS_L_V'
64510 WHEN 22 THEN 'AR_DISTRIBUTIONS_BASE_V'
64511 WHEN 23 THEN 'AR_DISTRIBUTIONS_L_V'
64512 WHEN 24 THEN 'AR_DISTRIBUTIONS_L_V'
64513 WHEN 25 THEN 'AR_DISTRIBUTIONS_L_V'
64514 WHEN 26 THEN 'AR_DISTRIBUTIONS_BASE_V'
64515 WHEN 27 THEN 'AR_DISTRIBUTIONS_BASE_V'
64516 WHEN 28 THEN 'AR_DISTRIBUTIONS_L_V'
64517
64518 ELSE null
64519 END object_name
64520 , CASE r
64521 WHEN 1 THEN 'LINE'
64522 WHEN 2 THEN 'LINE'
64523 WHEN 3 THEN 'LINE'
64524 WHEN 4 THEN 'LINE'
64525 WHEN 5 THEN 'LINE'
64526 WHEN 6 THEN 'LINE'
64527 WHEN 7 THEN 'LINE'
64528 WHEN 8 THEN 'LINE'
64529 WHEN 9 THEN 'LINE'
64530 WHEN 10 THEN 'LINE'
64531 WHEN 11 THEN 'LINE'
64532 WHEN 12 THEN 'LINE'
64533 WHEN 13 THEN 'LINE'
64534 WHEN 14 THEN 'LINE'
64535 WHEN 15 THEN 'LINE'
64536 WHEN 16 THEN 'LINE'
64537 WHEN 17 THEN 'LINE'
64538 WHEN 18 THEN 'LINE'
64539 WHEN 19 THEN 'LINE'
64540 WHEN 20 THEN 'LINE'
64541 WHEN 21 THEN 'LINE'
64542 WHEN 22 THEN 'LINE'
64543 WHEN 23 THEN 'LINE'
64544 WHEN 24 THEN 'LINE'
64545 WHEN 25 THEN 'LINE'
64546 WHEN 26 THEN 'LINE'
64547 WHEN 27 THEN 'LINE'
64548 WHEN 28 THEN 'LINE'
64549
64550 ELSE null
64551 END object_type_code
64552 , CASE r
64553 WHEN 1 THEN '222'
64554 WHEN 2 THEN '222'
64555 WHEN 3 THEN '222'
64556 WHEN 4 THEN '222'
64557 WHEN 5 THEN '222'
64558 WHEN 6 THEN '222'
64559 WHEN 7 THEN '222'
64560 WHEN 8 THEN '222'
64561 WHEN 9 THEN '222'
64562 WHEN 10 THEN '222'
64563 WHEN 11 THEN '222'
64564 WHEN 12 THEN '222'
64565 WHEN 13 THEN '222'
64566 WHEN 14 THEN '222'
64567 WHEN 15 THEN '222'
64568 WHEN 16 THEN '222'
64569 WHEN 17 THEN '222'
64570 WHEN 18 THEN '222'
64571 WHEN 19 THEN '222'
64572 WHEN 20 THEN '222'
64573 WHEN 21 THEN '222'
64574 WHEN 22 THEN '222'
64575 WHEN 23 THEN '222'
64579 WHEN 27 THEN '222'
64576 WHEN 24 THEN '222'
64577 WHEN 25 THEN '222'
64578 WHEN 26 THEN '222'
64580 WHEN 28 THEN '222'
64581
64582 ELSE null
64583 END source_application_id
64584 , 'S' source_type_code
64585 , CASE r
64586 WHEN 1 THEN 'DIST_CODE_COMBINATION_ID'
64587 WHEN 2 THEN 'TRX_LINE_DIST_CCID'
64588 WHEN 3 THEN 'DIST_SOURCE_TYPE'
64589 WHEN 4 THEN 'REC_ACT_TYPE'
64590 WHEN 5 THEN 'DIST_LINE_ID'
64591 WHEN 6 THEN 'DISTRIBUTION_TYPE'
64592 WHEN 7 THEN 'DIST_ENT_AMT'
64593 WHEN 8 THEN 'DIST_CURRENCY_CODE'
64594 WHEN 9 THEN 'DIST_CUR_CONVERSION_DATE'
64595 WHEN 10 THEN 'DIST_CUR_CONVERSION_RATE'
64596 WHEN 11 THEN 'DIST_CUR_CONVERSION_TYPE'
64597 WHEN 12 THEN 'DIST_TO_ACCTD_AMT'
64598 WHEN 13 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
64599 WHEN 14 THEN 'TRX_LINE_DIST_ID'
64600 WHEN 15 THEN 'TRX_DISTRIBUTION_TYPE'
64601 WHEN 16 THEN 'DIST_MFAR_ADDITIONAL_ENTRY'
64602 WHEN 17 THEN 'DIST_TO_CUR_CONVERSION_DATE'
64603 WHEN 18 THEN 'TRX_ENTITY_CODE'
64604 WHEN 19 THEN 'TRX_CUSTOMER_TRX_ID'
64605 WHEN 20 THEN 'DIST_ENT_AMT_FROM'
64606 WHEN 21 THEN 'DIST_CURRENCY_CODE_FROM'
64607 WHEN 22 THEN 'DIST_ACCTD_AMT'
64608 WHEN 23 THEN 'DIST_PARTY_ID'
64609 WHEN 24 THEN 'DIST_PARTY_SITE_ID'
64610 WHEN 25 THEN 'DIST_PARTY_TYPE'
64611 WHEN 26 THEN 'DIST_TO_CUR_CONVERSION_TYPE'
64612 WHEN 27 THEN 'DIST_TO_CUR_CONVERSION_RATE'
64613 WHEN 28 THEN 'DIST_SOURCE_TABLE'
64614
64615 ELSE null
64616 END source_code
64617 , CASE r
64618 WHEN 1 THEN TO_CHAR(l4.DIST_CODE_COMBINATION_ID)
64619 WHEN 2 THEN TO_CHAR(l2.TRX_LINE_DIST_CCID)
64620 WHEN 3 THEN TO_CHAR(l4.DIST_SOURCE_TYPE)
64621 WHEN 4 THEN TO_CHAR(l7.REC_ACT_TYPE)
64622 WHEN 5 THEN TO_CHAR(l4.DIST_LINE_ID)
64623 WHEN 6 THEN TO_CHAR(l4.DISTRIBUTION_TYPE)
64624 WHEN 7 THEN TO_CHAR(l4.DIST_ENT_AMT)
64625 WHEN 8 THEN TO_CHAR(l4.DIST_CURRENCY_CODE)
64626 WHEN 9 THEN TO_CHAR(l3.DIST_CUR_CONVERSION_DATE)
64627 WHEN 10 THEN TO_CHAR(l3.DIST_CUR_CONVERSION_RATE)
64628 WHEN 11 THEN TO_CHAR(l3.DIST_CUR_CONVERSION_TYPE)
64629 WHEN 12 THEN TO_CHAR(l3.DIST_TO_ACCTD_AMT)
64630 WHEN 13 THEN TO_CHAR(l2.TRX_LINE_DIST_ACCOUNT_CLASS)
64631 WHEN 14 THEN TO_CHAR(l2.TRX_LINE_DIST_ID)
64632 WHEN 15 THEN TO_CHAR(l2.TRX_DISTRIBUTION_TYPE)
64633 WHEN 16 THEN TO_CHAR(l4.DIST_MFAR_ADDITIONAL_ENTRY)
64634 WHEN 17 THEN TO_CHAR(l3.DIST_TO_CUR_CONVERSION_DATE)
64635 WHEN 18 THEN TO_CHAR(l10.TRX_ENTITY_CODE)
64636 WHEN 19 THEN TO_CHAR(l10.TRX_CUSTOMER_TRX_ID)
64637 WHEN 20 THEN TO_CHAR(l4.DIST_ENT_AMT_FROM)
64638 WHEN 21 THEN TO_CHAR(l4.DIST_CURRENCY_CODE_FROM)
64639 WHEN 22 THEN TO_CHAR(l3.DIST_ACCTD_AMT)
64640 WHEN 23 THEN TO_CHAR(l4.DIST_PARTY_ID)
64641 WHEN 24 THEN TO_CHAR(l4.DIST_PARTY_SITE_ID)
64642 WHEN 25 THEN TO_CHAR(l4.DIST_PARTY_TYPE)
64643 WHEN 26 THEN TO_CHAR(l3.DIST_TO_CUR_CONVERSION_TYPE)
64644 WHEN 27 THEN TO_CHAR(l3.DIST_TO_CUR_CONVERSION_RATE)
64645 WHEN 28 THEN TO_CHAR(l4.DIST_SOURCE_TABLE)
64646
64647 ELSE null
64648 END source_value
64649 , null source_meaning
64650 FROM xla_events_gt xet
64651 , AR_CUST_TRX_LINES_L_V l2
64652 , AR_DISTRIBUTIONS_BASE_V l3
64653 , AR_DISTRIBUTIONS_L_V l4
64654 , AR_RECEIVABLES_TRX_ACT_S_V l7
64655 , AR_TRANSACTIONS_S_V l10
64656 , (select rownum r from all_objects where rownum <= 28 and owner = p_apps_owner)
64657 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
64658 AND xet.event_class_code = C_EVENT_CLASS_CODE
64659 AND l3.event_id = xet.event_id
64660 AND l2.event_id (+) = l3.event_id
64661 AND l2.line_number (+) = l3.line_number
64662 AND l4.event_id = l3.event_id
64663 AND l4.line_number = l3.line_number
64664 AND l7.event_id (+) = l3.event_id
64665 AND l7.line_number (+) = l3.line_number
64666 AND l10.event_id (+) = l3.event_id
64667 AND l10.line_number (+) = l3.line_number
64668
64669 )
64670 ;
64671 --
64672 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
64673
64674 trace
64675 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
64676 ,p_level => C_LEVEL_STATEMENT
64677 ,p_module => l_log_module);
64678
64679 END IF;
64680
64681
64682 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64683 trace
64684 (p_msg => 'END of insert_sources_112'
64685 ,p_level => C_LEVEL_PROCEDURE
64686 ,p_module => l_log_module);
64687 END IF;
64688 EXCEPTION
64689 WHEN xla_exceptions_pkg.application_exception THEN
64690 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
64691 trace
64692 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
64693 ,p_level => C_LEVEL_EXCEPTION
64697 WHEN OTHERS THEN
64694 ,p_module => l_log_module);
64695 END IF;
64696 RAISE;
64698 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
64699 trace
64700 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
64701 ,p_level => C_LEVEL_EXCEPTION
64702 ,p_module => l_log_module);
64703 END IF;
64704 xla_exceptions_pkg.raise_message
64705 (p_location => 'XLA_00222_AAD_S_000007_PKG.insert_sources_112');
64706 END insert_sources_112;
64707 --
64708
64709 ---------------------------------------
64710 --
64711 -- PRIVATE FUNCTION
64712 -- EventClass_112
64713 --
64714 ----------------------------------------
64715 --
64716 FUNCTION EventClass_112
64717 (p_application_id IN NUMBER
64718 ,p_base_ledger_id IN NUMBER
64719 ,p_target_ledger_id IN NUMBER
64720 ,p_language IN VARCHAR2
64721 ,p_currency_code IN VARCHAR2
64722 ,p_sla_ledger_id IN NUMBER
64723 ,p_pad_start_date IN DATE
64724 ,p_pad_end_date IN DATE
64725 ,p_primary_ledger_id IN NUMBER)
64726 RETURN BOOLEAN IS
64727 --
64728 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'RECEIPT_ALL';
64729 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'RECEIPT';
64730
64731 l_calculate_acctd_flag VARCHAR2(1) :='N';
64732 l_calculate_g_l_flag VARCHAR2(1) :='Y';
64733 --
64734 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
64735 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
64736 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
64737 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
64738 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
64739 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
64740 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
64741 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
64742 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
64743 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
64744 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
64745 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
64746 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
64747 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
64748 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
64749 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
64750 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
64751 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
64752 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
64753 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
64754 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
64755 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
64756 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
64757 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
64758 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
64759 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
64760
64761 l_event_id NUMBER;
64762 l_previous_event_id NUMBER;
64763 l_first_event_id NUMBER;
64764 l_last_event_id NUMBER;
64765
64766 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
64767 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
64768 --
64769 --
64770 l_result BOOLEAN := TRUE;
64771 l_rows NUMBER := 1000;
64772 l_event_type_name VARCHAR2(80) := 'All';
64773 l_event_class_name VARCHAR2(80) := 'Receipt';
64774 l_description VARCHAR2(4000);
64775 l_transaction_reversal NUMBER;
64776 l_ae_header_id NUMBER;
64777 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
64778 l_log_module VARCHAR2(240);
64779 --
64780 l_acct_reversal_source VARCHAR2(30);
64781 l_trx_reversal_source VARCHAR2(30);
64782
64783 l_continue_with_lines BOOLEAN := TRUE;
64784 --
64785 l_acc_rev_gl_date_source DATE; -- 4262811
64786 --
64787 type t_array_event_id is table of number index by binary_integer;
64788
64789 l_rec_array_event t_rec_array_event;
64790 l_null_rec_array_event t_rec_array_event;
64791 l_array_ae_header_id xla_number_array_type;
64792 l_actual_flag VARCHAR2(1) := NULL;
64793 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
64794 l_balance_type_code VARCHAR2(1) :=NULL;
64795 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
64796
64797 --
64798 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
64799 --
64800
64801 TYPE t_array_source_1 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_BANK_CHARGES_CCID%TYPE INDEX BY BINARY_INTEGER;
64802 TYPE t_array_source_3 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_CONFIRMATION_CCID%TYPE INDEX BY BINARY_INTEGER;
64806 TYPE t_array_source_7 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_UNEARNED_CCID%TYPE INDEX BY BINARY_INTEGER;
64803 TYPE t_array_source_4 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_EARNED_CCID%TYPE INDEX BY BINARY_INTEGER;
64804 TYPE t_array_source_5 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_CASH_CCID%TYPE INDEX BY BINARY_INTEGER;
64805 TYPE t_array_source_6 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_REMITTANCE_CCID%TYPE INDEX BY BINARY_INTEGER;
64807 TYPE t_array_source_11 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_UNAPPLIED_CCID%TYPE INDEX BY BINARY_INTEGER;
64808 TYPE t_array_source_12 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_GAIN%TYPE INDEX BY BINARY_INTEGER;
64809 TYPE t_array_source_13 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_LOSS%TYPE INDEX BY BINARY_INTEGER;
64810 TYPE t_array_source_56 IS TABLE OF AR_RCT_METHOD_H_V.RCT_CLASS_REMIT_FLAG%TYPE INDEX BY BINARY_INTEGER;
64811 TYPE t_array_source_57 IS TABLE OF AR_RCT_METHOD_H_V.RCT_CLASS_CONFIRM_FLAG%TYPE INDEX BY BINARY_INTEGER;
64812 TYPE t_array_source_58 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_XLA_APPLIED_TO_APP_ID%TYPE INDEX BY BINARY_INTEGER;
64813 TYPE t_array_source_70 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_PAY_FROM_CUSTOMER%TYPE INDEX BY BINARY_INTEGER;
64814 TYPE t_array_source_71 IS TABLE OF AR_RCT_SITE_USES_H_V.RCT_SITE_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
64815 TYPE t_array_source_72 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_APP_STATUS%TYPE INDEX BY BINARY_INTEGER;
64816 TYPE t_array_source_80 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
64817 TYPE t_array_source_81 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
64818 TYPE t_array_source_82 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
64819 TYPE t_array_source_83 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_TRX_ACCT_REVERSAL%TYPE INDEX BY BINARY_INTEGER;
64820
64821 TYPE t_array_source_10 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
64822 TYPE t_array_source_14 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
64823 TYPE t_array_source_15 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
64824 TYPE t_array_source_16 IS TABLE OF AR_RECEIVABLES_TRX_ACT_S_V.REC_ACT_TYPE%TYPE INDEX BY BINARY_INTEGER;
64825 TYPE t_array_source_17 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
64826 TYPE t_array_source_18 IS TABLE OF AR_DISTRIBUTIONS_L_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
64827 TYPE t_array_source_19 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
64828 TYPE t_array_source_20 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
64829 TYPE t_array_source_21 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
64830 TYPE t_array_source_22 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
64831 TYPE t_array_source_23 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
64832 TYPE t_array_source_24 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
64833 TYPE t_array_source_28 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
64834 TYPE t_array_source_29 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
64835 TYPE t_array_source_30 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
64836 TYPE t_array_source_54 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_MFAR_ADDITIONAL_ENTRY%TYPE INDEX BY BINARY_INTEGER;
64837 TYPE t_array_source_55 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
64838 TYPE t_array_source_59 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_ENTITY_CODE%TYPE INDEX BY BINARY_INTEGER;
64839 TYPE t_array_source_60 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_CUSTOMER_TRX_ID%TYPE INDEX BY BINARY_INTEGER;
64840 TYPE t_array_source_61 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT_FROM%TYPE INDEX BY BINARY_INTEGER;
64841 TYPE t_array_source_62 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE_FROM%TYPE INDEX BY BINARY_INTEGER;
64842 TYPE t_array_source_63 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
64843 TYPE t_array_source_64 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_PARTY_ID%TYPE INDEX BY BINARY_INTEGER;
64844 TYPE t_array_source_65 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_PARTY_SITE_ID%TYPE INDEX BY BINARY_INTEGER;
64845 TYPE t_array_source_66 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
64846 TYPE t_array_source_67 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
64847 TYPE t_array_source_68 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
64848 TYPE t_array_source_69 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TABLE%TYPE INDEX BY BINARY_INTEGER;
64849
64850 l_array_source_1 t_array_source_1;
64851 l_array_source_3 t_array_source_3;
64852 l_array_source_4 t_array_source_4;
64853 l_array_source_5 t_array_source_5;
64854 l_array_source_6 t_array_source_6;
64855 l_array_source_7 t_array_source_7;
64856 l_array_source_11 t_array_source_11;
64857 l_array_source_12 t_array_source_12;
64858 l_array_source_13 t_array_source_13;
64859 l_array_source_56 t_array_source_56;
64860 l_array_source_57 t_array_source_57;
64861 l_array_source_58 t_array_source_58;
64862 l_array_source_70 t_array_source_70;
64863 l_array_source_71 t_array_source_71;
64864 l_array_source_72 t_array_source_72;
64865 l_array_source_80 t_array_source_80;
64866 l_array_source_81 t_array_source_81;
64867 l_array_source_82 t_array_source_82;
64868 l_array_source_83 t_array_source_83;
64869
64870 l_array_source_10 t_array_source_10;
64871 l_array_source_14 t_array_source_14;
64872 l_array_source_15 t_array_source_15;
64873 l_array_source_16 t_array_source_16;
64874 l_array_source_17 t_array_source_17;
64875 l_array_source_18 t_array_source_18;
64879 l_array_source_22 t_array_source_22;
64876 l_array_source_19 t_array_source_19;
64877 l_array_source_20 t_array_source_20;
64878 l_array_source_21 t_array_source_21;
64880 l_array_source_23 t_array_source_23;
64881 l_array_source_24 t_array_source_24;
64882 l_array_source_28 t_array_source_28;
64883 l_array_source_29 t_array_source_29;
64884 l_array_source_30 t_array_source_30;
64885 l_array_source_54 t_array_source_54;
64886 l_array_source_55 t_array_source_55;
64887 l_array_source_59 t_array_source_59;
64888 l_array_source_60 t_array_source_60;
64889 l_array_source_61 t_array_source_61;
64890 l_array_source_62 t_array_source_62;
64891 l_array_source_63 t_array_source_63;
64892 l_array_source_64 t_array_source_64;
64893 l_array_source_65 t_array_source_65;
64894 l_array_source_66 t_array_source_66;
64895 l_array_source_67 t_array_source_67;
64896 l_array_source_68 t_array_source_68;
64897 l_array_source_69 t_array_source_69;
64898
64899 --
64900 CURSOR header_cur
64901 IS
64902 SELECT /*+ leading(xet) cardinality(xet,1) */
64903 -- Event Class Code: RECEIPT
64904 xet.entity_id
64905 ,xet.legal_entity_id
64906 ,xet.entity_code
64907 ,xet.transaction_number
64908 ,xet.event_id
64909 ,xet.event_class_code
64910 ,xet.event_type_code
64911 ,xet.event_number
64912 ,xet.event_date
64913 ,xet.transaction_date
64914 ,xet.reference_num_1
64915 ,xet.reference_num_2
64916 ,xet.reference_num_3
64917 ,xet.reference_num_4
64918 ,xet.reference_char_1
64919 ,xet.reference_char_2
64920 ,xet.reference_char_3
64921 ,xet.reference_char_4
64922 ,xet.reference_date_1
64923 ,xet.reference_date_2
64924 ,xet.reference_date_3
64925 ,xet.reference_date_4
64926 ,xet.event_created_by
64927 ,xet.budgetary_control_flag
64928 , h8.RMT_BNK_BANK_CHARGES_CCID source_1
64929 , h8.RMT_BNK_CONFIRMATION_CCID source_3
64930 , h8.RMT_BNK_EARNED_CCID source_4
64931 , h8.RMT_BNK_CASH_CCID source_5
64932 , h8.RMT_BNK_REMITTANCE_CCID source_6
64933 , h8.RMT_BNK_UNEARNED_CCID source_7
64934 , h8.RMT_BNK_UNAPPLIED_CCID source_11
64935 , h9.CODE_COMBINATION_ID_GAIN source_12
64936 , h9.CODE_COMBINATION_ID_LOSS source_13
64937 , h5.RCT_CLASS_REMIT_FLAG source_56
64938 , h5.RCT_CLASS_CONFIRM_FLAG source_57
64939 , h1.RCT_XLA_APPLIED_TO_APP_ID source_58
64940 , h1.RCT_PAY_FROM_CUSTOMER source_70
64941 , h6.RCT_SITE_SITE_USE_ID source_71
64942 , h1.RCT_APP_STATUS source_72
64943 , h1.RCT_DOC_SEQUENCE_CATEGORY source_80
64944 , h1.RCT_DOC_SEQUENCE_ID source_81
64945 , h1.RCT_DOC_SEQUENCE_VALUE source_82
64946 , h1.RCT_TRX_ACCT_REVERSAL source_83
64947 FROM xla_events_gt xet
64948 , AR_CASH_RECEIPTS_H_V h1
64949 , AR_RCT_METHOD_H_V h5
64950 , AR_RCT_SITE_USES_H_V h6
64951 , AR_REMIT_BANK_ACCT_H_V h8
64952 , AR_SYSTEM_PARAM_H_V h9
64953 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
64954 and xet.event_class_code = C_EVENT_CLASS_CODE
64955 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
64956 AND h5.event_id (+) = h1.event_id
64957 AND h6.event_id (+) = h1.event_id
64958 AND h8.event_id (+) = h1.event_id
64959 AND h9.event_id (+) = h1.event_id
64960
64961 ORDER BY event_id
64962 ;
64963
64964
64965 --
64966 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
64967 IS
64968 SELECT /*+ leading(xet) cardinality(xet,1) */
64969 -- Event Class Code: RECEIPT
64970 xet.entity_id
64971 ,xet.legal_entity_id
64972 ,xet.entity_code
64973 ,xet.transaction_number
64974 ,xet.event_id
64975 ,xet.event_class_code
64976 ,xet.event_type_code
64977 ,xet.event_number
64978 ,xet.event_date
64979 ,xet.transaction_date
64980 ,xet.reference_num_1
64981 ,xet.reference_num_2
64982 ,xet.reference_num_3
64983 ,xet.reference_num_4
64984 ,xet.reference_char_1
64985 ,xet.reference_char_2
64986 ,xet.reference_char_3
64987 ,xet.reference_char_4
64988 ,xet.reference_date_1
64989 ,xet.reference_date_2
64990 ,xet.reference_date_3
64991 ,xet.reference_date_4
64992 ,xet.event_created_by
64993 ,xet.budgetary_control_flag
64994 , l3.LINE_NUMBER
64995 , l4.DIST_CODE_COMBINATION_ID source_10
64996 , l2.TRX_LINE_DIST_CCID source_14
64997 , l4.DIST_SOURCE_TYPE source_15
64998 , l7.REC_ACT_TYPE source_16
64999 , l4.DIST_LINE_ID source_17
65000 , l4.DISTRIBUTION_TYPE source_18
65001 , l4.DIST_ENT_AMT source_19
65002 , l4.DIST_CURRENCY_CODE source_20
65003 , l3.DIST_CUR_CONVERSION_DATE source_21
65004 , l3.DIST_CUR_CONVERSION_RATE source_22
65005 , l3.DIST_CUR_CONVERSION_TYPE source_23
65006 , l3.DIST_TO_ACCTD_AMT source_24
65007 , l2.TRX_LINE_DIST_ACCOUNT_CLASS source_28
65008 , l2.TRX_LINE_DIST_ID source_29
65009 , l2.TRX_DISTRIBUTION_TYPE source_30
65010 , l4.DIST_MFAR_ADDITIONAL_ENTRY source_54
65011 , l3.DIST_TO_CUR_CONVERSION_DATE source_55
65012 , l10.TRX_ENTITY_CODE source_59
65013 , l10.TRX_CUSTOMER_TRX_ID source_60
65014 , l4.DIST_ENT_AMT_FROM source_61
65015 , l4.DIST_CURRENCY_CODE_FROM source_62
65016 , l3.DIST_ACCTD_AMT source_63
65017 , l4.DIST_PARTY_ID source_64
65018 , l4.DIST_PARTY_SITE_ID source_65
65019 , l4.DIST_PARTY_TYPE source_66
65020 , l3.DIST_TO_CUR_CONVERSION_TYPE source_67
65021 , l3.DIST_TO_CUR_CONVERSION_RATE source_68
65025 , AR_DISTRIBUTIONS_BASE_V l3
65022 , l4.DIST_SOURCE_TABLE source_69
65023 FROM xla_events_gt xet
65024 , AR_CUST_TRX_LINES_L_V l2
65026 , AR_DISTRIBUTIONS_L_V l4
65027 , AR_RECEIVABLES_TRX_ACT_S_V l7
65028 , AR_TRANSACTIONS_S_V l10
65029 WHERE xet.event_id between x_first_event_id and x_last_event_id
65030 and xet.event_date between p_pad_start_date and p_pad_end_date
65031 and xet.event_class_code = C_EVENT_CLASS_CODE
65032 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
65033 AND l2.event_id (+) = l3.event_id
65034 AND l2.line_number (+) = l3.line_number
65035 AND l4.event_id = l3.event_id
65036 AND l4.line_number = l3.line_number
65037 AND l7.event_id (+) = l3.event_id
65038 AND l7.line_number (+) = l3.line_number
65039 AND l10.event_id (+) = l3.event_id
65040 AND l10.line_number (+) = l3.line_number
65041 ;
65042
65043 --
65044 BEGIN
65045 IF g_log_enabled THEN
65046 l_log_module := C_DEFAULT_MODULE||'.EventClass_112';
65047 END IF;
65048 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
65049 trace
65050 (p_msg => 'BEGIN of EventClass_112'
65051 ,p_level => C_LEVEL_PROCEDURE
65052 ,p_module => l_log_module);
65053 END IF;
65054
65055 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
65056 trace
65057 (p_msg => 'p_application_id = '||p_application_id||
65058 ' - p_base_ledger_id = '||p_base_ledger_id||
65059 ' - p_target_ledger_id = '||p_target_ledger_id||
65060 ' - p_language = '||p_language||
65061 ' - p_currency_code = '||p_currency_code||
65062 ' - p_sla_ledger_id = '||p_sla_ledger_id
65063 ,p_level => C_LEVEL_STATEMENT
65064 ,p_module => l_log_module);
65065 END IF;
65066 --
65067 -- initialze arrays
65068 --
65069 g_array_event.DELETE;
65070 l_rec_array_event := l_null_rec_array_event;
65071 --
65072 --------------------------------------
65073 -- 4262811 Initialze MPA Line Number
65074 --------------------------------------
65075 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
65076
65077 --
65078
65079 --
65080 OPEN header_cur;
65081 --
65082 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
65083 trace
65084 (p_msg => 'SQL - FETCH header_cur'
65085 ,p_level => C_LEVEL_STATEMENT
65086 ,p_module => l_log_module);
65087 END IF;
65088 --
65089 LOOP
65090 FETCH header_cur BULK COLLECT INTO
65091 l_array_entity_id
65092 , l_array_legal_entity_id
65093 , l_array_entity_code
65094 , l_array_transaction_num
65095 , l_array_event_id
65096 , l_array_class_code
65097 , l_array_event_type
65098 , l_array_event_number
65099 , l_array_event_date
65100 , l_array_transaction_date
65101 , l_array_reference_num_1
65102 , l_array_reference_num_2
65103 , l_array_reference_num_3
65104 , l_array_reference_num_4
65105 , l_array_reference_char_1
65106 , l_array_reference_char_2
65107 , l_array_reference_char_3
65108 , l_array_reference_char_4
65109 , l_array_reference_date_1
65110 , l_array_reference_date_2
65111 , l_array_reference_date_3
65112 , l_array_reference_date_4
65113 , l_array_event_created_by
65114 , l_array_budgetary_control_flag
65115 , l_array_source_1
65116 , l_array_source_3
65117 , l_array_source_4
65118 , l_array_source_5
65119 , l_array_source_6
65120 , l_array_source_7
65121 , l_array_source_11
65122 , l_array_source_12
65123 , l_array_source_13
65124 , l_array_source_56
65125 , l_array_source_57
65126 , l_array_source_58
65127 , l_array_source_70
65128 , l_array_source_71
65129 , l_array_source_72
65130 , l_array_source_80
65131 , l_array_source_81
65132 , l_array_source_82
65133 , l_array_source_83
65134 LIMIT l_rows;
65135 --
65136 IF (C_LEVEL_EVENT >= g_log_level) THEN
65137 trace
65138 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
65139 ,p_level => C_LEVEL_EVENT
65140 ,p_module => l_log_module);
65141 END IF;
65142 --
65143 EXIT WHEN l_array_entity_id.COUNT = 0;
65144
65145 -- initialize arrays
65146 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
65147 XLA_AE_LINES_PKG.g_rec_lines := NULL;
65148
65149 --
65150 -- Bug 4458708
65151 --
65152 XLA_AE_LINES_PKG.g_LineNumber := 0;
65153
65154
65155 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
65156 g_last_hdr_idx := l_array_event_id.LAST;
65157 --
65158 -- loop for the headers. Each iteration is for each header extract row
65159 -- fetched in header cursor
65160 --
65161 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
65162
65163 --
65164 -- set event info as cache for other routines to refer event attributes
65165 --
65166 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
65167 (p_application_id => p_application_id
65168 ,p_primary_ledger_id => p_primary_ledger_id
65169 ,p_base_ledger_id => p_base_ledger_id
65170 ,p_target_ledger_id => p_target_ledger_id
65171 ,p_entity_id => l_array_entity_id(hdr_idx)
65172 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
65173 ,p_entity_code => l_array_entity_code(hdr_idx)
65177 ,p_event_type_code => l_array_event_type(hdr_idx)
65174 ,p_transaction_num => l_array_transaction_num(hdr_idx)
65175 ,p_event_id => l_array_event_id(hdr_idx)
65176 ,p_event_class_code => l_array_class_code(hdr_idx)
65178 ,p_event_number => l_array_event_number(hdr_idx)
65179 ,p_event_date => l_array_event_date(hdr_idx)
65180 ,p_transaction_date => l_array_transaction_date(hdr_idx)
65181 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
65182 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
65183 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
65184 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
65185 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
65186 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
65187 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
65188 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
65189 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
65190 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
65191 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
65192 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
65193 ,p_event_created_by => l_array_event_created_by(hdr_idx)
65194 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
65195
65196 --
65197 -- set the status of entry to C_VALID (0)
65198 --
65199 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
65200
65201 --
65202 -- initialize a row for ae header
65203 --
65204 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
65205
65206 l_event_id := l_array_event_id(hdr_idx);
65207
65208 --
65209 -- storing the hdr_idx for event. May be used by line cursor.
65210 --
65211 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
65212
65213 --
65214 -- store sources from header extract. This can be improved to
65215 -- store only those sources from header extract that may be used in lines
65216 --
65217
65218 g_array_event(l_event_id).array_value_num('source_1') := l_array_source_1(hdr_idx);
65219 g_array_event(l_event_id).array_value_num('source_3') := l_array_source_3(hdr_idx);
65220 g_array_event(l_event_id).array_value_num('source_4') := l_array_source_4(hdr_idx);
65221 g_array_event(l_event_id).array_value_num('source_5') := l_array_source_5(hdr_idx);
65222 g_array_event(l_event_id).array_value_num('source_6') := l_array_source_6(hdr_idx);
65223 g_array_event(l_event_id).array_value_num('source_7') := l_array_source_7(hdr_idx);
65224 g_array_event(l_event_id).array_value_num('source_11') := l_array_source_11(hdr_idx);
65225 g_array_event(l_event_id).array_value_num('source_12') := l_array_source_12(hdr_idx);
65226 g_array_event(l_event_id).array_value_num('source_13') := l_array_source_13(hdr_idx);
65227 g_array_event(l_event_id).array_value_char('source_56') := l_array_source_56(hdr_idx);
65228 g_array_event(l_event_id).array_value_char('source_57') := l_array_source_57(hdr_idx);
65229 g_array_event(l_event_id).array_value_num('source_58') := l_array_source_58(hdr_idx);
65230 g_array_event(l_event_id).array_value_num('source_70') := l_array_source_70(hdr_idx);
65231 g_array_event(l_event_id).array_value_num('source_71') := l_array_source_71(hdr_idx);
65232 g_array_event(l_event_id).array_value_char('source_72') := l_array_source_72(hdr_idx);
65233 g_array_event(l_event_id).array_value_char('source_80') := l_array_source_80(hdr_idx);
65234 g_array_event(l_event_id).array_value_num('source_81') := l_array_source_81(hdr_idx);
65235 g_array_event(l_event_id).array_value_num('source_82') := l_array_source_82(hdr_idx);
65236 g_array_event(l_event_id).array_value_char('source_83') := l_array_source_83(hdr_idx);
65237
65238 --
65239 -- initilaize the status of ae headers for diffrent balance types
65240 -- the status is initialised to C_NOT_CREATED (2)
65241 --
65242 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
65243 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
65244 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
65245
65246 --
65247 -- call api to validate and store accounting attributes for header
65248 --
65249
65250 ------------------------------------------------------------
65251 -- Accrual Reversal : to get date for Standard Source (NONE)
65252 ------------------------------------------------------------
65253 l_acc_rev_gl_date_source := NULL;
65254
65255 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
65256 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_80');
65257 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
65258 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_81');
65259 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
65260 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_82');
65261 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
65262 l_rec_acct_attrs.array_date_value(4) :=
65263 xla_ae_sources_pkg.GetSystemSourceDate(
65264 p_source_code => 'XLA_EVENT_DATE'
65265 , p_source_type_code => 'Y'
65266 , p_source_application_id => 602
65267 );
65268 l_rec_acct_attrs.array_acct_attr_code(5) := 'TRX_ACCT_REVERSAL_OPTION';
65269 l_rec_acct_attrs.array_char_value(5) := g_array_event(l_event_id).array_value_char('source_83');
65270
65271
65272 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
65273
65274 XLA_AE_HEADER_PKG.SetJeCategoryName;
65275
65276 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
65280 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
65277 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
65278 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
65279 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
65281
65282
65283 -- No header level analytical criteria
65284
65285 --
65286 --accounting attribute enhancement, bug 3612931
65287 --
65288 l_trx_reversal_source := SUBSTR(g_array_event(l_event_id).array_value_char('source_83'), 1,30);
65289
65290 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
65291 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
65292
65293 xla_accounting_err_pkg.build_message
65294 (p_appli_s_name => 'XLA'
65295 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
65296 ,p_token_1 => 'ACCT_ATTR_NAME'
65297 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
65298 ,p_token_2 => 'PRODUCT_NAME'
65299 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
65300 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
65301 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
65302 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
65303
65304 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
65305 --
65306 -- following sets the accounting attributes needed to reverse
65307 -- accounting for a distributeion
65308 --
65309 xla_ae_lines_pkg.SetTrxReversalAttrs
65310 (p_event_id => l_event_id
65311 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
65312 ,p_trx_reversal_source => l_trx_reversal_source);
65313
65314 END IF;
65315
65316
65317 ----------------------------------------------------------------
65318 -- 4262811 - update the header statuses to invalid in need be
65319 ----------------------------------------------------------------
65320 --
65321 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
65322
65323
65324 -----------------------------------------------
65325 -- No accrual reversal for the event class/type
65326 -----------------------------------------------
65327 ----------------------------------------------------------------
65328
65329 --
65330 -- this ends the header loop iteration for one bulk fetch
65331 --
65332 END LOOP;
65333
65334 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
65335 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
65336
65337 --
65338 -- insert dummy rows into lines gt table that were created due to
65339 -- transaction reversals
65340 --
65341 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
65342 l_result := XLA_AE_LINES_PKG.InsertLines;
65343 END IF;
65344
65345 --
65346 -- reset the temp_line_num for each set of events fetched from header
65347 -- cursor rather than doing it for each new event in line cursor
65348 -- Bug 3939231
65349 --
65350 xla_ae_lines_pkg.g_temp_line_num := 0;
65351
65352
65353
65354 --
65355 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
65356 --
65357 --
65358 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
65359
65360 trace
65361 (p_msg => 'SQL - FETCH line_cur'
65362 ,p_level => C_LEVEL_STATEMENT
65363 ,p_module => l_log_module);
65364
65365 END IF;
65366 --
65367 --
65368 LOOP
65369 --
65370 FETCH line_cur BULK COLLECT INTO
65371 l_array_entity_id
65372 , l_array_legal_entity_id
65373 , l_array_entity_code
65374 , l_array_transaction_num
65375 , l_array_event_id
65376 , l_array_class_code
65377 , l_array_event_type
65378 , l_array_event_number
65379 , l_array_event_date
65380 , l_array_transaction_date
65381 , l_array_reference_num_1
65382 , l_array_reference_num_2
65383 , l_array_reference_num_3
65384 , l_array_reference_num_4
65385 , l_array_reference_char_1
65386 , l_array_reference_char_2
65387 , l_array_reference_char_3
65388 , l_array_reference_char_4
65389 , l_array_reference_date_1
65390 , l_array_reference_date_2
65391 , l_array_reference_date_3
65392 , l_array_reference_date_4
65393 , l_array_event_created_by
65394 , l_array_budgetary_control_flag
65395 , l_array_extract_line_num
65396 , l_array_source_10
65397 , l_array_source_14
65398 , l_array_source_15
65399 , l_array_source_16
65400 , l_array_source_17
65401 , l_array_source_18
65402 , l_array_source_19
65403 , l_array_source_20
65404 , l_array_source_21
65405 , l_array_source_22
65406 , l_array_source_23
65407 , l_array_source_24
65408 , l_array_source_28
65409 , l_array_source_29
65410 , l_array_source_30
65411 , l_array_source_54
65412 , l_array_source_55
65413 , l_array_source_59
65414 , l_array_source_60
65415 , l_array_source_61
65416 , l_array_source_62
65417 , l_array_source_63
65418 , l_array_source_64
65419 , l_array_source_65
65420 , l_array_source_66
65421 , l_array_source_67
65422 , l_array_source_68
65426 --
65423 , l_array_source_69
65424 LIMIT l_rows;
65425
65427 IF (C_LEVEL_EVENT >= g_log_level) THEN
65428 trace
65429 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
65430 ,p_level => C_LEVEL_EVENT
65431 ,p_module => l_log_module);
65432 END IF;
65433 --
65434 EXIT WHEN l_array_entity_id.count = 0;
65435
65436 XLA_AE_LINES_PKG.g_rec_lines := null;
65437
65438 --
65439 -- Bug 4458708
65440 --
65441 XLA_AE_LINES_PKG.g_LineNumber := 0;
65442 --
65443 --
65444
65445 FOR Idx IN 1..l_array_event_id.count LOOP
65446 --
65447 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
65448 --
65449 l_event_id := l_array_event_id(idx); -- 5648433
65450
65451 --
65452 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
65453 --
65454
65455 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
65456 (g_array_event(l_event_id).array_value_num('header_index'))
65457 ,'N'
65458 ) <> 'Y'
65459 THEN
65460 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
65461 trace
65462 (p_msg => 'Trancaction revesal option is not Y '
65463 ,p_level => C_LEVEL_STATEMENT
65464 ,p_module => l_log_module);
65465 END IF;
65466
65467 --
65468 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
65469 --
65470 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
65471 --
65472 -- set event info as cache for other routines to refer event attributes
65473 --
65474
65475 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
65476 l_previous_event_id := l_event_id;
65477
65478 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
65479 (p_application_id => p_application_id
65480 ,p_primary_ledger_id => p_primary_ledger_id
65481 ,p_base_ledger_id => p_base_ledger_id
65482 ,p_target_ledger_id => p_target_ledger_id
65483 ,p_entity_id => l_array_entity_id(Idx)
65484 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
65485 ,p_entity_code => l_array_entity_code(Idx)
65486 ,p_transaction_num => l_array_transaction_num(Idx)
65487 ,p_event_id => l_array_event_id(Idx)
65488 ,p_event_class_code => l_array_class_code(Idx)
65489 ,p_event_type_code => l_array_event_type(Idx)
65490 ,p_event_number => l_array_event_number(Idx)
65491 ,p_event_date => l_array_event_date(Idx)
65492 ,p_transaction_date => l_array_transaction_date(Idx)
65493 ,p_reference_num_1 => l_array_reference_num_1(Idx)
65494 ,p_reference_num_2 => l_array_reference_num_2(Idx)
65495 ,p_reference_num_3 => l_array_reference_num_3(Idx)
65496 ,p_reference_num_4 => l_array_reference_num_4(Idx)
65497 ,p_reference_char_1 => l_array_reference_char_1(Idx)
65498 ,p_reference_char_2 => l_array_reference_char_2(Idx)
65499 ,p_reference_char_3 => l_array_reference_char_3(Idx)
65500 ,p_reference_char_4 => l_array_reference_char_4(Idx)
65501 ,p_reference_date_1 => l_array_reference_date_1(Idx)
65502 ,p_reference_date_2 => l_array_reference_date_2(Idx)
65503 ,p_reference_date_3 => l_array_reference_date_3(Idx)
65504 ,p_reference_date_4 => l_array_reference_date_4(Idx)
65505 ,p_event_created_by => l_array_event_created_by(Idx)
65506 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
65507 --
65508 END IF;
65509
65510
65511
65512 --
65513 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
65514
65515 l_acct_reversal_source := SUBSTR(NULL, 1,30);
65516
65517 IF l_continue_with_lines THEN
65518 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
65519 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
65520
65521 xla_accounting_err_pkg.build_message
65522 (p_appli_s_name => 'XLA'
65523 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
65524 ,p_token_1 => 'LINE_NUMBER'
65525 ,p_value_1 => l_array_extract_line_num(Idx)
65526 ,p_token_2 => 'PRODUCT_NAME'
65527 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
65528 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
65529 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
65530 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
65531
65532 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
65533 --
65534 -- following sets the accounting attributes needed to reverse
65535 -- accounting for a distributeion
65536 --
65537
65538 --
65539 -- 5217187
65540 --
65541 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
65542 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
65543 g_array_event(l_event_id).array_value_num('header_index'));
65544 --
65545 --
65546
65547 -- No reversal code generated
65548
65549 xla_ae_lines_pkg.SetAcctReversalAttrs
65550 (p_event_id => l_event_id
65551 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
65555
65552 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65553 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
65554 END IF;
65556 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
65557 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
65558
65559 --
65560 AcctLineType_62 (
65561 p_application_id => p_application_id
65562 ,p_event_id => l_event_id
65563 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65564 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65565 ,p_actual_flag => l_actual_flag
65566 ,p_balance_type_code => l_balance_type_code
65567 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65568
65569 , p_source_1 => g_array_event(l_event_id).array_value_num('source_1')
65570 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
65571 , p_source_15 => l_array_source_15(Idx)
65572 , p_source_17 => l_array_source_17(Idx)
65573 , p_source_18 => l_array_source_18(Idx)
65574 , p_source_21 => l_array_source_21(Idx)
65575 , p_source_22 => l_array_source_22(Idx)
65576 , p_source_23 => l_array_source_23(Idx)
65577 , p_source_29 => l_array_source_29(Idx)
65578 , p_source_30 => l_array_source_30(Idx)
65579 , p_source_54 => l_array_source_54(Idx)
65580 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65581 , p_source_59 => l_array_source_59(Idx)
65582 , p_source_60 => l_array_source_60(Idx)
65583 , p_source_61 => l_array_source_61(Idx)
65584 , p_source_62 => l_array_source_62(Idx)
65585 , p_source_63 => l_array_source_63(Idx)
65586 , p_source_64 => l_array_source_64(Idx)
65587 , p_source_65 => l_array_source_65(Idx)
65588 , p_source_66 => l_array_source_66(Idx)
65589 );
65590 If(l_balance_type_code = 'A') THEN
65591 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65592 END IF;
65593
65594 --
65595
65596
65597 --
65598 AcctLineType_63 (
65599 p_application_id => p_application_id
65600 ,p_event_id => l_event_id
65601 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65602 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65603 ,p_actual_flag => l_actual_flag
65604 ,p_balance_type_code => l_balance_type_code
65605 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65606
65607 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
65608 , p_source_15 => l_array_source_15(Idx)
65609 , p_source_17 => l_array_source_17(Idx)
65610 , p_source_18 => l_array_source_18(Idx)
65611 , p_source_21 => l_array_source_21(Idx)
65612 , p_source_22 => l_array_source_22(Idx)
65613 , p_source_23 => l_array_source_23(Idx)
65614 , p_source_28 => l_array_source_28(Idx)
65615 , p_source_29 => l_array_source_29(Idx)
65616 , p_source_30 => l_array_source_30(Idx)
65617 , p_source_54 => l_array_source_54(Idx)
65618 , p_source_56 => g_array_event(l_event_id).array_value_char('source_56')
65619 , p_source_57 => g_array_event(l_event_id).array_value_char('source_57')
65620 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65621 , p_source_59 => l_array_source_59(Idx)
65622 , p_source_60 => l_array_source_60(Idx)
65623 , p_source_61 => l_array_source_61(Idx)
65624 , p_source_62 => l_array_source_62(Idx)
65625 , p_source_63 => l_array_source_63(Idx)
65626 , p_source_64 => l_array_source_64(Idx)
65627 , p_source_65 => l_array_source_65(Idx)
65628 , p_source_66 => l_array_source_66(Idx)
65629 );
65630 If(l_balance_type_code = 'A') THEN
65631 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65632 END IF;
65633
65634 --
65635
65636
65637 --
65638 AcctLineType_64 (
65639 p_application_id => p_application_id
65640 ,p_event_id => l_event_id
65641 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65642 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65643 ,p_actual_flag => l_actual_flag
65644 ,p_balance_type_code => l_balance_type_code
65645 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65646
65647 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
65648 , p_source_15 => l_array_source_15(Idx)
65649 , p_source_17 => l_array_source_17(Idx)
65650 , p_source_18 => l_array_source_18(Idx)
65651 , p_source_21 => l_array_source_21(Idx)
65652 , p_source_22 => l_array_source_22(Idx)
65653 , p_source_23 => l_array_source_23(Idx)
65654 , p_source_29 => l_array_source_29(Idx)
65655 , p_source_30 => l_array_source_30(Idx)
65656 , p_source_54 => l_array_source_54(Idx)
65657 , p_source_56 => g_array_event(l_event_id).array_value_char('source_56')
65658 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65659 , p_source_59 => l_array_source_59(Idx)
65660 , p_source_60 => l_array_source_60(Idx)
65661 , p_source_61 => l_array_source_61(Idx)
65662 , p_source_62 => l_array_source_62(Idx)
65663 , p_source_63 => l_array_source_63(Idx)
65664 , p_source_64 => l_array_source_64(Idx)
65665 , p_source_65 => l_array_source_65(Idx)
65666 , p_source_66 => l_array_source_66(Idx)
65667 );
65668 If(l_balance_type_code = 'A') THEN
65669 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65670 END IF;
65671
65672 --
65673
65674
65675 --
65676 AcctLineType_65 (
65677 p_application_id => p_application_id
65678 ,p_event_id => l_event_id
65679 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65680 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65681 ,p_actual_flag => l_actual_flag
65682 ,p_balance_type_code => l_balance_type_code
65683 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65684
65685 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
65689 , p_source_21 => l_array_source_21(Idx)
65686 , p_source_15 => l_array_source_15(Idx)
65687 , p_source_17 => l_array_source_17(Idx)
65688 , p_source_18 => l_array_source_18(Idx)
65690 , p_source_22 => l_array_source_22(Idx)
65691 , p_source_23 => l_array_source_23(Idx)
65692 , p_source_29 => l_array_source_29(Idx)
65693 , p_source_30 => l_array_source_30(Idx)
65694 , p_source_54 => l_array_source_54(Idx)
65695 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65696 , p_source_59 => l_array_source_59(Idx)
65697 , p_source_60 => l_array_source_60(Idx)
65698 , p_source_61 => l_array_source_61(Idx)
65699 , p_source_62 => l_array_source_62(Idx)
65700 , p_source_63 => l_array_source_63(Idx)
65701 , p_source_64 => l_array_source_64(Idx)
65702 , p_source_65 => l_array_source_65(Idx)
65703 , p_source_66 => l_array_source_66(Idx)
65704 );
65705 If(l_balance_type_code = 'A') THEN
65706 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65707 END IF;
65708
65709 --
65710
65711
65712 --
65713 AcctLineType_66 (
65714 p_application_id => p_application_id
65715 ,p_event_id => l_event_id
65716 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65717 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65718 ,p_actual_flag => l_actual_flag
65719 ,p_balance_type_code => l_balance_type_code
65720 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65721
65722 , p_source_15 => l_array_source_15(Idx)
65723 , p_source_17 => l_array_source_17(Idx)
65724 , p_source_18 => l_array_source_18(Idx)
65725 , p_source_19 => l_array_source_19(Idx)
65726 , p_source_20 => l_array_source_20(Idx)
65727 , p_source_24 => l_array_source_24(Idx)
65728 , p_source_29 => l_array_source_29(Idx)
65729 , p_source_30 => l_array_source_30(Idx)
65730 , p_source_54 => l_array_source_54(Idx)
65731 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65732 , p_source_59 => l_array_source_59(Idx)
65733 , p_source_60 => l_array_source_60(Idx)
65734 , p_source_66 => l_array_source_66(Idx)
65735 );
65736 If(l_balance_type_code = 'A') THEN
65737 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65738 END IF;
65739
65740 --
65741
65742
65743 --
65744 AcctLineType_67 (
65745 p_application_id => p_application_id
65746 ,p_event_id => l_event_id
65747 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65748 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65749 ,p_actual_flag => l_actual_flag
65750 ,p_balance_type_code => l_balance_type_code
65751 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65752
65753 , p_source_6 => g_array_event(l_event_id).array_value_num('source_6')
65754 , p_source_15 => l_array_source_15(Idx)
65755 , p_source_17 => l_array_source_17(Idx)
65756 , p_source_18 => l_array_source_18(Idx)
65757 , p_source_21 => l_array_source_21(Idx)
65758 , p_source_22 => l_array_source_22(Idx)
65759 , p_source_23 => l_array_source_23(Idx)
65760 , p_source_29 => l_array_source_29(Idx)
65761 , p_source_30 => l_array_source_30(Idx)
65762 , p_source_54 => l_array_source_54(Idx)
65763 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65764 , p_source_59 => l_array_source_59(Idx)
65765 , p_source_60 => l_array_source_60(Idx)
65766 , p_source_61 => l_array_source_61(Idx)
65767 , p_source_62 => l_array_source_62(Idx)
65768 , p_source_63 => l_array_source_63(Idx)
65769 , p_source_64 => l_array_source_64(Idx)
65770 , p_source_65 => l_array_source_65(Idx)
65771 , p_source_66 => l_array_source_66(Idx)
65772 );
65773 If(l_balance_type_code = 'A') THEN
65774 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65775 END IF;
65776
65777 --
65778
65779
65780 --
65781 AcctLineType_68 (
65782 p_application_id => p_application_id
65783 ,p_event_id => l_event_id
65784 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65785 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65786 ,p_actual_flag => l_actual_flag
65787 ,p_balance_type_code => l_balance_type_code
65788 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65789
65790 , p_source_15 => l_array_source_15(Idx)
65791 , p_source_17 => l_array_source_17(Idx)
65792 , p_source_18 => l_array_source_18(Idx)
65793 , p_source_19 => l_array_source_19(Idx)
65794 , p_source_20 => l_array_source_20(Idx)
65795 , p_source_24 => l_array_source_24(Idx)
65796 , p_source_29 => l_array_source_29(Idx)
65797 , p_source_30 => l_array_source_30(Idx)
65798 , p_source_54 => l_array_source_54(Idx)
65799 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65800 , p_source_59 => l_array_source_59(Idx)
65801 , p_source_60 => l_array_source_60(Idx)
65802 , p_source_66 => l_array_source_66(Idx)
65803 );
65804 If(l_balance_type_code = 'A') THEN
65805 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65806 END IF;
65807
65808 --
65809
65810
65811 --
65812 AcctLineType_74 (
65813 p_application_id => p_application_id
65814 ,p_event_id => l_event_id
65815 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65816 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65817 ,p_actual_flag => l_actual_flag
65818 ,p_balance_type_code => l_balance_type_code
65819 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65820
65821 , p_source_10 => l_array_source_10(Idx)
65822 , p_source_15 => l_array_source_15(Idx)
65823 , p_source_17 => l_array_source_17(Idx)
65824 , p_source_18 => l_array_source_18(Idx)
65825 , p_source_21 => l_array_source_21(Idx)
65826 , p_source_22 => l_array_source_22(Idx)
65827 , p_source_23 => l_array_source_23(Idx)
65828 , p_source_29 => l_array_source_29(Idx)
65829 , p_source_30 => l_array_source_30(Idx)
65830 , p_source_54 => l_array_source_54(Idx)
65834 , p_source_61 => l_array_source_61(Idx)
65831 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65832 , p_source_59 => l_array_source_59(Idx)
65833 , p_source_60 => l_array_source_60(Idx)
65835 , p_source_62 => l_array_source_62(Idx)
65836 , p_source_63 => l_array_source_63(Idx)
65837 , p_source_64 => l_array_source_64(Idx)
65838 , p_source_65 => l_array_source_65(Idx)
65839 , p_source_66 => l_array_source_66(Idx)
65840 );
65841 If(l_balance_type_code = 'A') THEN
65842 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65843 END IF;
65844
65845 --
65846
65847
65848 --
65849 AcctLineType_75 (
65850 p_application_id => p_application_id
65851 ,p_event_id => l_event_id
65852 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65853 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65854 ,p_actual_flag => l_actual_flag
65855 ,p_balance_type_code => l_balance_type_code
65856 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65857
65858 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
65859 , p_source_14 => l_array_source_14(Idx)
65860 , p_source_15 => l_array_source_15(Idx)
65861 , p_source_17 => l_array_source_17(Idx)
65862 , p_source_18 => l_array_source_18(Idx)
65863 , p_source_21 => l_array_source_21(Idx)
65864 , p_source_22 => l_array_source_22(Idx)
65865 , p_source_23 => l_array_source_23(Idx)
65866 , p_source_28 => l_array_source_28(Idx)
65867 , p_source_29 => l_array_source_29(Idx)
65868 , p_source_30 => l_array_source_30(Idx)
65869 , p_source_54 => l_array_source_54(Idx)
65870 , p_source_56 => g_array_event(l_event_id).array_value_char('source_56')
65871 , p_source_57 => g_array_event(l_event_id).array_value_char('source_57')
65872 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65873 , p_source_59 => l_array_source_59(Idx)
65874 , p_source_60 => l_array_source_60(Idx)
65875 , p_source_61 => l_array_source_61(Idx)
65876 , p_source_62 => l_array_source_62(Idx)
65877 , p_source_63 => l_array_source_63(Idx)
65878 , p_source_64 => l_array_source_64(Idx)
65879 , p_source_65 => l_array_source_65(Idx)
65880 , p_source_66 => l_array_source_66(Idx)
65881 );
65882 If(l_balance_type_code = 'A') THEN
65883 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65884 END IF;
65885
65886 --
65887
65888
65889 --
65890 AcctLineType_76 (
65891 p_application_id => p_application_id
65892 ,p_event_id => l_event_id
65893 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65894 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65895 ,p_actual_flag => l_actual_flag
65896 ,p_balance_type_code => l_balance_type_code
65897 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65898
65899 , p_source_5 => g_array_event(l_event_id).array_value_num('source_5')
65900 , p_source_14 => l_array_source_14(Idx)
65901 , p_source_15 => l_array_source_15(Idx)
65902 , p_source_17 => l_array_source_17(Idx)
65903 , p_source_18 => l_array_source_18(Idx)
65904 , p_source_21 => l_array_source_21(Idx)
65905 , p_source_22 => l_array_source_22(Idx)
65906 , p_source_23 => l_array_source_23(Idx)
65907 , p_source_29 => l_array_source_29(Idx)
65908 , p_source_30 => l_array_source_30(Idx)
65909 , p_source_54 => l_array_source_54(Idx)
65910 , p_source_56 => g_array_event(l_event_id).array_value_char('source_56')
65911 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65912 , p_source_59 => l_array_source_59(Idx)
65913 , p_source_60 => l_array_source_60(Idx)
65914 , p_source_61 => l_array_source_61(Idx)
65915 , p_source_62 => l_array_source_62(Idx)
65916 , p_source_63 => l_array_source_63(Idx)
65917 , p_source_64 => l_array_source_64(Idx)
65918 , p_source_65 => l_array_source_65(Idx)
65919 , p_source_66 => l_array_source_66(Idx)
65920 );
65921 If(l_balance_type_code = 'A') THEN
65922 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65923 END IF;
65924
65925 --
65926
65927
65928 --
65929 AcctLineType_77 (
65930 p_application_id => p_application_id
65931 ,p_event_id => l_event_id
65932 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65933 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65934 ,p_actual_flag => l_actual_flag
65935 ,p_balance_type_code => l_balance_type_code
65936 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65937
65938 , p_source_3 => g_array_event(l_event_id).array_value_num('source_3')
65939 , p_source_14 => l_array_source_14(Idx)
65940 , p_source_15 => l_array_source_15(Idx)
65941 , p_source_17 => l_array_source_17(Idx)
65942 , p_source_18 => l_array_source_18(Idx)
65943 , p_source_21 => l_array_source_21(Idx)
65944 , p_source_22 => l_array_source_22(Idx)
65945 , p_source_23 => l_array_source_23(Idx)
65946 , p_source_29 => l_array_source_29(Idx)
65947 , p_source_30 => l_array_source_30(Idx)
65948 , p_source_54 => l_array_source_54(Idx)
65949 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65950 , p_source_59 => l_array_source_59(Idx)
65951 , p_source_60 => l_array_source_60(Idx)
65952 , p_source_61 => l_array_source_61(Idx)
65953 , p_source_62 => l_array_source_62(Idx)
65954 , p_source_63 => l_array_source_63(Idx)
65955 , p_source_64 => l_array_source_64(Idx)
65956 , p_source_65 => l_array_source_65(Idx)
65957 , p_source_66 => l_array_source_66(Idx)
65958 );
65959 If(l_balance_type_code = 'A') THEN
65960 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65961 END IF;
65962
65963 --
65964
65965
65966 --
65967 AcctLineType_78 (
65968 p_application_id => p_application_id
65969 ,p_event_id => l_event_id
65970 ,p_calculate_acctd_flag => l_calculate_acctd_flag
65971 ,p_calculate_g_l_flag => l_calculate_g_l_flag
65972 ,p_actual_flag => l_actual_flag
65976 , p_source_15 => l_array_source_15(Idx)
65973 ,p_balance_type_code => l_balance_type_code
65974 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
65975
65977 , p_source_17 => l_array_source_17(Idx)
65978 , p_source_18 => l_array_source_18(Idx)
65979 , p_source_19 => l_array_source_19(Idx)
65980 , p_source_20 => l_array_source_20(Idx)
65981 , p_source_24 => l_array_source_24(Idx)
65982 , p_source_28 => l_array_source_28(Idx)
65983 , p_source_29 => l_array_source_29(Idx)
65984 , p_source_30 => l_array_source_30(Idx)
65985 , p_source_54 => l_array_source_54(Idx)
65986 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
65987 , p_source_59 => l_array_source_59(Idx)
65988 , p_source_60 => l_array_source_60(Idx)
65989 , p_source_66 => l_array_source_66(Idx)
65990 );
65991 If(l_balance_type_code = 'A') THEN
65992 l_actual_gain_loss_ref := l_gain_or_loss_ref;
65993 END IF;
65994
65995 --
65996
65997
65998 --
65999 AcctLineType_79 (
66000 p_application_id => p_application_id
66001 ,p_event_id => l_event_id
66002 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66003 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66004 ,p_actual_flag => l_actual_flag
66005 ,p_balance_type_code => l_balance_type_code
66006 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66007
66008 , p_source_6 => g_array_event(l_event_id).array_value_num('source_6')
66009 , p_source_14 => l_array_source_14(Idx)
66010 , p_source_15 => l_array_source_15(Idx)
66011 , p_source_17 => l_array_source_17(Idx)
66012 , p_source_18 => l_array_source_18(Idx)
66013 , p_source_21 => l_array_source_21(Idx)
66014 , p_source_22 => l_array_source_22(Idx)
66015 , p_source_23 => l_array_source_23(Idx)
66016 , p_source_29 => l_array_source_29(Idx)
66017 , p_source_30 => l_array_source_30(Idx)
66018 , p_source_54 => l_array_source_54(Idx)
66019 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66020 , p_source_59 => l_array_source_59(Idx)
66021 , p_source_60 => l_array_source_60(Idx)
66022 , p_source_61 => l_array_source_61(Idx)
66023 , p_source_62 => l_array_source_62(Idx)
66024 , p_source_63 => l_array_source_63(Idx)
66025 , p_source_64 => l_array_source_64(Idx)
66026 , p_source_65 => l_array_source_65(Idx)
66027 , p_source_66 => l_array_source_66(Idx)
66028 );
66029 If(l_balance_type_code = 'A') THEN
66030 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66031 END IF;
66032
66033 --
66034
66035
66036 --
66037 AcctLineType_80 (
66038 p_application_id => p_application_id
66039 ,p_event_id => l_event_id
66040 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66041 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66042 ,p_actual_flag => l_actual_flag
66043 ,p_balance_type_code => l_balance_type_code
66044 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66045
66046 , p_source_10 => l_array_source_10(Idx)
66047 , p_source_15 => l_array_source_15(Idx)
66048 , p_source_17 => l_array_source_17(Idx)
66049 , p_source_18 => l_array_source_18(Idx)
66050 , p_source_21 => l_array_source_21(Idx)
66051 , p_source_22 => l_array_source_22(Idx)
66052 , p_source_23 => l_array_source_23(Idx)
66053 , p_source_29 => l_array_source_29(Idx)
66054 , p_source_30 => l_array_source_30(Idx)
66055 , p_source_54 => l_array_source_54(Idx)
66056 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66057 , p_source_59 => l_array_source_59(Idx)
66058 , p_source_60 => l_array_source_60(Idx)
66059 , p_source_61 => l_array_source_61(Idx)
66060 , p_source_62 => l_array_source_62(Idx)
66061 , p_source_63 => l_array_source_63(Idx)
66062 , p_source_64 => l_array_source_64(Idx)
66063 , p_source_65 => l_array_source_65(Idx)
66064 , p_source_66 => l_array_source_66(Idx)
66065 );
66066 If(l_balance_type_code = 'A') THEN
66067 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66068 END IF;
66069
66070 --
66071
66072
66073 --
66074 AcctLineType_81 (
66075 p_application_id => p_application_id
66076 ,p_event_id => l_event_id
66077 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66078 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66079 ,p_actual_flag => l_actual_flag
66080 ,p_balance_type_code => l_balance_type_code
66081 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66082
66083 , p_source_10 => l_array_source_10(Idx)
66084 , p_source_15 => l_array_source_15(Idx)
66085 , p_source_17 => l_array_source_17(Idx)
66086 , p_source_18 => l_array_source_18(Idx)
66087 , p_source_21 => l_array_source_21(Idx)
66088 , p_source_22 => l_array_source_22(Idx)
66089 , p_source_23 => l_array_source_23(Idx)
66090 , p_source_29 => l_array_source_29(Idx)
66091 , p_source_30 => l_array_source_30(Idx)
66092 , p_source_54 => l_array_source_54(Idx)
66093 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66094 , p_source_59 => l_array_source_59(Idx)
66095 , p_source_60 => l_array_source_60(Idx)
66096 , p_source_61 => l_array_source_61(Idx)
66097 , p_source_62 => l_array_source_62(Idx)
66098 , p_source_63 => l_array_source_63(Idx)
66099 , p_source_64 => l_array_source_64(Idx)
66100 , p_source_65 => l_array_source_65(Idx)
66101 , p_source_66 => l_array_source_66(Idx)
66102 );
66103 If(l_balance_type_code = 'A') THEN
66104 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66105 END IF;
66106
66107 --
66108
66109
66110 --
66111 AcctLineType_82 (
66112 p_application_id => p_application_id
66113 ,p_event_id => l_event_id
66114 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66115 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66116 ,p_actual_flag => l_actual_flag
66117 ,p_balance_type_code => l_balance_type_code
66121 , p_source_15 => l_array_source_15(Idx)
66118 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66119
66120 , p_source_10 => l_array_source_10(Idx)
66122 , p_source_16 => l_array_source_16(Idx)
66123 , p_source_17 => l_array_source_17(Idx)
66124 , p_source_18 => l_array_source_18(Idx)
66125 , p_source_21 => l_array_source_21(Idx)
66126 , p_source_22 => l_array_source_22(Idx)
66127 , p_source_29 => l_array_source_29(Idx)
66128 , p_source_30 => l_array_source_30(Idx)
66129 , p_source_54 => l_array_source_54(Idx)
66130 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66131 , p_source_59 => l_array_source_59(Idx)
66132 , p_source_60 => l_array_source_60(Idx)
66133 , p_source_61 => l_array_source_61(Idx)
66134 , p_source_62 => l_array_source_62(Idx)
66135 , p_source_63 => l_array_source_63(Idx)
66136 , p_source_64 => l_array_source_64(Idx)
66137 , p_source_65 => l_array_source_65(Idx)
66138 , p_source_66 => l_array_source_66(Idx)
66139 , p_source_67 => l_array_source_67(Idx)
66140 );
66141 If(l_balance_type_code = 'A') THEN
66142 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66143 END IF;
66144
66145 --
66146
66147
66148 --
66149 AcctLineType_83 (
66150 p_application_id => p_application_id
66151 ,p_event_id => l_event_id
66152 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66153 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66154 ,p_actual_flag => l_actual_flag
66155 ,p_balance_type_code => l_balance_type_code
66156 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66157
66158 , p_source_10 => l_array_source_10(Idx)
66159 , p_source_15 => l_array_source_15(Idx)
66160 , p_source_17 => l_array_source_17(Idx)
66161 , p_source_18 => l_array_source_18(Idx)
66162 , p_source_21 => l_array_source_21(Idx)
66163 , p_source_22 => l_array_source_22(Idx)
66164 , p_source_23 => l_array_source_23(Idx)
66165 , p_source_29 => l_array_source_29(Idx)
66166 , p_source_30 => l_array_source_30(Idx)
66167 , p_source_54 => l_array_source_54(Idx)
66168 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66169 , p_source_59 => l_array_source_59(Idx)
66170 , p_source_60 => l_array_source_60(Idx)
66171 , p_source_61 => l_array_source_61(Idx)
66172 , p_source_62 => l_array_source_62(Idx)
66173 , p_source_63 => l_array_source_63(Idx)
66174 , p_source_64 => l_array_source_64(Idx)
66175 , p_source_65 => l_array_source_65(Idx)
66176 , p_source_66 => l_array_source_66(Idx)
66177 );
66178 If(l_balance_type_code = 'A') THEN
66179 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66180 END IF;
66181
66182 --
66183
66184
66185 --
66186 AcctLineType_84 (
66187 p_application_id => p_application_id
66188 ,p_event_id => l_event_id
66189 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66190 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66191 ,p_actual_flag => l_actual_flag
66192 ,p_balance_type_code => l_balance_type_code
66193 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66194
66195 , p_source_10 => l_array_source_10(Idx)
66196 , p_source_15 => l_array_source_15(Idx)
66197 , p_source_17 => l_array_source_17(Idx)
66198 , p_source_18 => l_array_source_18(Idx)
66199 , p_source_21 => l_array_source_21(Idx)
66200 , p_source_22 => l_array_source_22(Idx)
66201 , p_source_23 => l_array_source_23(Idx)
66202 , p_source_29 => l_array_source_29(Idx)
66203 , p_source_30 => l_array_source_30(Idx)
66204 , p_source_54 => l_array_source_54(Idx)
66205 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66206 , p_source_59 => l_array_source_59(Idx)
66207 , p_source_60 => l_array_source_60(Idx)
66208 , p_source_61 => l_array_source_61(Idx)
66209 , p_source_62 => l_array_source_62(Idx)
66210 , p_source_63 => l_array_source_63(Idx)
66211 , p_source_64 => l_array_source_64(Idx)
66212 , p_source_65 => l_array_source_65(Idx)
66213 , p_source_66 => l_array_source_66(Idx)
66214 );
66215 If(l_balance_type_code = 'A') THEN
66216 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66217 END IF;
66218
66219 --
66220
66221
66222 --
66223 AcctLineType_85 (
66224 p_application_id => p_application_id
66225 ,p_event_id => l_event_id
66226 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66227 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66228 ,p_actual_flag => l_actual_flag
66229 ,p_balance_type_code => l_balance_type_code
66230 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66231
66232 , p_source_10 => l_array_source_10(Idx)
66233 , p_source_15 => l_array_source_15(Idx)
66234 , p_source_17 => l_array_source_17(Idx)
66235 , p_source_18 => l_array_source_18(Idx)
66236 , p_source_21 => l_array_source_21(Idx)
66237 , p_source_22 => l_array_source_22(Idx)
66238 , p_source_23 => l_array_source_23(Idx)
66239 , p_source_29 => l_array_source_29(Idx)
66240 , p_source_30 => l_array_source_30(Idx)
66241 , p_source_54 => l_array_source_54(Idx)
66242 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66243 , p_source_59 => l_array_source_59(Idx)
66244 , p_source_60 => l_array_source_60(Idx)
66245 , p_source_61 => l_array_source_61(Idx)
66246 , p_source_62 => l_array_source_62(Idx)
66247 , p_source_63 => l_array_source_63(Idx)
66248 , p_source_64 => l_array_source_64(Idx)
66249 , p_source_65 => l_array_source_65(Idx)
66250 , p_source_66 => l_array_source_66(Idx)
66251 );
66252 If(l_balance_type_code = 'A') THEN
66253 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66254 END IF;
66255
66256 --
66257
66258
66259 --
66260 AcctLineType_86 (
66261 p_application_id => p_application_id
66262 ,p_event_id => l_event_id
66263 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66267 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66264 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66265 ,p_actual_flag => l_actual_flag
66266 ,p_balance_type_code => l_balance_type_code
66268
66269 , p_source_10 => l_array_source_10(Idx)
66270 , p_source_15 => l_array_source_15(Idx)
66271 , p_source_17 => l_array_source_17(Idx)
66272 , p_source_18 => l_array_source_18(Idx)
66273 , p_source_19 => l_array_source_19(Idx)
66274 , p_source_20 => l_array_source_20(Idx)
66275 , p_source_24 => l_array_source_24(Idx)
66276 , p_source_29 => l_array_source_29(Idx)
66277 , p_source_30 => l_array_source_30(Idx)
66278 , p_source_54 => l_array_source_54(Idx)
66279 , p_source_55 => l_array_source_55(Idx)
66280 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66281 , p_source_59 => l_array_source_59(Idx)
66282 , p_source_60 => l_array_source_60(Idx)
66283 , p_source_64 => l_array_source_64(Idx)
66284 , p_source_65 => l_array_source_65(Idx)
66285 , p_source_66 => l_array_source_66(Idx)
66286 , p_source_67 => l_array_source_67(Idx)
66287 , p_source_68 => l_array_source_68(Idx)
66288 );
66289 If(l_balance_type_code = 'A') THEN
66290 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66291 END IF;
66292
66293 --
66294
66295
66296 --
66297 AcctLineType_87 (
66298 p_application_id => p_application_id
66299 ,p_event_id => l_event_id
66300 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66301 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66302 ,p_actual_flag => l_actual_flag
66303 ,p_balance_type_code => l_balance_type_code
66304 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66305
66306 , p_source_4 => g_array_event(l_event_id).array_value_num('source_4')
66307 , p_source_14 => l_array_source_14(Idx)
66308 , p_source_15 => l_array_source_15(Idx)
66309 , p_source_17 => l_array_source_17(Idx)
66310 , p_source_18 => l_array_source_18(Idx)
66311 , p_source_19 => l_array_source_19(Idx)
66312 , p_source_20 => l_array_source_20(Idx)
66313 , p_source_24 => l_array_source_24(Idx)
66314 , p_source_29 => l_array_source_29(Idx)
66315 , p_source_30 => l_array_source_30(Idx)
66316 , p_source_54 => l_array_source_54(Idx)
66317 , p_source_55 => l_array_source_55(Idx)
66318 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66319 , p_source_59 => l_array_source_59(Idx)
66320 , p_source_60 => l_array_source_60(Idx)
66321 , p_source_64 => l_array_source_64(Idx)
66322 , p_source_65 => l_array_source_65(Idx)
66323 , p_source_66 => l_array_source_66(Idx)
66324 , p_source_67 => l_array_source_67(Idx)
66325 , p_source_68 => l_array_source_68(Idx)
66326 );
66327 If(l_balance_type_code = 'A') THEN
66328 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66329 END IF;
66330
66331 --
66332
66333
66334 --
66335 AcctLineType_88 (
66336 p_application_id => p_application_id
66337 ,p_event_id => l_event_id
66338 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66339 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66340 ,p_actual_flag => l_actual_flag
66341 ,p_balance_type_code => l_balance_type_code
66342 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66343
66344 , p_source_10 => l_array_source_10(Idx)
66345 , p_source_15 => l_array_source_15(Idx)
66346 , p_source_17 => l_array_source_17(Idx)
66347 , p_source_18 => l_array_source_18(Idx)
66348 , p_source_19 => l_array_source_19(Idx)
66349 , p_source_21 => l_array_source_21(Idx)
66350 , p_source_22 => l_array_source_22(Idx)
66351 , p_source_23 => l_array_source_23(Idx)
66352 , p_source_24 => l_array_source_24(Idx)
66353 , p_source_29 => l_array_source_29(Idx)
66354 , p_source_30 => l_array_source_30(Idx)
66355 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66356 , p_source_59 => l_array_source_59(Idx)
66357 , p_source_60 => l_array_source_60(Idx)
66358 , p_source_62 => l_array_source_62(Idx)
66359 , p_source_64 => l_array_source_64(Idx)
66360 , p_source_65 => l_array_source_65(Idx)
66361 , p_source_66 => l_array_source_66(Idx)
66362 );
66363 If(l_balance_type_code = 'A') THEN
66364 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66365 END IF;
66366
66367 --
66368
66369
66370 --
66371 AcctLineType_89 (
66372 p_application_id => p_application_id
66373 ,p_event_id => l_event_id
66374 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66375 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66376 ,p_actual_flag => l_actual_flag
66377 ,p_balance_type_code => l_balance_type_code
66378 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66379
66380 , p_source_10 => l_array_source_10(Idx)
66381 , p_source_15 => l_array_source_15(Idx)
66382 , p_source_17 => l_array_source_17(Idx)
66383 , p_source_18 => l_array_source_18(Idx)
66384 , p_source_19 => l_array_source_19(Idx)
66385 , p_source_21 => l_array_source_21(Idx)
66386 , p_source_22 => l_array_source_22(Idx)
66387 , p_source_23 => l_array_source_23(Idx)
66388 , p_source_24 => l_array_source_24(Idx)
66389 , p_source_29 => l_array_source_29(Idx)
66390 , p_source_30 => l_array_source_30(Idx)
66391 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66392 , p_source_59 => l_array_source_59(Idx)
66393 , p_source_60 => l_array_source_60(Idx)
66394 , p_source_62 => l_array_source_62(Idx)
66395 , p_source_64 => l_array_source_64(Idx)
66396 , p_source_65 => l_array_source_65(Idx)
66397 , p_source_66 => l_array_source_66(Idx)
66398 );
66399 If(l_balance_type_code = 'A') THEN
66400 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66401 END IF;
66402
66403 --
66404
66405
66406 --
66407 AcctLineType_90 (
66408 p_application_id => p_application_id
66412 ,p_actual_flag => l_actual_flag
66409 ,p_event_id => l_event_id
66410 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66411 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66413 ,p_balance_type_code => l_balance_type_code
66414 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66415
66416 , p_source_10 => l_array_source_10(Idx)
66417 , p_source_15 => l_array_source_15(Idx)
66418 , p_source_17 => l_array_source_17(Idx)
66419 , p_source_18 => l_array_source_18(Idx)
66420 , p_source_21 => l_array_source_21(Idx)
66421 , p_source_22 => l_array_source_22(Idx)
66422 , p_source_23 => l_array_source_23(Idx)
66423 , p_source_29 => l_array_source_29(Idx)
66424 , p_source_30 => l_array_source_30(Idx)
66425 , p_source_54 => l_array_source_54(Idx)
66426 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66427 , p_source_59 => l_array_source_59(Idx)
66428 , p_source_60 => l_array_source_60(Idx)
66429 , p_source_61 => l_array_source_61(Idx)
66430 , p_source_62 => l_array_source_62(Idx)
66431 , p_source_63 => l_array_source_63(Idx)
66432 , p_source_64 => l_array_source_64(Idx)
66433 , p_source_65 => l_array_source_65(Idx)
66434 , p_source_66 => l_array_source_66(Idx)
66435 , p_source_69 => l_array_source_69(Idx)
66436 );
66437 If(l_balance_type_code = 'A') THEN
66438 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66439 END IF;
66440
66441 --
66442
66443
66444 --
66445 AcctLineType_91 (
66446 p_application_id => p_application_id
66447 ,p_event_id => l_event_id
66448 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66449 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66450 ,p_actual_flag => l_actual_flag
66451 ,p_balance_type_code => l_balance_type_code
66452 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66453
66454 , p_source_10 => l_array_source_10(Idx)
66455 , p_source_15 => l_array_source_15(Idx)
66456 , p_source_17 => l_array_source_17(Idx)
66457 , p_source_18 => l_array_source_18(Idx)
66458 , p_source_21 => l_array_source_21(Idx)
66459 , p_source_22 => l_array_source_22(Idx)
66460 , p_source_23 => l_array_source_23(Idx)
66461 , p_source_29 => l_array_source_29(Idx)
66462 , p_source_30 => l_array_source_30(Idx)
66463 , p_source_54 => l_array_source_54(Idx)
66464 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66465 , p_source_59 => l_array_source_59(Idx)
66466 , p_source_60 => l_array_source_60(Idx)
66467 , p_source_61 => l_array_source_61(Idx)
66468 , p_source_62 => l_array_source_62(Idx)
66469 , p_source_63 => l_array_source_63(Idx)
66470 , p_source_64 => l_array_source_64(Idx)
66471 , p_source_65 => l_array_source_65(Idx)
66472 , p_source_66 => l_array_source_66(Idx)
66473 , p_source_69 => l_array_source_69(Idx)
66474 );
66475 If(l_balance_type_code = 'A') THEN
66476 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66477 END IF;
66478
66479 --
66480
66481
66482 --
66483 AcctLineType_92 (
66484 p_application_id => p_application_id
66485 ,p_event_id => l_event_id
66486 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66487 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66488 ,p_actual_flag => l_actual_flag
66489 ,p_balance_type_code => l_balance_type_code
66490 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66491
66492 , p_source_10 => l_array_source_10(Idx)
66493 , p_source_15 => l_array_source_15(Idx)
66494 , p_source_16 => l_array_source_16(Idx)
66495 , p_source_17 => l_array_source_17(Idx)
66496 , p_source_18 => l_array_source_18(Idx)
66497 , p_source_21 => l_array_source_21(Idx)
66498 , p_source_22 => l_array_source_22(Idx)
66499 , p_source_23 => l_array_source_23(Idx)
66500 , p_source_24 => l_array_source_24(Idx)
66501 , p_source_29 => l_array_source_29(Idx)
66502 , p_source_30 => l_array_source_30(Idx)
66503 , p_source_54 => l_array_source_54(Idx)
66504 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66505 , p_source_59 => l_array_source_59(Idx)
66506 , p_source_60 => l_array_source_60(Idx)
66507 , p_source_61 => l_array_source_61(Idx)
66508 , p_source_62 => l_array_source_62(Idx)
66509 , p_source_64 => l_array_source_64(Idx)
66510 , p_source_65 => l_array_source_65(Idx)
66511 , p_source_66 => l_array_source_66(Idx)
66512 );
66513 If(l_balance_type_code = 'A') THEN
66514 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66515 END IF;
66516
66517 --
66518
66519
66520 --
66521 AcctLineType_93 (
66522 p_application_id => p_application_id
66523 ,p_event_id => l_event_id
66524 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66525 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66526 ,p_actual_flag => l_actual_flag
66527 ,p_balance_type_code => l_balance_type_code
66528 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66529
66530 , p_source_10 => l_array_source_10(Idx)
66531 , p_source_15 => l_array_source_15(Idx)
66532 , p_source_16 => l_array_source_16(Idx)
66533 , p_source_17 => l_array_source_17(Idx)
66534 , p_source_18 => l_array_source_18(Idx)
66535 , p_source_21 => l_array_source_21(Idx)
66536 , p_source_22 => l_array_source_22(Idx)
66537 , p_source_23 => l_array_source_23(Idx)
66538 , p_source_29 => l_array_source_29(Idx)
66539 , p_source_30 => l_array_source_30(Idx)
66540 , p_source_54 => l_array_source_54(Idx)
66541 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66542 , p_source_59 => l_array_source_59(Idx)
66543 , p_source_60 => l_array_source_60(Idx)
66544 , p_source_61 => l_array_source_61(Idx)
66548 , p_source_65 => l_array_source_65(Idx)
66545 , p_source_62 => l_array_source_62(Idx)
66546 , p_source_63 => l_array_source_63(Idx)
66547 , p_source_64 => l_array_source_64(Idx)
66549 , p_source_66 => l_array_source_66(Idx)
66550 );
66551 If(l_balance_type_code = 'A') THEN
66552 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66553 END IF;
66554
66555 --
66556
66557
66558 --
66559 AcctLineType_94 (
66560 p_application_id => p_application_id
66561 ,p_event_id => l_event_id
66562 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66563 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66564 ,p_actual_flag => l_actual_flag
66565 ,p_balance_type_code => l_balance_type_code
66566 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66567
66568 , p_source_10 => l_array_source_10(Idx)
66569 , p_source_15 => l_array_source_15(Idx)
66570 , p_source_16 => l_array_source_16(Idx)
66571 , p_source_17 => l_array_source_17(Idx)
66572 , p_source_18 => l_array_source_18(Idx)
66573 , p_source_21 => l_array_source_21(Idx)
66574 , p_source_22 => l_array_source_22(Idx)
66575 , p_source_23 => l_array_source_23(Idx)
66576 , p_source_29 => l_array_source_29(Idx)
66577 , p_source_30 => l_array_source_30(Idx)
66578 , p_source_54 => l_array_source_54(Idx)
66579 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66580 , p_source_59 => l_array_source_59(Idx)
66581 , p_source_60 => l_array_source_60(Idx)
66582 , p_source_61 => l_array_source_61(Idx)
66583 , p_source_62 => l_array_source_62(Idx)
66584 , p_source_63 => l_array_source_63(Idx)
66585 , p_source_64 => l_array_source_64(Idx)
66586 , p_source_65 => l_array_source_65(Idx)
66587 , p_source_66 => l_array_source_66(Idx)
66588 );
66589 If(l_balance_type_code = 'A') THEN
66590 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66591 END IF;
66592
66593 --
66594
66595
66596 --
66597 AcctLineType_95 (
66598 p_application_id => p_application_id
66599 ,p_event_id => l_event_id
66600 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66601 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66602 ,p_actual_flag => l_actual_flag
66603 ,p_balance_type_code => l_balance_type_code
66604 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66605
66606 , p_source_10 => l_array_source_10(Idx)
66607 , p_source_15 => l_array_source_15(Idx)
66608 , p_source_17 => l_array_source_17(Idx)
66609 , p_source_18 => l_array_source_18(Idx)
66610 , p_source_21 => l_array_source_21(Idx)
66611 , p_source_22 => l_array_source_22(Idx)
66612 , p_source_23 => l_array_source_23(Idx)
66613 , p_source_29 => l_array_source_29(Idx)
66614 , p_source_30 => l_array_source_30(Idx)
66615 , p_source_54 => l_array_source_54(Idx)
66616 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66617 , p_source_59 => l_array_source_59(Idx)
66618 , p_source_60 => l_array_source_60(Idx)
66619 , p_source_61 => l_array_source_61(Idx)
66620 , p_source_62 => l_array_source_62(Idx)
66621 , p_source_63 => l_array_source_63(Idx)
66622 , p_source_64 => l_array_source_64(Idx)
66623 , p_source_65 => l_array_source_65(Idx)
66624 , p_source_66 => l_array_source_66(Idx)
66625 , p_source_69 => l_array_source_69(Idx)
66626 );
66627 If(l_balance_type_code = 'A') THEN
66628 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66629 END IF;
66630
66631 --
66632
66633
66634 --
66635 AcctLineType_96 (
66636 p_application_id => p_application_id
66637 ,p_event_id => l_event_id
66638 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66639 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66640 ,p_actual_flag => l_actual_flag
66641 ,p_balance_type_code => l_balance_type_code
66642 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66643
66644 , p_source_10 => l_array_source_10(Idx)
66645 , p_source_15 => l_array_source_15(Idx)
66646 , p_source_17 => l_array_source_17(Idx)
66647 , p_source_18 => l_array_source_18(Idx)
66648 , p_source_21 => l_array_source_21(Idx)
66649 , p_source_22 => l_array_source_22(Idx)
66650 , p_source_23 => l_array_source_23(Idx)
66651 , p_source_29 => l_array_source_29(Idx)
66652 , p_source_30 => l_array_source_30(Idx)
66653 , p_source_54 => l_array_source_54(Idx)
66654 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66655 , p_source_59 => l_array_source_59(Idx)
66656 , p_source_60 => l_array_source_60(Idx)
66657 , p_source_61 => l_array_source_61(Idx)
66658 , p_source_62 => l_array_source_62(Idx)
66659 , p_source_63 => l_array_source_63(Idx)
66660 , p_source_64 => l_array_source_64(Idx)
66661 , p_source_65 => l_array_source_65(Idx)
66662 , p_source_66 => l_array_source_66(Idx)
66663 , p_source_69 => l_array_source_69(Idx)
66664 );
66665 If(l_balance_type_code = 'A') THEN
66666 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66667 END IF;
66668
66669 --
66670
66671
66672 --
66673 AcctLineType_97 (
66674 p_application_id => p_application_id
66675 ,p_event_id => l_event_id
66676 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66677 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66678 ,p_actual_flag => l_actual_flag
66679 ,p_balance_type_code => l_balance_type_code
66680 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66681
66682 , p_source_10 => l_array_source_10(Idx)
66683 , p_source_15 => l_array_source_15(Idx)
66684 , p_source_17 => l_array_source_17(Idx)
66685 , p_source_18 => l_array_source_18(Idx)
66686 , p_source_19 => l_array_source_19(Idx)
66690 , p_source_30 => l_array_source_30(Idx)
66687 , p_source_20 => l_array_source_20(Idx)
66688 , p_source_24 => l_array_source_24(Idx)
66689 , p_source_29 => l_array_source_29(Idx)
66691 , p_source_54 => l_array_source_54(Idx)
66692 , p_source_55 => l_array_source_55(Idx)
66693 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66694 , p_source_59 => l_array_source_59(Idx)
66695 , p_source_60 => l_array_source_60(Idx)
66696 , p_source_64 => l_array_source_64(Idx)
66697 , p_source_65 => l_array_source_65(Idx)
66698 , p_source_66 => l_array_source_66(Idx)
66699 , p_source_67 => l_array_source_67(Idx)
66700 , p_source_68 => l_array_source_68(Idx)
66701 );
66702 If(l_balance_type_code = 'A') THEN
66703 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66704 END IF;
66705
66706 --
66707
66708
66709 --
66710 AcctLineType_98 (
66711 p_application_id => p_application_id
66712 ,p_event_id => l_event_id
66713 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66714 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66715 ,p_actual_flag => l_actual_flag
66716 ,p_balance_type_code => l_balance_type_code
66717 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66718
66719 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
66720 , p_source_15 => l_array_source_15(Idx)
66721 , p_source_16 => l_array_source_16(Idx)
66722 , p_source_17 => l_array_source_17(Idx)
66723 , p_source_18 => l_array_source_18(Idx)
66724 , p_source_21 => l_array_source_21(Idx)
66725 , p_source_22 => l_array_source_22(Idx)
66726 , p_source_23 => l_array_source_23(Idx)
66727 , p_source_29 => l_array_source_29(Idx)
66728 , p_source_30 => l_array_source_30(Idx)
66729 , p_source_54 => l_array_source_54(Idx)
66730 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66731 , p_source_59 => l_array_source_59(Idx)
66732 , p_source_60 => l_array_source_60(Idx)
66733 , p_source_61 => l_array_source_61(Idx)
66734 , p_source_62 => l_array_source_62(Idx)
66735 , p_source_63 => l_array_source_63(Idx)
66736 , p_source_66 => l_array_source_66(Idx)
66737 , p_source_69 => l_array_source_69(Idx)
66738 , p_source_70 => g_array_event(l_event_id).array_value_num('source_70')
66739 , p_source_71 => g_array_event(l_event_id).array_value_num('source_71')
66740 );
66741 If(l_balance_type_code = 'A') THEN
66742 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66743 END IF;
66744
66745 --
66746
66747
66748 --
66749 AcctLineType_99 (
66750 p_application_id => p_application_id
66751 ,p_event_id => l_event_id
66752 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66753 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66754 ,p_actual_flag => l_actual_flag
66755 ,p_balance_type_code => l_balance_type_code
66756 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66757
66758 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
66759 , p_source_15 => l_array_source_15(Idx)
66760 , p_source_17 => l_array_source_17(Idx)
66761 , p_source_18 => l_array_source_18(Idx)
66762 , p_source_21 => l_array_source_21(Idx)
66763 , p_source_22 => l_array_source_22(Idx)
66764 , p_source_23 => l_array_source_23(Idx)
66765 , p_source_29 => l_array_source_29(Idx)
66766 , p_source_30 => l_array_source_30(Idx)
66767 , p_source_54 => l_array_source_54(Idx)
66768 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66769 , p_source_59 => l_array_source_59(Idx)
66770 , p_source_60 => l_array_source_60(Idx)
66771 , p_source_61 => l_array_source_61(Idx)
66772 , p_source_62 => l_array_source_62(Idx)
66773 , p_source_63 => l_array_source_63(Idx)
66774 , p_source_66 => l_array_source_66(Idx)
66775 , p_source_69 => l_array_source_69(Idx)
66776 , p_source_70 => g_array_event(l_event_id).array_value_num('source_70')
66777 , p_source_71 => g_array_event(l_event_id).array_value_num('source_71')
66778 , p_source_72 => g_array_event(l_event_id).array_value_char('source_72')
66779 );
66780 If(l_balance_type_code = 'A') THEN
66781 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66782 END IF;
66783
66784 --
66785
66786
66787 --
66788 AcctLineType_100 (
66789 p_application_id => p_application_id
66790 ,p_event_id => l_event_id
66791 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66792 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66793 ,p_actual_flag => l_actual_flag
66794 ,p_balance_type_code => l_balance_type_code
66795 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66796
66797 , p_source_11 => g_array_event(l_event_id).array_value_num('source_11')
66798 , p_source_15 => l_array_source_15(Idx)
66799 , p_source_17 => l_array_source_17(Idx)
66800 , p_source_18 => l_array_source_18(Idx)
66801 , p_source_21 => l_array_source_21(Idx)
66802 , p_source_22 => l_array_source_22(Idx)
66803 , p_source_23 => l_array_source_23(Idx)
66804 , p_source_29 => l_array_source_29(Idx)
66805 , p_source_30 => l_array_source_30(Idx)
66806 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66807 , p_source_59 => l_array_source_59(Idx)
66808 , p_source_60 => l_array_source_60(Idx)
66809 , p_source_61 => l_array_source_61(Idx)
66810 , p_source_62 => l_array_source_62(Idx)
66811 , p_source_63 => l_array_source_63(Idx)
66812 , p_source_64 => l_array_source_64(Idx)
66813 , p_source_65 => l_array_source_65(Idx)
66814 , p_source_66 => l_array_source_66(Idx)
66815 );
66816 If(l_balance_type_code = 'A') THEN
66817 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66818 END IF;
66819
66820 --
66821
66822
66823 --
66824 AcctLineType_101 (
66825 p_application_id => p_application_id
66826 ,p_event_id => l_event_id
66830 ,p_balance_type_code => l_balance_type_code
66827 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66828 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66829 ,p_actual_flag => l_actual_flag
66831 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66832
66833 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
66834 , p_source_14 => l_array_source_14(Idx)
66835 , p_source_15 => l_array_source_15(Idx)
66836 , p_source_17 => l_array_source_17(Idx)
66837 , p_source_18 => l_array_source_18(Idx)
66838 , p_source_19 => l_array_source_19(Idx)
66839 , p_source_20 => l_array_source_20(Idx)
66840 , p_source_24 => l_array_source_24(Idx)
66841 , p_source_29 => l_array_source_29(Idx)
66842 , p_source_30 => l_array_source_30(Idx)
66843 , p_source_54 => l_array_source_54(Idx)
66844 , p_source_55 => l_array_source_55(Idx)
66845 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66846 , p_source_59 => l_array_source_59(Idx)
66847 , p_source_60 => l_array_source_60(Idx)
66848 , p_source_64 => l_array_source_64(Idx)
66849 , p_source_65 => l_array_source_65(Idx)
66850 , p_source_66 => l_array_source_66(Idx)
66851 , p_source_67 => l_array_source_67(Idx)
66852 , p_source_68 => l_array_source_68(Idx)
66853 );
66854 If(l_balance_type_code = 'A') THEN
66855 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66856 END IF;
66857
66858 --
66859
66860
66861 --
66862 AcctLineType_102 (
66863 p_application_id => p_application_id
66864 ,p_event_id => l_event_id
66865 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66866 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66867 ,p_actual_flag => l_actual_flag
66868 ,p_balance_type_code => l_balance_type_code
66869 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66870
66871 , p_source_10 => l_array_source_10(Idx)
66872 , p_source_15 => l_array_source_15(Idx)
66873 , p_source_17 => l_array_source_17(Idx)
66874 , p_source_18 => l_array_source_18(Idx)
66875 , p_source_21 => l_array_source_21(Idx)
66876 , p_source_22 => l_array_source_22(Idx)
66877 , p_source_23 => l_array_source_23(Idx)
66878 , p_source_29 => l_array_source_29(Idx)
66879 , p_source_30 => l_array_source_30(Idx)
66880 , p_source_54 => l_array_source_54(Idx)
66881 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66882 , p_source_59 => l_array_source_59(Idx)
66883 , p_source_60 => l_array_source_60(Idx)
66884 , p_source_61 => l_array_source_61(Idx)
66885 , p_source_62 => l_array_source_62(Idx)
66886 , p_source_63 => l_array_source_63(Idx)
66887 , p_source_64 => l_array_source_64(Idx)
66888 , p_source_65 => l_array_source_65(Idx)
66889 , p_source_66 => l_array_source_66(Idx)
66890 );
66891 If(l_balance_type_code = 'A') THEN
66892 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66893 END IF;
66894
66895 --
66896
66897
66898 --
66899 AcctLineType_103 (
66900 p_application_id => p_application_id
66901 ,p_event_id => l_event_id
66902 ,p_calculate_acctd_flag => l_calculate_acctd_flag
66903 ,p_calculate_g_l_flag => l_calculate_g_l_flag
66904 ,p_actual_flag => l_actual_flag
66905 ,p_balance_type_code => l_balance_type_code
66906 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
66907
66908 , p_source_10 => l_array_source_10(Idx)
66909 , p_source_15 => l_array_source_15(Idx)
66910 , p_source_16 => l_array_source_16(Idx)
66911 , p_source_17 => l_array_source_17(Idx)
66912 , p_source_18 => l_array_source_18(Idx)
66913 , p_source_21 => l_array_source_21(Idx)
66914 , p_source_22 => l_array_source_22(Idx)
66915 , p_source_23 => l_array_source_23(Idx)
66916 , p_source_29 => l_array_source_29(Idx)
66917 , p_source_30 => l_array_source_30(Idx)
66918 , p_source_54 => l_array_source_54(Idx)
66919 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
66920 , p_source_59 => l_array_source_59(Idx)
66921 , p_source_60 => l_array_source_60(Idx)
66922 , p_source_61 => l_array_source_61(Idx)
66923 , p_source_62 => l_array_source_62(Idx)
66924 , p_source_63 => l_array_source_63(Idx)
66925 , p_source_64 => l_array_source_64(Idx)
66926 , p_source_65 => l_array_source_65(Idx)
66927 , p_source_66 => l_array_source_66(Idx)
66928 );
66929 If(l_balance_type_code = 'A') THEN
66930 l_actual_gain_loss_ref := l_gain_or_loss_ref;
66931 END IF;
66932
66933 --
66934
66935 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
66936 -- or secondary ledger that has different currency with primary
66937 -- or alc that is calculated by sla
66938 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
66939 (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'))
66940
66941 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
66942 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
66943 AND (l_actual_flag = 'A')) THEN
66944 XLA_AE_LINES_PKG.CreateGainOrLossLines(
66945 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
66946 ,p_application_id => p_application_id
66947 ,p_amb_context_code => 'DEFAULT'
66948 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
66949 ,p_event_class_code => C_EVENT_CLASS_CODE
66950 ,p_event_type_code => C_EVENT_TYPE_CODE
66951
66952 ,p_gain_ccid => TO_NUMBER(g_array_event(l_event_id).array_value_num('source_12'))
66953 ,p_loss_ccid => TO_NUMBER(g_array_event(l_event_id).array_value_num('source_13'))
66954
66955 ,p_actual_flag => l_actual_flag
66959 );
66956 ,p_enc_flag => null
66957 ,p_actual_g_l_ref => l_actual_gain_loss_ref
66958 ,p_enc_g_l_ref => null
66960 END IF;
66961 END IF;
66962 END IF;
66963
66964 ELSE
66965 --
66966 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
66967 --
66968 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
66969 trace
66970 (p_msg => 'Trancaction revesal option is Y'
66971 ,p_level => C_LEVEL_STATEMENT
66972 ,p_module => l_log_module);
66973 END IF;
66974 END IF;
66975
66976 END LOOP;
66977 l_result := XLA_AE_LINES_PKG.InsertLines ;
66978 end loop;
66979 close line_cur;
66980
66981
66982 --
66983 -- insert headers into xla_ae_headers_gt table
66984 --
66985 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
66986
66987 -- insert into errors table here.
66988
66989 END LOOP;
66990
66991 --
66992 -- 4865292
66993 --
66994 -- Compare g_hdr_extract_count with event count in
66995 -- CreateHeadersAndLines.
66996 --
66997 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
66998
66999 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67000 trace (p_msg => '# rows extracted from header extract objects '
67001 || ' (running total): '
67002 || g_hdr_extract_count
67003 ,p_level => C_LEVEL_STATEMENT
67004 ,p_module => l_log_module);
67005 END IF;
67006
67007 CLOSE header_cur;
67008 --
67009
67010 --
67011 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67012 trace
67013 (p_msg => 'END of EventClass_112'
67014 ,p_level => C_LEVEL_PROCEDURE
67015 ,p_module => l_log_module);
67016 END IF;
67017 --
67018 RETURN l_result;
67019 EXCEPTION
67020 WHEN xla_exceptions_pkg.application_exception THEN
67021
67022 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
67023
67024
67025 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
67026
67027 RAISE;
67028
67029 WHEN NO_DATA_FOUND THEN
67030
67031 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
67032 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
67033
67034 FOR header_record IN header_cur
67035 LOOP
67036 l_array_header_events(header_record.event_id) := header_record.event_id;
67037 END LOOP;
67038
67039 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
67040 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
67041
67042 fnd_file.put_line(fnd_file.LOG, ' ');
67043 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
67044 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
67045 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
67046
67047 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
67048 LOOP
67049 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
67050 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
67051 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
67052 END IF;
67053 END LOOP;
67054
67055 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
67056 fnd_file.put_line(fnd_file.LOG, ' ');
67057
67058
67059 xla_exceptions_pkg.raise_message
67060 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_112');
67061
67062
67063 WHEN OTHERS THEN
67064 xla_exceptions_pkg.raise_message
67065 (p_location => 'XLA_00222_AAD_S_000007_PKG.EventClass_112');
67066 END EventClass_112;
67067 --
67068
67069 --
67070 --+============================================+
67071 --| |
67072 --| PRIVATE FUNCTION |
67073 --| |
67074 --+============================================+
67075 --
67076 FUNCTION CreateHeadersAndLines
67077 (p_application_id IN NUMBER
67078 ,p_base_ledger_id IN NUMBER
67079 ,p_target_ledger_id IN NUMBER
67080 ,p_pad_start_date IN DATE
67081 ,p_pad_end_date IN DATE
67082 ,p_primary_ledger_id IN NUMBER)
67083 RETURN BOOLEAN IS
67084 l_created BOOLEAN:=FALSE;
67085 l_event_id NUMBER;
67086 l_event_date DATE;
67087 l_language VARCHAR2(30);
67088 l_currency_code VARCHAR2(30);
67089 l_sla_ledger_id NUMBER;
67090 l_log_module VARCHAR2(240);
67091
67092 BEGIN
67093 --
67094 IF g_log_enabled THEN
67095 l_log_module := C_DEFAULT_MODULE||'.CreateHeadersAndLines';
67096 END IF;
67097 --
67098 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67099 trace
67100 (p_msg => 'BEGIN of CreateHeadersAndLines'
67101 ,p_level => C_LEVEL_PROCEDURE
67102 ,p_module => l_log_module);
67103 END IF;
67104
67105 l_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
67106 l_currency_code := xla_ae_journal_entry_pkg.g_cache_ledgers_info.currency_code;
67107 l_sla_ledger_id := xla_ae_journal_entry_pkg.g_cache_ledgers_info.sla_ledger_id;
67108
67109 --
67110 -- initialize array of lines with NULL
67111 --
67115 -- initialize header extract count -- Bug 4865292
67112 xla_ae_lines_pkg.SetNullLine;
67113
67114 --
67116 --
67117 g_hdr_extract_count:= 0;
67118
67119
67120 l_created := EventClass_104(
67121 p_application_id => p_application_id
67122 , p_base_ledger_id => p_base_ledger_id
67123 , p_target_ledger_id => p_target_ledger_id
67124 , p_language => l_language
67125 , p_currency_code => l_currency_code
67126 , p_sla_ledger_id => l_sla_ledger_id
67127 , p_pad_start_date => p_pad_start_date
67128 , p_pad_end_date => p_pad_end_date
67129 , p_primary_ledger_id => p_primary_ledger_id
67130 );
67131
67132
67133
67134 IF ( g_diagnostics_mode ='Y' ) THEN
67135
67136 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67137 trace
67138 (p_msg => 'CALL Transaction Objects Diagnostics'
67139 ,p_level => C_LEVEL_STATEMENT
67140 ,p_module => l_log_module);
67141
67142 END IF;
67143
67144 insert_sources_104(
67145 p_target_ledger_id => p_target_ledger_id
67146 , p_language => l_language
67147 , p_sla_ledger_id => l_sla_ledger_id
67148 , p_pad_start_date => p_pad_start_date
67149 , p_pad_end_date => p_pad_end_date
67150 );
67151
67152 END IF;
67153
67154 l_created := EventClass_105(
67155 p_application_id => p_application_id
67156 , p_base_ledger_id => p_base_ledger_id
67157 , p_target_ledger_id => p_target_ledger_id
67158 , p_language => l_language
67159 , p_currency_code => l_currency_code
67160 , p_sla_ledger_id => l_sla_ledger_id
67161 , p_pad_start_date => p_pad_start_date
67162 , p_pad_end_date => p_pad_end_date
67163 , p_primary_ledger_id => p_primary_ledger_id
67164 );
67165
67166
67167
67168 IF ( g_diagnostics_mode ='Y' ) THEN
67169
67170 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67171 trace
67172 (p_msg => 'CALL Transaction Objects Diagnostics'
67173 ,p_level => C_LEVEL_STATEMENT
67174 ,p_module => l_log_module);
67175
67176 END IF;
67177
67178 insert_sources_105(
67179 p_target_ledger_id => p_target_ledger_id
67180 , p_language => l_language
67181 , p_sla_ledger_id => l_sla_ledger_id
67182 , p_pad_start_date => p_pad_start_date
67183 , p_pad_end_date => p_pad_end_date
67184 );
67185
67186 END IF;
67187
67188 l_created := EventClass_106(
67189 p_application_id => p_application_id
67190 , p_base_ledger_id => p_base_ledger_id
67191 , p_target_ledger_id => p_target_ledger_id
67192 , p_language => l_language
67193 , p_currency_code => l_currency_code
67194 , p_sla_ledger_id => l_sla_ledger_id
67195 , p_pad_start_date => p_pad_start_date
67196 , p_pad_end_date => p_pad_end_date
67197 , p_primary_ledger_id => p_primary_ledger_id
67198 );
67199
67200
67201
67202 IF ( g_diagnostics_mode ='Y' ) THEN
67203
67204 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67205 trace
67206 (p_msg => 'CALL Transaction Objects Diagnostics'
67207 ,p_level => C_LEVEL_STATEMENT
67208 ,p_module => l_log_module);
67209
67210 END IF;
67211
67212 insert_sources_106(
67213 p_target_ledger_id => p_target_ledger_id
67214 , p_language => l_language
67215 , p_sla_ledger_id => l_sla_ledger_id
67216 , p_pad_start_date => p_pad_start_date
67217 , p_pad_end_date => p_pad_end_date
67218 );
67219
67220 END IF;
67221
67222 l_created := EventClass_107(
67223 p_application_id => p_application_id
67224 , p_base_ledger_id => p_base_ledger_id
67225 , p_target_ledger_id => p_target_ledger_id
67226 , p_language => l_language
67227 , p_currency_code => l_currency_code
67228 , p_sla_ledger_id => l_sla_ledger_id
67229 , p_pad_start_date => p_pad_start_date
67230 , p_pad_end_date => p_pad_end_date
67231 , p_primary_ledger_id => p_primary_ledger_id
67232 );
67233
67234
67235
67236 IF ( g_diagnostics_mode ='Y' ) THEN
67237
67238 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67239 trace
67240 (p_msg => 'CALL Transaction Objects Diagnostics'
67241 ,p_level => C_LEVEL_STATEMENT
67242 ,p_module => l_log_module);
67243
67244 END IF;
67245
67246 insert_sources_107(
67247 p_target_ledger_id => p_target_ledger_id
67248 , p_language => l_language
67249 , p_sla_ledger_id => l_sla_ledger_id
67250 , p_pad_start_date => p_pad_start_date
67251 , p_pad_end_date => p_pad_end_date
67252 );
67253
67254 END IF;
67255
67256 l_created := EventClass_108(
67257 p_application_id => p_application_id
67261 , p_currency_code => l_currency_code
67258 , p_base_ledger_id => p_base_ledger_id
67259 , p_target_ledger_id => p_target_ledger_id
67260 , p_language => l_language
67262 , p_sla_ledger_id => l_sla_ledger_id
67263 , p_pad_start_date => p_pad_start_date
67264 , p_pad_end_date => p_pad_end_date
67265 , p_primary_ledger_id => p_primary_ledger_id
67266 );
67267
67268
67269
67270 IF ( g_diagnostics_mode ='Y' ) THEN
67271
67272 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67273 trace
67274 (p_msg => 'CALL Transaction Objects Diagnostics'
67275 ,p_level => C_LEVEL_STATEMENT
67276 ,p_module => l_log_module);
67277
67278 END IF;
67279
67280 insert_sources_108(
67281 p_target_ledger_id => p_target_ledger_id
67282 , p_language => l_language
67283 , p_sla_ledger_id => l_sla_ledger_id
67284 , p_pad_start_date => p_pad_start_date
67285 , p_pad_end_date => p_pad_end_date
67286 );
67287
67288 END IF;
67289
67290 l_created := EventClass_109(
67291 p_application_id => p_application_id
67292 , p_base_ledger_id => p_base_ledger_id
67293 , p_target_ledger_id => p_target_ledger_id
67294 , p_language => l_language
67295 , p_currency_code => l_currency_code
67296 , p_sla_ledger_id => l_sla_ledger_id
67297 , p_pad_start_date => p_pad_start_date
67298 , p_pad_end_date => p_pad_end_date
67299 , p_primary_ledger_id => p_primary_ledger_id
67300 );
67301
67302
67303
67304 IF ( g_diagnostics_mode ='Y' ) THEN
67305
67306 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67307 trace
67308 (p_msg => 'CALL Transaction Objects Diagnostics'
67309 ,p_level => C_LEVEL_STATEMENT
67310 ,p_module => l_log_module);
67311
67312 END IF;
67313
67314 insert_sources_109(
67315 p_target_ledger_id => p_target_ledger_id
67316 , p_language => l_language
67317 , p_sla_ledger_id => l_sla_ledger_id
67318 , p_pad_start_date => p_pad_start_date
67319 , p_pad_end_date => p_pad_end_date
67320 );
67321
67322 END IF;
67323
67324 l_created := EventClass_110(
67325 p_application_id => p_application_id
67326 , p_base_ledger_id => p_base_ledger_id
67327 , p_target_ledger_id => p_target_ledger_id
67328 , p_language => l_language
67329 , p_currency_code => l_currency_code
67330 , p_sla_ledger_id => l_sla_ledger_id
67331 , p_pad_start_date => p_pad_start_date
67332 , p_pad_end_date => p_pad_end_date
67333 , p_primary_ledger_id => p_primary_ledger_id
67334 );
67335
67336
67337
67338 IF ( g_diagnostics_mode ='Y' ) THEN
67339
67340 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67341 trace
67342 (p_msg => 'CALL Transaction Objects Diagnostics'
67343 ,p_level => C_LEVEL_STATEMENT
67344 ,p_module => l_log_module);
67345
67346 END IF;
67347
67348 insert_sources_110(
67349 p_target_ledger_id => p_target_ledger_id
67350 , p_language => l_language
67351 , p_sla_ledger_id => l_sla_ledger_id
67352 , p_pad_start_date => p_pad_start_date
67353 , p_pad_end_date => p_pad_end_date
67354 );
67355
67356 END IF;
67357
67358 l_created := EventClass_111(
67359 p_application_id => p_application_id
67360 , p_base_ledger_id => p_base_ledger_id
67361 , p_target_ledger_id => p_target_ledger_id
67362 , p_language => l_language
67363 , p_currency_code => l_currency_code
67364 , p_sla_ledger_id => l_sla_ledger_id
67365 , p_pad_start_date => p_pad_start_date
67366 , p_pad_end_date => p_pad_end_date
67367 , p_primary_ledger_id => p_primary_ledger_id
67368 );
67369
67370
67371
67372 IF ( g_diagnostics_mode ='Y' ) THEN
67373
67374 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67375 trace
67376 (p_msg => 'CALL Transaction Objects Diagnostics'
67377 ,p_level => C_LEVEL_STATEMENT
67378 ,p_module => l_log_module);
67379
67380 END IF;
67381
67382 insert_sources_111(
67383 p_target_ledger_id => p_target_ledger_id
67384 , p_language => l_language
67385 , p_sla_ledger_id => l_sla_ledger_id
67386 , p_pad_start_date => p_pad_start_date
67387 , p_pad_end_date => p_pad_end_date
67388 );
67389
67390 END IF;
67391
67392 l_created := EventClass_112(
67393 p_application_id => p_application_id
67394 , p_base_ledger_id => p_base_ledger_id
67395 , p_target_ledger_id => p_target_ledger_id
67396 , p_language => l_language
67400 , p_pad_end_date => p_pad_end_date
67397 , p_currency_code => l_currency_code
67398 , p_sla_ledger_id => l_sla_ledger_id
67399 , p_pad_start_date => p_pad_start_date
67401 , p_primary_ledger_id => p_primary_ledger_id
67402 );
67403
67404
67405
67406 IF ( g_diagnostics_mode ='Y' ) THEN
67407
67408 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67409 trace
67410 (p_msg => 'CALL Transaction Objects Diagnostics'
67411 ,p_level => C_LEVEL_STATEMENT
67412 ,p_module => l_log_module);
67413
67414 END IF;
67415
67416 insert_sources_112(
67417 p_target_ledger_id => p_target_ledger_id
67418 , p_language => l_language
67419 , p_sla_ledger_id => l_sla_ledger_id
67420 , p_pad_start_date => p_pad_start_date
67421 , p_pad_end_date => p_pad_end_date
67422 );
67423
67424 END IF;
67425
67426
67427 --
67428 -- Bug 4865292
67429 -- When the number of events and that of header extract do not match,
67430 -- set the no header extract flag to indicate there are some issues
67431 -- in header extract.
67432 --
67433 -- Event count context is set in xla_accounting_pkg.unit_processor.
67434 -- Build_Message for this error is called in xla_accounting_pkg.post_accounting
67435 -- to report it as a general error.
67436 --
67437 IF xla_context_pkg.get_event_count_context <> g_hdr_extract_count
67438 AND xla_context_pkg.get_event_nohdr_context <> 'Y' THEN
67439
67440 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67441 trace
67442 (p_msg => '# of extracted headers and events does not match'
67443 ,p_level => C_LEVEL_STATEMENT
67444 ,p_module => l_log_module);
67445
67446 trace
67447 (p_msg => '# of extracted headers: '
67448 ||g_hdr_extract_count
67449 ,p_level => C_LEVEL_STATEMENT
67450 ,p_module => l_log_module);
67451
67452 trace
67453 (p_msg => '# of events in xla_events_gt: '
67454 ||xla_context_pkg.get_event_count_context
67455 ,p_level => C_LEVEL_STATEMENT
67456 ,p_module => l_log_module);
67457
67458 trace
67459 (p_msg => 'Event No Header Extract Context: '
67460 ||xla_context_pkg.get_event_nohdr_context
67461 ,p_level => C_LEVEL_STATEMENT
67462 ,p_module => l_log_module);
67463
67464 END IF;
67465
67466
67467 xla_context_pkg.set_event_nohdr_context
67468 (p_nohdr_extract_flag => 'Y'
67469 ,p_client_id => sys_context('USERENV','CLIENT_IDENTIFIER'));
67470
67471 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67472 trace
67473 (p_msg => 'No Header Extract Flag is set to Y'
67474 ,p_level => C_LEVEL_STATEMENT
67475 ,p_module => l_log_module);
67476 END IF;
67477
67478 END IF;
67479
67480 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67481 trace
67482 (p_msg => 'END of CreateHeadersAndLines'
67483 ,p_level => C_LEVEL_PROCEDURE
67484 ,p_module => l_log_module);
67485 END IF;
67486
67487 RETURN l_created;
67488 EXCEPTION
67489 WHEN xla_exceptions_pkg.application_exception THEN
67490 RAISE;
67491 WHEN OTHERS THEN
67492 xla_exceptions_pkg.raise_message
67493 (p_location => 'XLA_00222_AAD_S_000007_PKG.CreateHeadersAndLines');
67494 END CreateHeadersAndLines;
67495 --
67496 --
67497
67498 --
67499 --+============================================+
67500 --| |
67501 --| PUBLIC FUNCTION |
67502 --| |
67503 --+============================================+
67504 --
67505 FUNCTION CreateJournalEntries
67506 (p_application_id IN NUMBER
67507 ,p_base_ledger_id IN NUMBER
67508 ,p_pad_start_date IN DATE
67509 ,p_pad_end_date IN DATE
67510 ,p_primary_ledger_id IN NUMBER)
67511 RETURN NUMBER IS
67512 l_log_module VARCHAR2(240);
67513 l_array_ledgers xla_accounting_cache_pkg.t_array_ledger_id;
67514 l_temp_result BOOLEAN;
67515 l_result NUMBER;
67516 BEGIN
67517 --
67518 IF g_log_enabled THEN
67519 l_log_module := C_DEFAULT_MODULE||'.CreateJournalEntries';
67520 END IF;
67521 --
67522 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67523 trace
67524 (p_msg => 'BEGIN of CreateJournalEntries'||
67525 ' - p_base_ledger_id = '||TO_CHAR(p_base_ledger_id)
67526 ,p_level => C_LEVEL_PROCEDURE
67527 ,p_module => l_log_module);
67528
67529 END IF;
67530
67531 --
67532 g_diagnostics_mode:= xla_accounting_engine_pkg.g_diagnostics_mode;
67533
67534 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67535 trace
67536 (p_msg => 'g_diagnostics_mode = '||g_diagnostics_mode
67537 ,p_level => C_LEVEL_STATEMENT
67538 ,p_module => l_log_module);
67539 END IF;
67540 --
67541 xla_ae_journal_entry_pkg.SetProductAcctDefinition
67542 (p_product_rule_code => 'MFAR_ACCRUAL_ACCOUNT'
67543 ,p_product_rule_type_code => 'S'
67544 ,p_product_rule_version => ''
67545 ,p_product_rule_name => 'Multi-Fund Account Receivables Accrual - Account Method'
67546 ,p_amb_context_code => 'DEFAULT'
67547 );
67548
67549 l_array_ledgers :=
67550 xla_ae_journal_entry_pkg.GetAlternateCurrencyLedger
67551 (p_base_ledger_id => p_base_ledger_id);
67552
67553 FOR Idx IN 1 .. l_array_ledgers.COUNT LOOP
67554 l_temp_result :=
67555 XLA_AE_JOURNAL_ENTRY_PKG.GetLedgersInfo
67556 (p_application_id => p_application_id
67557 ,p_base_ledger_id => p_base_ledger_id
67558 ,p_target_ledger_id => l_array_ledgers(Idx)
67559 ,p_primary_ledger_id => p_primary_ledger_id
67560 ,p_pad_start_date => p_pad_start_date
67561 ,p_pad_end_date => p_pad_end_date);
67562
67563 l_temp_result :=
67564 l_temp_result AND
67565 CreateHeadersAndLines
67566 (p_application_id => p_application_id
67567 ,p_base_ledger_id => p_base_ledger_id
67568 ,p_target_ledger_id => l_array_ledgers(Idx)
67569 ,p_pad_start_date => p_pad_start_date
67570 ,p_pad_end_date => p_pad_end_date
67571 ,p_primary_ledger_id => p_primary_ledger_id
67572 );
67573 END LOOP;
67574
67575
67576 IF (g_diagnostics_mode = 'Y' AND
67577 C_LEVEL_UNEXPECTED >= g_log_level AND
67578 xla_environment_pkg.g_Req_Id IS NOT NULL ) THEN
67579
67580 xla_accounting_dump_pkg.acctg_event_extract_log(
67581 p_application_id => p_application_id
67582 ,p_request_id => xla_environment_pkg.g_Req_Id
67583 );
67584
67585 END IF;
67586
67587 CASE l_temp_result
67588 WHEN TRUE THEN l_result := 0;
67589 ELSE l_result := 2;
67590 END CASE;
67591
67592 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67593 trace
67594 (p_msg => 'return value. = '||TO_CHAR(l_result)
67595 ,p_level => C_LEVEL_PROCEDURE
67596 ,p_module => l_log_module);
67597 trace
67598 (p_msg => 'END of CreateJournalEntries '
67599 ,p_level => C_LEVEL_PROCEDURE
67600 ,p_module => l_log_module);
67601 END IF;
67602
67603 RETURN l_result;
67604 EXCEPTION
67605 WHEN xla_exceptions_pkg.application_exception THEN
67606 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67607 trace
67608 (p_msg => 'ERROR. = '||sqlerrm
67609 ,p_level => C_LEVEL_PROCEDURE
67610 ,p_module => l_log_module);
67611 END IF;
67612 RAISE;
67613 WHEN OTHERS THEN
67614 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67615 trace
67616 (p_msg => 'ERROR. = '||sqlerrm
67617 ,p_level => C_LEVEL_PROCEDURE
67618 ,p_module => l_log_module);
67619 END IF;
67620 xla_exceptions_pkg.raise_message
67621 (p_location => 'XLA_00222_AAD_S_000007_PKG.CreateJournalEntries');
67622 END CreateJournalEntries;
67623 --
67624 --=============================================================================
67625 --
67626 --
67627 --
67628 --
67629 --
67630 --
67631 --
67632 --
67633 --
67634 --
67635 --
67636 --
67637 --
67638 --
67639 --
67640 --
67641 --
67642 --
67643 --
67644 --
67645 --
67646 --
67647 --=============================================================================
67648 --=============================================================================
67649 -- *********** Initialization routine **********
67650 --=============================================================================
67651
67652 BEGIN
67653 g_log_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
67654 g_log_enabled := fnd_log.test
67655 (log_level => g_log_level
67656 ,module => C_DEFAULT_MODULE);
67657
67658 IF NOT g_log_enabled THEN
67659 g_log_level := C_LEVEL_LOG_DISABLED;
67660 END IF;
67661 --
67662 END XLA_00222_AAD_S_000007_PKG;
67663 --