[Home] [Help]
PACKAGE BODY: APPS.XLA_00222_AAD_S_000005_PKG
Source
1 PACKAGE BODY XLA_00222_AAD_S_000005_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_000005_PKG |
10 | |
11 | DESCRIPTION |
12 | Package generated From Product Accounting Definition |
13 | Name : Federal Receivables Accrual |
14 | Code : FEDERAL_AR_ACCRUAL |
15 | Owner : PRODUCT |
16 | Version : |
17 | AMB Context Code: DEFAULT |
18 | HISTORY |
19 | Generated at 30-03-2009 at 05:03:42 by user ANONYMOUS |
20 +=======================================================================*/
21 --
22 --
23 TYPE t_rec_array_event IS RECORD
24 (array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
25 ,array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
26 ,array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
27 ,array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
28 ,array_event_id xla_number_array_type --XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
29 ,array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
30 ,array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L
31 ,array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
32 ,array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
33 ,array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
34 ,array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
35 ,array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
36 ,array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num
37 ,array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
38 ,array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
39 ,array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
40 ,array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L
41 ,array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
42 ,array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
43 ,array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
44 ,array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date
45 ,array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L
46 );
47 --
48 type t_array_value_num is table of number index by varchar2(30);
49 type t_array_value_char is table of varchar2(240) index by varchar2(30);
50 type t_array_value_date is table of date index by varchar2(30);
51
52 type t_rec_value is record
53 (array_value_num t_array_value_num
54 ,array_value_char t_array_value_char
55 ,array_value_date t_array_value_date);
56
57 type t_array_event is table of t_rec_value index by binary_integer;
58
59 g_array_event t_array_event;
60
61 --=============================================================================
62 -- *********** Diagnostics **********
63 --=============================================================================
64
65 g_diagnostics_mode VARCHAR2(1);
66 g_last_hdr_idx NUMBER; -- 4262811 MPA
67 g_hdr_extract_count PLS_INTEGER;
68
69 --=============================================================================
70 -- *********** Local Trace Routine **********
71 --=============================================================================
72
73 C_LEVEL_STATEMENT CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
74 C_LEVEL_PROCEDURE CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
75 C_LEVEL_EVENT CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
76 C_LEVEL_EXCEPTION CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
77 C_LEVEL_ERROR CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
78 C_LEVEL_UNEXPECTED CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
79
80 C_LEVEL_LOG_DISABLED CONSTANT NUMBER := 99;
81 C_DEFAULT_MODULE CONSTANT VARCHAR2(240) := 'xla.plsql.XLA_00222_AAD_S_000005_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_000005_PKG.trace');
109 END trace;
110
111 --
112 --+============================================+
113 --| |
114 --| PRIVATE PROCEDURES/FUNCTIONS |
115 --| |
116 --+============================================+
117 --
118
119 --
120 /*======================================================================+
121 | |
122 | Private Function |
123 | ValidateLookupMeaning |
124 | |
125 +======================================================================*/
126 FUNCTION ValidateLookupMeaning(
127 p_meaning IN VARCHAR2
128 , p_lookup_code IN VARCHAR2
129 , p_lookup_type IN VARCHAR2
130 , p_source_code IN VARCHAR2
131 , p_source_type_code IN VARCHAR2
132 , p_source_application_id IN INTEGER
133 )
134 RETURN VARCHAR2
135 IS
136 l_log_module VARCHAR2(240);
137 BEGIN
138 IF g_log_enabled THEN
139 l_log_module := C_DEFAULT_MODULE||'.ValidateLookupMeaning';
140 END IF;
141 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
142 trace
143 (p_msg => 'BEGIN of ValidateLookupMeaning'
144 ,p_level => C_LEVEL_PROCEDURE
145 ,p_module => l_log_module);
146 END IF;
147 --
148 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
149 trace
150 (p_msg => 'p_source_code = '|| p_source_code||
151 ' - p_source_type_code = '|| p_source_type_code||
152 ' - p_source_application_id = '|| p_source_application_id||
153 ' - p_lookup_code = '|| p_lookup_code||
154 ' - p_lookup_type = '|| p_lookup_type||
155 ' - p_meaning = '|| p_meaning
156 ,p_level => C_LEVEL_PROCEDURE
157 ,p_module => l_log_module);
158
159 END IF;
160
161 IF p_lookup_code IS NOT NULL AND p_meaning IS NULL THEN
162 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
163 xla_accounting_err_pkg. build_message
164 (p_appli_s_name => 'XLA'
165 ,p_msg_name => 'XLA_AP_NO_LOOKUP_MEANING'
166 ,p_token_1 => 'SOURCE_NAME'
167 ,p_value_1 => xla_ae_sources_pkg.GetSourceName(
171 )
168 p_source_code
169 , p_source_type_code
170 , p_source_application_id
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_000005_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_000005_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 --Transaction Type Name
241 , p_source_1 IN VARCHAR2
242 --Transaction Number
243 , p_source_2 IN VARCHAR2
244 --Transaction Document Sequence Number
245 , p_source_3 IN NUMBER
246 )
247 RETURN VARCHAR2
248 IS
249 l_component_type VARCHAR2(80) ;
250 l_component_code VARCHAR2(30) ;
251 l_component_type_code VARCHAR2(1) ;
252 l_component_appl_id INTEGER ;
253 l_amb_context_code VARCHAR2(30) ;
254 l_ledger_language VARCHAR2(30) ;
255 l_source VARCHAR2(1996) ;
256 l_description VARCHAR2(2000) ;
257 l_log_module VARCHAR2(240) ;
258 BEGIN
259 IF g_log_enabled THEN
260 l_log_module := C_DEFAULT_MODULE||'.Description_1';
261 END IF;
262 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
263 trace
264 (p_msg => 'BEGIN of Description_1'
265 ,p_level => C_LEVEL_PROCEDURE
266 ,p_module => l_log_module);
267 END IF;
268
269 l_ledger_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
270 l_component_type := 'AMB_DESCRIPTION';
271 l_component_code := 'CM_L';
272 l_component_type_code := 'S';
273 l_component_appl_id := 222;
274 l_amb_context_code := 'DEFAULT';
275 l_source := NULL;
276 l_description := NULL;
277
278
279 IF p_source_2 IS NOT NULL
280 THEN
281
282 IF
283 l_ledger_language = 'US' THEN
284 l_description := SUBSTR(CONCAT(l_description,'Credit Memo Application to Transaction Type -'),1,2000);
285 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
286 END IF;
287 l_source := SUBSTR(p_source_1,1,1996);
288 IF l_source IS NOT NULL THEN
289 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
290 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
291 END IF;
292 IF
293 l_ledger_language = 'US' THEN
294 l_description := SUBSTR(CONCAT(l_description,' Transaction Number'),1,2000);
295 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
296 END IF;
297 l_source := SUBSTR(p_source_2,1,1996);
298 IF l_source IS NOT NULL THEN
299 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
300 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
301 END IF;
302 IF
303 l_ledger_language = 'US' THEN
304 l_description := SUBSTR(CONCAT(l_description,' Transaction Document Number'),1,2000);
305 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
306 END IF;
307 l_source := SUBSTR(TO_CHAR(p_source_3),1,1996);
308 IF l_source IS NOT NULL THEN
309 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
313 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
310 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
311 END IF;
312 l_description := SUBSTR(l_description,1,1996);
314 trace
315 (p_msg => 'END of Description_1'
316 ,p_level => C_LEVEL_PROCEDURE
317 ,p_module => l_log_module);
318
319 END IF;
320 RETURN l_description;
321
322 END IF;
323 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
324 trace
325 (p_msg => 'END of Description_1'
326 ,p_level => C_LEVEL_PROCEDURE
327 ,p_module => l_log_module);
328 END IF;
329 RETURN NULL;
330 EXCEPTION
331 WHEN VALUE_ERROR THEN
332 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
333 trace
334 (p_msg => 'ERROR: '||sqlerrm
335 ,p_level => C_LEVEL_EXCEPTION
336 ,p_module => l_log_module);
337 END IF;
338 RAISE;
339 WHEN xla_exceptions_pkg.application_exception THEN
340 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
341 trace
342 (p_msg => 'ERROR: '||sqlerrm
343 ,p_level => C_LEVEL_EXCEPTION
344 ,p_module => l_log_module);
345 END IF;
346 RAISE;
347 WHEN OTHERS THEN
348 xla_exceptions_pkg.raise_message
349 (p_location => 'XLA_00222_AAD_S_000005_PKG.Description_1');
350 END Description_1;
351
352 ---------------------------------------
353 --
354 -- PRIVATE FUNCTION
355 -- Description_2
356 --
357 ---------------------------------------
358 FUNCTION Description_2 (
359 p_application_id IN NUMBER
360 , p_ae_header_id IN NUMBER DEFAULT NULL
361 --Transaction Type Name
362 , p_source_1 IN VARCHAR2
363 --Transaction Number
364 , p_source_2 IN VARCHAR2
365 --Transaction Document Sequence Number
366 , p_source_3 IN NUMBER
367 )
368 RETURN VARCHAR2
369 IS
370 l_component_type VARCHAR2(80) ;
371 l_component_code VARCHAR2(30) ;
372 l_component_type_code VARCHAR2(1) ;
373 l_component_appl_id INTEGER ;
374 l_amb_context_code VARCHAR2(30) ;
375 l_ledger_language VARCHAR2(30) ;
376 l_source VARCHAR2(1996) ;
377 l_description VARCHAR2(2000) ;
378 l_log_module VARCHAR2(240) ;
379 BEGIN
380 IF g_log_enabled THEN
381 l_log_module := C_DEFAULT_MODULE||'.Description_2';
382 END IF;
383 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
384 trace
385 (p_msg => 'BEGIN of Description_2'
386 ,p_level => C_LEVEL_PROCEDURE
387 ,p_module => l_log_module);
388 END IF;
389
390 l_ledger_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
391 l_component_type := 'AMB_DESCRIPTION';
392 l_component_code := 'RCT_L';
393 l_component_type_code := 'S';
394 l_component_appl_id := 222;
395 l_amb_context_code := 'DEFAULT';
396 l_source := NULL;
397 l_description := NULL;
398
399
400 IF p_source_2 IS NOT NULL
401 THEN
402
403 IF
404 l_ledger_language = 'US' THEN
405 l_description := SUBSTR(CONCAT(l_description,'Receipt Application to Transaction Type -'),1,2000);
406 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
407 END IF;
408 l_source := SUBSTR(p_source_1,1,1996);
409 IF l_source IS NOT NULL THEN
410 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
411 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
412 END IF;
413 IF
414 l_ledger_language = 'US' THEN
415 l_description := SUBSTR(CONCAT(l_description,' Transaction Number'),1,2000);
416 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
417 END IF;
418 l_source := SUBSTR(p_source_2,1,1996);
419 IF l_source IS NOT NULL THEN
420 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
421 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
422 END IF;
423 IF
424 l_ledger_language = 'US' THEN
425 l_description := SUBSTR(CONCAT(l_description,' Transaction Document Number'),1,2000);
426 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
427 END IF;
428 l_source := SUBSTR(TO_CHAR(p_source_3),1,1996);
429 IF l_source IS NOT NULL THEN
430 l_description := SUBSTR(CONCAT(l_description,l_source),1,2000);
431 l_description := SUBSTR(CONCAT(l_description,' '),1,2000);
432 END IF;
433 l_description := SUBSTR(l_description,1,1996);
434 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
435 trace
436 (p_msg => 'END of Description_2'
437 ,p_level => C_LEVEL_PROCEDURE
438 ,p_module => l_log_module);
439
440 END IF;
441 RETURN l_description;
442
443 END IF;
444 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
445 trace
446 (p_msg => 'END of Description_2'
447 ,p_level => C_LEVEL_PROCEDURE
448 ,p_module => l_log_module);
449 END IF;
450 RETURN NULL;
451 EXCEPTION
452 WHEN VALUE_ERROR THEN
453 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
454 trace
455 (p_msg => 'ERROR: '||sqlerrm
456 ,p_level => C_LEVEL_EXCEPTION
457 ,p_module => l_log_module);
461 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
458 END IF;
459 RAISE;
460 WHEN xla_exceptions_pkg.application_exception THEN
462 trace
463 (p_msg => 'ERROR: '||sqlerrm
464 ,p_level => C_LEVEL_EXCEPTION
465 ,p_module => l_log_module);
466 END IF;
467 RAISE;
468 WHEN OTHERS THEN
469 xla_exceptions_pkg.raise_message
470 (p_location => 'XLA_00222_AAD_S_000005_PKG.Description_2');
471 END Description_2;
472
473 ---------------------------------------
474 --
475 -- PRIVATE FUNCTION
476 -- AcctDerRule_3
477 --
478 ---------------------------------------
479 FUNCTION AcctDerRule_3 (
480 p_application_id IN NUMBER
481 , p_ae_header_id IN NUMBER
482 , p_side IN VARCHAR2
483 --Credit Memo Distribution GL Account
484 , p_source_4 IN NUMBER
485 , x_transaction_coa_id OUT NOCOPY NUMBER
486 , x_accounting_coa_id OUT NOCOPY NUMBER
487 , x_value_type_code OUT NOCOPY VARCHAR2
488 )
489 RETURN NUMBER
490 IS
491 l_component_type VARCHAR2(80) ;
492 l_component_code VARCHAR2(30) ;
493 l_component_type_code VARCHAR2(1) ;
494 l_component_appl_id INTEGER ;
495 l_amb_context_code VARCHAR2(30) ;
496 l_log_module VARCHAR2(240) ;
497 l_output_value NUMBER ;
498 BEGIN
499 IF g_log_enabled THEN
500 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_3';
501 END IF;
502 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
503 trace
504 (p_msg => 'BEGIN of AcctDerRule_3'
505 ,p_level => C_LEVEL_PROCEDURE
506 ,p_module => l_log_module);
507 END IF;
508 --
509 l_component_type := 'AMB_ADR';
510 l_component_code := 'CM_DIST_CCID';
511 l_component_type_code := 'S';
512 l_component_appl_id := 222;
513 l_amb_context_code := 'DEFAULT';
514 x_transaction_coa_id := null;
515 x_accounting_coa_id := null;
516 --
517
518 --
519 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
520 trace
521 (p_msg => 'END of AcctDerRule_3'
522 ,p_level => C_LEVEL_PROCEDURE
523 ,p_module => l_log_module);
524 END IF;
525 x_value_type_code := 'S';
526 l_output_value := TO_NUMBER(TO_NUMBER(p_source_4));
527 RETURN l_output_value;
528
529 --
530 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
531 trace
532 (p_msg => 'END of AcctDerRule_3(invalid)'
533 ,p_level => C_LEVEL_PROCEDURE
534 ,p_module => l_log_module);
535 END IF;
536 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
537 x_value_type_code := null;
538 l_output_value := null;
539 xla_accounting_err_pkg.build_message
540 (p_appli_s_name => 'XLA'
541 ,p_msg_name => 'XLA_AP_INVALID_ADR'
542 ,p_token_1 => 'COMPONENT_NAME'
543 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
544 l_component_type
545 , l_component_code
546 , l_component_type_code
547 , l_component_appl_id
548 , l_amb_context_code
549 )
550 ,p_token_2 => 'OWNER'
551 ,p_value_2 => xla_lookups_pkg.get_meaning(
552 'XLA_OWNER_TYPE'
553 ,l_component_type_code
554 )
555 ,p_token_3 => 'PAD_NAME'
556 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
557 ,p_token_4 => 'PAD_OWNER'
558 ,p_value_4 => xla_lookups_pkg.get_meaning(
559 'XLA_OWNER_TYPE'
560 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
561 )
562 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
563 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
564 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
565 ,p_ae_header_id => NULL
566 );
567 RETURN l_output_value;
568 EXCEPTION
569 WHEN xla_exceptions_pkg.application_exception THEN
570 RAISE;
571 WHEN OTHERS THEN
572 xla_exceptions_pkg.raise_message
573 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_3');
574 END AcctDerRule_3;
575 --
576
577 ---------------------------------------
578 --
579 -- PRIVATE FUNCTION
580 -- AcctDerRule_4
581 --
582 ---------------------------------------
583 FUNCTION AcctDerRule_4 (
584 p_application_id IN NUMBER
585 , p_ae_header_id IN NUMBER
586 , p_side IN VARCHAR2
587 --Distribution GL Account
588 , p_source_5 IN NUMBER
589 , x_transaction_coa_id OUT NOCOPY NUMBER
590 , x_accounting_coa_id OUT NOCOPY NUMBER
591 , x_value_type_code OUT NOCOPY VARCHAR2
592 )
593 RETURN NUMBER
594 IS
595 l_component_type VARCHAR2(80) ;
596 l_component_code VARCHAR2(30) ;
597 l_component_type_code VARCHAR2(1) ;
598 l_component_appl_id INTEGER ;
599 l_amb_context_code VARCHAR2(30) ;
600 l_log_module VARCHAR2(240) ;
601 l_output_value NUMBER ;
602 BEGIN
603 IF g_log_enabled THEN
604 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_4';
605 END IF;
606 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
607 trace
608 (p_msg => 'BEGIN of AcctDerRule_4'
609 ,p_level => C_LEVEL_PROCEDURE
610 ,p_module => l_log_module);
611 END IF;
612 --
613 l_component_type := 'AMB_ADR';
614 l_component_code := 'DIST_CCID';
615 l_component_type_code := 'S';
616 l_component_appl_id := 222;
617 l_amb_context_code := 'DEFAULT';
618 x_transaction_coa_id := null;
619 x_accounting_coa_id := null;
620 --
621
622 --
623 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
624 trace
625 (p_msg => 'END of AcctDerRule_4'
626 ,p_level => C_LEVEL_PROCEDURE
627 ,p_module => l_log_module);
628 END IF;
629 x_value_type_code := 'S';
630 l_output_value := TO_NUMBER(TO_NUMBER(p_source_5));
631 RETURN l_output_value;
632
633 --
634 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
635 trace
636 (p_msg => 'END of AcctDerRule_4(invalid)'
637 ,p_level => C_LEVEL_PROCEDURE
638 ,p_module => l_log_module);
639 END IF;
640 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
641 x_value_type_code := null;
642 l_output_value := null;
643 xla_accounting_err_pkg.build_message
644 (p_appli_s_name => 'XLA'
645 ,p_msg_name => 'XLA_AP_INVALID_ADR'
646 ,p_token_1 => 'COMPONENT_NAME'
647 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
648 l_component_type
649 , l_component_code
650 , l_component_type_code
651 , l_component_appl_id
652 , l_amb_context_code
653 )
654 ,p_token_2 => 'OWNER'
655 ,p_value_2 => xla_lookups_pkg.get_meaning(
656 'XLA_OWNER_TYPE'
657 ,l_component_type_code
658 )
659 ,p_token_3 => 'PAD_NAME'
660 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
661 ,p_token_4 => 'PAD_OWNER'
662 ,p_value_4 => xla_lookups_pkg.get_meaning(
663 'XLA_OWNER_TYPE'
664 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
665 )
666 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
667 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
668 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
669 ,p_ae_header_id => NULL
670 );
671 RETURN l_output_value;
672 EXCEPTION
673 WHEN xla_exceptions_pkg.application_exception THEN
674 RAISE;
675 WHEN OTHERS THEN
676 xla_exceptions_pkg.raise_message
677 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_4');
678 END AcctDerRule_4;
679 --
680
681 ---------------------------------------
682 --
683 -- PRIVATE FUNCTION
684 -- AcctDerRule_5
685 --
686 ---------------------------------------
687 FUNCTION AcctDerRule_5 (
688 p_application_id IN NUMBER
689 , p_ae_header_id IN NUMBER
690 , p_side IN VARCHAR2
691 --Distribution Gain Loss Account
692 , p_source_6 IN NUMBER
693 --System Gain Account
694 , p_source_7 IN NUMBER
695 , x_transaction_coa_id OUT NOCOPY NUMBER
696 , x_accounting_coa_id OUT NOCOPY NUMBER
697 , x_value_type_code OUT NOCOPY VARCHAR2
698 )
699 RETURN NUMBER
700 IS
701 l_component_type VARCHAR2(80) ;
702 l_component_code VARCHAR2(30) ;
703 l_component_type_code VARCHAR2(1) ;
704 l_component_appl_id INTEGER ;
705 l_amb_context_code VARCHAR2(30) ;
706 l_log_module VARCHAR2(240) ;
707 l_output_value NUMBER ;
708 BEGIN
709 IF g_log_enabled THEN
710 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_5';
711 END IF;
712 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
713 trace
714 (p_msg => 'BEGIN of AcctDerRule_5'
715 ,p_level => C_LEVEL_PROCEDURE
716 ,p_module => l_log_module);
717 END IF;
718 --
719 l_component_type := 'AMB_ADR';
720 l_component_code := 'DIST_GAIN_GL_ACCOUNT';
721 l_component_type_code := 'S';
722 l_component_appl_id := 222;
723 l_amb_context_code := 'DEFAULT';
724 x_transaction_coa_id := null;
725 x_accounting_coa_id := null;
726 --
727
728 IF TO_NUMBER(p_source_6) IS NOT NULL
729 THEN
730 --
731 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
732 trace
733 (p_msg => 'END of AcctDerRule_5'
734 ,p_level => C_LEVEL_PROCEDURE
735 ,p_module => l_log_module);
736 END IF;
737 x_value_type_code := 'S';
738 l_output_value := TO_NUMBER(TO_NUMBER(p_source_6));
739 RETURN l_output_value;
740
741 END IF;
742
743 --
744 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
745 trace
746 (p_msg => 'END of AcctDerRule_5'
747 ,p_level => C_LEVEL_PROCEDURE
748 ,p_module => l_log_module);
749 END IF;
750 x_value_type_code := 'S';
751 l_output_value := TO_NUMBER(TO_NUMBER(p_source_7));
752 RETURN l_output_value;
753
754 --
755 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
756 trace
757 (p_msg => 'END of AcctDerRule_5(invalid)'
758 ,p_level => C_LEVEL_PROCEDURE
759 ,p_module => l_log_module);
760 END IF;
761 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
762 x_value_type_code := null;
763 l_output_value := null;
764 xla_accounting_err_pkg.build_message
765 (p_appli_s_name => 'XLA'
766 ,p_msg_name => 'XLA_AP_INVALID_ADR'
767 ,p_token_1 => 'COMPONENT_NAME'
768 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
769 l_component_type
770 , l_component_code
771 , l_component_type_code
772 , l_component_appl_id
773 , l_amb_context_code
774 )
775 ,p_token_2 => 'OWNER'
776 ,p_value_2 => xla_lookups_pkg.get_meaning(
777 'XLA_OWNER_TYPE'
778 ,l_component_type_code
779 )
780 ,p_token_3 => 'PAD_NAME'
781 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
782 ,p_token_4 => 'PAD_OWNER'
783 ,p_value_4 => xla_lookups_pkg.get_meaning(
784 'XLA_OWNER_TYPE'
788 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
785 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
786 )
787 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
789 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
790 ,p_ae_header_id => NULL
791 );
792 RETURN l_output_value;
793 EXCEPTION
794 WHEN xla_exceptions_pkg.application_exception THEN
795 RAISE;
796 WHEN OTHERS THEN
797 xla_exceptions_pkg.raise_message
798 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_5');
799 END AcctDerRule_5;
800 --
801
802 ---------------------------------------
803 --
804 -- PRIVATE FUNCTION
805 -- AcctDerRule_6
806 --
807 ---------------------------------------
808 FUNCTION AcctDerRule_6 (
809 p_application_id IN NUMBER
810 , p_ae_header_id IN NUMBER
811 , p_side IN VARCHAR2
812 --Distribution Gain Loss Account
813 , p_source_6 IN NUMBER
814 --System Loss Account
815 , p_source_8 IN NUMBER
816 , x_transaction_coa_id OUT NOCOPY NUMBER
817 , x_accounting_coa_id OUT NOCOPY NUMBER
818 , x_value_type_code OUT NOCOPY VARCHAR2
819 )
820 RETURN NUMBER
821 IS
822 l_component_type VARCHAR2(80) ;
823 l_component_code VARCHAR2(30) ;
824 l_component_type_code VARCHAR2(1) ;
825 l_component_appl_id INTEGER ;
826 l_amb_context_code VARCHAR2(30) ;
827 l_log_module VARCHAR2(240) ;
828 l_output_value NUMBER ;
829 BEGIN
830 IF g_log_enabled THEN
831 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_6';
832 END IF;
833 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
834 trace
835 (p_msg => 'BEGIN of AcctDerRule_6'
836 ,p_level => C_LEVEL_PROCEDURE
837 ,p_module => l_log_module);
838 END IF;
839 --
840 l_component_type := 'AMB_ADR';
841 l_component_code := 'DIST_LOSS_GL_ACCOUNT';
842 l_component_type_code := 'S';
843 l_component_appl_id := 222;
844 l_amb_context_code := 'DEFAULT';
845 x_transaction_coa_id := null;
846 x_accounting_coa_id := null;
847 --
848
849 IF TO_NUMBER(p_source_6) IS NOT NULL
850 THEN
851 --
852 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
853 trace
854 (p_msg => 'END of AcctDerRule_6'
855 ,p_level => C_LEVEL_PROCEDURE
856 ,p_module => l_log_module);
857 END IF;
858 x_value_type_code := 'S';
859 l_output_value := TO_NUMBER(TO_NUMBER(p_source_6));
860 RETURN l_output_value;
861
862 END IF;
863
864 --
865 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
866 trace
867 (p_msg => 'END of AcctDerRule_6'
868 ,p_level => C_LEVEL_PROCEDURE
869 ,p_module => l_log_module);
870 END IF;
871 x_value_type_code := 'S';
872 l_output_value := TO_NUMBER(TO_NUMBER(p_source_8));
873 RETURN l_output_value;
874
875 --
876 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
877 trace
878 (p_msg => 'END of AcctDerRule_6(invalid)'
879 ,p_level => C_LEVEL_PROCEDURE
880 ,p_module => l_log_module);
881 END IF;
882 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
883 x_value_type_code := null;
884 l_output_value := null;
885 xla_accounting_err_pkg.build_message
886 (p_appli_s_name => 'XLA'
887 ,p_msg_name => 'XLA_AP_INVALID_ADR'
888 ,p_token_1 => 'COMPONENT_NAME'
889 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
890 l_component_type
891 , l_component_code
892 , l_component_type_code
893 , l_component_appl_id
894 , l_amb_context_code
895 )
896 ,p_token_2 => 'OWNER'
897 ,p_value_2 => xla_lookups_pkg.get_meaning(
898 'XLA_OWNER_TYPE'
899 ,l_component_type_code
900 )
901 ,p_token_3 => 'PAD_NAME'
902 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
903 ,p_token_4 => 'PAD_OWNER'
904 ,p_value_4 => xla_lookups_pkg.get_meaning(
905 'XLA_OWNER_TYPE'
906 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
907 )
908 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
909 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
910 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
911 ,p_ae_header_id => NULL
912 );
913 RETURN l_output_value;
914 EXCEPTION
915 WHEN xla_exceptions_pkg.application_exception THEN
916 RAISE;
917 WHEN OTHERS THEN
918 xla_exceptions_pkg.raise_message
919 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_6');
920 END AcctDerRule_6;
921 --
922
923 ---------------------------------------
924 --
925 -- PRIVATE FUNCTION
926 -- AcctDerRule_7
927 --
928 ---------------------------------------
929 FUNCTION AcctDerRule_7 (
930 p_application_id IN NUMBER
931 , p_ae_header_id IN NUMBER
932 , p_side IN VARCHAR2
933 , p_override_seg_flag IN VARCHAR2
934 --Federal Fund Category
935 , p_source_9 IN VARCHAR2
936 , x_transaction_coa_id OUT NOCOPY NUMBER
937 , x_accounting_coa_id OUT NOCOPY NUMBER
938 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
939 , x_flex_value_set_id OUT NOCOPY NUMBER
940 , x_value_type_code OUT NOCOPY VARCHAR2
941 , x_value_combination_id OUT NOCOPY NUMBER
942 , x_value_segment_code OUT NOCOPY VARCHAR2
943 )
944 RETURN VARCHAR2
945 IS
946 l_component_type VARCHAR2(80) ;
947 l_component_code VARCHAR2(30) ;
948 l_component_type_code VARCHAR2(1) ;
949 l_component_appl_id INTEGER ;
950 l_amb_context_code VARCHAR2(30) ;
951 l_log_module VARCHAR2(240) ;
952 l_output_value VARCHAR2(30) ;
953 BEGIN
954 IF g_log_enabled THEN
955 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_7';
956 END IF;
957 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
958
959 trace
960 (p_msg => 'BEGIN of AcctDerRule_7'
961 ,p_level => C_LEVEL_PROCEDURE
962 ,p_module => l_log_module);
963
964 END IF;
965
966 l_component_type := 'AMB_ADR';
967 l_component_code := 'FV_AR_422101_MISC_RCT_CR';
968 l_component_type_code := 'S';
969 l_component_appl_id := 222;
970 l_amb_context_code := 'DEFAULT';
971 x_transaction_coa_id := null;
972 x_accounting_coa_id := null;
973 x_flexfield_segment_code := null;
974 x_flex_value_set_id := 1009988 ;
975
976
977 IF NVL(p_source_9,'
978 ') = 'Reimbursable'
979 THEN
980 --
981 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
982
983 trace
984 (p_msg => 'END of AcctDerRule_7'
985 ,p_level => C_LEVEL_PROCEDURE
986 ,p_module => l_log_module);
987
988 END IF;
989 x_value_combination_id := null ;
990 x_value_segment_code := null ;
991 x_value_type_code := 'C';
992 l_output_value := '422101';
993 RETURN l_output_value;
994
995 ELSE
996 IF p_override_seg_flag = 'Y' THEN
997 RETURN '#$NO_OVERRIDE#$';
998 END IF;
999 END IF;
1000
1001 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1002
1003 trace
1004 (p_msg => 'END of AcctDerRule_7(invalid)'
1005 ,p_level => C_LEVEL_PROCEDURE
1006 ,p_module => l_log_module);
1007
1008 END IF;
1009
1010 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1011 x_value_combination_id := null;
1012 x_value_segment_code := null;
1013 x_value_type_code := null;
1014 l_output_value := null;
1015 xla_accounting_err_pkg.build_message
1016 (p_appli_s_name => 'XLA'
1017 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1018 ,p_token_1 => 'COMPONENT_NAME'
1019 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1020 l_component_type
1021 , l_component_code
1022 , l_component_type_code
1023 , l_component_appl_id
1024 , l_amb_context_code
1025 )
1026 ,p_token_2 => 'OWNER'
1027 ,p_value_2 => xla_lookups_pkg.get_meaning(
1028 'XLA_OWNER_TYPE'
1029 ,l_component_type_code
1030 )
1031 ,p_token_3 => 'PAD_NAME'
1032 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1033 ,p_token_4 => 'PAD_OWNER'
1034 ,p_value_4 => xla_lookups_pkg.get_meaning(
1035 'XLA_OWNER_TYPE'
1036 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1037 )
1038 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1039 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1040 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1041 ,p_ae_header_id => NULL
1042 );
1043 RETURN l_output_value;
1044 EXCEPTION
1045 WHEN xla_exceptions_pkg.application_exception THEN
1046 RAISE;
1047 WHEN OTHERS THEN
1048 xla_exceptions_pkg.raise_message
1049 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_7');
1050 END AcctDerRule_7;
1051 --
1052
1053 ---------------------------------------
1054 --
1055 -- PRIVATE FUNCTION
1056 -- AcctDerRule_8
1057 --
1058 ---------------------------------------
1059 FUNCTION AcctDerRule_8 (
1060 p_application_id IN NUMBER
1061 , p_ae_header_id IN NUMBER
1062 , p_side IN VARCHAR2
1063 , p_override_seg_flag IN VARCHAR2
1064 --Federal Fund Category
1065 , p_source_9 IN VARCHAR2
1066 --Bill To Customer Classification
1067 , p_source_10 IN VARCHAR2
1068 , x_transaction_coa_id OUT NOCOPY NUMBER
1069 , x_accounting_coa_id OUT NOCOPY NUMBER
1070 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1071 , x_flex_value_set_id OUT NOCOPY NUMBER
1072 , x_value_type_code OUT NOCOPY VARCHAR2
1073 , x_value_combination_id OUT NOCOPY NUMBER
1074 , x_value_segment_code OUT NOCOPY VARCHAR2
1075 )
1076 RETURN VARCHAR2
1077 IS
1078 l_component_type VARCHAR2(80) ;
1079 l_component_code VARCHAR2(30) ;
1080 l_component_type_code VARCHAR2(1) ;
1081 l_component_appl_id INTEGER ;
1082 l_amb_context_code VARCHAR2(30) ;
1083 l_log_module VARCHAR2(240) ;
1084 l_output_value VARCHAR2(30) ;
1085 BEGIN
1086 IF g_log_enabled THEN
1087 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_8';
1088 END IF;
1089 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1090
1091 trace
1092 (p_msg => 'BEGIN of AcctDerRule_8'
1093 ,p_level => C_LEVEL_PROCEDURE
1094 ,p_module => l_log_module);
1095
1096 END IF;
1097
1098 l_component_type := 'AMB_ADR';
1099 l_component_code := 'FV_AR_422X0X_INV_REIM_CR';
1100 l_component_type_code := 'S';
1101 l_component_appl_id := 222;
1102 l_amb_context_code := 'DEFAULT';
1103 x_transaction_coa_id := null;
1104 x_accounting_coa_id := null;
1105 x_flexfield_segment_code := null;
1106 x_flex_value_set_id := 1009988 ;
1107
1108
1109 IF NVL(p_source_10,'
1110 ') = 'FEDERAL' AND
1111 NVL(p_source_9,'
1112 ') = 'Reimbursable'
1113 THEN
1114 --
1115 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1116
1117 trace
1118 (p_msg => 'END of AcctDerRule_8'
1119 ,p_level => C_LEVEL_PROCEDURE
1120 ,p_module => l_log_module);
1121
1122 END IF;
1123 x_value_combination_id := null ;
1124 x_value_segment_code := null ;
1125 x_value_type_code := 'C';
1126 l_output_value := '422101';
1127 RETURN l_output_value;
1128
1129 ELSIF NVL(p_source_10,'
1130 ') <> 'FEDERAL' AND
1131 NVL(p_source_9,'
1132 ') = 'Reimbursable'
1133 THEN
1134 --
1135 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1136
1137 trace
1138 (p_msg => 'END of AcctDerRule_8'
1139 ,p_level => C_LEVEL_PROCEDURE
1140 ,p_module => l_log_module);
1141
1142 END IF;
1143 x_value_combination_id := null ;
1144 x_value_segment_code := null ;
1145 x_value_type_code := 'C';
1146 l_output_value := '422202';
1147 RETURN l_output_value;
1148
1149 ELSE
1150 IF p_override_seg_flag = 'Y' THEN
1151 RETURN '#$NO_OVERRIDE#$';
1152 END IF;
1153 END IF;
1154
1155 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1156
1157 trace
1158 (p_msg => 'END of AcctDerRule_8(invalid)'
1159 ,p_level => C_LEVEL_PROCEDURE
1160 ,p_module => l_log_module);
1161
1162 END IF;
1163
1164 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1165 x_value_combination_id := null;
1166 x_value_segment_code := null;
1167 x_value_type_code := null;
1168 l_output_value := null;
1169 xla_accounting_err_pkg.build_message
1170 (p_appli_s_name => 'XLA'
1171 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1172 ,p_token_1 => 'COMPONENT_NAME'
1173 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1174 l_component_type
1175 , l_component_code
1176 , l_component_type_code
1177 , l_component_appl_id
1178 , l_amb_context_code
1179 )
1180 ,p_token_2 => 'OWNER'
1181 ,p_value_2 => xla_lookups_pkg.get_meaning(
1182 'XLA_OWNER_TYPE'
1183 ,l_component_type_code
1184 )
1185 ,p_token_3 => 'PAD_NAME'
1186 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1187 ,p_token_4 => 'PAD_OWNER'
1188 ,p_value_4 => xla_lookups_pkg.get_meaning(
1189 'XLA_OWNER_TYPE'
1190 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1191 )
1192 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1193 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1194 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1195 ,p_ae_header_id => NULL
1196 );
1197 RETURN l_output_value;
1198 EXCEPTION
1199 WHEN xla_exceptions_pkg.application_exception THEN
1200 RAISE;
1201 WHEN OTHERS THEN
1202 xla_exceptions_pkg.raise_message
1203 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_8');
1204 END AcctDerRule_8;
1205 --
1206
1207 ---------------------------------------
1208 --
1209 -- PRIVATE FUNCTION
1210 -- AcctDerRule_9
1211 --
1212 ---------------------------------------
1213 FUNCTION AcctDerRule_9 (
1214 p_application_id IN NUMBER
1215 , p_ae_header_id IN NUMBER
1216 , p_side IN VARCHAR2
1217 , p_override_seg_flag IN VARCHAR2
1218 --Federal Account Rule
1219 , p_source_11 IN VARCHAR2
1220 , x_transaction_coa_id OUT NOCOPY NUMBER
1221 , x_accounting_coa_id OUT NOCOPY NUMBER
1222 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1223 , x_flex_value_set_id OUT NOCOPY NUMBER
1224 , x_value_type_code OUT NOCOPY VARCHAR2
1225 , x_value_combination_id OUT NOCOPY NUMBER
1226 , x_value_segment_code OUT NOCOPY VARCHAR2
1227 )
1228 RETURN VARCHAR2
1229 IS
1230 l_component_type VARCHAR2(80) ;
1231 l_component_code VARCHAR2(30) ;
1232 l_component_type_code VARCHAR2(1) ;
1233 l_component_appl_id INTEGER ;
1234 l_amb_context_code VARCHAR2(30) ;
1235 l_log_module VARCHAR2(240) ;
1236 l_output_value VARCHAR2(30) ;
1237 BEGIN
1238 IF g_log_enabled THEN
1239 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_9';
1240 END IF;
1241 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1242
1243 trace
1244 (p_msg => 'BEGIN of AcctDerRule_9'
1245 ,p_level => C_LEVEL_PROCEDURE
1246 ,p_module => l_log_module);
1247
1248 END IF;
1249
1250 l_component_type := 'AMB_ADR';
1251 l_component_code := 'FV_AR_425101_RCT_CR';
1252 l_component_type_code := 'S';
1253 l_component_appl_id := 222;
1254 l_amb_context_code := 'DEFAULT';
1255 x_transaction_coa_id := null;
1256 x_accounting_coa_id := null;
1257 x_flexfield_segment_code := null;
1258 x_flex_value_set_id := 1009988 ;
1259
1260
1261 IF NVL(p_source_11,'
1262 ') = 'Order No Advance'
1263 THEN
1264 --
1265 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1266
1267 trace
1268 (p_msg => 'END of AcctDerRule_9'
1269 ,p_level => C_LEVEL_PROCEDURE
1270 ,p_module => l_log_module);
1271
1272 END IF;
1273 x_value_combination_id := null ;
1274 x_value_segment_code := null ;
1275 x_value_type_code := 'C';
1276 l_output_value := '425101';
1277 RETURN l_output_value;
1278
1279 ELSE
1280 IF p_override_seg_flag = 'Y' THEN
1281 RETURN '#$NO_OVERRIDE#$';
1282 END IF;
1283 END IF;
1284
1285 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1286
1287 trace
1288 (p_msg => 'END of AcctDerRule_9(invalid)'
1289 ,p_level => C_LEVEL_PROCEDURE
1290 ,p_module => l_log_module);
1291
1292 END IF;
1293
1294 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1295 x_value_combination_id := null;
1296 x_value_segment_code := null;
1297 x_value_type_code := null;
1298 l_output_value := null;
1299 xla_accounting_err_pkg.build_message
1300 (p_appli_s_name => 'XLA'
1301 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1302 ,p_token_1 => 'COMPONENT_NAME'
1303 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1304 l_component_type
1305 , l_component_code
1306 , l_component_type_code
1307 , l_component_appl_id
1308 , l_amb_context_code
1309 )
1310 ,p_token_2 => 'OWNER'
1311 ,p_value_2 => xla_lookups_pkg.get_meaning(
1312 'XLA_OWNER_TYPE'
1313 ,l_component_type_code
1314 )
1315 ,p_token_3 => 'PAD_NAME'
1316 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1317 ,p_token_4 => 'PAD_OWNER'
1318 ,p_value_4 => xla_lookups_pkg.get_meaning(
1319 'XLA_OWNER_TYPE'
1320 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1321 )
1322 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1323 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1324 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1325 ,p_ae_header_id => NULL
1326 );
1327 RETURN l_output_value;
1328 EXCEPTION
1329 WHEN xla_exceptions_pkg.application_exception THEN
1330 RAISE;
1331 WHEN OTHERS THEN
1332 xla_exceptions_pkg.raise_message
1333 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_9');
1334 END AcctDerRule_9;
1335 --
1336
1337 ---------------------------------------
1338 --
1339 -- PRIVATE FUNCTION
1340 -- AcctDerRule_10
1341 --
1342 ---------------------------------------
1343 FUNCTION AcctDerRule_10 (
1344 p_application_id IN NUMBER
1345 , p_ae_header_id IN NUMBER
1346 , p_side IN VARCHAR2
1347 , p_override_seg_flag IN VARCHAR2
1348 --Federal Fund Category
1349 , p_source_9 IN VARCHAR2
1350 , x_transaction_coa_id OUT NOCOPY NUMBER
1351 , x_accounting_coa_id OUT NOCOPY NUMBER
1352 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1353 , x_flex_value_set_id OUT NOCOPY NUMBER
1354 , x_value_type_code OUT NOCOPY VARCHAR2
1355 , x_value_combination_id OUT NOCOPY NUMBER
1356 , x_value_segment_code OUT NOCOPY VARCHAR2
1357 )
1358 RETURN VARCHAR2
1359 IS
1360 l_component_type VARCHAR2(80) ;
1361 l_component_code VARCHAR2(30) ;
1362 l_component_type_code VARCHAR2(1) ;
1363 l_component_appl_id INTEGER ;
1364 l_amb_context_code VARCHAR2(30) ;
1365 l_log_module VARCHAR2(240) ;
1366 l_output_value VARCHAR2(30) ;
1367 BEGIN
1368 IF g_log_enabled THEN
1369 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_10';
1370 END IF;
1371 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1372
1373 trace
1374 (p_msg => 'BEGIN of AcctDerRule_10'
1375 ,p_level => C_LEVEL_PROCEDURE
1376 ,p_module => l_log_module);
1377
1378 END IF;
1379
1380 l_component_type := 'AMB_ADR';
1381 l_component_code := 'FV_AR_425201_MISC_RCT_DR';
1382 l_component_type_code := 'S';
1383 l_component_appl_id := 222;
1384 l_amb_context_code := 'DEFAULT';
1385 x_transaction_coa_id := null;
1386 x_accounting_coa_id := null;
1387 x_flexfield_segment_code := null;
1388 x_flex_value_set_id := 1009988 ;
1389
1390
1391 IF NVL(p_source_9,'
1392 ') = 'Reimbursable'
1393 THEN
1394 --
1395 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1396
1397 trace
1398 (p_msg => 'END of AcctDerRule_10'
1399 ,p_level => C_LEVEL_PROCEDURE
1400 ,p_module => l_log_module);
1401
1402 END IF;
1403 x_value_combination_id := null ;
1404 x_value_segment_code := null ;
1405 x_value_type_code := 'C';
1406 l_output_value := '425201';
1407 RETURN l_output_value;
1408
1409 ELSE
1410 IF p_override_seg_flag = 'Y' THEN
1411 RETURN '#$NO_OVERRIDE#$';
1412 END IF;
1413 END IF;
1414
1415 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1416
1417 trace
1418 (p_msg => 'END of AcctDerRule_10(invalid)'
1419 ,p_level => C_LEVEL_PROCEDURE
1420 ,p_module => l_log_module);
1421
1422 END IF;
1423
1424 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1425 x_value_combination_id := null;
1426 x_value_segment_code := null;
1427 x_value_type_code := null;
1428 l_output_value := null;
1429 xla_accounting_err_pkg.build_message
1430 (p_appli_s_name => 'XLA'
1431 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1435 , l_component_code
1432 ,p_token_1 => 'COMPONENT_NAME'
1433 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1434 l_component_type
1436 , l_component_type_code
1437 , l_component_appl_id
1438 , l_amb_context_code
1439 )
1440 ,p_token_2 => 'OWNER'
1441 ,p_value_2 => xla_lookups_pkg.get_meaning(
1442 'XLA_OWNER_TYPE'
1443 ,l_component_type_code
1444 )
1445 ,p_token_3 => 'PAD_NAME'
1446 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1447 ,p_token_4 => 'PAD_OWNER'
1448 ,p_value_4 => xla_lookups_pkg.get_meaning(
1449 'XLA_OWNER_TYPE'
1450 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1451 )
1452 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1453 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1454 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1455 ,p_ae_header_id => NULL
1456 );
1457 RETURN l_output_value;
1458 EXCEPTION
1459 WHEN xla_exceptions_pkg.application_exception THEN
1460 RAISE;
1461 WHEN OTHERS THEN
1462 xla_exceptions_pkg.raise_message
1463 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_10');
1464 END AcctDerRule_10;
1465 --
1466
1467 ---------------------------------------
1468 --
1469 -- PRIVATE FUNCTION
1470 -- AcctDerRule_11
1471 --
1472 ---------------------------------------
1473 FUNCTION AcctDerRule_11 (
1474 p_application_id IN NUMBER
1475 , p_ae_header_id IN NUMBER
1476 , p_side IN VARCHAR2
1477 , p_override_seg_flag IN VARCHAR2
1478 --Federal Account Rule
1479 , p_source_11 IN VARCHAR2
1480 , x_transaction_coa_id OUT NOCOPY NUMBER
1481 , x_accounting_coa_id OUT NOCOPY NUMBER
1482 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1483 , x_flex_value_set_id OUT NOCOPY NUMBER
1484 , x_value_type_code OUT NOCOPY VARCHAR2
1485 , x_value_combination_id OUT NOCOPY NUMBER
1486 , x_value_segment_code OUT NOCOPY VARCHAR2
1487 )
1488 RETURN VARCHAR2
1489 IS
1490 l_component_type VARCHAR2(80) ;
1491 l_component_code VARCHAR2(30) ;
1492 l_component_type_code VARCHAR2(1) ;
1493 l_component_appl_id INTEGER ;
1494 l_amb_context_code VARCHAR2(30) ;
1495 l_log_module VARCHAR2(240) ;
1496 l_output_value VARCHAR2(30) ;
1497 BEGIN
1498 IF g_log_enabled THEN
1499 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_11';
1500 END IF;
1501 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1502
1503 trace
1504 (p_msg => 'BEGIN of AcctDerRule_11'
1505 ,p_level => C_LEVEL_PROCEDURE
1506 ,p_module => l_log_module);
1507
1508 END IF;
1509
1510 l_component_type := 'AMB_ADR';
1511 l_component_code := 'FV_AR_425201_RCT_DR';
1512 l_component_type_code := 'S';
1513 l_component_appl_id := 222;
1514 l_amb_context_code := 'DEFAULT';
1515 x_transaction_coa_id := null;
1516 x_accounting_coa_id := null;
1517 x_flexfield_segment_code := null;
1518 x_flex_value_set_id := 1009988 ;
1519
1520
1521 IF NVL(p_source_11,'
1522 ') = 'Order No Advance'
1523 THEN
1524 --
1525 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1526
1527 trace
1528 (p_msg => 'END of AcctDerRule_11'
1529 ,p_level => C_LEVEL_PROCEDURE
1530 ,p_module => l_log_module);
1531
1532 END IF;
1533 x_value_combination_id := null ;
1534 x_value_segment_code := null ;
1535 x_value_type_code := 'C';
1536 l_output_value := '425201';
1537 RETURN l_output_value;
1538
1539 ELSE
1540 IF p_override_seg_flag = 'Y' THEN
1541 RETURN '#$NO_OVERRIDE#$';
1542 END IF;
1543 END IF;
1544
1545 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1546
1547 trace
1548 (p_msg => 'END of AcctDerRule_11(invalid)'
1549 ,p_level => C_LEVEL_PROCEDURE
1550 ,p_module => l_log_module);
1551
1552 END IF;
1553
1554 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1555 x_value_combination_id := null;
1556 x_value_segment_code := null;
1557 x_value_type_code := null;
1558 l_output_value := null;
1559 xla_accounting_err_pkg.build_message
1560 (p_appli_s_name => 'XLA'
1561 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1562 ,p_token_1 => 'COMPONENT_NAME'
1563 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1564 l_component_type
1565 , l_component_code
1566 , l_component_type_code
1567 , l_component_appl_id
1568 , l_amb_context_code
1569 )
1570 ,p_token_2 => 'OWNER'
1571 ,p_value_2 => xla_lookups_pkg.get_meaning(
1572 'XLA_OWNER_TYPE'
1573 ,l_component_type_code
1574 )
1575 ,p_token_3 => 'PAD_NAME'
1576 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1577 ,p_token_4 => 'PAD_OWNER'
1578 ,p_value_4 => xla_lookups_pkg.get_meaning(
1579 'XLA_OWNER_TYPE'
1580 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1581 )
1582 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1583 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1584 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1585 ,p_ae_header_id => NULL
1586 );
1587 RETURN l_output_value;
1588 EXCEPTION
1589 WHEN xla_exceptions_pkg.application_exception THEN
1590 RAISE;
1591 WHEN OTHERS THEN
1592 xla_exceptions_pkg.raise_message
1593 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_11');
1594 END AcctDerRule_11;
1595 --
1596
1597 ---------------------------------------
1598 --
1599 -- PRIVATE FUNCTION
1600 -- AcctDerRule_12
1601 --
1602 ---------------------------------------
1603 FUNCTION AcctDerRule_12 (
1604 p_application_id IN NUMBER
1605 , p_ae_header_id IN NUMBER
1606 , p_side IN VARCHAR2
1607 , p_override_seg_flag IN VARCHAR2
1608 --Federal Fund Category
1609 , p_source_9 IN VARCHAR2
1610 --Bill To Customer Classification
1611 , p_source_10 IN VARCHAR2
1612 , x_transaction_coa_id OUT NOCOPY NUMBER
1613 , x_accounting_coa_id OUT NOCOPY NUMBER
1614 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1615 , x_flex_value_set_id OUT NOCOPY NUMBER
1616 , x_value_type_code OUT NOCOPY VARCHAR2
1617 , x_value_combination_id OUT NOCOPY NUMBER
1618 , x_value_segment_code OUT NOCOPY VARCHAR2
1619 )
1620 RETURN VARCHAR2
1621 IS
1622 l_component_type VARCHAR2(80) ;
1623 l_component_code VARCHAR2(30) ;
1624 l_component_type_code VARCHAR2(1) ;
1625 l_component_appl_id INTEGER ;
1626 l_amb_context_code VARCHAR2(30) ;
1627 l_log_module VARCHAR2(240) ;
1628 l_output_value VARCHAR2(30) ;
1629 BEGIN
1630 IF g_log_enabled THEN
1631 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_12';
1632 END IF;
1633 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1634
1635 trace
1636 (p_msg => 'BEGIN of AcctDerRule_12'
1637 ,p_level => C_LEVEL_PROCEDURE
1638 ,p_module => l_log_module);
1639
1640 END IF;
1641
1642 l_component_type := 'AMB_ADR';
1643 l_component_code := 'FV_AR_425X0X_INV_REIM_DR';
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 x_flexfield_segment_code := null;
1650 x_flex_value_set_id := 1009988 ;
1651
1652
1653 IF NVL(p_source_10,'
1654 ') = 'FEDERAL' AND
1655 NVL(p_source_9,'
1656 ') = 'Reimbursable'
1657 THEN
1658 --
1659 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1660
1661 trace
1662 (p_msg => 'END of AcctDerRule_12'
1663 ,p_level => C_LEVEL_PROCEDURE
1664 ,p_module => l_log_module);
1665
1666 END IF;
1667 x_value_combination_id := null ;
1668 x_value_segment_code := null ;
1669 x_value_type_code := 'C';
1670 l_output_value := '425101';
1671 RETURN l_output_value;
1672
1673 ELSIF NVL(p_source_10,'
1674 ') <> 'FEDERAL' AND
1675 NVL(p_source_9,'
1676 ') = 'Reimbursable'
1677 THEN
1678 --
1679 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1680
1681 trace
1682 (p_msg => 'END of AcctDerRule_12'
1683 ,p_level => C_LEVEL_PROCEDURE
1684 ,p_module => l_log_module);
1685
1686 END IF;
1687 x_value_combination_id := null ;
1688 x_value_segment_code := null ;
1689 x_value_type_code := 'C';
1690 l_output_value := '425202';
1691 RETURN l_output_value;
1692
1693 ELSE
1694 IF p_override_seg_flag = 'Y' THEN
1695 RETURN '#$NO_OVERRIDE#$';
1696 END IF;
1697 END IF;
1698
1699 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1700
1701 trace
1702 (p_msg => 'END of AcctDerRule_12(invalid)'
1703 ,p_level => C_LEVEL_PROCEDURE
1704 ,p_module => l_log_module);
1705
1706 END IF;
1707
1708 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1709 x_value_combination_id := null;
1710 x_value_segment_code := null;
1711 x_value_type_code := null;
1712 l_output_value := null;
1713 xla_accounting_err_pkg.build_message
1714 (p_appli_s_name => 'XLA'
1715 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1716 ,p_token_1 => 'COMPONENT_NAME'
1717 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1718 l_component_type
1719 , l_component_code
1720 , l_component_type_code
1721 , l_component_appl_id
1722 , l_amb_context_code
1723 )
1724 ,p_token_2 => 'OWNER'
1725 ,p_value_2 => xla_lookups_pkg.get_meaning(
1726 'XLA_OWNER_TYPE'
1727 ,l_component_type_code
1728 )
1729 ,p_token_3 => 'PAD_NAME'
1730 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1731 ,p_token_4 => 'PAD_OWNER'
1732 ,p_value_4 => xla_lookups_pkg.get_meaning(
1733 'XLA_OWNER_TYPE'
1734 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1735 )
1736 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1737 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1738 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1739 ,p_ae_header_id => NULL
1740 );
1741 RETURN l_output_value;
1742 EXCEPTION
1743 WHEN xla_exceptions_pkg.application_exception THEN
1744 RAISE;
1745 WHEN OTHERS THEN
1746 xla_exceptions_pkg.raise_message
1747 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_12');
1748 END AcctDerRule_12;
1749 --
1750
1751 ---------------------------------------
1752 --
1753 -- PRIVATE FUNCTION
1754 -- AcctDerRule_13
1755 --
1756 ---------------------------------------
1757 FUNCTION AcctDerRule_13 (
1758 p_application_id IN NUMBER
1759 , p_ae_header_id IN NUMBER
1760 , p_side IN VARCHAR2
1761 , p_override_seg_flag IN VARCHAR2
1762 --Federal Fund Expired Status
1763 , p_source_12 IN VARCHAR2
1764 --Federal Prior Year Flag
1765 , p_source_13 IN VARCHAR2
1766 --Federal Fund Time Frame
1767 , p_source_14 IN VARCHAR2
1768 , x_transaction_coa_id OUT NOCOPY NUMBER
1769 , x_accounting_coa_id OUT NOCOPY NUMBER
1770 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1771 , x_flex_value_set_id OUT NOCOPY NUMBER
1772 , x_value_type_code OUT NOCOPY VARCHAR2
1773 , x_value_combination_id OUT NOCOPY NUMBER
1774 , x_value_segment_code OUT NOCOPY VARCHAR2
1775 )
1776 RETURN VARCHAR2
1777 IS
1778 l_component_type VARCHAR2(80) ;
1779 l_component_code VARCHAR2(30) ;
1780 l_component_type_code VARCHAR2(1) ;
1781 l_component_appl_id INTEGER ;
1782 l_amb_context_code VARCHAR2(30) ;
1783 l_log_module VARCHAR2(240) ;
1784 l_output_value VARCHAR2(30) ;
1785 BEGIN
1786 IF g_log_enabled THEN
1787 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_13';
1788 END IF;
1789 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1790
1791 trace
1792 (p_msg => 'BEGIN of AcctDerRule_13'
1793 ,p_level => C_LEVEL_PROCEDURE
1794 ,p_module => l_log_module);
1795
1796 END IF;
1797
1798 l_component_type := 'AMB_ADR';
1799 l_component_code := 'FV_AR_445001_MISC_RCT_CR';
1800 l_component_type_code := 'S';
1801 l_component_appl_id := 222;
1802 l_amb_context_code := 'DEFAULT';
1803 x_transaction_coa_id := null;
1804 x_accounting_coa_id := null;
1805 x_flexfield_segment_code := null;
1806 x_flex_value_set_id := 1009988 ;
1807
1808
1809 IF NVL(p_source_12,'
1810 ') = 'Unexpired' AND
1811 NVL(p_source_13,'
1812 ') = 'Y' AND
1813 (NVL(p_source_14,'
1814 ') = 'MULTIPLE' OR
1815 NVL(p_source_14,'
1816 ') = 'NO_YEAR')
1817 THEN
1818 --
1819 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1820
1821 trace
1822 (p_msg => 'END of AcctDerRule_13'
1823 ,p_level => C_LEVEL_PROCEDURE
1824 ,p_module => l_log_module);
1825
1826 END IF;
1827 x_value_combination_id := null ;
1828 x_value_segment_code := null ;
1829 x_value_type_code := 'C';
1830 l_output_value := '445001';
1831 RETURN l_output_value;
1832
1833 ELSE
1834 IF p_override_seg_flag = 'Y' THEN
1835 RETURN '#$NO_OVERRIDE#$';
1836 END IF;
1837 END IF;
1838
1839 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1840
1841 trace
1842 (p_msg => 'END of AcctDerRule_13(invalid)'
1843 ,p_level => C_LEVEL_PROCEDURE
1844 ,p_module => l_log_module);
1845
1846 END IF;
1847
1848 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1849 x_value_combination_id := null;
1850 x_value_segment_code := null;
1851 x_value_type_code := null;
1852 l_output_value := null;
1853 xla_accounting_err_pkg.build_message
1854 (p_appli_s_name => 'XLA'
1855 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1856 ,p_token_1 => 'COMPONENT_NAME'
1857 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1858 l_component_type
1859 , l_component_code
1860 , l_component_type_code
1861 , l_component_appl_id
1862 , l_amb_context_code
1863 )
1867 ,l_component_type_code
1864 ,p_token_2 => 'OWNER'
1865 ,p_value_2 => xla_lookups_pkg.get_meaning(
1866 'XLA_OWNER_TYPE'
1868 )
1869 ,p_token_3 => 'PAD_NAME'
1870 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
1871 ,p_token_4 => 'PAD_OWNER'
1872 ,p_value_4 => xla_lookups_pkg.get_meaning(
1873 'XLA_OWNER_TYPE'
1874 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
1875 )
1876 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
1877 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
1878 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
1879 ,p_ae_header_id => NULL
1880 );
1881 RETURN l_output_value;
1882 EXCEPTION
1883 WHEN xla_exceptions_pkg.application_exception THEN
1884 RAISE;
1885 WHEN OTHERS THEN
1889 --
1886 xla_exceptions_pkg.raise_message
1887 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_13');
1888 END AcctDerRule_13;
1890
1891 ---------------------------------------
1892 --
1893 -- PRIVATE FUNCTION
1894 -- AcctDerRule_14
1895 --
1896 ---------------------------------------
1897 FUNCTION AcctDerRule_14 (
1898 p_application_id IN NUMBER
1899 , p_ae_header_id IN NUMBER
1900 , p_side IN VARCHAR2
1901 , p_override_seg_flag IN VARCHAR2
1902 --Federal Fund Expired Status
1903 , p_source_12 IN VARCHAR2
1904 --Federal Prior Year Flag
1905 , p_source_13 IN VARCHAR2
1906 --Federal Fund Time Frame
1907 , p_source_14 IN VARCHAR2
1908 , x_transaction_coa_id OUT NOCOPY NUMBER
1909 , x_accounting_coa_id OUT NOCOPY NUMBER
1910 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
1911 , x_flex_value_set_id OUT NOCOPY NUMBER
1912 , x_value_type_code OUT NOCOPY VARCHAR2
1913 , x_value_combination_id OUT NOCOPY NUMBER
1914 , x_value_segment_code OUT NOCOPY VARCHAR2
1915 )
1916 RETURN VARCHAR2
1917 IS
1918 l_component_type VARCHAR2(80) ;
1919 l_component_code VARCHAR2(30) ;
1920 l_component_type_code VARCHAR2(1) ;
1921 l_component_appl_id INTEGER ;
1922 l_amb_context_code VARCHAR2(30) ;
1923 l_log_module VARCHAR2(240) ;
1924 l_output_value VARCHAR2(30) ;
1925 BEGIN
1926 IF g_log_enabled THEN
1927 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_14';
1928 END IF;
1929 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1930
1931 trace
1932 (p_msg => 'BEGIN of AcctDerRule_14'
1933 ,p_level => C_LEVEL_PROCEDURE
1934 ,p_module => l_log_module);
1935
1936 END IF;
1937
1938 l_component_type := 'AMB_ADR';
1939 l_component_code := 'FV_AR_445001_RCT_CR';
1940 l_component_type_code := 'S';
1941 l_component_appl_id := 222;
1942 l_amb_context_code := 'DEFAULT';
1943 x_transaction_coa_id := null;
1944 x_accounting_coa_id := null;
1945 x_flexfield_segment_code := null;
1946 x_flex_value_set_id := 1009988 ;
1947
1948
1949 IF NVL(p_source_12,'
1950 ') = 'Unexpired' AND
1951 NVL(p_source_13,'
1952 ') = 'Y' AND
1953 (NVL(p_source_14,'
1954 ') = 'MULTIPLE' OR
1955 NVL(p_source_14,'
1956 ') = 'NO_YEAR')
1957 THEN
1958 --
1959 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1960
1961 trace
1962 (p_msg => 'END of AcctDerRule_14'
1963 ,p_level => C_LEVEL_PROCEDURE
1964 ,p_module => l_log_module);
1965
1966 END IF;
1967 x_value_combination_id := null ;
1968 x_value_segment_code := null ;
1969 x_value_type_code := 'C';
1970 l_output_value := '445001';
1971 RETURN l_output_value;
1972
1973 ELSE
1974 IF p_override_seg_flag = 'Y' THEN
1975 RETURN '#$NO_OVERRIDE#$';
1976 END IF;
1977 END IF;
1978
1979 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1980
1981 trace
1982 (p_msg => 'END of AcctDerRule_14(invalid)'
1983 ,p_level => C_LEVEL_PROCEDURE
1984 ,p_module => l_log_module);
1985
1986 END IF;
1987
1988 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
1989 x_value_combination_id := null;
1990 x_value_segment_code := null;
1991 x_value_type_code := null;
1992 l_output_value := null;
1993 xla_accounting_err_pkg.build_message
1994 (p_appli_s_name => 'XLA'
1995 ,p_msg_name => 'XLA_AP_INVALID_ADR'
1996 ,p_token_1 => 'COMPONENT_NAME'
1997 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
1998 l_component_type
1999 , l_component_code
2000 , l_component_type_code
2001 , l_component_appl_id
2002 , l_amb_context_code
2003 )
2004 ,p_token_2 => 'OWNER'
2005 ,p_value_2 => xla_lookups_pkg.get_meaning(
2006 'XLA_OWNER_TYPE'
2007 ,l_component_type_code
2008 )
2009 ,p_token_3 => 'PAD_NAME'
2010 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2011 ,p_token_4 => 'PAD_OWNER'
2012 ,p_value_4 => xla_lookups_pkg.get_meaning(
2013 'XLA_OWNER_TYPE'
2014 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2015 )
2016 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2017 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2018 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2019 ,p_ae_header_id => NULL
2020 );
2021 RETURN l_output_value;
2022 EXCEPTION
2023 WHEN xla_exceptions_pkg.application_exception THEN
2024 RAISE;
2025 WHEN OTHERS THEN
2026 xla_exceptions_pkg.raise_message
2027 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_14');
2028 END AcctDerRule_14;
2029 --
2030
2031 ---------------------------------------
2032 --
2033 -- PRIVATE FUNCTION
2034 -- AcctDerRule_15
2035 --
2036 ---------------------------------------
2037 FUNCTION AcctDerRule_15 (
2038 p_application_id IN NUMBER
2039 , p_ae_header_id IN NUMBER
2040 , p_side IN VARCHAR2
2041 , p_override_seg_flag IN VARCHAR2
2042 --Federal Fund Expired Status
2043 , p_source_12 IN VARCHAR2
2044 --Federal Prior Year Flag
2045 , p_source_13 IN VARCHAR2
2046 --Federal Fund Time Frame
2047 , p_source_14 IN VARCHAR2
2048 , x_transaction_coa_id OUT NOCOPY NUMBER
2049 , x_accounting_coa_id OUT NOCOPY NUMBER
2053 , x_value_combination_id OUT NOCOPY NUMBER
2050 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2051 , x_flex_value_set_id OUT NOCOPY NUMBER
2052 , x_value_type_code OUT NOCOPY VARCHAR2
2054 , x_value_segment_code OUT NOCOPY VARCHAR2
2055 )
2056 RETURN VARCHAR2
2057 IS
2058 l_component_type VARCHAR2(80) ;
2059 l_component_code VARCHAR2(30) ;
2060 l_component_type_code VARCHAR2(1) ;
2061 l_component_appl_id INTEGER ;
2062 l_amb_context_code VARCHAR2(30) ;
2063 l_log_module VARCHAR2(240) ;
2064 l_output_value VARCHAR2(30) ;
2065 BEGIN
2066 IF g_log_enabled THEN
2067 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_15';
2068 END IF;
2069 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2070
2071 trace
2072 (p_msg => 'BEGIN of AcctDerRule_15'
2073 ,p_level => C_LEVEL_PROCEDURE
2074 ,p_module => l_log_module);
2075
2076 END IF;
2077
2078 l_component_type := 'AMB_ADR';
2079 l_component_code := 'FV_AR_465002_MISC_RCT_CR';
2080 l_component_type_code := 'S';
2081 l_component_appl_id := 222;
2082 l_amb_context_code := 'DEFAULT';
2083 x_transaction_coa_id := null;
2084 x_accounting_coa_id := null;
2085 x_flexfield_segment_code := null;
2086 x_flex_value_set_id := 1009988 ;
2087
2088
2089 IF NVL(p_source_12,'
2090 ') = 'Expired' AND
2091 NVL(p_source_13,'
2092 ') = 'Y' AND
2093 (NVL(p_source_14,'
2094 ') = 'SINGLE' OR
2095 NVL(p_source_14,'
2096 ') = 'MULTIPLE' OR
2097 NVL(p_source_14,'
2098 ') = 'NO_YEAR')
2099 THEN
2100 --
2101 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2102
2103 trace
2104 (p_msg => 'END of AcctDerRule_15'
2105 ,p_level => C_LEVEL_PROCEDURE
2106 ,p_module => l_log_module);
2107
2108 END IF;
2109 x_value_combination_id := null ;
2110 x_value_segment_code := null ;
2111 x_value_type_code := 'C';
2112 l_output_value := '465002';
2113 RETURN l_output_value;
2114
2115 ELSE
2116 IF p_override_seg_flag = 'Y' THEN
2117 RETURN '#$NO_OVERRIDE#$';
2118 END IF;
2119 END IF;
2120
2121 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2122
2123 trace
2124 (p_msg => 'END of AcctDerRule_15(invalid)'
2125 ,p_level => C_LEVEL_PROCEDURE
2126 ,p_module => l_log_module);
2127
2128 END IF;
2129
2130 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2131 x_value_combination_id := null;
2132 x_value_segment_code := null;
2133 x_value_type_code := null;
2134 l_output_value := null;
2135 xla_accounting_err_pkg.build_message
2136 (p_appli_s_name => 'XLA'
2137 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2138 ,p_token_1 => 'COMPONENT_NAME'
2139 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2140 l_component_type
2141 , l_component_code
2142 , l_component_type_code
2143 , l_component_appl_id
2144 , l_amb_context_code
2145 )
2146 ,p_token_2 => 'OWNER'
2147 ,p_value_2 => xla_lookups_pkg.get_meaning(
2148 'XLA_OWNER_TYPE'
2149 ,l_component_type_code
2150 )
2151 ,p_token_3 => 'PAD_NAME'
2152 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2153 ,p_token_4 => 'PAD_OWNER'
2154 ,p_value_4 => xla_lookups_pkg.get_meaning(
2155 'XLA_OWNER_TYPE'
2156 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2157 )
2158 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2159 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2160 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2161 ,p_ae_header_id => NULL
2162 );
2163 RETURN l_output_value;
2164 EXCEPTION
2165 WHEN xla_exceptions_pkg.application_exception THEN
2166 RAISE;
2167 WHEN OTHERS THEN
2168 xla_exceptions_pkg.raise_message
2169 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_15');
2170 END AcctDerRule_15;
2171 --
2172
2173 ---------------------------------------
2174 --
2175 -- PRIVATE FUNCTION
2176 -- AcctDerRule_16
2177 --
2178 ---------------------------------------
2179 FUNCTION AcctDerRule_16 (
2183 , p_override_seg_flag IN VARCHAR2
2180 p_application_id IN NUMBER
2181 , p_ae_header_id IN NUMBER
2182 , p_side IN VARCHAR2
2184 --Federal Fund Expired Status
2185 , p_source_12 IN VARCHAR2
2186 --Federal Prior Year Flag
2187 , p_source_13 IN VARCHAR2
2188 --Federal Fund Time Frame
2189 , p_source_14 IN VARCHAR2
2190 , x_transaction_coa_id OUT NOCOPY NUMBER
2191 , x_accounting_coa_id OUT NOCOPY NUMBER
2192 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2193 , x_flex_value_set_id OUT NOCOPY NUMBER
2194 , x_value_type_code OUT NOCOPY VARCHAR2
2195 , x_value_combination_id OUT NOCOPY NUMBER
2196 , x_value_segment_code OUT NOCOPY VARCHAR2
2197 )
2198 RETURN VARCHAR2
2199 IS
2200 l_component_type VARCHAR2(80) ;
2201 l_component_code VARCHAR2(30) ;
2202 l_component_type_code VARCHAR2(1) ;
2203 l_component_appl_id INTEGER ;
2204 l_amb_context_code VARCHAR2(30) ;
2205 l_log_module VARCHAR2(240) ;
2206 l_output_value VARCHAR2(30) ;
2207 BEGIN
2208 IF g_log_enabled THEN
2209 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_16';
2210 END IF;
2211 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2212
2213 trace
2214 (p_msg => 'BEGIN of AcctDerRule_16'
2215 ,p_level => C_LEVEL_PROCEDURE
2216 ,p_module => l_log_module);
2217
2218 END IF;
2219
2220 l_component_type := 'AMB_ADR';
2221 l_component_code := 'FV_AR_465002_RCT_CR';
2222 l_component_type_code := 'S';
2223 l_component_appl_id := 222;
2224 l_amb_context_code := 'DEFAULT';
2225 x_transaction_coa_id := null;
2226 x_accounting_coa_id := null;
2227 x_flexfield_segment_code := null;
2228 x_flex_value_set_id := 1009988 ;
2229
2230
2231 IF NVL(p_source_12,'
2232 ') = 'Expired' AND
2233 NVL(p_source_13,'
2234 ') = 'Y' AND
2235 (NVL(p_source_14,'
2236 ') = 'SINGLE' OR
2237 NVL(p_source_14,'
2238 ') = 'MULTIPLE' OR
2239 NVL(p_source_14,'
2240 ') = 'NO_YEAR')
2241 THEN
2242 --
2243 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2244
2245 trace
2246 (p_msg => 'END of AcctDerRule_16'
2247 ,p_level => C_LEVEL_PROCEDURE
2248 ,p_module => l_log_module);
2249
2250 END IF;
2251 x_value_combination_id := null ;
2252 x_value_segment_code := null ;
2253 x_value_type_code := 'C';
2254 l_output_value := '465002';
2255 RETURN l_output_value;
2256
2257 ELSE
2258 IF p_override_seg_flag = 'Y' THEN
2259 RETURN '#$NO_OVERRIDE#$';
2260 END IF;
2261 END IF;
2262
2263 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2264
2265 trace
2266 (p_msg => 'END of AcctDerRule_16(invalid)'
2267 ,p_level => C_LEVEL_PROCEDURE
2268 ,p_module => l_log_module);
2269
2270 END IF;
2271
2272 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2273 x_value_combination_id := null;
2274 x_value_segment_code := null;
2275 x_value_type_code := null;
2276 l_output_value := null;
2277 xla_accounting_err_pkg.build_message
2278 (p_appli_s_name => 'XLA'
2279 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2280 ,p_token_1 => 'COMPONENT_NAME'
2281 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2282 l_component_type
2283 , l_component_code
2284 , l_component_type_code
2285 , l_component_appl_id
2286 , l_amb_context_code
2287 )
2288 ,p_token_2 => 'OWNER'
2289 ,p_value_2 => xla_lookups_pkg.get_meaning(
2290 'XLA_OWNER_TYPE'
2291 ,l_component_type_code
2292 )
2293 ,p_token_3 => 'PAD_NAME'
2294 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2295 ,p_token_4 => 'PAD_OWNER'
2296 ,p_value_4 => xla_lookups_pkg.get_meaning(
2297 'XLA_OWNER_TYPE'
2298 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2299 )
2300 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2301 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2302 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2303 ,p_ae_header_id => NULL
2304 );
2305 RETURN l_output_value;
2306 EXCEPTION
2307 WHEN xla_exceptions_pkg.application_exception THEN
2308 RAISE;
2309 WHEN OTHERS THEN
2310 xla_exceptions_pkg.raise_message
2311 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_16');
2312 END AcctDerRule_16;
2313 --
2317 -- PRIVATE FUNCTION
2314
2315 ---------------------------------------
2316 --
2318 -- AcctDerRule_17
2319 --
2320 ---------------------------------------
2321 FUNCTION AcctDerRule_17 (
2322 p_application_id IN NUMBER
2323 , p_ae_header_id IN NUMBER
2324 , p_side IN VARCHAR2
2325 , p_override_seg_flag IN VARCHAR2
2326 --Federal Fund Expired Status
2327 , p_source_12 IN VARCHAR2
2328 --Federal Prior Year Flag
2329 , p_source_13 IN VARCHAR2
2330 --Federal Fund Time Frame
2331 , p_source_14 IN VARCHAR2
2332 --Federal Apportionment Category
2333 , p_source_15 IN VARCHAR2
2334 , x_transaction_coa_id OUT NOCOPY NUMBER
2335 , x_accounting_coa_id OUT NOCOPY NUMBER
2336 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2337 , x_flex_value_set_id OUT NOCOPY NUMBER
2338 , x_value_type_code OUT NOCOPY VARCHAR2
2339 , x_value_combination_id OUT NOCOPY NUMBER
2340 , x_value_segment_code OUT NOCOPY VARCHAR2
2341 )
2342 RETURN VARCHAR2
2343 IS
2344 l_component_type VARCHAR2(80) ;
2345 l_component_code VARCHAR2(30) ;
2346 l_component_type_code VARCHAR2(1) ;
2347 l_component_appl_id INTEGER ;
2348 l_amb_context_code VARCHAR2(30) ;
2349 l_log_module VARCHAR2(240) ;
2350 l_output_value VARCHAR2(30) ;
2351 BEGIN
2352 IF g_log_enabled THEN
2353 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_17';
2354 END IF;
2355 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2356
2357 trace
2358 (p_msg => 'BEGIN of AcctDerRule_17'
2359 ,p_level => C_LEVEL_PROCEDURE
2360 ,p_module => l_log_module);
2361
2362 END IF;
2363
2364 l_component_type := 'AMB_ADR';
2365 l_component_code := 'FV_AR_46X002_MISC_RCT_CR';
2366 l_component_type_code := 'S';
2367 l_component_appl_id := 222;
2368 l_amb_context_code := 'DEFAULT';
2369 x_transaction_coa_id := null;
2370 x_accounting_coa_id := null;
2371 x_flexfield_segment_code := null;
2372 x_flex_value_set_id := 1009988 ;
2373
2374
2375 IF NVL(p_source_12,'
2376 ') = 'Unexpired' AND
2377 NVL(p_source_13,'
2378 ') = 'N' AND
2379 (NVL(p_source_15,'
2380 ') = 'A' OR
2381 NVL(p_source_15,'
2382 ') = 'B') AND
2383 (NVL(p_source_14,'
2384 ') = 'SINGLE' OR
2385 NVL(p_source_14,'
2386 ') = 'MULTIPLE' OR
2387 NVL(p_source_14,'
2388 ') = 'NO_YEAR')
2389 THEN
2390 --
2391 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2392
2393 trace
2394 (p_msg => 'END of AcctDerRule_17'
2395 ,p_level => C_LEVEL_PROCEDURE
2396 ,p_module => l_log_module);
2397
2398 END IF;
2399 x_value_combination_id := null ;
2400 x_value_segment_code := null ;
2401 x_value_type_code := 'C';
2402 l_output_value := '461002';
2403 RETURN l_output_value;
2404
2405 ELSIF NVL(p_source_12,'
2406 ') = 'Unexpired' AND
2407 NVL(p_source_13,'
2408 ') = 'N' AND
2409 NVL(p_source_15,'
2410 ') = 'C' AND
2411 (NVL(p_source_14,'
2412 ') = 'SINGLE' OR
2413 NVL(p_source_14,'
2414 ') = 'MULTIPLE' OR
2415 NVL(p_source_14,'
2416 ') = 'NO_YEAR')
2417 THEN
2418 --
2419 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2420
2421 trace
2422 (p_msg => 'END of AcctDerRule_17'
2423 ,p_level => C_LEVEL_PROCEDURE
2424 ,p_module => l_log_module);
2425
2426 END IF;
2427 x_value_combination_id := null ;
2428 x_value_segment_code := null ;
2429 x_value_type_code := 'C';
2430 l_output_value := '462002';
2431 RETURN l_output_value;
2432
2433 ELSE
2434 IF p_override_seg_flag = 'Y' THEN
2435 RETURN '#$NO_OVERRIDE#$';
2436 END IF;
2437 END IF;
2438
2439 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2440
2441 trace
2442 (p_msg => 'END of AcctDerRule_17(invalid)'
2443 ,p_level => C_LEVEL_PROCEDURE
2444 ,p_module => l_log_module);
2445
2446 END IF;
2447
2448 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2449 x_value_combination_id := null;
2450 x_value_segment_code := null;
2451 x_value_type_code := null;
2452 l_output_value := null;
2453 xla_accounting_err_pkg.build_message
2454 (p_appli_s_name => 'XLA'
2455 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2456 ,p_token_1 => 'COMPONENT_NAME'
2457 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2458 l_component_type
2459 , l_component_code
2460 , l_component_type_code
2461 , l_component_appl_id
2462 , l_amb_context_code
2463 )
2464 ,p_token_2 => 'OWNER'
2465 ,p_value_2 => xla_lookups_pkg.get_meaning(
2466 'XLA_OWNER_TYPE'
2470 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2467 ,l_component_type_code
2468 )
2469 ,p_token_3 => 'PAD_NAME'
2471 ,p_token_4 => 'PAD_OWNER'
2472 ,p_value_4 => xla_lookups_pkg.get_meaning(
2473 'XLA_OWNER_TYPE'
2474 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2475 )
2476 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2477 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2478 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2479 ,p_ae_header_id => NULL
2480 );
2481 RETURN l_output_value;
2482 EXCEPTION
2483 WHEN xla_exceptions_pkg.application_exception THEN
2484 RAISE;
2485 WHEN OTHERS THEN
2486 xla_exceptions_pkg.raise_message
2487 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_17');
2488 END AcctDerRule_17;
2489 --
2490
2491 ---------------------------------------
2492 --
2493 -- PRIVATE FUNCTION
2494 -- AcctDerRule_18
2495 --
2496 ---------------------------------------
2497 FUNCTION AcctDerRule_18 (
2498 p_application_id IN NUMBER
2499 , p_ae_header_id IN NUMBER
2500 , p_side IN VARCHAR2
2501 , p_override_seg_flag IN VARCHAR2
2502 --Federal Fund Expired Status
2503 , p_source_12 IN VARCHAR2
2504 --Federal Prior Year Flag
2505 , p_source_13 IN VARCHAR2
2506 --Federal Fund Time Frame
2507 , p_source_14 IN VARCHAR2
2508 --Federal Apportionment Category
2509 , p_source_15 IN VARCHAR2
2510 , x_transaction_coa_id OUT NOCOPY NUMBER
2511 , x_accounting_coa_id OUT NOCOPY NUMBER
2512 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2513 , x_flex_value_set_id OUT NOCOPY NUMBER
2514 , x_value_type_code OUT NOCOPY VARCHAR2
2515 , x_value_combination_id OUT NOCOPY NUMBER
2516 , x_value_segment_code OUT NOCOPY VARCHAR2
2517 )
2518 RETURN VARCHAR2
2519 IS
2520 l_component_type VARCHAR2(80) ;
2521 l_component_code VARCHAR2(30) ;
2522 l_component_type_code VARCHAR2(1) ;
2523 l_component_appl_id INTEGER ;
2524 l_amb_context_code VARCHAR2(30) ;
2525 l_log_module VARCHAR2(240) ;
2526 l_output_value VARCHAR2(30) ;
2527 BEGIN
2528 IF g_log_enabled THEN
2529 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_18';
2530 END IF;
2531 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2532
2533 trace
2534 (p_msg => 'BEGIN of AcctDerRule_18'
2535 ,p_level => C_LEVEL_PROCEDURE
2536 ,p_module => l_log_module);
2537
2538 END IF;
2539
2540 l_component_type := 'AMB_ADR';
2541 l_component_code := 'FV_AR_46X002_RCT_CR';
2542 l_component_type_code := 'S';
2543 l_component_appl_id := 222;
2544 l_amb_context_code := 'DEFAULT';
2545 x_transaction_coa_id := null;
2546 x_accounting_coa_id := null;
2547 x_flexfield_segment_code := null;
2548 x_flex_value_set_id := 1009988 ;
2549
2550
2551 IF NVL(p_source_12,'
2552 ') = 'Unexpired' AND
2553 NVL(p_source_13,'
2554 ') = 'N' AND
2555 (NVL(p_source_15,'
2556 ') = 'A' OR
2557 NVL(p_source_15,'
2558 ') = 'B') AND
2559 (NVL(p_source_14,'
2560 ') = 'SINGLE' OR
2561 NVL(p_source_14,'
2562 ') = 'MULTIPLE' OR
2563 NVL(p_source_14,'
2564 ') = 'NO_YEAR')
2565 THEN
2566 --
2567 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2568
2569 trace
2570 (p_msg => 'END of AcctDerRule_18'
2571 ,p_level => C_LEVEL_PROCEDURE
2572 ,p_module => l_log_module);
2573
2574 END IF;
2575 x_value_combination_id := null ;
2576 x_value_segment_code := null ;
2577 x_value_type_code := 'C';
2578 l_output_value := '461002';
2579 RETURN l_output_value;
2580
2581 ELSIF NVL(p_source_12,'
2582 ') = 'Unexpired' AND
2583 NVL(p_source_13,'
2584 ') = 'N' AND
2585 NVL(p_source_15,'
2586 ') = 'C' AND
2587 (NVL(p_source_14,'
2588 ') = 'SINGLE' OR
2589 NVL(p_source_14,'
2590 ') = 'MULTIPLE' OR
2591 NVL(p_source_14,'
2592 ') = 'NO_YEAR')
2593 THEN
2594 --
2595 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2596
2597 trace
2598 (p_msg => 'END of AcctDerRule_18'
2599 ,p_level => C_LEVEL_PROCEDURE
2600 ,p_module => l_log_module);
2601
2602 END IF;
2603 x_value_combination_id := null ;
2604 x_value_segment_code := null ;
2605 x_value_type_code := 'C';
2606 l_output_value := '462002';
2607 RETURN l_output_value;
2608
2609 ELSE
2610 IF p_override_seg_flag = 'Y' THEN
2611 RETURN '#$NO_OVERRIDE#$';
2612 END IF;
2613 END IF;
2614
2615 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2616
2617 trace
2618 (p_msg => 'END of AcctDerRule_18(invalid)'
2622 END IF;
2619 ,p_level => C_LEVEL_PROCEDURE
2620 ,p_module => l_log_module);
2621
2623
2624 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2625 x_value_combination_id := null;
2626 x_value_segment_code := null;
2627 x_value_type_code := null;
2628 l_output_value := null;
2629 xla_accounting_err_pkg.build_message
2630 (p_appli_s_name => 'XLA'
2631 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2632 ,p_token_1 => 'COMPONENT_NAME'
2633 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2634 l_component_type
2635 , l_component_code
2636 , l_component_type_code
2637 , l_component_appl_id
2638 , l_amb_context_code
2639 )
2640 ,p_token_2 => 'OWNER'
2641 ,p_value_2 => xla_lookups_pkg.get_meaning(
2642 'XLA_OWNER_TYPE'
2643 ,l_component_type_code
2644 )
2645 ,p_token_3 => 'PAD_NAME'
2646 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2647 ,p_token_4 => 'PAD_OWNER'
2648 ,p_value_4 => xla_lookups_pkg.get_meaning(
2649 'XLA_OWNER_TYPE'
2650 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2651 )
2652 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2653 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2654 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2655 ,p_ae_header_id => NULL
2656 );
2657 RETURN l_output_value;
2658 EXCEPTION
2659 WHEN xla_exceptions_pkg.application_exception THEN
2660 RAISE;
2661 WHEN OTHERS THEN
2662 xla_exceptions_pkg.raise_message
2663 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_18');
2664 END AcctDerRule_18;
2665 --
2666
2667 ---------------------------------------
2668 --
2669 -- PRIVATE FUNCTION
2670 -- AcctDerRule_19
2671 --
2672 ---------------------------------------
2673 FUNCTION AcctDerRule_19 (
2674 p_application_id IN NUMBER
2675 , p_ae_header_id IN NUMBER
2676 , p_side IN VARCHAR2
2677 , p_override_seg_flag IN VARCHAR2
2678 --Federal Fund Expired Status
2679 , p_source_12 IN VARCHAR2
2680 --Federal Prior Year Flag
2681 , p_source_13 IN VARCHAR2
2682 --Federal Fund Time Frame
2683 , p_source_14 IN VARCHAR2
2684 --Federal Apportionment Category
2685 , p_source_15 IN VARCHAR2
2686 , x_transaction_coa_id OUT NOCOPY NUMBER
2687 , x_accounting_coa_id OUT NOCOPY NUMBER
2688 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2689 , x_flex_value_set_id OUT NOCOPY NUMBER
2690 , x_value_type_code OUT NOCOPY VARCHAR2
2691 , x_value_combination_id OUT NOCOPY NUMBER
2692 , x_value_segment_code OUT NOCOPY VARCHAR2
2693 )
2694 RETURN VARCHAR2
2695 IS
2696 l_component_type VARCHAR2(80) ;
2697 l_component_code VARCHAR2(30) ;
2698 l_component_type_code VARCHAR2(1) ;
2699 l_component_appl_id INTEGER ;
2700 l_amb_context_code VARCHAR2(30) ;
2701 l_log_module VARCHAR2(240) ;
2702 l_output_value VARCHAR2(30) ;
2703 BEGIN
2704 IF g_log_enabled THEN
2705 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_19';
2706 END IF;
2707 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2708
2709 trace
2710 (p_msg => 'BEGIN of AcctDerRule_19'
2711 ,p_level => C_LEVEL_PROCEDURE
2712 ,p_module => l_log_module);
2713
2714 END IF;
2715
2716 l_component_type := 'AMB_ADR';
2717 l_component_code := 'FV_AR_490201_MISC_RCT_DR';
2718 l_component_type_code := 'S';
2719 l_component_appl_id := 222;
2720 l_amb_context_code := 'DEFAULT';
2721 x_transaction_coa_id := null;
2722 x_accounting_coa_id := null;
2723 x_flexfield_segment_code := null;
2724 x_flex_value_set_id := 1009988 ;
2725
2726
2727 IF NVL(p_source_12,'
2728 ') = 'Unexpired' AND
2729 NVL(p_source_13,'
2730 ') = 'N' AND
2731 (NVL(p_source_15,'
2732 ') = 'A' OR
2733 NVL(p_source_15,'
2734 ') = 'B' OR
2735 NVL(p_source_15,'
2736 ') = 'C') AND
2737 (NVL(p_source_14,'
2738 ') = 'SINGLE' OR
2739 NVL(p_source_14,'
2740 ') = 'MULTIPLE' OR
2741 NVL(p_source_14,'
2742 ') = 'NO_YEAR')
2743 THEN
2744 --
2745 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2746
2747 trace
2748 (p_msg => 'END of AcctDerRule_19'
2749 ,p_level => C_LEVEL_PROCEDURE
2753 x_value_combination_id := null ;
2750 ,p_module => l_log_module);
2751
2752 END IF;
2754 x_value_segment_code := null ;
2755 x_value_type_code := 'C';
2756 l_output_value := '490201';
2757 RETURN l_output_value;
2758
2759 ELSE
2760 IF p_override_seg_flag = 'Y' THEN
2761 RETURN '#$NO_OVERRIDE#$';
2762 END IF;
2763 END IF;
2764
2765 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2766
2767 trace
2768 (p_msg => 'END of AcctDerRule_19(invalid)'
2769 ,p_level => C_LEVEL_PROCEDURE
2770 ,p_module => l_log_module);
2771
2772 END IF;
2773
2774 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2775 x_value_combination_id := null;
2776 x_value_segment_code := null;
2777 x_value_type_code := null;
2778 l_output_value := null;
2779 xla_accounting_err_pkg.build_message
2780 (p_appli_s_name => 'XLA'
2781 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2782 ,p_token_1 => 'COMPONENT_NAME'
2783 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2784 l_component_type
2785 , l_component_code
2786 , l_component_type_code
2787 , l_component_appl_id
2788 , l_amb_context_code
2789 )
2790 ,p_token_2 => 'OWNER'
2791 ,p_value_2 => xla_lookups_pkg.get_meaning(
2792 'XLA_OWNER_TYPE'
2793 ,l_component_type_code
2794 )
2795 ,p_token_3 => 'PAD_NAME'
2796 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2797 ,p_token_4 => 'PAD_OWNER'
2798 ,p_value_4 => xla_lookups_pkg.get_meaning(
2799 'XLA_OWNER_TYPE'
2800 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2801 )
2802 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2803 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2804 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2805 ,p_ae_header_id => NULL
2806 );
2807 RETURN l_output_value;
2808 EXCEPTION
2809 WHEN xla_exceptions_pkg.application_exception THEN
2810 RAISE;
2811 WHEN OTHERS THEN
2812 xla_exceptions_pkg.raise_message
2813 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_19');
2814 END AcctDerRule_19;
2815 --
2816
2817 ---------------------------------------
2818 --
2819 -- PRIVATE FUNCTION
2820 -- AcctDerRule_20
2821 --
2822 ---------------------------------------
2823 FUNCTION AcctDerRule_20 (
2824 p_application_id IN NUMBER
2825 , p_ae_header_id IN NUMBER
2826 , p_side IN VARCHAR2
2827 , p_override_seg_flag IN VARCHAR2
2828 --Federal Fund Expired Status
2829 , p_source_12 IN VARCHAR2
2830 --Federal Prior Year Flag
2831 , p_source_13 IN VARCHAR2
2832 --Federal Fund Time Frame
2833 , p_source_14 IN VARCHAR2
2834 , x_transaction_coa_id OUT NOCOPY NUMBER
2835 , x_accounting_coa_id OUT NOCOPY NUMBER
2836 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2837 , x_flex_value_set_id OUT NOCOPY NUMBER
2838 , x_value_type_code OUT NOCOPY VARCHAR2
2839 , x_value_combination_id OUT NOCOPY NUMBER
2840 , x_value_segment_code OUT NOCOPY VARCHAR2
2841 )
2842 RETURN VARCHAR2
2843 IS
2844 l_component_type VARCHAR2(80) ;
2845 l_component_code VARCHAR2(30) ;
2846 l_component_type_code VARCHAR2(1) ;
2847 l_component_appl_id INTEGER ;
2848 l_amb_context_code VARCHAR2(30) ;
2849 l_log_module VARCHAR2(240) ;
2850 l_output_value VARCHAR2(30) ;
2851 BEGIN
2852 IF g_log_enabled THEN
2853 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_20';
2854 END IF;
2855 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2856
2857 trace
2858 (p_msg => 'BEGIN of AcctDerRule_20'
2859 ,p_level => C_LEVEL_PROCEDURE
2860 ,p_module => l_log_module);
2861
2862 END IF;
2863
2864 l_component_type := 'AMB_ADR';
2865 l_component_code := 'FV_AR_497201_MISC_RCT_DR';
2866 l_component_type_code := 'S';
2867 l_component_appl_id := 222;
2868 l_amb_context_code := 'DEFAULT';
2869 x_transaction_coa_id := null;
2870 x_accounting_coa_id := null;
2871 x_flexfield_segment_code := null;
2872 x_flex_value_set_id := 1009988 ;
2873
2874
2875 IF ((NVL(p_source_12,'
2876 ') = 'Expired' AND
2877 NVL(p_source_13,'
2878 ') = 'Y' AND
2882 ') = 'MULTIPLE' OR
2879 (NVL(p_source_14,'
2880 ') = 'SINGLE' OR
2881 NVL(p_source_14,'
2883 NVL(p_source_14,'
2884 ') = 'NO_YEAR')
2885 ) OR (NVL(p_source_12,'
2886 ') = 'Unexpired' AND
2887 NVL(p_source_13,'
2888 ') = 'Y' AND
2889 (NVL(p_source_14,'
2890 ') = 'MULTIPLE' OR
2891 NVL(p_source_14,'
2892 ') = 'NO_YEAR')
2893 )) THEN
2894 --
2895 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2896
2897 trace
2898 (p_msg => 'END of AcctDerRule_20'
2899 ,p_level => C_LEVEL_PROCEDURE
2900 ,p_module => l_log_module);
2901
2902 END IF;
2903 x_value_combination_id := null ;
2904 x_value_segment_code := null ;
2905 x_value_type_code := 'C';
2906 l_output_value := '497201';
2907 RETURN l_output_value;
2908
2909 ELSE
2910 IF p_override_seg_flag = 'Y' THEN
2911 RETURN '#$NO_OVERRIDE#$';
2912 END IF;
2913 END IF;
2914
2915 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2916
2917 trace
2918 (p_msg => 'END of AcctDerRule_20(invalid)'
2919 ,p_level => C_LEVEL_PROCEDURE
2920 ,p_module => l_log_module);
2921
2922 END IF;
2923
2924 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
2925 x_value_combination_id := null;
2926 x_value_segment_code := null;
2927 x_value_type_code := null;
2928 l_output_value := null;
2929 xla_accounting_err_pkg.build_message
2930 (p_appli_s_name => 'XLA'
2931 ,p_msg_name => 'XLA_AP_INVALID_ADR'
2932 ,p_token_1 => 'COMPONENT_NAME'
2933 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
2934 l_component_type
2935 , l_component_code
2936 , l_component_type_code
2937 , l_component_appl_id
2938 , l_amb_context_code
2939 )
2940 ,p_token_2 => 'OWNER'
2941 ,p_value_2 => xla_lookups_pkg.get_meaning(
2942 'XLA_OWNER_TYPE'
2943 ,l_component_type_code
2944 )
2945 ,p_token_3 => 'PAD_NAME'
2946 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
2947 ,p_token_4 => 'PAD_OWNER'
2948 ,p_value_4 => xla_lookups_pkg.get_meaning(
2949 'XLA_OWNER_TYPE'
2950 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
2951 )
2952 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
2953 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
2954 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
2955 ,p_ae_header_id => NULL
2956 );
2957 RETURN l_output_value;
2958 EXCEPTION
2959 WHEN xla_exceptions_pkg.application_exception THEN
2960 RAISE;
2961 WHEN OTHERS THEN
2962 xla_exceptions_pkg.raise_message
2963 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_20');
2964 END AcctDerRule_20;
2965 --
2966
2967 ---------------------------------------
2968 --
2969 -- PRIVATE FUNCTION
2970 -- AcctDerRule_21
2971 --
2972 ---------------------------------------
2973 FUNCTION AcctDerRule_21 (
2974 p_application_id IN NUMBER
2975 , p_ae_header_id IN NUMBER
2976 , p_side IN VARCHAR2
2977 , p_override_seg_flag IN VARCHAR2
2978 --Federal Account Rule
2979 , p_source_11 IN VARCHAR2
2980 --Federal Fund Expired Status
2981 , p_source_12 IN VARCHAR2
2982 --Federal Prior Year Flag
2983 , p_source_13 IN VARCHAR2
2984 --Federal Fund Time Frame
2985 , p_source_14 IN VARCHAR2
2986 --Federal Apportionment Category
2987 , p_source_15 IN VARCHAR2
2988 , x_transaction_coa_id OUT NOCOPY NUMBER
2989 , x_accounting_coa_id OUT NOCOPY NUMBER
2990 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
2991 , x_flex_value_set_id OUT NOCOPY NUMBER
2992 , x_value_type_code OUT NOCOPY VARCHAR2
2993 , x_value_combination_id OUT NOCOPY NUMBER
2994 , x_value_segment_code OUT NOCOPY VARCHAR2
2995 )
2996 RETURN VARCHAR2
2997 IS
2998 l_component_type VARCHAR2(80) ;
2999 l_component_code VARCHAR2(30) ;
3000 l_component_type_code VARCHAR2(1) ;
3001 l_component_appl_id INTEGER ;
3002 l_amb_context_code VARCHAR2(30) ;
3003 l_log_module VARCHAR2(240) ;
3004 l_output_value VARCHAR2(30) ;
3005 BEGIN
3006 IF g_log_enabled THEN
3007 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_21';
3008 END IF;
3009 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3010
3011 trace
3012 (p_msg => 'BEGIN of AcctDerRule_21'
3013 ,p_level => C_LEVEL_PROCEDURE
3014 ,p_module => l_log_module);
3018 l_component_type := 'AMB_ADR';
3015
3016 END IF;
3017
3019 l_component_code := 'FV_AR_4X0201_RCT_DR';
3020 l_component_type_code := 'S';
3021 l_component_appl_id := 222;
3022 l_amb_context_code := 'DEFAULT';
3023 x_transaction_coa_id := null;
3024 x_accounting_coa_id := null;
3025 x_flexfield_segment_code := null;
3026 x_flex_value_set_id := 1009988 ;
3027
3028
3029 IF NVL(p_source_12,'
3030 ') = 'Unexpired' AND
3031 NVL(p_source_13,'
3032 ') = 'N' AND
3033 (NVL(p_source_15,'
3034 ') = 'A' OR
3035 NVL(p_source_15,'
3036 ') = 'B' OR
3037 NVL(p_source_15,'
3038 ') = 'C') AND
3039 (NVL(p_source_14,'
3040 ') = 'SINGLE' OR
3041 NVL(p_source_14,'
3042 ') = 'MULTIPLE' OR
3043 NVL(p_source_14,'
3044 ') = 'NO_YEAR') AND
3045 NVL(p_source_11,'
3046 ') = 'Overpayment Refund'
3047 THEN
3048 --
3049 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3050
3051 trace
3052 (p_msg => 'END of AcctDerRule_21'
3053 ,p_level => C_LEVEL_PROCEDURE
3054 ,p_module => l_log_module);
3055
3056 END IF;
3057 x_value_combination_id := null ;
3058 x_value_segment_code := null ;
3059 x_value_type_code := 'C';
3060 l_output_value := '490201';
3061 RETURN l_output_value;
3062
3063 ELSIF NVL(p_source_12,'
3067 (NVL(p_source_15,'
3064 ') = 'Unexpired' AND
3065 NVL(p_source_13,'
3066 ') = 'N' AND
3068 ') = 'A' OR
3069 NVL(p_source_15,'
3070 ') = 'B' OR
3071 NVL(p_source_15,'
3072 ') = 'C') AND
3073 (NVL(p_source_14,'
3074 ') = 'SINGLE' OR
3075 NVL(p_source_14,'
3076 ') = 'MULTIPLE' OR
3077 NVL(p_source_14,'
3078 ') = 'NO_YEAR') AND
3079 NVL(p_source_11,'
3080 ') = 'Advance Refund'
3081 THEN
3082 --
3083 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3084
3085 trace
3086 (p_msg => 'END of AcctDerRule_21'
3087 ,p_level => C_LEVEL_PROCEDURE
3088 ,p_module => l_log_module);
3089
3090 END IF;
3091 x_value_combination_id := null ;
3092 x_value_segment_code := null ;
3093 x_value_type_code := 'C';
3094 l_output_value := '480201';
3095 RETURN l_output_value;
3096
3097 ELSE
3098 IF p_override_seg_flag = 'Y' THEN
3099 RETURN '#$NO_OVERRIDE#$';
3100 END IF;
3101 END IF;
3102
3103 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3104
3105 trace
3106 (p_msg => 'END of AcctDerRule_21(invalid)'
3107 ,p_level => C_LEVEL_PROCEDURE
3108 ,p_module => l_log_module);
3109
3110 END IF;
3111
3112 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3113 x_value_combination_id := null;
3114 x_value_segment_code := null;
3115 x_value_type_code := null;
3116 l_output_value := null;
3117 xla_accounting_err_pkg.build_message
3118 (p_appli_s_name => 'XLA'
3119 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3120 ,p_token_1 => 'COMPONENT_NAME'
3121 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3122 l_component_type
3123 , l_component_code
3124 , l_component_type_code
3125 , l_component_appl_id
3126 , l_amb_context_code
3127 )
3128 ,p_token_2 => 'OWNER'
3129 ,p_value_2 => xla_lookups_pkg.get_meaning(
3130 'XLA_OWNER_TYPE'
3131 ,l_component_type_code
3132 )
3133 ,p_token_3 => 'PAD_NAME'
3134 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3135 ,p_token_4 => 'PAD_OWNER'
3136 ,p_value_4 => xla_lookups_pkg.get_meaning(
3137 'XLA_OWNER_TYPE'
3141 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3138 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3139 )
3140 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3142 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3143 ,p_ae_header_id => NULL
3144 );
3145 RETURN l_output_value;
3146 EXCEPTION
3147 WHEN xla_exceptions_pkg.application_exception THEN
3148 RAISE;
3149 WHEN OTHERS THEN
3150 xla_exceptions_pkg.raise_message
3151 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_21');
3152 END AcctDerRule_21;
3153 --
3154
3155 ---------------------------------------
3156 --
3157 -- PRIVATE FUNCTION
3158 -- AcctDerRule_22
3159 --
3160 ---------------------------------------
3161 FUNCTION AcctDerRule_22 (
3162 p_application_id IN NUMBER
3163 , p_ae_header_id IN NUMBER
3164 , p_side IN VARCHAR2
3165 , p_override_seg_flag IN VARCHAR2
3166 --Federal Account Rule
3167 , p_source_11 IN VARCHAR2
3168 --Federal Fund Expired Status
3169 , p_source_12 IN VARCHAR2
3170 --Federal Prior Year Flag
3171 , p_source_13 IN VARCHAR2
3172 --Federal Fund Time Frame
3173 , p_source_14 IN VARCHAR2
3174 , x_transaction_coa_id OUT NOCOPY NUMBER
3175 , x_accounting_coa_id OUT NOCOPY NUMBER
3176 , x_flexfield_segment_code OUT NOCOPY VARCHAR2
3177 , x_flex_value_set_id OUT NOCOPY NUMBER
3178 , x_value_type_code OUT NOCOPY VARCHAR2
3179 , x_value_combination_id OUT NOCOPY NUMBER
3180 , x_value_segment_code OUT NOCOPY VARCHAR2
3181 )
3182 RETURN VARCHAR2
3183 IS
3184 l_component_type VARCHAR2(80) ;
3185 l_component_code VARCHAR2(30) ;
3186 l_component_type_code VARCHAR2(1) ;
3187 l_component_appl_id INTEGER ;
3188 l_amb_context_code VARCHAR2(30) ;
3189 l_log_module VARCHAR2(240) ;
3190 l_output_value VARCHAR2(30) ;
3191 BEGIN
3192 IF g_log_enabled THEN
3193 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_22';
3194 END IF;
3195 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3196
3197 trace
3198 (p_msg => 'BEGIN of AcctDerRule_22'
3199 ,p_level => C_LEVEL_PROCEDURE
3200 ,p_module => l_log_module);
3201
3202 END IF;
3203
3204 l_component_type := 'AMB_ADR';
3205 l_component_code := 'FV_AR_4X7201_RCT_DR';
3206 l_component_type_code := 'S';
3207 l_component_appl_id := 222;
3208 l_amb_context_code := 'DEFAULT';
3209 x_transaction_coa_id := null;
3210 x_accounting_coa_id := null;
3211 x_flexfield_segment_code := null;
3212 x_flex_value_set_id := 1009988 ;
3213
3214
3215 IF ((NVL(p_source_12,'
3216 ') = 'Expired' AND
3217 NVL(p_source_13,'
3218 ') = 'Y' AND
3219 (NVL(p_source_14,'
3220 ') = 'SINGLE' OR
3221 NVL(p_source_14,'
3222 ') = 'MULTIPLE' OR
3223 NVL(p_source_14,'
3224 ') = 'NO_YEAR')
3225 ) OR (NVL(p_source_12,'
3226 ') = 'Unexpired' AND
3227 NVL(p_source_13,'
3228 ') = 'Y' AND
3229 (NVL(p_source_14,'
3230 ') = 'MULTIPLE' OR
3231 NVL(p_source_14,'
3232 ') = 'NO_YEAR')
3233 )) AND NVL(p_source_11,'
3234 ') = 'Overpayment Refund'
3235 THEN
3236 --
3240 (p_msg => 'END of AcctDerRule_22'
3237 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3238
3239 trace
3241 ,p_level => C_LEVEL_PROCEDURE
3242 ,p_module => l_log_module);
3243
3244 END IF;
3245 x_value_combination_id := null ;
3246 x_value_segment_code := null ;
3247 x_value_type_code := 'C';
3248 l_output_value := '497201';
3249 RETURN l_output_value;
3250
3251 ELSIF ((NVL(p_source_12,'
3252 ') = 'Expired' AND
3253 NVL(p_source_13,'
3254 ') = 'Y' AND
3255 (NVL(p_source_14,'
3256 ') = 'SINGLE' OR
3257 NVL(p_source_14,'
3258 ') = 'MUTIPLE' OR
3259 NVL(p_source_14,'
3260 ') = 'NO_YEAR')
3261 ) OR (NVL(p_source_12,'
3262 ') = 'Unexpired' AND
3263 NVL(p_source_13,'
3264 ') = 'Y' AND
3265 (NVL(p_source_14,'
3266 ') = 'MUTIPLE' OR
3267 NVL(p_source_14,'
3268 ') = 'NO_YEAR')
3269 )) AND NVL(p_source_11,'
3270 ') = 'Advance Refund'
3271 THEN
3272 --
3273 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3274
3275 trace
3276 (p_msg => 'END of AcctDerRule_22'
3277 ,p_level => C_LEVEL_PROCEDURE
3278 ,p_module => l_log_module);
3279
3280 END IF;
3281 x_value_combination_id := null ;
3282 x_value_segment_code := null ;
3283 x_value_type_code := 'C';
3284 l_output_value := '487201';
3285 RETURN l_output_value;
3286
3287 ELSE
3288 IF p_override_seg_flag = 'Y' THEN
3289 RETURN '#$NO_OVERRIDE#$';
3290 END IF;
3291 END IF;
3292
3293 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3294
3295 trace
3296 (p_msg => 'END of AcctDerRule_22(invalid)'
3297 ,p_level => C_LEVEL_PROCEDURE
3298 ,p_module => l_log_module);
3299
3300 END IF;
3301
3302 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3303 x_value_combination_id := null;
3304 x_value_segment_code := null;
3305 x_value_type_code := null;
3306 l_output_value := null;
3307 xla_accounting_err_pkg.build_message
3308 (p_appli_s_name => 'XLA'
3309 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3310 ,p_token_1 => 'COMPONENT_NAME'
3311 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3312 l_component_type
3313 , l_component_code
3314 , l_component_type_code
3315 , l_component_appl_id
3316 , l_amb_context_code
3317 )
3318 ,p_token_2 => 'OWNER'
3319 ,p_value_2 => xla_lookups_pkg.get_meaning(
3320 'XLA_OWNER_TYPE'
3321 ,l_component_type_code
3322 )
3323 ,p_token_3 => 'PAD_NAME'
3324 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3325 ,p_token_4 => 'PAD_OWNER'
3326 ,p_value_4 => xla_lookups_pkg.get_meaning(
3327 'XLA_OWNER_TYPE'
3328 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3329 )
3330 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3331 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3332 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3333 ,p_ae_header_id => NULL
3334 );
3335 RETURN l_output_value;
3336 EXCEPTION
3337 WHEN xla_exceptions_pkg.application_exception THEN
3338 RAISE;
3339 WHEN OTHERS THEN
3340 xla_exceptions_pkg.raise_message
3341 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_22');
3342 END AcctDerRule_22;
3343 --
3344
3345 ---------------------------------------
3346 --
3347 -- PRIVATE FUNCTION
3348 -- AcctDerRule_23
3349 --
3350 ---------------------------------------
3351 FUNCTION AcctDerRule_23 (
3352 p_application_id IN NUMBER
3353 , p_ae_header_id IN NUMBER
3354 , p_side IN VARCHAR2
3355 --Transaction Default Receivable Account
3356 , p_source_16 IN NUMBER
3357 , x_transaction_coa_id OUT NOCOPY NUMBER
3358 , x_accounting_coa_id OUT NOCOPY NUMBER
3359 , x_value_type_code OUT NOCOPY VARCHAR2
3360 )
3361 RETURN NUMBER
3362 IS
3363 l_component_type VARCHAR2(80) ;
3364 l_component_code VARCHAR2(30) ;
3365 l_component_type_code VARCHAR2(1) ;
3366 l_component_appl_id INTEGER ;
3367 l_amb_context_code VARCHAR2(30) ;
3368 l_log_module VARCHAR2(240) ;
3369 l_output_value NUMBER ;
3370 BEGIN
3371 IF g_log_enabled THEN
3372 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_23';
3373 END IF;
3374 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3375 trace
3376 (p_msg => 'BEGIN of AcctDerRule_23'
3377 ,p_level => C_LEVEL_PROCEDURE
3378 ,p_module => l_log_module);
3379 END IF;
3380 --
3381 l_component_type := 'AMB_ADR';
3382 l_component_code := 'MFAR_TRX_DEF_REC_CCID';
3383 l_component_type_code := 'S';
3384 l_component_appl_id := 222;
3385 l_amb_context_code := 'DEFAULT';
3386 x_transaction_coa_id := null;
3387 x_accounting_coa_id := null;
3388 --
3389
3390 --
3391 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3392 trace
3393 (p_msg => 'END of AcctDerRule_23'
3394 ,p_level => C_LEVEL_PROCEDURE
3395 ,p_module => l_log_module);
3396 END IF;
3397 x_value_type_code := 'S';
3398 l_output_value := TO_NUMBER(TO_NUMBER(p_source_16));
3399 RETURN l_output_value;
3400
3401 --
3402 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3403 trace
3404 (p_msg => 'END of AcctDerRule_23(invalid)'
3405 ,p_level => C_LEVEL_PROCEDURE
3406 ,p_module => l_log_module);
3407 END IF;
3408 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3409 x_value_type_code := null;
3410 l_output_value := null;
3411 xla_accounting_err_pkg.build_message
3412 (p_appli_s_name => 'XLA'
3413 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3414 ,p_token_1 => 'COMPONENT_NAME'
3415 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3416 l_component_type
3417 , l_component_code
3418 , l_component_type_code
3419 , l_component_appl_id
3420 , l_amb_context_code
3421 )
3422 ,p_token_2 => 'OWNER'
3423 ,p_value_2 => xla_lookups_pkg.get_meaning(
3424 'XLA_OWNER_TYPE'
3425 ,l_component_type_code
3426 )
3427 ,p_token_3 => 'PAD_NAME'
3428 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3429 ,p_token_4 => 'PAD_OWNER'
3430 ,p_value_4 => xla_lookups_pkg.get_meaning(
3431 'XLA_OWNER_TYPE'
3432 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3433 )
3434 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3435 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3436 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3437 ,p_ae_header_id => NULL
3438 );
3439 RETURN l_output_value;
3440 EXCEPTION
3441 WHEN xla_exceptions_pkg.application_exception THEN
3442 RAISE;
3443 WHEN OTHERS THEN
3444 xla_exceptions_pkg.raise_message
3445 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_23');
3446 END AcctDerRule_23;
3447 --
3448
3449 ---------------------------------------
3450 --
3451 -- PRIVATE FUNCTION
3452 -- AcctDerRule_24
3453 --
3454 ---------------------------------------
3455 FUNCTION AcctDerRule_24 (
3456 p_application_id IN NUMBER
3457 , p_ae_header_id IN NUMBER
3458 , p_side IN VARCHAR2
3459 --Remittance Bank Account Unapplied Account
3460 , p_source_17 IN NUMBER
3461 , x_transaction_coa_id OUT NOCOPY NUMBER
3462 , x_accounting_coa_id OUT NOCOPY NUMBER
3463 , x_value_type_code OUT NOCOPY VARCHAR2
3464 )
3465 RETURN NUMBER
3466 IS
3467 l_component_type VARCHAR2(80) ;
3468 l_component_code VARCHAR2(30) ;
3469 l_component_type_code VARCHAR2(1) ;
3470 l_component_appl_id INTEGER ;
3471 l_amb_context_code VARCHAR2(30) ;
3472 l_log_module VARCHAR2(240) ;
3473 l_output_value NUMBER ;
3474 BEGIN
3475 IF g_log_enabled THEN
3476 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_24';
3477 END IF;
3478 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3479 trace
3480 (p_msg => 'BEGIN of AcctDerRule_24'
3481 ,p_level => C_LEVEL_PROCEDURE
3482 ,p_module => l_log_module);
3483 END IF;
3484 --
3485 l_component_type := 'AMB_ADR';
3486 l_component_code := 'RMT_BNK_UNAPP_CCID';
3487 l_component_type_code := 'S';
3488 l_component_appl_id := 222;
3489 l_amb_context_code := 'DEFAULT';
3490 x_transaction_coa_id := null;
3491 x_accounting_coa_id := null;
3492 --
3493
3494 --
3495 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3496 trace
3497 (p_msg => 'END of AcctDerRule_24'
3498 ,p_level => C_LEVEL_PROCEDURE
3499 ,p_module => l_log_module);
3500 END IF;
3501 x_value_type_code := 'S';
3502 l_output_value := TO_NUMBER(TO_NUMBER(p_source_17));
3503 RETURN l_output_value;
3504
3505 --
3506 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3507 trace
3508 (p_msg => 'END of AcctDerRule_24(invalid)'
3509 ,p_level => C_LEVEL_PROCEDURE
3510 ,p_module => l_log_module);
3511 END IF;
3512 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3513 x_value_type_code := null;
3514 l_output_value := null;
3515 xla_accounting_err_pkg.build_message
3516 (p_appli_s_name => 'XLA'
3517 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3518 ,p_token_1 => 'COMPONENT_NAME'
3519 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3520 l_component_type
3521 , l_component_code
3522 , l_component_type_code
3523 , l_component_appl_id
3524 , l_amb_context_code
3525 )
3526 ,p_token_2 => 'OWNER'
3527 ,p_value_2 => xla_lookups_pkg.get_meaning(
3528 'XLA_OWNER_TYPE'
3529 ,l_component_type_code
3530 )
3531 ,p_token_3 => 'PAD_NAME'
3532 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3533 ,p_token_4 => 'PAD_OWNER'
3534 ,p_value_4 => xla_lookups_pkg.get_meaning(
3535 'XLA_OWNER_TYPE'
3536 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3537 )
3538 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3539 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3540 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3541 ,p_ae_header_id => NULL
3542 );
3543 RETURN l_output_value;
3544 EXCEPTION
3545 WHEN xla_exceptions_pkg.application_exception THEN
3546 RAISE;
3547 WHEN OTHERS THEN
3548 xla_exceptions_pkg.raise_message
3549 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_24');
3550 END AcctDerRule_24;
3551 --
3552
3553 ---------------------------------------
3554 --
3555 -- PRIVATE FUNCTION
3556 -- AcctDerRule_25
3557 --
3558 ---------------------------------------
3559 FUNCTION AcctDerRule_25 (
3560 p_application_id IN NUMBER
3561 , p_ae_header_id IN NUMBER
3562 , p_side IN VARCHAR2
3563 --Remittance Bank Account Unidentified Account
3564 , p_source_18 IN NUMBER
3565 , x_transaction_coa_id OUT NOCOPY NUMBER
3566 , x_accounting_coa_id OUT NOCOPY NUMBER
3567 , x_value_type_code OUT NOCOPY VARCHAR2
3568 )
3569 RETURN NUMBER
3570 IS
3571 l_component_type VARCHAR2(80) ;
3572 l_component_code VARCHAR2(30) ;
3573 l_component_type_code VARCHAR2(1) ;
3574 l_component_appl_id INTEGER ;
3575 l_amb_context_code VARCHAR2(30) ;
3576 l_log_module VARCHAR2(240) ;
3577 l_output_value NUMBER ;
3578 BEGIN
3579 IF g_log_enabled THEN
3580 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_25';
3581 END IF;
3582 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3583 trace
3584 (p_msg => 'BEGIN of AcctDerRule_25'
3585 ,p_level => C_LEVEL_PROCEDURE
3586 ,p_module => l_log_module);
3587 END IF;
3588 --
3589 l_component_type := 'AMB_ADR';
3590 l_component_code := 'RMT_BNK_UNID_CCID';
3591 l_component_type_code := 'S';
3592 l_component_appl_id := 222;
3593 l_amb_context_code := 'DEFAULT';
3594 x_transaction_coa_id := null;
3595 x_accounting_coa_id := null;
3596 --
3597
3598 --
3599 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3600 trace
3601 (p_msg => 'END of AcctDerRule_25'
3602 ,p_level => C_LEVEL_PROCEDURE
3603 ,p_module => l_log_module);
3604 END IF;
3605 x_value_type_code := 'S';
3606 l_output_value := TO_NUMBER(TO_NUMBER(p_source_18));
3607 RETURN l_output_value;
3608
3609 --
3610 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3611 trace
3612 (p_msg => 'END of AcctDerRule_25(invalid)'
3613 ,p_level => C_LEVEL_PROCEDURE
3614 ,p_module => l_log_module);
3615 END IF;
3616 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3617 x_value_type_code := null;
3618 l_output_value := null;
3619 xla_accounting_err_pkg.build_message
3620 (p_appli_s_name => 'XLA'
3621 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3622 ,p_token_1 => 'COMPONENT_NAME'
3623 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3624 l_component_type
3625 , l_component_code
3626 , l_component_type_code
3627 , l_component_appl_id
3628 , l_amb_context_code
3629 )
3630 ,p_token_2 => 'OWNER'
3631 ,p_value_2 => xla_lookups_pkg.get_meaning(
3632 'XLA_OWNER_TYPE'
3633 ,l_component_type_code
3634 )
3635 ,p_token_3 => 'PAD_NAME'
3636 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3637 ,p_token_4 => 'PAD_OWNER'
3638 ,p_value_4 => xla_lookups_pkg.get_meaning(
3639 'XLA_OWNER_TYPE'
3640 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3641 )
3642 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3643 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3644 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3645 ,p_ae_header_id => NULL
3649 WHEN xla_exceptions_pkg.application_exception THEN
3646 );
3647 RETURN l_output_value;
3648 EXCEPTION
3650 RAISE;
3651 WHEN OTHERS THEN
3652 xla_exceptions_pkg.raise_message
3653 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_25');
3654 END AcctDerRule_25;
3655 --
3656
3657 ---------------------------------------
3658 --
3659 -- PRIVATE FUNCTION
3660 -- AcctDerRule_26
3661 --
3662 ---------------------------------------
3663 FUNCTION AcctDerRule_26 (
3664 p_application_id IN NUMBER
3665 , p_ae_header_id IN NUMBER
3666 , p_side IN VARCHAR2
3667 --System Gain Account
3668 , p_source_7 IN NUMBER
3669 , x_transaction_coa_id OUT NOCOPY NUMBER
3670 , x_accounting_coa_id OUT NOCOPY NUMBER
3671 , x_value_type_code OUT NOCOPY VARCHAR2
3672 )
3673 RETURN NUMBER
3674 IS
3675 l_component_type VARCHAR2(80) ;
3676 l_component_code VARCHAR2(30) ;
3677 l_component_type_code VARCHAR2(1) ;
3678 l_component_appl_id INTEGER ;
3679 l_amb_context_code VARCHAR2(30) ;
3680 l_log_module VARCHAR2(240) ;
3681 l_output_value NUMBER ;
3682 BEGIN
3683 IF g_log_enabled THEN
3684 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_26';
3685 END IF;
3686 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3687 trace
3688 (p_msg => 'BEGIN of AcctDerRule_26'
3689 ,p_level => C_LEVEL_PROCEDURE
3690 ,p_module => l_log_module);
3691 END IF;
3692 --
3693 l_component_type := 'AMB_ADR';
3694 l_component_code := 'SYS_GAIN_CCID';
3695 l_component_type_code := 'S';
3696 l_component_appl_id := 222;
3697 l_amb_context_code := 'DEFAULT';
3698 x_transaction_coa_id := null;
3699 x_accounting_coa_id := null;
3700 --
3701
3702 --
3703 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3704 trace
3705 (p_msg => 'END of AcctDerRule_26'
3706 ,p_level => C_LEVEL_PROCEDURE
3707 ,p_module => l_log_module);
3708 END IF;
3709 x_value_type_code := 'S';
3710 l_output_value := TO_NUMBER(TO_NUMBER(p_source_7));
3711 RETURN l_output_value;
3712
3713 --
3714 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3715 trace
3716 (p_msg => 'END of AcctDerRule_26(invalid)'
3717 ,p_level => C_LEVEL_PROCEDURE
3718 ,p_module => l_log_module);
3719 END IF;
3720 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3721 x_value_type_code := null;
3722 l_output_value := null;
3723 xla_accounting_err_pkg.build_message
3724 (p_appli_s_name => 'XLA'
3725 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3726 ,p_token_1 => 'COMPONENT_NAME'
3727 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3728 l_component_type
3729 , l_component_code
3730 , l_component_type_code
3731 , l_component_appl_id
3732 , l_amb_context_code
3733 )
3734 ,p_token_2 => 'OWNER'
3735 ,p_value_2 => xla_lookups_pkg.get_meaning(
3736 'XLA_OWNER_TYPE'
3737 ,l_component_type_code
3738 )
3739 ,p_token_3 => 'PAD_NAME'
3740 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3741 ,p_token_4 => 'PAD_OWNER'
3742 ,p_value_4 => xla_lookups_pkg.get_meaning(
3743 'XLA_OWNER_TYPE'
3744 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3745 )
3746 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3747 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3748 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3749 ,p_ae_header_id => NULL
3750 );
3751 RETURN l_output_value;
3752 EXCEPTION
3753 WHEN xla_exceptions_pkg.application_exception THEN
3754 RAISE;
3755 WHEN OTHERS THEN
3756 xla_exceptions_pkg.raise_message
3757 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_26');
3758 END AcctDerRule_26;
3759 --
3760
3761 ---------------------------------------
3762 --
3763 -- PRIVATE FUNCTION
3764 -- AcctDerRule_27
3765 --
3766 ---------------------------------------
3767 FUNCTION AcctDerRule_27 (
3768 p_application_id IN NUMBER
3769 , p_ae_header_id IN NUMBER
3770 , p_side IN VARCHAR2
3771 --System Loss Account
3772 , p_source_8 IN NUMBER
3773 , x_transaction_coa_id OUT NOCOPY NUMBER
3774 , x_accounting_coa_id OUT NOCOPY NUMBER
3775 , x_value_type_code OUT NOCOPY VARCHAR2
3776 )
3777 RETURN NUMBER
3778 IS
3779 l_component_type VARCHAR2(80) ;
3780 l_component_code VARCHAR2(30) ;
3784 l_log_module VARCHAR2(240) ;
3781 l_component_type_code VARCHAR2(1) ;
3782 l_component_appl_id INTEGER ;
3783 l_amb_context_code VARCHAR2(30) ;
3785 l_output_value NUMBER ;
3786 BEGIN
3787 IF g_log_enabled THEN
3788 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_27';
3789 END IF;
3790 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3791 trace
3792 (p_msg => 'BEGIN of AcctDerRule_27'
3793 ,p_level => C_LEVEL_PROCEDURE
3794 ,p_module => l_log_module);
3795 END IF;
3796 --
3797 l_component_type := 'AMB_ADR';
3798 l_component_code := 'SYS_LOSS_CCID';
3799 l_component_type_code := 'S';
3800 l_component_appl_id := 222;
3801 l_amb_context_code := 'DEFAULT';
3802 x_transaction_coa_id := null;
3803 x_accounting_coa_id := null;
3804 --
3805
3806 --
3807 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3808 trace
3809 (p_msg => 'END of AcctDerRule_27'
3810 ,p_level => C_LEVEL_PROCEDURE
3811 ,p_module => l_log_module);
3812 END IF;
3813 x_value_type_code := 'S';
3814 l_output_value := TO_NUMBER(TO_NUMBER(p_source_8));
3815 RETURN l_output_value;
3816
3817 --
3818 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3819 trace
3820 (p_msg => 'END of AcctDerRule_27(invalid)'
3821 ,p_level => C_LEVEL_PROCEDURE
3822 ,p_module => l_log_module);
3823 END IF;
3824 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3825 x_value_type_code := null;
3826 l_output_value := null;
3827 xla_accounting_err_pkg.build_message
3828 (p_appli_s_name => 'XLA'
3829 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3830 ,p_token_1 => 'COMPONENT_NAME'
3831 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3832 l_component_type
3833 , l_component_code
3834 , l_component_type_code
3835 , l_component_appl_id
3836 , l_amb_context_code
3837 )
3838 ,p_token_2 => 'OWNER'
3839 ,p_value_2 => xla_lookups_pkg.get_meaning(
3840 'XLA_OWNER_TYPE'
3841 ,l_component_type_code
3842 )
3843 ,p_token_3 => 'PAD_NAME'
3844 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3845 ,p_token_4 => 'PAD_OWNER'
3846 ,p_value_4 => xla_lookups_pkg.get_meaning(
3847 'XLA_OWNER_TYPE'
3848 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3849 )
3850 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3851 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3852 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3853 ,p_ae_header_id => NULL
3854 );
3855 RETURN l_output_value;
3856 EXCEPTION
3857 WHEN xla_exceptions_pkg.application_exception THEN
3858 RAISE;
3859 WHEN OTHERS THEN
3860 xla_exceptions_pkg.raise_message
3861 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_27');
3862 END AcctDerRule_27;
3863 --
3864
3865 ---------------------------------------
3866 --
3867 -- PRIVATE FUNCTION
3868 -- AcctDerRule_28
3869 --
3870 ---------------------------------------
3871 FUNCTION AcctDerRule_28 (
3872 p_application_id IN NUMBER
3873 , p_ae_header_id IN NUMBER
3874 , p_side IN VARCHAR2
3875 --Transaction Distribution GL Account
3876 , p_source_19 IN NUMBER
3877 , x_transaction_coa_id OUT NOCOPY NUMBER
3878 , x_accounting_coa_id OUT NOCOPY NUMBER
3879 , x_value_type_code OUT NOCOPY VARCHAR2
3880 )
3881 RETURN NUMBER
3882 IS
3883 l_component_type VARCHAR2(80) ;
3884 l_component_code VARCHAR2(30) ;
3885 l_component_type_code VARCHAR2(1) ;
3886 l_component_appl_id INTEGER ;
3887 l_amb_context_code VARCHAR2(30) ;
3888 l_log_module VARCHAR2(240) ;
3889 l_output_value NUMBER ;
3890 BEGIN
3891 IF g_log_enabled THEN
3892 l_log_module := C_DEFAULT_MODULE||'.AcctDerRule_28';
3893 END IF;
3894 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3895 trace
3896 (p_msg => 'BEGIN of AcctDerRule_28'
3897 ,p_level => C_LEVEL_PROCEDURE
3898 ,p_module => l_log_module);
3899 END IF;
3900 --
3901 l_component_type := 'AMB_ADR';
3902 l_component_code := 'TRX_DIST_CCID';
3903 l_component_type_code := 'S';
3904 l_component_appl_id := 222;
3905 l_amb_context_code := 'DEFAULT';
3906 x_transaction_coa_id := null;
3907 x_accounting_coa_id := null;
3908 --
3909
3910 --
3911 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3912 trace
3913 (p_msg => 'END of AcctDerRule_28'
3917 x_value_type_code := 'S';
3914 ,p_level => C_LEVEL_PROCEDURE
3915 ,p_module => l_log_module);
3916 END IF;
3918 l_output_value := TO_NUMBER(TO_NUMBER(p_source_19));
3919 RETURN l_output_value;
3920
3921 --
3922 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3923 trace
3924 (p_msg => 'END of AcctDerRule_28(invalid)'
3925 ,p_level => C_LEVEL_PROCEDURE
3926 ,p_module => l_log_module);
3927 END IF;
3928 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
3929 x_value_type_code := null;
3930 l_output_value := null;
3931 xla_accounting_err_pkg.build_message
3932 (p_appli_s_name => 'XLA'
3933 ,p_msg_name => 'XLA_AP_INVALID_ADR'
3934 ,p_token_1 => 'COMPONENT_NAME'
3935 ,p_value_1 => xla_ae_sources_pkg.GetComponentName (
3936 l_component_type
3937 , l_component_code
3938 , l_component_type_code
3939 , l_component_appl_id
3940 , l_amb_context_code
3941 )
3942 ,p_token_2 => 'OWNER'
3943 ,p_value_2 => xla_lookups_pkg.get_meaning(
3944 'XLA_OWNER_TYPE'
3945 ,l_component_type_code
3946 )
3947 ,p_token_3 => 'PAD_NAME'
3948 ,p_value_3 => xla_ae_journal_entry_pkg.g_cache_pad.pad_session_name
3949 ,p_token_4 => 'PAD_OWNER'
3950 ,p_value_4 => xla_lookups_pkg.get_meaning(
3951 'XLA_OWNER_TYPE'
3952 ,xla_ae_journal_entry_pkg.g_cache_pad.product_rule_type_code
3953 )
3954 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
3955 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
3956 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id
3957 ,p_ae_header_id => NULL
3958 );
3959 RETURN l_output_value;
3960 EXCEPTION
3961 WHEN xla_exceptions_pkg.application_exception THEN
3962 RAISE;
3963 WHEN OTHERS THEN
3964 xla_exceptions_pkg.raise_message
3965 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctDerRule_28');
3966 END AcctDerRule_28;
3967 --
3968
3969 ---------------------------------------
3970 --
3971 -- PRIVATE FUNCTION
3972 -- AcctLineType_29
3973 --
3974 ---------------------------------------
3975 PROCEDURE AcctLineType_29 (
3976 p_application_id IN NUMBER
3977 ,p_event_id IN NUMBER
3978 ,p_calculate_acctd_flag IN VARCHAR2
3979 ,p_calculate_g_l_flag IN VARCHAR2
3980 ,p_actual_flag IN OUT VARCHAR2
3981 ,p_balance_type_code OUT VARCHAR2
3982 ,p_gain_or_loss_ref OUT VARCHAR2
3983
3984 --Distribution GL Account
3985 , p_source_5 IN NUMBER
3986 --Distribution Source Type
3987 , p_source_20 IN VARCHAR2
3988 --Receivable Activity Type
3989 , p_source_21 IN VARCHAR2
3990 --Distribution Line Identifier
3991 , p_source_22 IN NUMBER
3992 --Distribution Type
3993 , p_source_23 IN VARCHAR2
3994 --Entered Amount
3995 , p_source_24 IN NUMBER
3996 --Currency Code
3997 , p_source_25 IN VARCHAR2
3998 --Exchange Date
3999 , p_source_26 IN DATE
4000 --Exchange Rate
4001 , p_source_27 IN NUMBER
4002 --Exchange Rate Type
4003 , p_source_28 IN VARCHAR2
4004 --Applied To Document Accounting Amount
4005 , p_source_29 IN NUMBER
4006 --Bill To Customer Account Identifier
4007 , p_source_30 IN NUMBER
4008 --Bill To Customer Site Use Identifier
4009 , p_source_31 IN NUMBER
4010 --SLA Party Type
4011 , p_source_32 IN VARCHAR2
4012 )
4013 IS
4014
4015 l_component_type VARCHAR2(80);
4016 l_component_code VARCHAR2(30);
4017 l_component_type_code VARCHAR2(1);
4018 l_component_appl_id INTEGER;
4019 l_amb_context_code VARCHAR2(30);
4020 l_entity_code VARCHAR2(30);
4021 l_event_class_code VARCHAR2(30);
4022 l_ae_header_id NUMBER;
4023 l_event_type_code VARCHAR2(30);
4024 l_line_definition_code VARCHAR2(30);
4025 l_line_definition_owner_code VARCHAR2(1);
4026 --
4027 -- adr variables
4028 l_segment VARCHAR2(30);
4029 l_ccid NUMBER;
4030 l_adr_transaction_coa_id NUMBER;
4031 l_adr_accounting_coa_id NUMBER;
4032 l_adr_flexfield_segment_code VARCHAR2(30);
4033 l_adr_flex_value_set_id NUMBER;
4034 l_adr_value_type_code VARCHAR2(30);
4035 l_adr_value_combination_id NUMBER;
4036 l_adr_value_segment_code VARCHAR2(30);
4037
4038 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
4039 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
4040 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
4044 l_entered_amt_idx NUMBER;
4041 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
4042
4043 -- 4262811 Variables ------------------------------------------------------------------------------------------
4045 l_accted_amt_idx NUMBER;
4046 l_acc_rev_flag VARCHAR2(1);
4047 l_accrual_line_num NUMBER;
4048 l_tmp_amt NUMBER;
4049 l_acc_rev_natural_side_code VARCHAR2(1);
4050
4051 l_num_entries NUMBER;
4052 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
4053 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
4054 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
4055 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
4056 l_recog_line_1 NUMBER;
4057 l_recog_line_2 NUMBER;
4058
4059 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
4060 l_bflow_applied_to_amt NUMBER; -- 5132302
4061 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
4062
4063 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
4064
4065 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
4066 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
4067
4068 ---------------------------------------------------------------------------------------------------------------
4069
4070
4071 --
4072 -- bulk performance
4073 --
4074 l_balance_type_code VARCHAR2(1);
4075 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
4076 l_log_module VARCHAR2(240);
4077
4078 --
4079 -- Upgrade strategy
4080 --
4081 l_actual_upg_option VARCHAR2(1);
4082 l_enc_upg_option VARCHAR2(1);
4083
4084 --
4085 BEGIN
4086 --
4087 IF g_log_enabled THEN
4088 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_29';
4089 END IF;
4090 --
4091 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4092
4093 trace
4094 (p_msg => 'BEGIN of AcctLineType_29'
4095 ,p_level => C_LEVEL_PROCEDURE
4096 ,p_module => l_log_module);
4097
4098 END IF;
4099 --
4100 l_component_type := 'AMB_JLT';
4101 l_component_code := 'ADJ';
4102 l_component_type_code := 'S';
4103 l_component_appl_id := 222;
4104 l_amb_context_code := 'DEFAULT';
4105 l_entity_code := 'ADJUSTMENTS';
4106 l_event_class_code := 'ADJUSTMENT';
4107 l_event_type_code := 'ADJUSTMENT_ALL';
4108 l_line_definition_owner_code := 'S';
4109 l_line_definition_code := 'AR_ADJ_DEFAULT_ACCRUAL';
4110 --
4111 l_balance_type_code := 'A';
4112 l_segment := NULL;
4113 l_ccid := NULL;
4114 l_adr_transaction_coa_id := NULL;
4115 l_adr_accounting_coa_id := NULL;
4116 l_adr_flexfield_segment_code := NULL;
4117 l_adr_flex_value_set_id := NULL;
4118 l_adr_value_type_code := NULL;
4119 l_adr_value_combination_id := NULL;
4120 l_adr_value_segment_code := NULL;
4121
4122 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
4123 l_bflow_class_code := ''; -- 4219869 Business Flow
4124 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
4125 l_budgetary_control_flag := 'N';
4126
4127 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4128 l_bflow_applied_to_amt := NULL; -- 5132302
4129 l_entered_amt_idx := NULL; -- 4262811
4130 l_accted_amt_idx := NULL; -- 4262811
4131 l_acc_rev_flag := NULL; -- 4262811
4132 l_accrual_line_num := NULL; -- 4262811
4133 l_tmp_amt := NULL; -- 4262811
4134 --
4135
4136 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
4137 l_balance_type_code <> 'B' THEN
4138 IF NVL(p_source_20,'
4139 ') = 'ADJ' AND
4140 NVL(p_source_21,'
4141 ') <> 'ENDORSEMENT'
4142 THEN
4143
4144 --
4145 XLA_AE_LINES_PKG.SetNewLine;
4146
4147 p_balance_type_code := l_balance_type_code;
4148 -- set the flag so later we will know whether the gain loss line needs to be created
4149
4150 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
4151 p_actual_flag :='A';
4152 END IF;
4153
4154 --
4155 -- bulk performance
4156 --
4157 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
4158 p_header_num => 0); -- 4262811
4159 --
4160 -- set accounting line options
4161 --
4162 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
4163 p_natural_side_code => 'C'
4164 , p_gain_or_loss_flag => 'N'
4165 , p_gl_transfer_mode_code => 'S'
4166 , p_acct_entry_type_code => 'A'
4167 , p_switch_side_flag => 'Y'
4168 , p_merge_duplicate_code => 'A'
4169 );
4170 --
4171 l_acc_rev_natural_side_code := 'D'; -- 4262811
4172 --
4173 --
4174 -- set accounting line type info
4175 --
4176 xla_ae_lines_pkg.SetAcctLineType
4177 (p_component_type => l_component_type
4178 ,p_event_type_code => l_event_type_code
4182 ,p_accounting_line_type_code => l_component_type_code
4179 ,p_line_definition_owner_code => l_line_definition_owner_code
4180 ,p_line_definition_code => l_line_definition_code
4181 ,p_accounting_line_code => l_component_code
4183 ,p_accounting_line_appl_id => l_component_appl_id
4184 ,p_amb_context_code => l_amb_context_code
4185 ,p_entity_code => l_entity_code
4186 ,p_event_class_code => l_event_class_code);
4187 --
4188 -- set accounting class
4189 --
4190 xla_ae_lines_pkg.SetAcctClass(
4191 p_accounting_class_code => 'ADJ'
4192 , p_ae_header_id => l_ae_header_id
4193 );
4194
4195 --
4196 -- set rounding class
4197 --
4198 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
4199 'RECEIVABLE';
4200
4201 --
4202 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
4203 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
4204 --
4205 -- bulk performance
4206 --
4207 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
4208
4209 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
4210 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
4211
4212 -- 4955764
4213 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4214 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
4215
4216 -- 4458381 Public Sector Enh
4217
4218 --
4219 -- set accounting attributes for the line type
4220 --
4221 l_entered_amt_idx := 3;
4222 l_accted_amt_idx := 8;
4223 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4224 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
4225 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
4226 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
4227 l_rec_acct_attrs.array_char_value(2) := p_source_23;
4228 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
4229 l_rec_acct_attrs.array_num_value(3) := p_source_24;
4230 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
4231 l_rec_acct_attrs.array_char_value(4) := p_source_25;
4232 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
4233 l_rec_acct_attrs.array_date_value(5) := p_source_26;
4234 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
4235 l_rec_acct_attrs.array_num_value(6) := p_source_27;
4236 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
4237 l_rec_acct_attrs.array_char_value(7) := p_source_28;
4238 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
4239 l_rec_acct_attrs.array_num_value(8) := p_source_29;
4240 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
4241 l_rec_acct_attrs.array_num_value(9) := p_source_30;
4242 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
4243 l_rec_acct_attrs.array_num_value(10) := p_source_31;
4244 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
4245 l_rec_acct_attrs.array_char_value(11) := p_source_32;
4246
4247 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
4248 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
4249
4250 ---------------------------------------------------------------------------------------------------------------
4251 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
4252 ---------------------------------------------------------------------------------------------------------------
4253 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
4254
4255 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4256 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4257
4258 IF xla_accounting_cache_pkg.GetValueChar
4259 (p_source_code => 'LEDGER_CATEGORY_CODE'
4260 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
4261 AND l_bflow_method_code = 'PRIOR_ENTRY'
4262 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
4263 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
4264 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
4265 )
4266 THEN
4267 xla_ae_lines_pkg.BflowUpgEntry
4268 (p_business_method_code => l_bflow_method_code
4269 ,p_business_class_code => l_bflow_class_code
4270 ,p_balance_type => l_balance_type_code);
4271 ELSE
4272 NULL;
4273 -- No business flow processing for business flow method of NONE.
4274 END IF;
4275
4276 --
4277 -- call analytical criteria
4278 --
4279
4280 --
4281 -- call description
4282 --
4283 -- No description or it is inherited.
4284 --
4285 -- call ADRs
4286 -- Bug 4922099
4287 --
4288 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4289 (NVL(l_actual_upg_option, 'N') = 'O') OR
4290 (NVL(l_enc_upg_option, 'N') = 'O')
4291 )
4292 THEN
4293 NULL;
4294 --
4295 --
4296
4297 l_ccid := AcctDerRule_4(
4301 , x_transaction_coa_id => l_adr_transaction_coa_id
4302 , x_accounting_coa_id => l_adr_accounting_coa_id
4303 , x_value_type_code => l_adr_value_type_code
4304 , p_side => 'NA'
4305 );
4306
4307 xla_ae_lines_pkg.set_ccid(
4308 p_code_combination_id => l_ccid
4309 , p_value_type_code => l_adr_value_type_code
4310 , p_transaction_coa_id => l_adr_transaction_coa_id
4311 , p_accounting_coa_id => l_adr_accounting_coa_id
4312 , p_adr_code => 'DIST_CCID'
4313 , p_adr_type_code => 'S'
4314 , p_component_type => l_component_type
4315 , p_component_code => l_component_code
4316 , p_component_type_code => l_component_type_code
4317 , p_component_appl_id => l_component_appl_id
4318 , p_amb_context_code => l_amb_context_code
4319 , p_side => 'NA'
4320 );
4321
4322
4323 --
4324 --
4325 END IF;
4326 --
4327 -- Bug 4922099
4328 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
4329 (NVL(l_enc_upg_option, 'N') = 'O')
4330 ) AND
4331 (l_bflow_method_code = 'PRIOR_ENTRY')
4332 )
4333 THEN
4334 IF
4335 --
4336 1 = 2
4337 --
4338 THEN
4339 xla_accounting_err_pkg.build_message
4340 (p_appli_s_name => 'XLA'
4341 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4342 ,p_token_1 => 'LINE_NUMBER'
4343 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
4344 ,p_token_2 => 'LINE_TYPE_NAME'
4345 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
4346 l_component_type
4347 ,l_component_code
4348 ,l_component_type_code
4349 ,l_component_appl_id
4350 ,l_amb_context_code
4351 ,l_entity_code
4352 ,l_event_class_code
4353 )
4354 ,p_token_3 => 'OWNER'
4355 ,p_value_3 => xla_lookups_pkg.get_meaning(
4356 p_lookup_type => 'XLA_OWNER_TYPE'
4357 ,p_lookup_code => l_component_type_code
4358 )
4359 ,p_token_4 => 'PRODUCT_NAME'
4360 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
4361 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
4362 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
4363 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
4364 ,p_ae_header_id => NULL
4365 );
4366
4367 IF (C_LEVEL_ERROR>= g_log_level) THEN
4368 trace
4369 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4370 ,p_level => C_LEVEL_ERROR
4371 ,p_module => l_log_module);
4372 END IF;
4373 END IF;
4374 END IF;
4375 --
4376 --
4377 ------------------------------------------------------------------------------------------------
4378 -- 4219869 Business Flow
4379 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
4380 -- Prior Entry. Currently, the following code is always generated.
4381 ------------------------------------------------------------------------------------------------
4382 XLA_AE_LINES_PKG.ValidateCurrentLine;
4383
4384 ------------------------------------------------------------------------------------
4385 -- 4219869 Business Flow
4386 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
4387 ------------------------------------------------------------------------------------
4388 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
4389
4390 ----------------------------------------------------------------------------------
4391 -- 4219869 Business Flow
4392 -- Update journal entry status -- Need to generate this within IF <condition>
4393 ----------------------------------------------------------------------------------
4394 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4395 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
4396 ,p_balance_type_code => l_balance_type_code
4397 );
4398
4399 -------------------------------------------------------------------------------------------
4400 -- 4262811 - Generate the Accrual Reversal lines
4401 -------------------------------------------------------------------------------------------
4402 BEGIN
4403 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
4404 (g_array_event(p_event_id).array_value_num('header_index'));
4405 IF l_acc_rev_flag IS NULL THEN
4406 l_acc_rev_flag := 'N';
4407 END IF;
4408 EXCEPTION
4409 WHEN OTHERS THEN
4410 l_acc_rev_flag := 'N';
4411 END;
4412 --
4413 IF (l_acc_rev_flag = 'Y') THEN
4414
4415 -- 4645092 ------------------------------------------------------------------------------
4416 -- To allow MPA report to determine if it should generate report process
4417 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
4418 ------------------------------------------------------------------------------------------
4419
4420 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
4421 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
4422 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
4423 -- call ADRs
4424 -- Bug 4922099
4427 (NVL(l_actual_upg_option, 'N') = 'O') OR
4298 p_application_id => p_application_id
4299 , p_ae_header_id => l_ae_header_id
4300 , p_source_5 => p_source_5
4425 --
4426 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4428 (NVL(l_enc_upg_option, 'N') = 'O')
4429 )
4430 THEN
4431 NULL;
4432 --
4433 --
4434
4435 l_ccid := AcctDerRule_4(
4436 p_application_id => p_application_id
4437 , p_ae_header_id => l_ae_header_id
4438 , p_source_5 => p_source_5
4439 , x_transaction_coa_id => l_adr_transaction_coa_id
4440 , x_accounting_coa_id => l_adr_accounting_coa_id
4441 , x_value_type_code => l_adr_value_type_code
4442 , p_side => 'NA'
4443 );
4444
4445 xla_ae_lines_pkg.set_ccid(
4446 p_code_combination_id => l_ccid
4447 , p_value_type_code => l_adr_value_type_code
4448 , p_transaction_coa_id => l_adr_transaction_coa_id
4449 , p_accounting_coa_id => l_adr_accounting_coa_id
4450 , p_adr_code => 'DIST_CCID'
4451 , p_adr_type_code => 'S'
4452 , p_component_type => l_component_type
4453 , p_component_code => l_component_code
4454 , p_component_type_code => l_component_type_code
4455 , p_component_appl_id => l_component_appl_id
4456 , p_amb_context_code => l_amb_context_code
4457 , p_side => 'NA'
4458 );
4459
4460
4461 --
4462 --
4463 END IF;
4464
4465 --
4466 -- Update the line information that should be overwritten
4467 --
4468 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
4469 p_header_num => 1);
4470 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
4471
4472 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
4473
4474 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
4475 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
4476 END IF;
4477
4478 --
4479 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
4480 --
4481 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
4482 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
4483 ELSE
4484 ---------------------------------------------------------------------------------------------------
4485 -- 4262811a Switch Sign
4486 ---------------------------------------------------------------------------------------------------
4487 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
4488 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
4489 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4490 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
4491 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4492 -- 5132302
4493 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
4494 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
4495
4496 END IF;
4497
4498 -- 4955764
4499 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4500 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
4501
4502
4503 XLA_AE_LINES_PKG.ValidateCurrentLine;
4504 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
4505
4506 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4507 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
4508 ,p_balance_type_code => l_balance_type_code);
4509
4510 END IF;
4511
4512 -----------------------------------------------------------------------------------------
4513 -- 4262811 Multiperiod Accounting
4514 -----------------------------------------------------------------------------------------
4515 -- No MPA option is assigned.
4516
4517
4518 END IF;
4519 END IF;
4520 --
4521
4522 --
4523 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4524 trace
4525 (p_msg => 'END of AcctLineType_29'
4526 ,p_level => C_LEVEL_PROCEDURE
4527 ,p_module => l_log_module);
4528 END IF;
4529 --
4530 EXCEPTION
4531 WHEN xla_exceptions_pkg.application_exception THEN
4532 RAISE;
4533 WHEN OTHERS THEN
4534 xla_exceptions_pkg.raise_message
4535 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_29');
4536 END AcctLineType_29;
4537 --
4538
4539 ---------------------------------------
4540 --
4541 -- PRIVATE FUNCTION
4542 -- AcctLineType_30
4543 --
4544 ---------------------------------------
4545 PROCEDURE AcctLineType_30 (
4546 p_application_id IN NUMBER
4547 ,p_event_id IN NUMBER
4548 ,p_calculate_acctd_flag IN VARCHAR2
4549 ,p_calculate_g_l_flag IN VARCHAR2
4550 ,p_actual_flag IN OUT VARCHAR2
4551 ,p_balance_type_code OUT VARCHAR2
4552 ,p_gain_or_loss_ref OUT VARCHAR2
4553
4554 --Distribution GL Account
4555 , p_source_5 IN NUMBER
4556 --Distribution Source Type
4557 , p_source_20 IN VARCHAR2
4558 --Receivable Activity Type
4559 , p_source_21 IN VARCHAR2
4560 --Distribution Line Identifier
4561 , p_source_22 IN NUMBER
4562 --Distribution Type
4563 , p_source_23 IN VARCHAR2
4564 --Entered Amount
4565 , p_source_24 IN NUMBER
4566 --Currency Code
4567 , p_source_25 IN VARCHAR2
4568 --Exchange Date
4569 , p_source_26 IN DATE
4570 --Exchange Rate
4571 , p_source_27 IN NUMBER
4572 --Exchange Rate Type
4573 , p_source_28 IN VARCHAR2
4574 --Applied To Document Accounting Amount
4575 , p_source_29 IN NUMBER
4576 --Bill To Customer Account Identifier
4577 , p_source_30 IN NUMBER
4578 --Bill To Customer Site Use Identifier
4579 , p_source_31 IN NUMBER
4580 --SLA Party Type
4581 , p_source_32 IN VARCHAR2
4582 )
4583 IS
4584
4588 l_component_appl_id INTEGER;
4585 l_component_type VARCHAR2(80);
4586 l_component_code VARCHAR2(30);
4587 l_component_type_code VARCHAR2(1);
4589 l_amb_context_code VARCHAR2(30);
4590 l_entity_code VARCHAR2(30);
4591 l_event_class_code VARCHAR2(30);
4592 l_ae_header_id NUMBER;
4593 l_event_type_code VARCHAR2(30);
4594 l_line_definition_code VARCHAR2(30);
4595 l_line_definition_owner_code VARCHAR2(1);
4596 --
4597 -- adr variables
4598 l_segment VARCHAR2(30);
4599 l_ccid NUMBER;
4600 l_adr_transaction_coa_id NUMBER;
4601 l_adr_accounting_coa_id NUMBER;
4602 l_adr_flexfield_segment_code VARCHAR2(30);
4603 l_adr_flex_value_set_id NUMBER;
4604 l_adr_value_type_code VARCHAR2(30);
4605 l_adr_value_combination_id NUMBER;
4606 l_adr_value_segment_code VARCHAR2(30);
4607
4608 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
4609 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
4610 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
4611 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
4612
4613 -- 4262811 Variables ------------------------------------------------------------------------------------------
4614 l_entered_amt_idx NUMBER;
4615 l_accted_amt_idx NUMBER;
4616 l_acc_rev_flag VARCHAR2(1);
4617 l_accrual_line_num NUMBER;
4618 l_tmp_amt NUMBER;
4619 l_acc_rev_natural_side_code VARCHAR2(1);
4620
4621 l_num_entries NUMBER;
4622 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
4623 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
4624 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
4625 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
4626 l_recog_line_1 NUMBER;
4627 l_recog_line_2 NUMBER;
4628
4629 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
4630 l_bflow_applied_to_amt NUMBER; -- 5132302
4631 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
4632
4633 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
4634
4635 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
4636 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
4637
4638 ---------------------------------------------------------------------------------------------------------------
4639
4640
4641 --
4642 -- bulk performance
4643 --
4644 l_balance_type_code VARCHAR2(1);
4645 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
4646 l_log_module VARCHAR2(240);
4647
4648 --
4649 -- Upgrade strategy
4650 --
4651 l_actual_upg_option VARCHAR2(1);
4652 l_enc_upg_option VARCHAR2(1);
4653
4654 --
4655 BEGIN
4656 --
4657 IF g_log_enabled THEN
4658 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_30';
4659 END IF;
4660 --
4661 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4662
4663 trace
4664 (p_msg => 'BEGIN of AcctLineType_30'
4665 ,p_level => C_LEVEL_PROCEDURE
4666 ,p_module => l_log_module);
4667
4668 END IF;
4669 --
4670 l_component_type := 'AMB_JLT';
4671 l_component_code := 'ADJ_BR_ENDORSE';
4672 l_component_type_code := 'S';
4673 l_component_appl_id := 222;
4674 l_amb_context_code := 'DEFAULT';
4675 l_entity_code := 'ADJUSTMENTS';
4676 l_event_class_code := 'ADJUSTMENT';
4677 l_event_type_code := 'ADJUSTMENT_ALL';
4678 l_line_definition_owner_code := 'S';
4679 l_line_definition_code := 'AR_ADJ_DEFAULT_ACCRUAL';
4680 --
4681 l_balance_type_code := 'A';
4682 l_segment := NULL;
4683 l_ccid := NULL;
4684 l_adr_transaction_coa_id := NULL;
4685 l_adr_accounting_coa_id := NULL;
4686 l_adr_flexfield_segment_code := NULL;
4687 l_adr_flex_value_set_id := NULL;
4688 l_adr_value_type_code := NULL;
4689 l_adr_value_combination_id := NULL;
4690 l_adr_value_segment_code := NULL;
4691
4692 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
4693 l_bflow_class_code := ''; -- 4219869 Business Flow
4694 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
4695 l_budgetary_control_flag := 'N';
4696
4697 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4698 l_bflow_applied_to_amt := NULL; -- 5132302
4699 l_entered_amt_idx := NULL; -- 4262811
4700 l_accted_amt_idx := NULL; -- 4262811
4701 l_acc_rev_flag := NULL; -- 4262811
4702 l_accrual_line_num := NULL; -- 4262811
4703 l_tmp_amt := NULL; -- 4262811
4704 --
4705
4706 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
4707 l_balance_type_code <> 'B' THEN
4708 IF NVL(p_source_20,'
4709 ') = 'ADJ' AND
4710 NVL(p_source_21,'
4711 ') = 'ENDORSEMENT'
4712 THEN
4713
4714 --
4715 XLA_AE_LINES_PKG.SetNewLine;
4716
4717 p_balance_type_code := l_balance_type_code;
4718 -- set the flag so later we will know whether the gain loss line needs to be created
4719
4720 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
4721 p_actual_flag :='A';
4722 END IF;
4723
4724 --
4725 -- bulk performance
4726 --
4727 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
4728 p_header_num => 0); -- 4262811
4729 --
4730 -- set accounting line options
4731 --
4732 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
4733 p_natural_side_code => 'C'
4734 , p_gain_or_loss_flag => 'N'
4735 , p_gl_transfer_mode_code => 'S'
4736 , p_acct_entry_type_code => 'A'
4737 , p_switch_side_flag => 'Y'
4738 , p_merge_duplicate_code => 'A'
4739 );
4740 --
4741 l_acc_rev_natural_side_code := 'D'; -- 4262811
4742 --
4743 --
4744 -- set accounting line type info
4745 --
4746 xla_ae_lines_pkg.SetAcctLineType
4747 (p_component_type => l_component_type
4751 ,p_accounting_line_code => l_component_code
4748 ,p_event_type_code => l_event_type_code
4749 ,p_line_definition_owner_code => l_line_definition_owner_code
4750 ,p_line_definition_code => l_line_definition_code
4752 ,p_accounting_line_type_code => l_component_type_code
4753 ,p_accounting_line_appl_id => l_component_appl_id
4754 ,p_amb_context_code => l_amb_context_code
4755 ,p_entity_code => l_entity_code
4756 ,p_event_class_code => l_event_class_code);
4757 --
4758 -- set accounting class
4759 --
4760 xla_ae_lines_pkg.SetAcctClass(
4761 p_accounting_class_code => 'ENDORSEMENT'
4762 , p_ae_header_id => l_ae_header_id
4763 );
4764
4765 --
4766 -- set rounding class
4767 --
4768 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
4769 'RECEIVABLE';
4770
4771 --
4772 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
4773 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
4774 --
4775 -- bulk performance
4776 --
4777 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
4778
4779 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
4780 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
4781
4782 -- 4955764
4783 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
4784 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
4785
4786 -- 4458381 Public Sector Enh
4787
4788 --
4789 -- set accounting attributes for the line type
4790 --
4791 l_entered_amt_idx := 3;
4792 l_accted_amt_idx := 8;
4793 l_bflow_applied_to_amt_idx := NULL; -- 5132302
4794 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
4795 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
4796 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
4797 l_rec_acct_attrs.array_char_value(2) := p_source_23;
4798 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
4799 l_rec_acct_attrs.array_num_value(3) := p_source_24;
4800 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
4801 l_rec_acct_attrs.array_char_value(4) := p_source_25;
4802 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
4803 l_rec_acct_attrs.array_date_value(5) := p_source_26;
4804 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
4805 l_rec_acct_attrs.array_num_value(6) := p_source_27;
4806 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
4807 l_rec_acct_attrs.array_char_value(7) := p_source_28;
4808 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
4809 l_rec_acct_attrs.array_num_value(8) := p_source_29;
4810 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
4811 l_rec_acct_attrs.array_num_value(9) := p_source_30;
4812 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
4813 l_rec_acct_attrs.array_num_value(10) := p_source_31;
4814 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
4815 l_rec_acct_attrs.array_char_value(11) := p_source_32;
4816
4817 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
4818 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
4819
4820 ---------------------------------------------------------------------------------------------------------------
4821 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
4822 ---------------------------------------------------------------------------------------------------------------
4823 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
4824
4825 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4826 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
4827
4828 IF xla_accounting_cache_pkg.GetValueChar
4829 (p_source_code => 'LEDGER_CATEGORY_CODE'
4830 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
4831 AND l_bflow_method_code = 'PRIOR_ENTRY'
4832 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
4833 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
4834 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
4835 )
4836 THEN
4837 xla_ae_lines_pkg.BflowUpgEntry
4838 (p_business_method_code => l_bflow_method_code
4839 ,p_business_class_code => l_bflow_class_code
4840 ,p_balance_type => l_balance_type_code);
4841 ELSE
4842 NULL;
4843 -- No business flow processing for business flow method of NONE.
4844 END IF;
4845
4846 --
4850 --
4847 -- call analytical criteria
4848 --
4849
4851 -- call description
4852 --
4853 -- No description or it is inherited.
4854 --
4855 -- call ADRs
4856 -- Bug 4922099
4857 --
4858 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4859 (NVL(l_actual_upg_option, 'N') = 'O') OR
4860 (NVL(l_enc_upg_option, 'N') = 'O')
4861 )
4862 THEN
4863 NULL;
4864 --
4865 --
4866
4867 l_ccid := AcctDerRule_4(
4868 p_application_id => p_application_id
4869 , p_ae_header_id => l_ae_header_id
4870 , p_source_5 => p_source_5
4871 , x_transaction_coa_id => l_adr_transaction_coa_id
4872 , x_accounting_coa_id => l_adr_accounting_coa_id
4873 , x_value_type_code => l_adr_value_type_code
4874 , p_side => 'NA'
4875 );
4876
4877 xla_ae_lines_pkg.set_ccid(
4878 p_code_combination_id => l_ccid
4879 , p_value_type_code => l_adr_value_type_code
4880 , p_transaction_coa_id => l_adr_transaction_coa_id
4881 , p_accounting_coa_id => l_adr_accounting_coa_id
4882 , p_adr_code => 'DIST_CCID'
4883 , p_adr_type_code => 'S'
4884 , p_component_type => l_component_type
4885 , p_component_code => l_component_code
4886 , p_component_type_code => l_component_type_code
4887 , p_component_appl_id => l_component_appl_id
4888 , p_amb_context_code => l_amb_context_code
4889 , p_side => 'NA'
4890 );
4891
4892
4893 --
4894 --
4895 END IF;
4896 --
4897 -- Bug 4922099
4898 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
4899 (NVL(l_enc_upg_option, 'N') = 'O')
4900 ) AND
4901 (l_bflow_method_code = 'PRIOR_ENTRY')
4902 )
4903 THEN
4904 IF
4905 --
4906 1 = 2
4907 --
4908 THEN
4909 xla_accounting_err_pkg.build_message
4910 (p_appli_s_name => 'XLA'
4911 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4912 ,p_token_1 => 'LINE_NUMBER'
4913 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
4914 ,p_token_2 => 'LINE_TYPE_NAME'
4915 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
4916 l_component_type
4917 ,l_component_code
4918 ,l_component_type_code
4919 ,l_component_appl_id
4920 ,l_amb_context_code
4921 ,l_entity_code
4922 ,l_event_class_code
4923 )
4924 ,p_token_3 => 'OWNER'
4928 )
4925 ,p_value_3 => xla_lookups_pkg.get_meaning(
4926 p_lookup_type => 'XLA_OWNER_TYPE'
4927 ,p_lookup_code => l_component_type_code
4929 ,p_token_4 => 'PRODUCT_NAME'
4930 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
4931 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
4932 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
4933 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
4934 ,p_ae_header_id => NULL
4935 );
4936
4937 IF (C_LEVEL_ERROR>= g_log_level) THEN
4938 trace
4939 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
4940 ,p_level => C_LEVEL_ERROR
4941 ,p_module => l_log_module);
4942 END IF;
4943 END IF;
4944 END IF;
4945 --
4946 --
4947 ------------------------------------------------------------------------------------------------
4948 -- 4219869 Business Flow
4949 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
4950 -- Prior Entry. Currently, the following code is always generated.
4951 ------------------------------------------------------------------------------------------------
4952 XLA_AE_LINES_PKG.ValidateCurrentLine;
4953
4954 ------------------------------------------------------------------------------------
4955 -- 4219869 Business Flow
4956 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
4957 ------------------------------------------------------------------------------------
4958 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
4959
4960 ----------------------------------------------------------------------------------
4961 -- 4219869 Business Flow
4962 -- Update journal entry status -- Need to generate this within IF <condition>
4963 ----------------------------------------------------------------------------------
4964 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
4965 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
4966 ,p_balance_type_code => l_balance_type_code
4967 );
4968
4969 -------------------------------------------------------------------------------------------
4970 -- 4262811 - Generate the Accrual Reversal lines
4971 -------------------------------------------------------------------------------------------
4972 BEGIN
4973 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
4974 (g_array_event(p_event_id).array_value_num('header_index'));
4975 IF l_acc_rev_flag IS NULL THEN
4976 l_acc_rev_flag := 'N';
4977 END IF;
4978 EXCEPTION
4979 WHEN OTHERS THEN
4980 l_acc_rev_flag := 'N';
4981 END;
4982 --
4983 IF (l_acc_rev_flag = 'Y') THEN
4984
4985 -- 4645092 ------------------------------------------------------------------------------
4986 -- To allow MPA report to determine if it should generate report process
4987 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
4988 ------------------------------------------------------------------------------------------
4989
4990 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
4991 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
4992 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
4993 -- call ADRs
4994 -- Bug 4922099
4995 --
4996 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
4997 (NVL(l_actual_upg_option, 'N') = 'O') OR
4998 (NVL(l_enc_upg_option, 'N') = 'O')
4999 )
5000 THEN
5001 NULL;
5002 --
5003 --
5004
5005 l_ccid := AcctDerRule_4(
5006 p_application_id => p_application_id
5007 , p_ae_header_id => l_ae_header_id
5008 , p_source_5 => p_source_5
5009 , x_transaction_coa_id => l_adr_transaction_coa_id
5010 , x_accounting_coa_id => l_adr_accounting_coa_id
5011 , x_value_type_code => l_adr_value_type_code
5012 , p_side => 'NA'
5013 );
5014
5015 xla_ae_lines_pkg.set_ccid(
5016 p_code_combination_id => l_ccid
5017 , p_value_type_code => l_adr_value_type_code
5018 , p_transaction_coa_id => l_adr_transaction_coa_id
5019 , p_accounting_coa_id => l_adr_accounting_coa_id
5020 , p_adr_code => 'DIST_CCID'
5021 , p_adr_type_code => 'S'
5022 , p_component_type => l_component_type
5023 , p_component_code => l_component_code
5024 , p_component_type_code => l_component_type_code
5025 , p_component_appl_id => l_component_appl_id
5026 , p_amb_context_code => l_amb_context_code
5027 , p_side => 'NA'
5028 );
5029
5030
5031 --
5032 --
5033 END IF;
5034
5035 --
5036 -- Update the line information that should be overwritten
5037 --
5038 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
5039 p_header_num => 1);
5043
5040 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
5041
5042 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
5044 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
5045 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
5046 END IF;
5047
5048 --
5049 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
5050 --
5051 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
5052 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
5053 ELSE
5054 ---------------------------------------------------------------------------------------------------
5055 -- 4262811a Switch Sign
5056 ---------------------------------------------------------------------------------------------------
5057 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
5058 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5059 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5060 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5061 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5062 -- 5132302
5063 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
5064 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5065
5066 END IF;
5067
5068 -- 4955764
5069 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5070 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
5071
5072
5073 XLA_AE_LINES_PKG.ValidateCurrentLine;
5074 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5075
5076 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5077 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
5078 ,p_balance_type_code => l_balance_type_code);
5079
5080 END IF;
5081
5082 -----------------------------------------------------------------------------------------
5083 -- 4262811 Multiperiod Accounting
5084 -----------------------------------------------------------------------------------------
5085 -- No MPA option is assigned.
5086
5087
5088 END IF;
5089 END IF;
5090 --
5091
5092 --
5093 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5094 trace
5095 (p_msg => 'END of AcctLineType_30'
5096 ,p_level => C_LEVEL_PROCEDURE
5097 ,p_module => l_log_module);
5098 END IF;
5099 --
5100 EXCEPTION
5101 WHEN xla_exceptions_pkg.application_exception THEN
5102 RAISE;
5103 WHEN OTHERS THEN
5104 xla_exceptions_pkg.raise_message
5105 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_30');
5106 END AcctLineType_30;
5107 --
5108
5109 ---------------------------------------
5110 --
5111 -- PRIVATE FUNCTION
5112 -- AcctLineType_31
5113 --
5114 ---------------------------------------
5115 PROCEDURE AcctLineType_31 (
5116 p_application_id IN NUMBER
5117 ,p_event_id IN NUMBER
5118 ,p_calculate_acctd_flag IN VARCHAR2
5119 ,p_calculate_g_l_flag IN VARCHAR2
5120 ,p_actual_flag IN OUT VARCHAR2
5121 ,p_balance_type_code OUT VARCHAR2
5122 ,p_gain_or_loss_ref OUT VARCHAR2
5123
5124 --Distribution GL Account
5125 , p_source_5 IN NUMBER
5126 --Distribution Source Type
5127 , p_source_20 IN VARCHAR2
5128 --Distribution Line Identifier
5129 , p_source_22 IN NUMBER
5130 --Distribution Type
5131 , p_source_23 IN VARCHAR2
5132 --Entered Amount
5133 , p_source_24 IN NUMBER
5134 --Currency Code
5135 , p_source_25 IN VARCHAR2
5136 --Exchange Date
5137 , p_source_26 IN DATE
5138 --Exchange Rate
5139 , p_source_27 IN NUMBER
5140 --Exchange Rate Type
5141 , p_source_28 IN VARCHAR2
5142 --Applied To Document Accounting Amount
5143 , p_source_29 IN NUMBER
5144 --Bill To Customer Account Identifier
5145 , p_source_30 IN NUMBER
5146 --Bill To Customer Site Use Identifier
5147 , p_source_31 IN NUMBER
5148 --SLA Party Type
5149 , p_source_32 IN VARCHAR2
5150 )
5151 IS
5152
5153 l_component_type VARCHAR2(80);
5154 l_component_code VARCHAR2(30);
5155 l_component_type_code VARCHAR2(1);
5156 l_component_appl_id INTEGER;
5157 l_amb_context_code VARCHAR2(30);
5158 l_entity_code VARCHAR2(30);
5159 l_event_class_code VARCHAR2(30);
5160 l_ae_header_id NUMBER;
5161 l_event_type_code VARCHAR2(30);
5162 l_line_definition_code VARCHAR2(30);
5163 l_line_definition_owner_code VARCHAR2(1);
5164 --
5165 -- adr variables
5166 l_segment VARCHAR2(30);
5167 l_ccid NUMBER;
5168 l_adr_transaction_coa_id NUMBER;
5169 l_adr_accounting_coa_id NUMBER;
5170 l_adr_flexfield_segment_code VARCHAR2(30);
5174 l_adr_value_segment_code VARCHAR2(30);
5171 l_adr_flex_value_set_id NUMBER;
5172 l_adr_value_type_code VARCHAR2(30);
5173 l_adr_value_combination_id NUMBER;
5175
5176 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
5177 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
5178 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
5179 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
5180
5181 -- 4262811 Variables ------------------------------------------------------------------------------------------
5182 l_entered_amt_idx NUMBER;
5183 l_accted_amt_idx NUMBER;
5184 l_acc_rev_flag VARCHAR2(1);
5185 l_accrual_line_num NUMBER;
5186 l_tmp_amt NUMBER;
5187 l_acc_rev_natural_side_code VARCHAR2(1);
5188
5189 l_num_entries NUMBER;
5190 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
5191 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
5192 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
5193 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
5194 l_recog_line_1 NUMBER;
5195 l_recog_line_2 NUMBER;
5196
5197 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
5198 l_bflow_applied_to_amt NUMBER; -- 5132302
5199 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
5200
5201 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
5202
5203 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
5204 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
5205
5206 ---------------------------------------------------------------------------------------------------------------
5207
5208
5209 --
5210 -- bulk performance
5211 --
5212 l_balance_type_code VARCHAR2(1);
5213 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
5214 l_log_module VARCHAR2(240);
5215
5216 --
5217 -- Upgrade strategy
5218 --
5219 l_actual_upg_option VARCHAR2(1);
5220 l_enc_upg_option VARCHAR2(1);
5221
5222 --
5223 BEGIN
5224 --
5225 IF g_log_enabled THEN
5226 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_31';
5227 END IF;
5228 --
5229 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5230
5231 trace
5232 (p_msg => 'BEGIN of AcctLineType_31'
5233 ,p_level => C_LEVEL_PROCEDURE
5234 ,p_module => l_log_module);
5235
5236 END IF;
5237 --
5238 l_component_type := 'AMB_JLT';
5239 l_component_code := 'ADJ_CHRG';
5240 l_component_type_code := 'S';
5241 l_component_appl_id := 222;
5242 l_amb_context_code := 'DEFAULT';
5243 l_entity_code := 'ADJUSTMENTS';
5244 l_event_class_code := 'ADJUSTMENT';
5245 l_event_type_code := 'ADJUSTMENT_ALL';
5246 l_line_definition_owner_code := 'S';
5247 l_line_definition_code := 'AR_ADJ_DEFAULT_ACCRUAL';
5248 --
5249 l_balance_type_code := 'A';
5250 l_segment := NULL;
5251 l_ccid := NULL;
5252 l_adr_transaction_coa_id := NULL;
5253 l_adr_accounting_coa_id := NULL;
5254 l_adr_flexfield_segment_code := NULL;
5255 l_adr_flex_value_set_id := NULL;
5256 l_adr_value_type_code := NULL;
5257 l_adr_value_combination_id := NULL;
5258 l_adr_value_segment_code := NULL;
5259
5260 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
5261 l_bflow_class_code := ''; -- 4219869 Business Flow
5262 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
5263 l_budgetary_control_flag := 'N';
5264
5265 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5266 l_bflow_applied_to_amt := NULL; -- 5132302
5267 l_entered_amt_idx := NULL; -- 4262811
5268 l_accted_amt_idx := NULL; -- 4262811
5269 l_acc_rev_flag := NULL; -- 4262811
5270 l_accrual_line_num := NULL; -- 4262811
5271 l_tmp_amt := NULL; -- 4262811
5272 --
5273
5274 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
5275 l_balance_type_code <> 'B' THEN
5276 IF NVL(p_source_20,'
5277 ') = 'FINCHRG' OR
5278 NVL(p_source_20,'
5279 ') = 'FINCHRG_NON_REC_TAX'
5280 THEN
5281
5282 --
5283 XLA_AE_LINES_PKG.SetNewLine;
5284
5285 p_balance_type_code := l_balance_type_code;
5286 -- set the flag so later we will know whether the gain loss line needs to be created
5287
5288 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
5289 p_actual_flag :='A';
5290 END IF;
5291
5292 --
5293 -- bulk performance
5294 --
5295 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
5296 p_header_num => 0); -- 4262811
5297 --
5298 -- set accounting line options
5299 --
5300 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
5301 p_natural_side_code => 'C'
5302 , p_gain_or_loss_flag => 'N'
5303 , p_gl_transfer_mode_code => 'S'
5304 , p_acct_entry_type_code => 'A'
5305 , p_switch_side_flag => 'Y'
5306 , p_merge_duplicate_code => 'A'
5307 );
5308 --
5309 l_acc_rev_natural_side_code := 'D'; -- 4262811
5313 --
5310 --
5311 --
5312 -- set accounting line type info
5314 xla_ae_lines_pkg.SetAcctLineType
5315 (p_component_type => l_component_type
5316 ,p_event_type_code => l_event_type_code
5317 ,p_line_definition_owner_code => l_line_definition_owner_code
5318 ,p_line_definition_code => l_line_definition_code
5319 ,p_accounting_line_code => l_component_code
5320 ,p_accounting_line_type_code => l_component_type_code
5321 ,p_accounting_line_appl_id => l_component_appl_id
5322 ,p_amb_context_code => l_amb_context_code
5323 ,p_entity_code => l_entity_code
5324 ,p_event_class_code => l_event_class_code);
5325 --
5326 -- set accounting class
5327 --
5328 xla_ae_lines_pkg.SetAcctClass(
5329 p_accounting_class_code => 'CHARGES'
5330 , p_ae_header_id => l_ae_header_id
5331 );
5332
5333 --
5334 -- set rounding class
5335 --
5339 --
5336 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
5337 'RECEIVABLE';
5338
5340 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
5341 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
5342 --
5343 -- bulk performance
5344 --
5345 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
5346
5347 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
5348 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
5349
5350 -- 4955764
5351 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5352 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
5353
5354 -- 4458381 Public Sector Enh
5355
5356 --
5357 -- set accounting attributes for the line type
5358 --
5359 l_entered_amt_idx := 3;
5360 l_accted_amt_idx := 8;
5361 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5362 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
5363 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
5364 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
5365 l_rec_acct_attrs.array_char_value(2) := p_source_23;
5366 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
5367 l_rec_acct_attrs.array_num_value(3) := p_source_24;
5368 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
5369 l_rec_acct_attrs.array_char_value(4) := p_source_25;
5370 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
5371 l_rec_acct_attrs.array_date_value(5) := p_source_26;
5372 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
5373 l_rec_acct_attrs.array_num_value(6) := p_source_27;
5374 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
5375 l_rec_acct_attrs.array_char_value(7) := p_source_28;
5376 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
5377 l_rec_acct_attrs.array_num_value(8) := p_source_29;
5378 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
5379 l_rec_acct_attrs.array_num_value(9) := p_source_30;
5380 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
5381 l_rec_acct_attrs.array_num_value(10) := p_source_31;
5382 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
5383 l_rec_acct_attrs.array_char_value(11) := p_source_32;
5384
5385 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
5386 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
5387
5388 ---------------------------------------------------------------------------------------------------------------
5389 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
5390 ---------------------------------------------------------------------------------------------------------------
5391 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
5392
5393 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5394 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5395
5396 IF xla_accounting_cache_pkg.GetValueChar
5397 (p_source_code => 'LEDGER_CATEGORY_CODE'
5398 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
5399 AND l_bflow_method_code = 'PRIOR_ENTRY'
5400 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
5401 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
5402 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
5403 )
5404 THEN
5405 xla_ae_lines_pkg.BflowUpgEntry
5406 (p_business_method_code => l_bflow_method_code
5407 ,p_business_class_code => l_bflow_class_code
5408 ,p_balance_type => l_balance_type_code);
5409 ELSE
5410 NULL;
5411 -- No business flow processing for business flow method of NONE.
5412 END IF;
5413
5414 --
5415 -- call analytical criteria
5416 --
5417
5418 --
5419 -- call description
5420 --
5421 -- No description or it is inherited.
5422 --
5423 -- call ADRs
5424 -- Bug 4922099
5425 --
5426 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5427 (NVL(l_actual_upg_option, 'N') = 'O') OR
5428 (NVL(l_enc_upg_option, 'N') = 'O')
5429 )
5430 THEN
5431 NULL;
5432 --
5433 --
5434
5435 l_ccid := AcctDerRule_4(
5436 p_application_id => p_application_id
5437 , p_ae_header_id => l_ae_header_id
5438 , p_source_5 => p_source_5
5439 , x_transaction_coa_id => l_adr_transaction_coa_id
5440 , x_accounting_coa_id => l_adr_accounting_coa_id
5441 , x_value_type_code => l_adr_value_type_code
5442 , p_side => 'NA'
5443 );
5444
5445 xla_ae_lines_pkg.set_ccid(
5446 p_code_combination_id => l_ccid
5447 , p_value_type_code => l_adr_value_type_code
5448 , p_transaction_coa_id => l_adr_transaction_coa_id
5449 , p_accounting_coa_id => l_adr_accounting_coa_id
5450 , p_adr_code => 'DIST_CCID'
5451 , p_adr_type_code => 'S'
5452 , p_component_type => l_component_type
5453 , p_component_code => l_component_code
5454 , p_component_type_code => l_component_type_code
5455 , p_component_appl_id => l_component_appl_id
5456 , p_amb_context_code => l_amb_context_code
5457 , p_side => 'NA'
5458 );
5459
5460
5461 --
5462 --
5463 END IF;
5464 --
5465 -- Bug 4922099
5466 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
5467 (NVL(l_enc_upg_option, 'N') = 'O')
5468 ) AND
5469 (l_bflow_method_code = 'PRIOR_ENTRY')
5470 )
5471 THEN
5472 IF
5473 --
5474 1 = 2
5475 --
5476 THEN
5477 xla_accounting_err_pkg.build_message
5478 (p_appli_s_name => 'XLA'
5479 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5480 ,p_token_1 => 'LINE_NUMBER'
5481 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
5482 ,p_token_2 => 'LINE_TYPE_NAME'
5483 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
5484 l_component_type
5485 ,l_component_code
5486 ,l_component_type_code
5487 ,l_component_appl_id
5488 ,l_amb_context_code
5489 ,l_entity_code
5490 ,l_event_class_code
5491 )
5492 ,p_token_3 => 'OWNER'
5493 ,p_value_3 => xla_lookups_pkg.get_meaning(
5494 p_lookup_type => 'XLA_OWNER_TYPE'
5495 ,p_lookup_code => l_component_type_code
5496 )
5497 ,p_token_4 => 'PRODUCT_NAME'
5498 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
5499 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
5500 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
5501 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
5502 ,p_ae_header_id => NULL
5503 );
5504
5505 IF (C_LEVEL_ERROR>= g_log_level) THEN
5506 trace
5507 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
5508 ,p_level => C_LEVEL_ERROR
5509 ,p_module => l_log_module);
5510 END IF;
5511 END IF;
5512 END IF;
5513 --
5514 --
5515 ------------------------------------------------------------------------------------------------
5516 -- 4219869 Business Flow
5517 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
5518 -- Prior Entry. Currently, the following code is always generated.
5519 ------------------------------------------------------------------------------------------------
5520 XLA_AE_LINES_PKG.ValidateCurrentLine;
5521
5522 ------------------------------------------------------------------------------------
5523 -- 4219869 Business Flow
5524 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
5525 ------------------------------------------------------------------------------------
5526 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5527
5528 ----------------------------------------------------------------------------------
5529 -- 4219869 Business Flow
5530 -- Update journal entry status -- Need to generate this within IF <condition>
5531 ----------------------------------------------------------------------------------
5532 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5533 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
5534 ,p_balance_type_code => l_balance_type_code
5535 );
5536
5537 -------------------------------------------------------------------------------------------
5538 -- 4262811 - Generate the Accrual Reversal lines
5539 -------------------------------------------------------------------------------------------
5540 BEGIN
5541 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
5542 (g_array_event(p_event_id).array_value_num('header_index'));
5543 IF l_acc_rev_flag IS NULL THEN
5544 l_acc_rev_flag := 'N';
5545 END IF;
5546 EXCEPTION
5547 WHEN OTHERS THEN
5548 l_acc_rev_flag := 'N';
5549 END;
5550 --
5551 IF (l_acc_rev_flag = 'Y') THEN
5552
5553 -- 4645092 ------------------------------------------------------------------------------
5554 -- To allow MPA report to determine if it should generate report process
5555 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
5556 ------------------------------------------------------------------------------------------
5557
5558 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
5559 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
5560 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
5561 -- call ADRs
5562 -- Bug 4922099
5563 --
5564 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5565 (NVL(l_actual_upg_option, 'N') = 'O') OR
5566 (NVL(l_enc_upg_option, 'N') = 'O')
5567 )
5568 THEN
5569 NULL;
5570 --
5571 --
5572
5573 l_ccid := AcctDerRule_4(
5574 p_application_id => p_application_id
5575 , p_ae_header_id => l_ae_header_id
5576 , p_source_5 => p_source_5
5577 , x_transaction_coa_id => l_adr_transaction_coa_id
5578 , x_accounting_coa_id => l_adr_accounting_coa_id
5579 , x_value_type_code => l_adr_value_type_code
5580 , p_side => 'NA'
5581 );
5582
5583 xla_ae_lines_pkg.set_ccid(
5584 p_code_combination_id => l_ccid
5585 , p_value_type_code => l_adr_value_type_code
5586 , p_transaction_coa_id => l_adr_transaction_coa_id
5587 , p_accounting_coa_id => l_adr_accounting_coa_id
5588 , p_adr_code => 'DIST_CCID'
5589 , p_adr_type_code => 'S'
5590 , p_component_type => l_component_type
5591 , p_component_code => l_component_code
5592 , p_component_type_code => l_component_type_code
5593 , p_component_appl_id => l_component_appl_id
5594 , p_amb_context_code => l_amb_context_code
5595 , p_side => 'NA'
5596 );
5597
5598
5599 --
5600 --
5601 END IF;
5602
5603 --
5604 -- Update the line information that should be overwritten
5605 --
5606 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
5607 p_header_num => 1);
5608 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
5609
5610 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
5611
5612 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
5613 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
5614 END IF;
5615
5616 --
5617 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
5618 --
5619 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
5620 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
5621 ELSE
5622 ---------------------------------------------------------------------------------------------------
5623 -- 4262811a Switch Sign
5624 ---------------------------------------------------------------------------------------------------
5625 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
5626 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5627 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5628 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
5629 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5630 -- 5132302
5631 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
5632 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
5633
5634 END IF;
5635
5636 -- 4955764
5637 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5638 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
5639
5640
5641 XLA_AE_LINES_PKG.ValidateCurrentLine;
5642 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
5643
5644 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
5645 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
5646 ,p_balance_type_code => l_balance_type_code);
5647
5648 END IF;
5649
5650 -----------------------------------------------------------------------------------------
5651 -- 4262811 Multiperiod Accounting
5652 -----------------------------------------------------------------------------------------
5653 -- No MPA option is assigned.
5654
5655
5656 END IF;
5657 END IF;
5658 --
5659
5660 --
5661 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5662 trace
5663 (p_msg => 'END of AcctLineType_31'
5664 ,p_level => C_LEVEL_PROCEDURE
5665 ,p_module => l_log_module);
5666 END IF;
5667 --
5668 EXCEPTION
5669 WHEN xla_exceptions_pkg.application_exception THEN
5670 RAISE;
5671 WHEN OTHERS THEN
5672 xla_exceptions_pkg.raise_message
5673 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_31');
5674 END AcctLineType_31;
5675 --
5676
5677 ---------------------------------------
5678 --
5679 -- PRIVATE FUNCTION
5680 -- AcctLineType_32
5681 --
5682 ---------------------------------------
5683 PROCEDURE AcctLineType_32 (
5684 p_application_id IN NUMBER
5685 ,p_event_id IN NUMBER
5686 ,p_calculate_acctd_flag IN VARCHAR2
5687 ,p_calculate_g_l_flag IN VARCHAR2
5688 ,p_actual_flag IN OUT VARCHAR2
5689 ,p_balance_type_code OUT VARCHAR2
5690 ,p_gain_or_loss_ref OUT VARCHAR2
5691
5692 --Distribution GL Account
5693 , p_source_5 IN NUMBER
5694 --Distribution Source Type
5695 , p_source_20 IN VARCHAR2
5696 --Distribution Line Identifier
5697 , p_source_22 IN NUMBER
5698 --Distribution Type
5699 , p_source_23 IN VARCHAR2
5700 --Entered Amount
5701 , p_source_24 IN NUMBER
5702 --Currency Code
5703 , p_source_25 IN VARCHAR2
5704 --Exchange Date
5705 , p_source_26 IN DATE
5706 --Exchange Rate
5707 , p_source_27 IN NUMBER
5708 --Exchange Rate Type
5709 , p_source_28 IN VARCHAR2
5710 --Applied To Document Accounting Amount
5711 , p_source_29 IN NUMBER
5712 --Bill To Customer Account Identifier
5713 , p_source_30 IN NUMBER
5714 --Bill To Customer Site Use Identifier
5715 , p_source_31 IN NUMBER
5716 --SLA Party Type
5717 , p_source_32 IN VARCHAR2
5718 )
5719 IS
5720
5721 l_component_type VARCHAR2(80);
5722 l_component_code VARCHAR2(30);
5723 l_component_type_code VARCHAR2(1);
5724 l_component_appl_id INTEGER;
5725 l_amb_context_code VARCHAR2(30);
5726 l_entity_code VARCHAR2(30);
5727 l_event_class_code VARCHAR2(30);
5728 l_ae_header_id NUMBER;
5729 l_event_type_code VARCHAR2(30);
5730 l_line_definition_code VARCHAR2(30);
5731 l_line_definition_owner_code VARCHAR2(1);
5732 --
5733 -- adr variables
5734 l_segment VARCHAR2(30);
5735 l_ccid NUMBER;
5736 l_adr_transaction_coa_id NUMBER;
5737 l_adr_accounting_coa_id NUMBER;
5738 l_adr_flexfield_segment_code VARCHAR2(30);
5739 l_adr_flex_value_set_id NUMBER;
5740 l_adr_value_type_code VARCHAR2(30);
5741 l_adr_value_combination_id NUMBER;
5742 l_adr_value_segment_code VARCHAR2(30);
5743
5744 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
5745 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
5746 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
5747 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
5748
5749 -- 4262811 Variables ------------------------------------------------------------------------------------------
5750 l_entered_amt_idx NUMBER;
5751 l_accted_amt_idx NUMBER;
5752 l_acc_rev_flag VARCHAR2(1);
5753 l_accrual_line_num NUMBER;
5754 l_tmp_amt NUMBER;
5755 l_acc_rev_natural_side_code VARCHAR2(1);
5756
5757 l_num_entries NUMBER;
5758 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
5759 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
5760 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
5761 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
5762 l_recog_line_1 NUMBER;
5763 l_recog_line_2 NUMBER;
5764
5765 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
5766 l_bflow_applied_to_amt NUMBER; -- 5132302
5767 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
5768
5769 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
5770
5771 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
5772 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
5773
5774 ---------------------------------------------------------------------------------------------------------------
5775
5776
5777 --
5778 -- bulk performance
5779 --
5780 l_balance_type_code VARCHAR2(1);
5781 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
5782 l_log_module VARCHAR2(240);
5783
5784 --
5785 -- Upgrade strategy
5786 --
5787 l_actual_upg_option VARCHAR2(1);
5788 l_enc_upg_option VARCHAR2(1);
5789
5790 --
5791 BEGIN
5792 --
5793 IF g_log_enabled THEN
5794 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_32';
5795 END IF;
5796 --
5797 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
5798
5799 trace
5800 (p_msg => 'BEGIN of AcctLineType_32'
5801 ,p_level => C_LEVEL_PROCEDURE
5802 ,p_module => l_log_module);
5803
5804 END IF;
5805 --
5806 l_component_type := 'AMB_JLT';
5807 l_component_code := 'ADJ_DEFAULT_REC';
5808 l_component_type_code := 'S';
5809 l_component_appl_id := 222;
5810 l_amb_context_code := 'DEFAULT';
5811 l_entity_code := 'ADJUSTMENTS';
5812 l_event_class_code := 'ADJUSTMENT';
5813 l_event_type_code := 'ADJUSTMENT_ALL';
5814 l_line_definition_owner_code := 'S';
5815 l_line_definition_code := 'AR_ADJ_DEFAULT_ACCRUAL';
5816 --
5817 l_balance_type_code := 'A';
5818 l_segment := NULL;
5819 l_ccid := NULL;
5820 l_adr_transaction_coa_id := NULL;
5821 l_adr_accounting_coa_id := NULL;
5822 l_adr_flexfield_segment_code := NULL;
5823 l_adr_flex_value_set_id := NULL;
5824 l_adr_value_type_code := NULL;
5825 l_adr_value_combination_id := NULL;
5826 l_adr_value_segment_code := NULL;
5827
5828 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
5829 l_bflow_class_code := ''; -- 4219869 Business Flow
5830 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
5831 l_budgetary_control_flag := 'N';
5832
5833 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5834 l_bflow_applied_to_amt := NULL; -- 5132302
5835 l_entered_amt_idx := NULL; -- 4262811
5836 l_accted_amt_idx := NULL; -- 4262811
5837 l_acc_rev_flag := NULL; -- 4262811
5838 l_accrual_line_num := NULL; -- 4262811
5839 l_tmp_amt := NULL; -- 4262811
5840 --
5841
5842 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
5843 l_balance_type_code <> 'B' THEN
5844 IF NVL(p_source_20,'
5845 ') = 'REC'
5846 THEN
5847
5848 --
5849 XLA_AE_LINES_PKG.SetNewLine;
5850
5851 p_balance_type_code := l_balance_type_code;
5852 -- set the flag so later we will know whether the gain loss line needs to be created
5853
5854 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
5855 p_actual_flag :='A';
5856 END IF;
5857
5858 --
5859 -- bulk performance
5860 --
5861 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
5862 p_header_num => 0); -- 4262811
5863 --
5864 -- set accounting line options
5865 --
5866 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
5867 p_natural_side_code => 'C'
5868 , p_gain_or_loss_flag => 'N'
5869 , p_gl_transfer_mode_code => 'S'
5870 , p_acct_entry_type_code => 'A'
5871 , p_switch_side_flag => 'Y'
5872 , p_merge_duplicate_code => 'A'
5873 );
5874 --
5875 l_acc_rev_natural_side_code := 'D'; -- 4262811
5876 --
5877 --
5878 -- set accounting line type info
5879 --
5880 xla_ae_lines_pkg.SetAcctLineType
5881 (p_component_type => l_component_type
5882 ,p_event_type_code => l_event_type_code
5883 ,p_line_definition_owner_code => l_line_definition_owner_code
5884 ,p_line_definition_code => l_line_definition_code
5885 ,p_accounting_line_code => l_component_code
5886 ,p_accounting_line_type_code => l_component_type_code
5887 ,p_accounting_line_appl_id => l_component_appl_id
5888 ,p_amb_context_code => l_amb_context_code
5889 ,p_entity_code => l_entity_code
5890 ,p_event_class_code => l_event_class_code);
5891 --
5892 -- set accounting class
5893 --
5894 xla_ae_lines_pkg.SetAcctClass(
5895 p_accounting_class_code => 'RECEIVABLE'
5896 , p_ae_header_id => l_ae_header_id
5897 );
5898
5899 --
5900 -- set rounding class
5901 --
5902 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
5903 'RECEIVABLE';
5904
5905 --
5906 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
5907 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
5908 --
5909 -- bulk performance
5910 --
5911 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
5912
5913 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
5914 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
5915
5916 -- 4955764
5917 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
5918 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
5919
5920 -- 4458381 Public Sector Enh
5921
5922 --
5923 -- set accounting attributes for the line type
5924 --
5925 l_entered_amt_idx := 3;
5926 l_accted_amt_idx := 8;
5927 l_bflow_applied_to_amt_idx := NULL; -- 5132302
5928 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
5929 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
5930 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
5931 l_rec_acct_attrs.array_char_value(2) := p_source_23;
5932 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
5933 l_rec_acct_attrs.array_num_value(3) := p_source_24;
5934 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
5935 l_rec_acct_attrs.array_char_value(4) := p_source_25;
5936 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
5937 l_rec_acct_attrs.array_date_value(5) := p_source_26;
5938 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
5939 l_rec_acct_attrs.array_num_value(6) := p_source_27;
5940 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
5941 l_rec_acct_attrs.array_char_value(7) := p_source_28;
5942 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
5943 l_rec_acct_attrs.array_num_value(8) := p_source_29;
5944 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
5945 l_rec_acct_attrs.array_num_value(9) := p_source_30;
5946 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
5947 l_rec_acct_attrs.array_num_value(10) := p_source_31;
5948 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
5949 l_rec_acct_attrs.array_char_value(11) := p_source_32;
5950
5951 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
5952 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
5953
5954 ---------------------------------------------------------------------------------------------------------------
5955 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
5956 ---------------------------------------------------------------------------------------------------------------
5957 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
5958
5959 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5960 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
5961
5962 IF xla_accounting_cache_pkg.GetValueChar
5963 (p_source_code => 'LEDGER_CATEGORY_CODE'
5964 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
5965 AND l_bflow_method_code = 'PRIOR_ENTRY'
5966 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
5970 THEN
5967 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
5968 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
5969 )
5971 xla_ae_lines_pkg.BflowUpgEntry
5972 (p_business_method_code => l_bflow_method_code
5973 ,p_business_class_code => l_bflow_class_code
5974 ,p_balance_type => l_balance_type_code);
5975 ELSE
5976 NULL;
5977 -- No business flow processing for business flow method of NONE.
5978 END IF;
5979
5980 --
5981 -- call analytical criteria
5982 --
5983
5984 --
5985 -- call description
5986 --
5987 -- No description or it is inherited.
5988 --
5989 -- call ADRs
5990 -- Bug 4922099
5991 --
5992 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
5993 (NVL(l_actual_upg_option, 'N') = 'O') OR
5994 (NVL(l_enc_upg_option, 'N') = 'O')
5995 )
5996 THEN
5997 NULL;
5998 --
5999 --
6000
6001 l_ccid := AcctDerRule_4(
6002 p_application_id => p_application_id
6003 , p_ae_header_id => l_ae_header_id
6004 , p_source_5 => p_source_5
6005 , x_transaction_coa_id => l_adr_transaction_coa_id
6006 , x_accounting_coa_id => l_adr_accounting_coa_id
6007 , x_value_type_code => l_adr_value_type_code
6008 , p_side => 'NA'
6009 );
6010
6011 xla_ae_lines_pkg.set_ccid(
6012 p_code_combination_id => l_ccid
6013 , p_value_type_code => l_adr_value_type_code
6014 , p_transaction_coa_id => l_adr_transaction_coa_id
6015 , p_accounting_coa_id => l_adr_accounting_coa_id
6016 , p_adr_code => 'DIST_CCID'
6017 , p_adr_type_code => 'S'
6018 , p_component_type => l_component_type
6019 , p_component_code => l_component_code
6020 , p_component_type_code => l_component_type_code
6021 , p_component_appl_id => l_component_appl_id
6022 , p_amb_context_code => l_amb_context_code
6023 , p_side => 'NA'
6024 );
6025
6026
6027 --
6028 --
6029 END IF;
6030 --
6031 -- Bug 4922099
6032 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
6033 (NVL(l_enc_upg_option, 'N') = 'O')
6034 ) AND
6035 (l_bflow_method_code = 'PRIOR_ENTRY')
6036 )
6037 THEN
6038 IF
6039 --
6040 1 = 2
6041 --
6042 THEN
6043 xla_accounting_err_pkg.build_message
6044 (p_appli_s_name => 'XLA'
6045 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6046 ,p_token_1 => 'LINE_NUMBER'
6047 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
6048 ,p_token_2 => 'LINE_TYPE_NAME'
6049 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
6050 l_component_type
6051 ,l_component_code
6052 ,l_component_type_code
6053 ,l_component_appl_id
6054 ,l_amb_context_code
6055 ,l_entity_code
6056 ,l_event_class_code
6057 )
6058 ,p_token_3 => 'OWNER'
6059 ,p_value_3 => xla_lookups_pkg.get_meaning(
6060 p_lookup_type => 'XLA_OWNER_TYPE'
6061 ,p_lookup_code => l_component_type_code
6062 )
6063 ,p_token_4 => 'PRODUCT_NAME'
6064 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
6065 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
6066 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
6067 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
6068 ,p_ae_header_id => NULL
6069 );
6070
6071 IF (C_LEVEL_ERROR>= g_log_level) THEN
6072 trace
6073 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6074 ,p_level => C_LEVEL_ERROR
6075 ,p_module => l_log_module);
6076 END IF;
6077 END IF;
6078 END IF;
6079 --
6080 --
6081 ------------------------------------------------------------------------------------------------
6082 -- 4219869 Business Flow
6086 XLA_AE_LINES_PKG.ValidateCurrentLine;
6083 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
6084 -- Prior Entry. Currently, the following code is always generated.
6085 ------------------------------------------------------------------------------------------------
6087
6088 ------------------------------------------------------------------------------------
6089 -- 4219869 Business Flow
6090 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
6091 ------------------------------------------------------------------------------------
6092 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6093
6094 ----------------------------------------------------------------------------------
6095 -- 4219869 Business Flow
6096 -- Update journal entry status -- Need to generate this within IF <condition>
6097 ----------------------------------------------------------------------------------
6098 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6099 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
6100 ,p_balance_type_code => l_balance_type_code
6101 );
6102
6103 -------------------------------------------------------------------------------------------
6104 -- 4262811 - Generate the Accrual Reversal lines
6105 -------------------------------------------------------------------------------------------
6106 BEGIN
6107 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
6108 (g_array_event(p_event_id).array_value_num('header_index'));
6109 IF l_acc_rev_flag IS NULL THEN
6110 l_acc_rev_flag := 'N';
6111 END IF;
6112 EXCEPTION
6113 WHEN OTHERS THEN
6114 l_acc_rev_flag := 'N';
6115 END;
6116 --
6117 IF (l_acc_rev_flag = 'Y') THEN
6118
6119 -- 4645092 ------------------------------------------------------------------------------
6120 -- To allow MPA report to determine if it should generate report process
6121 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
6122 ------------------------------------------------------------------------------------------
6123
6124 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
6125 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
6126 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
6127 -- call ADRs
6128 -- Bug 4922099
6129 --
6130 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6131 (NVL(l_actual_upg_option, 'N') = 'O') OR
6132 (NVL(l_enc_upg_option, 'N') = 'O')
6133 )
6134 THEN
6135 NULL;
6136 --
6137 --
6138
6139 l_ccid := AcctDerRule_4(
6140 p_application_id => p_application_id
6141 , p_ae_header_id => l_ae_header_id
6142 , p_source_5 => p_source_5
6143 , x_transaction_coa_id => l_adr_transaction_coa_id
6144 , x_accounting_coa_id => l_adr_accounting_coa_id
6145 , x_value_type_code => l_adr_value_type_code
6146 , p_side => 'NA'
6147 );
6148
6149 xla_ae_lines_pkg.set_ccid(
6150 p_code_combination_id => l_ccid
6151 , p_value_type_code => l_adr_value_type_code
6152 , p_transaction_coa_id => l_adr_transaction_coa_id
6153 , p_accounting_coa_id => l_adr_accounting_coa_id
6154 , p_adr_code => 'DIST_CCID'
6155 , p_adr_type_code => 'S'
6156 , p_component_type => l_component_type
6157 , p_component_code => l_component_code
6158 , p_component_type_code => l_component_type_code
6159 , p_component_appl_id => l_component_appl_id
6160 , p_amb_context_code => l_amb_context_code
6161 , p_side => 'NA'
6162 );
6163
6164
6165 --
6166 --
6167 END IF;
6168
6169 --
6170 -- Update the line information that should be overwritten
6171 --
6172 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
6173 p_header_num => 1);
6174 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
6175
6176 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
6177
6178 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
6179 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
6180 END IF;
6181
6182 --
6183 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
6184 --
6185 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
6186 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
6187 ELSE
6188 ---------------------------------------------------------------------------------------------------
6189 -- 4262811a Switch Sign
6190 ---------------------------------------------------------------------------------------------------
6191 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
6192 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6196 -- 5132302
6193 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6194 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6195 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6197 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
6198 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6199
6200 END IF;
6201
6202 -- 4955764
6203 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6204 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
6205
6206
6207 XLA_AE_LINES_PKG.ValidateCurrentLine;
6208 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6209
6210 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6211 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
6212 ,p_balance_type_code => l_balance_type_code);
6213
6214 END IF;
6215
6216 -----------------------------------------------------------------------------------------
6217 -- 4262811 Multiperiod Accounting
6218 -----------------------------------------------------------------------------------------
6219 -- No MPA option is assigned.
6220
6221
6222 END IF;
6223 END IF;
6224 --
6225
6226 --
6227 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6228 trace
6229 (p_msg => 'END of AcctLineType_32'
6230 ,p_level => C_LEVEL_PROCEDURE
6231 ,p_module => l_log_module);
6232 END IF;
6233 --
6234 EXCEPTION
6235 WHEN xla_exceptions_pkg.application_exception THEN
6236 RAISE;
6237 WHEN OTHERS THEN
6238 xla_exceptions_pkg.raise_message
6239 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_32');
6240 END AcctLineType_32;
6241 --
6242
6243 ---------------------------------------
6244 --
6245 -- PRIVATE FUNCTION
6246 -- AcctLineType_33
6247 --
6248 ---------------------------------------
6249 PROCEDURE AcctLineType_33 (
6250 p_application_id IN NUMBER
6251 ,p_event_id IN NUMBER
6252 ,p_calculate_acctd_flag IN VARCHAR2
6253 ,p_calculate_g_l_flag IN VARCHAR2
6254 ,p_actual_flag IN OUT VARCHAR2
6255 ,p_balance_type_code OUT VARCHAR2
6256 ,p_gain_or_loss_ref OUT VARCHAR2
6257
6258 --Distribution GL Account
6259 , p_source_5 IN NUMBER
6260 --Distribution Source Type
6261 , p_source_20 IN VARCHAR2
6262 --Distribution Line Identifier
6263 , p_source_22 IN NUMBER
6264 --Distribution Type
6265 , p_source_23 IN VARCHAR2
6266 --Entered Amount
6267 , p_source_24 IN NUMBER
6268 --Currency Code
6269 , p_source_25 IN VARCHAR2
6270 --Exchange Date
6271 , p_source_26 IN DATE
6272 --Exchange Rate
6273 , p_source_27 IN NUMBER
6274 --Exchange Rate Type
6275 , p_source_28 IN VARCHAR2
6276 --Applied To Document Accounting Amount
6277 , p_source_29 IN NUMBER
6278 --Bill To Customer Account Identifier
6279 , p_source_30 IN NUMBER
6280 --Bill To Customer Site Use Identifier
6281 , p_source_31 IN NUMBER
6282 --SLA Party Type
6283 , p_source_32 IN VARCHAR2
6284 )
6285 IS
6286
6287 l_component_type VARCHAR2(80);
6288 l_component_code VARCHAR2(30);
6289 l_component_type_code VARCHAR2(1);
6290 l_component_appl_id INTEGER;
6291 l_amb_context_code VARCHAR2(30);
6292 l_entity_code VARCHAR2(30);
6293 l_event_class_code VARCHAR2(30);
6294 l_ae_header_id NUMBER;
6295 l_event_type_code VARCHAR2(30);
6296 l_line_definition_code VARCHAR2(30);
6297 l_line_definition_owner_code VARCHAR2(1);
6298 --
6299 -- adr variables
6300 l_segment VARCHAR2(30);
6301 l_ccid NUMBER;
6302 l_adr_transaction_coa_id NUMBER;
6303 l_adr_accounting_coa_id NUMBER;
6304 l_adr_flexfield_segment_code VARCHAR2(30);
6305 l_adr_flex_value_set_id NUMBER;
6306 l_adr_value_type_code VARCHAR2(30);
6307 l_adr_value_combination_id NUMBER;
6308 l_adr_value_segment_code VARCHAR2(30);
6309
6310 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
6311 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
6312 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
6313 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
6314
6315 -- 4262811 Variables ------------------------------------------------------------------------------------------
6316 l_entered_amt_idx NUMBER;
6317 l_accted_amt_idx NUMBER;
6318 l_acc_rev_flag VARCHAR2(1);
6319 l_accrual_line_num NUMBER;
6320 l_tmp_amt NUMBER;
6321 l_acc_rev_natural_side_code VARCHAR2(1);
6322
6323 l_num_entries NUMBER;
6324 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
6325 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
6326 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
6330
6327 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
6328 l_recog_line_1 NUMBER;
6329 l_recog_line_2 NUMBER;
6331 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
6332 l_bflow_applied_to_amt NUMBER; -- 5132302
6333 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
6334
6335 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
6336
6337 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
6338 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
6339
6340 ---------------------------------------------------------------------------------------------------------------
6341
6342
6343 --
6344 -- bulk performance
6345 --
6346 l_balance_type_code VARCHAR2(1);
6347 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
6348 l_log_module VARCHAR2(240);
6349
6350 --
6351 -- Upgrade strategy
6352 --
6353 l_actual_upg_option VARCHAR2(1);
6354 l_enc_upg_option VARCHAR2(1);
6355
6356 --
6357 BEGIN
6358 --
6359 IF g_log_enabled THEN
6360 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_33';
6361 END IF;
6362 --
6363 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6364
6365 trace
6366 (p_msg => 'BEGIN of AcctLineType_33'
6367 ,p_level => C_LEVEL_PROCEDURE
6368 ,p_module => l_log_module);
6369
6370 END IF;
6371 --
6372 l_component_type := 'AMB_JLT';
6373 l_component_code := 'ADJ_DEFERRED_TAX';
6374 l_component_type_code := 'S';
6375 l_component_appl_id := 222;
6376 l_amb_context_code := 'DEFAULT';
6377 l_entity_code := 'ADJUSTMENTS';
6378 l_event_class_code := 'ADJUSTMENT';
6379 l_event_type_code := 'ADJUSTMENT_ALL';
6380 l_line_definition_owner_code := 'S';
6381 l_line_definition_code := 'AR_ADJ_DEFAULT_ACCRUAL';
6382 --
6383 l_balance_type_code := 'A';
6384 l_segment := NULL;
6385 l_ccid := NULL;
6386 l_adr_transaction_coa_id := NULL;
6387 l_adr_accounting_coa_id := NULL;
6388 l_adr_flexfield_segment_code := NULL;
6389 l_adr_flex_value_set_id := NULL;
6390 l_adr_value_type_code := NULL;
6391 l_adr_value_combination_id := NULL;
6392 l_adr_value_segment_code := NULL;
6393
6394 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
6395 l_bflow_class_code := ''; -- 4219869 Business Flow
6396 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
6397 l_budgetary_control_flag := 'N';
6398
6399 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6400 l_bflow_applied_to_amt := NULL; -- 5132302
6401 l_entered_amt_idx := NULL; -- 4262811
6402 l_accted_amt_idx := NULL; -- 4262811
6403 l_acc_rev_flag := NULL; -- 4262811
6404 l_accrual_line_num := NULL; -- 4262811
6405 l_tmp_amt := NULL; -- 4262811
6406 --
6407
6408 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
6409 l_balance_type_code <> 'B' THEN
6410 IF NVL(p_source_20,'
6411 ') = 'DEFERRED_TAX'
6412 THEN
6413
6414 --
6415 XLA_AE_LINES_PKG.SetNewLine;
6416
6417 p_balance_type_code := l_balance_type_code;
6418 -- set the flag so later we will know whether the gain loss line needs to be created
6419
6420 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
6421 p_actual_flag :='A';
6422 END IF;
6423
6424 --
6425 -- bulk performance
6426 --
6427 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
6428 p_header_num => 0); -- 4262811
6429 --
6430 -- set accounting line options
6431 --
6432 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
6433 p_natural_side_code => 'C'
6434 , p_gain_or_loss_flag => 'N'
6435 , p_gl_transfer_mode_code => 'S'
6436 , p_acct_entry_type_code => 'A'
6437 , p_switch_side_flag => 'Y'
6438 , p_merge_duplicate_code => 'A'
6439 );
6440 --
6441 l_acc_rev_natural_side_code := 'D'; -- 4262811
6442 --
6443 --
6444 -- set accounting line type info
6445 --
6446 xla_ae_lines_pkg.SetAcctLineType
6447 (p_component_type => l_component_type
6448 ,p_event_type_code => l_event_type_code
6449 ,p_line_definition_owner_code => l_line_definition_owner_code
6450 ,p_line_definition_code => l_line_definition_code
6451 ,p_accounting_line_code => l_component_code
6452 ,p_accounting_line_type_code => l_component_type_code
6453 ,p_accounting_line_appl_id => l_component_appl_id
6454 ,p_amb_context_code => l_amb_context_code
6455 ,p_entity_code => l_entity_code
6456 ,p_event_class_code => l_event_class_code);
6457 --
6458 -- set accounting class
6459 --
6460 xla_ae_lines_pkg.SetAcctClass(
6461 p_accounting_class_code => 'DEFERRED_TAX'
6462 , p_ae_header_id => l_ae_header_id
6463 );
6464
6465 --
6466 -- set rounding class
6467 --
6468 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
6469 'RECEIVABLE';
6470
6471 --
6472 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
6473 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
6474 --
6475 -- bulk performance
6476 --
6477 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
6478
6479 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
6480 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
6481
6482 -- 4955764
6483 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6484 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
6485
6486 -- 4458381 Public Sector Enh
6487
6488 --
6489 -- set accounting attributes for the line type
6490 --
6491 l_entered_amt_idx := 3;
6492 l_accted_amt_idx := 8;
6493 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6494 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
6495 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
6496 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
6497 l_rec_acct_attrs.array_char_value(2) := p_source_23;
6498 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
6499 l_rec_acct_attrs.array_num_value(3) := p_source_24;
6500 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
6501 l_rec_acct_attrs.array_char_value(4) := p_source_25;
6502 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
6503 l_rec_acct_attrs.array_date_value(5) := p_source_26;
6504 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
6505 l_rec_acct_attrs.array_num_value(6) := p_source_27;
6506 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
6507 l_rec_acct_attrs.array_char_value(7) := p_source_28;
6508 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
6509 l_rec_acct_attrs.array_num_value(8) := p_source_29;
6510 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
6511 l_rec_acct_attrs.array_num_value(9) := p_source_30;
6512 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
6513 l_rec_acct_attrs.array_num_value(10) := p_source_31;
6514 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
6515 l_rec_acct_attrs.array_char_value(11) := p_source_32;
6516
6517 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
6518 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
6519
6520 ---------------------------------------------------------------------------------------------------------------
6521 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
6522 ---------------------------------------------------------------------------------------------------------------
6523 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
6524
6525 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6526 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
6527
6528 IF xla_accounting_cache_pkg.GetValueChar
6529 (p_source_code => 'LEDGER_CATEGORY_CODE'
6530 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
6531 AND l_bflow_method_code = 'PRIOR_ENTRY'
6532 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
6533 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
6534 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
6535 )
6536 THEN
6537 xla_ae_lines_pkg.BflowUpgEntry
6538 (p_business_method_code => l_bflow_method_code
6539 ,p_business_class_code => l_bflow_class_code
6540 ,p_balance_type => l_balance_type_code);
6541 ELSE
6542 NULL;
6543 -- No business flow processing for business flow method of NONE.
6544 END IF;
6545
6546 --
6547 -- call analytical criteria
6548 --
6549
6550 --
6551 -- call description
6552 --
6553 -- No description or it is inherited.
6554 --
6555 -- call ADRs
6556 -- Bug 4922099
6557 --
6558 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6559 (NVL(l_actual_upg_option, 'N') = 'O') OR
6560 (NVL(l_enc_upg_option, 'N') = 'O')
6561 )
6562 THEN
6563 NULL;
6564 --
6565 --
6566
6567 l_ccid := AcctDerRule_4(
6568 p_application_id => p_application_id
6569 , p_ae_header_id => l_ae_header_id
6570 , p_source_5 => p_source_5
6571 , x_transaction_coa_id => l_adr_transaction_coa_id
6572 , x_accounting_coa_id => l_adr_accounting_coa_id
6573 , x_value_type_code => l_adr_value_type_code
6574 , p_side => 'NA'
6575 );
6576
6577 xla_ae_lines_pkg.set_ccid(
6578 p_code_combination_id => l_ccid
6579 , p_value_type_code => l_adr_value_type_code
6580 , p_transaction_coa_id => l_adr_transaction_coa_id
6581 , p_accounting_coa_id => l_adr_accounting_coa_id
6582 , p_adr_code => 'DIST_CCID'
6583 , p_adr_type_code => 'S'
6584 , p_component_type => l_component_type
6585 , p_component_code => l_component_code
6586 , p_component_type_code => l_component_type_code
6587 , p_component_appl_id => l_component_appl_id
6588 , p_amb_context_code => l_amb_context_code
6589 , p_side => 'NA'
6590 );
6591
6592
6593 --
6594 --
6595 END IF;
6596 --
6597 -- Bug 4922099
6598 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
6599 (NVL(l_enc_upg_option, 'N') = 'O')
6600 ) AND
6601 (l_bflow_method_code = 'PRIOR_ENTRY')
6602 )
6603 THEN
6604 IF
6605 --
6606 1 = 2
6607 --
6608 THEN
6609 xla_accounting_err_pkg.build_message
6610 (p_appli_s_name => 'XLA'
6611 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6612 ,p_token_1 => 'LINE_NUMBER'
6613 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
6614 ,p_token_2 => 'LINE_TYPE_NAME'
6615 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
6616 l_component_type
6617 ,l_component_code
6618 ,l_component_type_code
6622 ,l_event_class_code
6619 ,l_component_appl_id
6620 ,l_amb_context_code
6621 ,l_entity_code
6623 )
6624 ,p_token_3 => 'OWNER'
6625 ,p_value_3 => xla_lookups_pkg.get_meaning(
6626 p_lookup_type => 'XLA_OWNER_TYPE'
6627 ,p_lookup_code => l_component_type_code
6628 )
6629 ,p_token_4 => 'PRODUCT_NAME'
6630 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
6631 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
6632 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
6633 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
6634 ,p_ae_header_id => NULL
6635 );
6636
6637 IF (C_LEVEL_ERROR>= g_log_level) THEN
6638 trace
6639 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
6640 ,p_level => C_LEVEL_ERROR
6641 ,p_module => l_log_module);
6642 END IF;
6643 END IF;
6644 END IF;
6645 --
6646 --
6647 ------------------------------------------------------------------------------------------------
6648 -- 4219869 Business Flow
6649 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
6650 -- Prior Entry. Currently, the following code is always generated.
6651 ------------------------------------------------------------------------------------------------
6652 XLA_AE_LINES_PKG.ValidateCurrentLine;
6653
6654 ------------------------------------------------------------------------------------
6655 -- 4219869 Business Flow
6656 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
6657 ------------------------------------------------------------------------------------
6658 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6659
6660 ----------------------------------------------------------------------------------
6661 -- 4219869 Business Flow
6662 -- Update journal entry status -- Need to generate this within IF <condition>
6663 ----------------------------------------------------------------------------------
6664 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6665 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
6666 ,p_balance_type_code => l_balance_type_code
6667 );
6668
6669 -------------------------------------------------------------------------------------------
6670 -- 4262811 - Generate the Accrual Reversal lines
6671 -------------------------------------------------------------------------------------------
6672 BEGIN
6673 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
6674 (g_array_event(p_event_id).array_value_num('header_index'));
6675 IF l_acc_rev_flag IS NULL THEN
6676 l_acc_rev_flag := 'N';
6677 END IF;
6678 EXCEPTION
6679 WHEN OTHERS THEN
6680 l_acc_rev_flag := 'N';
6681 END;
6682 --
6683 IF (l_acc_rev_flag = 'Y') THEN
6684
6685 -- 4645092 ------------------------------------------------------------------------------
6686 -- To allow MPA report to determine if it should generate report process
6687 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
6688 ------------------------------------------------------------------------------------------
6689
6690 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
6691 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
6692 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
6693 -- call ADRs
6694 -- Bug 4922099
6695 --
6696 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
6697 (NVL(l_actual_upg_option, 'N') = 'O') OR
6698 (NVL(l_enc_upg_option, 'N') = 'O')
6699 )
6700 THEN
6701 NULL;
6702 --
6703 --
6704
6705 l_ccid := AcctDerRule_4(
6706 p_application_id => p_application_id
6707 , p_ae_header_id => l_ae_header_id
6708 , p_source_5 => p_source_5
6709 , x_transaction_coa_id => l_adr_transaction_coa_id
6710 , x_accounting_coa_id => l_adr_accounting_coa_id
6711 , x_value_type_code => l_adr_value_type_code
6712 , p_side => 'NA'
6713 );
6714
6715 xla_ae_lines_pkg.set_ccid(
6716 p_code_combination_id => l_ccid
6717 , p_value_type_code => l_adr_value_type_code
6718 , p_transaction_coa_id => l_adr_transaction_coa_id
6719 , p_accounting_coa_id => l_adr_accounting_coa_id
6720 , p_adr_code => 'DIST_CCID'
6721 , p_adr_type_code => 'S'
6722 , p_component_type => l_component_type
6723 , p_component_code => l_component_code
6727 , p_side => 'NA'
6724 , p_component_type_code => l_component_type_code
6725 , p_component_appl_id => l_component_appl_id
6726 , p_amb_context_code => l_amb_context_code
6728 );
6729
6730
6731 --
6732 --
6733 END IF;
6734
6735 --
6736 -- Update the line information that should be overwritten
6737 --
6738 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
6739 p_header_num => 1);
6740 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
6741
6742 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
6743
6744 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
6745 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
6746 END IF;
6747
6748 --
6749 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
6750 --
6751 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
6752 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
6753 ELSE
6754 ---------------------------------------------------------------------------------------------------
6755 -- 4262811a Switch Sign
6756 ---------------------------------------------------------------------------------------------------
6757 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
6758 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6759 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6760 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
6761 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6762 -- 5132302
6763 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
6764 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
6765
6766 END IF;
6767
6768 -- 4955764
6769 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
6770 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
6771
6772
6773 XLA_AE_LINES_PKG.ValidateCurrentLine;
6774 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
6775
6776 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
6777 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
6778 ,p_balance_type_code => l_balance_type_code);
6779
6780 END IF;
6781
6782 -----------------------------------------------------------------------------------------
6783 -- 4262811 Multiperiod Accounting
6784 -----------------------------------------------------------------------------------------
6785 -- No MPA option is assigned.
6786
6787
6788 END IF;
6789 END IF;
6790 --
6791
6792 --
6793 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6794 trace
6795 (p_msg => 'END of AcctLineType_33'
6796 ,p_level => C_LEVEL_PROCEDURE
6797 ,p_module => l_log_module);
6798 END IF;
6799 --
6800 EXCEPTION
6801 WHEN xla_exceptions_pkg.application_exception THEN
6802 RAISE;
6803 WHEN OTHERS THEN
6804 xla_exceptions_pkg.raise_message
6805 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_33');
6806 END AcctLineType_33;
6807 --
6808
6809 ---------------------------------------
6810 --
6811 -- PRIVATE FUNCTION
6812 -- AcctLineType_34
6813 --
6814 ---------------------------------------
6815 PROCEDURE AcctLineType_34 (
6816 p_application_id IN NUMBER
6817 ,p_event_id IN NUMBER
6818 ,p_calculate_acctd_flag IN VARCHAR2
6819 ,p_calculate_g_l_flag IN VARCHAR2
6820 ,p_actual_flag IN OUT VARCHAR2
6821 ,p_balance_type_code OUT VARCHAR2
6822 ,p_gain_or_loss_ref OUT VARCHAR2
6823
6824 --Distribution GL Account
6825 , p_source_5 IN NUMBER
6826 --Distribution Source Type
6827 , p_source_20 IN VARCHAR2
6828 --Distribution Line Identifier
6829 , p_source_22 IN NUMBER
6830 --Distribution Type
6831 , p_source_23 IN VARCHAR2
6832 --Entered Amount
6833 , p_source_24 IN NUMBER
6834 --Currency Code
6835 , p_source_25 IN VARCHAR2
6836 --Exchange Date
6837 , p_source_26 IN DATE
6838 --Exchange Rate
6839 , p_source_27 IN NUMBER
6840 --Exchange Rate Type
6841 , p_source_28 IN VARCHAR2
6842 --Applied To Document Accounting Amount
6843 , p_source_29 IN NUMBER
6844 --Bill To Customer Account Identifier
6845 , p_source_30 IN NUMBER
6846 --Bill To Customer Site Use Identifier
6847 , p_source_31 IN NUMBER
6848 --SLA Party Type
6849 , p_source_32 IN VARCHAR2
6850 )
6851 IS
6852
6853 l_component_type VARCHAR2(80);
6854 l_component_code VARCHAR2(30);
6855 l_component_type_code VARCHAR2(1);
6856 l_component_appl_id INTEGER;
6857 l_amb_context_code VARCHAR2(30);
6858 l_entity_code VARCHAR2(30);
6859 l_event_class_code VARCHAR2(30);
6860 l_ae_header_id NUMBER;
6864 --
6861 l_event_type_code VARCHAR2(30);
6862 l_line_definition_code VARCHAR2(30);
6863 l_line_definition_owner_code VARCHAR2(1);
6865 -- adr variables
6866 l_segment VARCHAR2(30);
6867 l_ccid NUMBER;
6868 l_adr_transaction_coa_id NUMBER;
6869 l_adr_accounting_coa_id NUMBER;
6870 l_adr_flexfield_segment_code VARCHAR2(30);
6871 l_adr_flex_value_set_id NUMBER;
6872 l_adr_value_type_code VARCHAR2(30);
6873 l_adr_value_combination_id NUMBER;
6874 l_adr_value_segment_code VARCHAR2(30);
6875
6876 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
6877 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
6878 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
6879 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
6880
6881 -- 4262811 Variables ------------------------------------------------------------------------------------------
6882 l_entered_amt_idx NUMBER;
6883 l_accted_amt_idx NUMBER;
6884 l_acc_rev_flag VARCHAR2(1);
6885 l_accrual_line_num NUMBER;
6886 l_tmp_amt NUMBER;
6887 l_acc_rev_natural_side_code VARCHAR2(1);
6888
6889 l_num_entries NUMBER;
6890 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
6891 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
6892 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
6893 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
6894 l_recog_line_1 NUMBER;
6895 l_recog_line_2 NUMBER;
6896
6897 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
6898 l_bflow_applied_to_amt NUMBER; -- 5132302
6899 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
6900
6901 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
6902
6903 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
6904 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
6905
6906 ---------------------------------------------------------------------------------------------------------------
6907
6908
6909 --
6910 -- bulk performance
6911 --
6912 l_balance_type_code VARCHAR2(1);
6913 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
6914 l_log_module VARCHAR2(240);
6915
6916 --
6917 -- Upgrade strategy
6918 --
6919 l_actual_upg_option VARCHAR2(1);
6920 l_enc_upg_option VARCHAR2(1);
6921
6922 --
6923 BEGIN
6924 --
6925 IF g_log_enabled THEN
6926 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_34';
6927 END IF;
6928 --
6929 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6930
6931 trace
6932 (p_msg => 'BEGIN of AcctLineType_34'
6933 ,p_level => C_LEVEL_PROCEDURE
6934 ,p_module => l_log_module);
6935
6936 END IF;
6937 --
6938 l_component_type := 'AMB_JLT';
6939 l_component_code := 'ADJ_FINCHRG_NON_REC_TAX';
6940 l_component_type_code := 'S';
6941 l_component_appl_id := 222;
6942 l_amb_context_code := 'DEFAULT';
6943 l_entity_code := 'ADJUSTMENTS';
6944 l_event_class_code := 'ADJUSTMENT';
6945 l_event_type_code := 'ADJUSTMENT_ALL';
6946 l_line_definition_owner_code := 'S';
6947 l_line_definition_code := 'AR_ADJ_DEFAULT_ACCRUAL';
6948 --
6949 l_balance_type_code := 'A';
6950 l_segment := NULL;
6951 l_ccid := NULL;
6952 l_adr_transaction_coa_id := NULL;
6953 l_adr_accounting_coa_id := NULL;
6954 l_adr_flexfield_segment_code := NULL;
6955 l_adr_flex_value_set_id := NULL;
6956 l_adr_value_type_code := NULL;
6957 l_adr_value_combination_id := NULL;
6958 l_adr_value_segment_code := NULL;
6959
6960 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
6961 l_bflow_class_code := ''; -- 4219869 Business Flow
6962 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
6963 l_budgetary_control_flag := 'N';
6964
6965 l_bflow_applied_to_amt_idx := NULL; -- 5132302
6966 l_bflow_applied_to_amt := NULL; -- 5132302
6967 l_entered_amt_idx := NULL; -- 4262811
6968 l_accted_amt_idx := NULL; -- 4262811
6969 l_acc_rev_flag := NULL; -- 4262811
6970 l_accrual_line_num := NULL; -- 4262811
6971 l_tmp_amt := NULL; -- 4262811
6972 --
6973
6974 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
6975 l_balance_type_code <> 'B' THEN
6976 IF NVL(p_source_20,'
6977 ') = 'FINCHRG_NON_REC_TAX'
6978 THEN
6979
6980 --
6981 XLA_AE_LINES_PKG.SetNewLine;
6982
6983 p_balance_type_code := l_balance_type_code;
6984 -- set the flag so later we will know whether the gain loss line needs to be created
6985
6986 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
6987 p_actual_flag :='A';
6988 END IF;
6989
6990 --
6991 -- bulk performance
6992 --
6993 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
6994 p_header_num => 0); -- 4262811
6995 --
6996 -- set accounting line options
6997 --
6998 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
6999 p_natural_side_code => 'C'
7003 , p_switch_side_flag => 'Y'
7000 , p_gain_or_loss_flag => 'N'
7001 , p_gl_transfer_mode_code => 'S'
7002 , p_acct_entry_type_code => 'A'
7004 , p_merge_duplicate_code => 'A'
7005 );
7006 --
7007 l_acc_rev_natural_side_code := 'D'; -- 4262811
7008 --
7009 --
7010 -- set accounting line type info
7011 --
7012 xla_ae_lines_pkg.SetAcctLineType
7013 (p_component_type => l_component_type
7014 ,p_event_type_code => l_event_type_code
7015 ,p_line_definition_owner_code => l_line_definition_owner_code
7016 ,p_line_definition_code => l_line_definition_code
7017 ,p_accounting_line_code => l_component_code
7018 ,p_accounting_line_type_code => l_component_type_code
7019 ,p_accounting_line_appl_id => l_component_appl_id
7020 ,p_amb_context_code => l_amb_context_code
7021 ,p_entity_code => l_entity_code
7022 ,p_event_class_code => l_event_class_code);
7023 --
7024 -- set accounting class
7025 --
7026 xla_ae_lines_pkg.SetAcctClass(
7027 p_accounting_class_code => 'FINCHRG_NON_REC_TAX'
7028 , p_ae_header_id => l_ae_header_id
7029 );
7030
7031 --
7032 -- set rounding class
7033 --
7034 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
7035 'RECEIVABLE';
7036
7037 --
7038 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
7039 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
7040 --
7041 -- bulk performance
7042 --
7043 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
7044
7045 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
7046 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
7047
7048 -- 4955764
7049 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7050 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
7051
7052 -- 4458381 Public Sector Enh
7053
7054 --
7055 -- set accounting attributes for the line type
7056 --
7057 l_entered_amt_idx := 3;
7058 l_accted_amt_idx := 8;
7059 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7060 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
7061 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
7062 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
7063 l_rec_acct_attrs.array_char_value(2) := p_source_23;
7064 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
7065 l_rec_acct_attrs.array_num_value(3) := p_source_24;
7066 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
7067 l_rec_acct_attrs.array_char_value(4) := p_source_25;
7068 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
7069 l_rec_acct_attrs.array_date_value(5) := p_source_26;
7070 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
7071 l_rec_acct_attrs.array_num_value(6) := p_source_27;
7072 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
7073 l_rec_acct_attrs.array_char_value(7) := p_source_28;
7074 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
7075 l_rec_acct_attrs.array_num_value(8) := p_source_29;
7076 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
7077 l_rec_acct_attrs.array_num_value(9) := p_source_30;
7078 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
7079 l_rec_acct_attrs.array_num_value(10) := p_source_31;
7080 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
7081 l_rec_acct_attrs.array_char_value(11) := p_source_32;
7082
7083 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
7084 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
7085
7086 ---------------------------------------------------------------------------------------------------------------
7087 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
7088 ---------------------------------------------------------------------------------------------------------------
7089 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
7090
7091 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7092 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7093
7094 IF xla_accounting_cache_pkg.GetValueChar
7095 (p_source_code => 'LEDGER_CATEGORY_CODE'
7096 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
7097 AND l_bflow_method_code = 'PRIOR_ENTRY'
7098 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
7099 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
7100 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
7101 )
7102 THEN
7103 xla_ae_lines_pkg.BflowUpgEntry
7104 (p_business_method_code => l_bflow_method_code
7105 ,p_business_class_code => l_bflow_class_code
7106 ,p_balance_type => l_balance_type_code);
7107 ELSE
7108 NULL;
7109 -- No business flow processing for business flow method of NONE.
7110 END IF;
7111
7112 --
7113 -- call analytical criteria
7114 --
7115
7116 --
7117 -- call description
7118 --
7119 -- No description or it is inherited.
7120 --
7121 -- call ADRs
7122 -- Bug 4922099
7123 --
7124 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7125 (NVL(l_actual_upg_option, 'N') = 'O') OR
7126 (NVL(l_enc_upg_option, 'N') = 'O')
7127 )
7128 THEN
7129 NULL;
7130 --
7131 --
7132
7133 l_ccid := AcctDerRule_4(
7134 p_application_id => p_application_id
7135 , p_ae_header_id => l_ae_header_id
7136 , p_source_5 => p_source_5
7137 , x_transaction_coa_id => l_adr_transaction_coa_id
7138 , x_accounting_coa_id => l_adr_accounting_coa_id
7139 , x_value_type_code => l_adr_value_type_code
7140 , p_side => 'NA'
7141 );
7142
7143 xla_ae_lines_pkg.set_ccid(
7144 p_code_combination_id => l_ccid
7145 , p_value_type_code => l_adr_value_type_code
7146 , p_transaction_coa_id => l_adr_transaction_coa_id
7147 , p_accounting_coa_id => l_adr_accounting_coa_id
7148 , p_adr_code => 'DIST_CCID'
7149 , p_adr_type_code => 'S'
7150 , p_component_type => l_component_type
7151 , p_component_code => l_component_code
7152 , p_component_type_code => l_component_type_code
7153 , p_component_appl_id => l_component_appl_id
7154 , p_amb_context_code => l_amb_context_code
7155 , p_side => 'NA'
7156 );
7157
7158
7159 --
7160 --
7161 END IF;
7162 --
7163 -- Bug 4922099
7164 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
7165 (NVL(l_enc_upg_option, 'N') = 'O')
7166 ) AND
7167 (l_bflow_method_code = 'PRIOR_ENTRY')
7168 )
7169 THEN
7170 IF
7171 --
7172 1 = 2
7173 --
7174 THEN
7175 xla_accounting_err_pkg.build_message
7176 (p_appli_s_name => 'XLA'
7177 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7178 ,p_token_1 => 'LINE_NUMBER'
7179 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
7180 ,p_token_2 => 'LINE_TYPE_NAME'
7181 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
7182 l_component_type
7183 ,l_component_code
7184 ,l_component_type_code
7185 ,l_component_appl_id
7186 ,l_amb_context_code
7187 ,l_entity_code
7188 ,l_event_class_code
7189 )
7190 ,p_token_3 => 'OWNER'
7191 ,p_value_3 => xla_lookups_pkg.get_meaning(
7192 p_lookup_type => 'XLA_OWNER_TYPE'
7193 ,p_lookup_code => l_component_type_code
7194 )
7195 ,p_token_4 => 'PRODUCT_NAME'
7196 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
7197 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
7198 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
7199 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
7200 ,p_ae_header_id => NULL
7201 );
7202
7203 IF (C_LEVEL_ERROR>= g_log_level) THEN
7204 trace
7205 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7206 ,p_level => C_LEVEL_ERROR
7207 ,p_module => l_log_module);
7208 END IF;
7209 END IF;
7210 END IF;
7211 --
7212 --
7213 ------------------------------------------------------------------------------------------------
7214 -- 4219869 Business Flow
7215 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
7216 -- Prior Entry. Currently, the following code is always generated.
7217 ------------------------------------------------------------------------------------------------
7218 XLA_AE_LINES_PKG.ValidateCurrentLine;
7219
7220 ------------------------------------------------------------------------------------
7221 -- 4219869 Business Flow
7222 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
7223 ------------------------------------------------------------------------------------
7224 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7225
7226 ----------------------------------------------------------------------------------
7227 -- 4219869 Business Flow
7228 -- Update journal entry status -- Need to generate this within IF <condition>
7229 ----------------------------------------------------------------------------------
7230 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7231 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
7232 ,p_balance_type_code => l_balance_type_code
7233 );
7234
7235 -------------------------------------------------------------------------------------------
7236 -- 4262811 - Generate the Accrual Reversal lines
7237 -------------------------------------------------------------------------------------------
7238 BEGIN
7239 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
7240 (g_array_event(p_event_id).array_value_num('header_index'));
7241 IF l_acc_rev_flag IS NULL THEN
7242 l_acc_rev_flag := 'N';
7243 END IF;
7244 EXCEPTION
7245 WHEN OTHERS THEN
7246 l_acc_rev_flag := 'N';
7247 END;
7248 --
7249 IF (l_acc_rev_flag = 'Y') THEN
7250
7251 -- 4645092 ------------------------------------------------------------------------------
7252 -- To allow MPA report to determine if it should generate report process
7253 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
7254 ------------------------------------------------------------------------------------------
7255
7256 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
7257 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
7258 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
7259 -- call ADRs
7260 -- Bug 4922099
7261 --
7262 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7263 (NVL(l_actual_upg_option, 'N') = 'O') OR
7264 (NVL(l_enc_upg_option, 'N') = 'O')
7265 )
7266 THEN
7267 NULL;
7268 --
7269 --
7270
7271 l_ccid := AcctDerRule_4(
7272 p_application_id => p_application_id
7273 , p_ae_header_id => l_ae_header_id
7274 , p_source_5 => p_source_5
7275 , x_transaction_coa_id => l_adr_transaction_coa_id
7276 , x_accounting_coa_id => l_adr_accounting_coa_id
7277 , x_value_type_code => l_adr_value_type_code
7278 , p_side => 'NA'
7279 );
7280
7281 xla_ae_lines_pkg.set_ccid(
7282 p_code_combination_id => l_ccid
7283 , p_value_type_code => l_adr_value_type_code
7284 , p_transaction_coa_id => l_adr_transaction_coa_id
7285 , p_accounting_coa_id => l_adr_accounting_coa_id
7286 , p_adr_code => 'DIST_CCID'
7287 , p_adr_type_code => 'S'
7288 , p_component_type => l_component_type
7289 , p_component_code => l_component_code
7290 , p_component_type_code => l_component_type_code
7291 , p_component_appl_id => l_component_appl_id
7292 , p_amb_context_code => l_amb_context_code
7293 , p_side => 'NA'
7294 );
7295
7296
7297 --
7298 --
7299 END IF;
7300
7301 --
7302 -- Update the line information that should be overwritten
7303 --
7304 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
7305 p_header_num => 1);
7306 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
7307
7308 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
7309
7310 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
7311 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
7312 END IF;
7313
7314 --
7315 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
7316 --
7317 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
7318 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
7319 ELSE
7320 ---------------------------------------------------------------------------------------------------
7321 -- 4262811a Switch Sign
7322 ---------------------------------------------------------------------------------------------------
7323 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
7324 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7325 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7326 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7327 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7328 -- 5132302
7329 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
7330 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7331
7332 END IF;
7333
7334 -- 4955764
7335 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7336 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
7337
7338
7339 XLA_AE_LINES_PKG.ValidateCurrentLine;
7340 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7341
7342 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7343 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
7344 ,p_balance_type_code => l_balance_type_code);
7345
7346 END IF;
7347
7348 -----------------------------------------------------------------------------------------
7349 -- 4262811 Multiperiod Accounting
7350 -----------------------------------------------------------------------------------------
7351 -- No MPA option is assigned.
7352
7353
7354 END IF;
7355 END IF;
7356 --
7357
7358 --
7359 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7360 trace
7361 (p_msg => 'END of AcctLineType_34'
7362 ,p_level => C_LEVEL_PROCEDURE
7363 ,p_module => l_log_module);
7364 END IF;
7365 --
7366 EXCEPTION
7367 WHEN xla_exceptions_pkg.application_exception THEN
7368 RAISE;
7369 WHEN OTHERS THEN
7370 xla_exceptions_pkg.raise_message
7371 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_34');
7372 END AcctLineType_34;
7373 --
7374
7375 ---------------------------------------
7376 --
7377 -- PRIVATE FUNCTION
7378 -- AcctLineType_35
7379 --
7380 ---------------------------------------
7381 PROCEDURE AcctLineType_35 (
7382 p_application_id IN NUMBER
7383 ,p_event_id IN NUMBER
7384 ,p_calculate_acctd_flag IN VARCHAR2
7385 ,p_calculate_g_l_flag IN VARCHAR2
7386 ,p_actual_flag IN OUT VARCHAR2
7387 ,p_balance_type_code OUT VARCHAR2
7388 ,p_gain_or_loss_ref OUT VARCHAR2
7389
7390 --Distribution GL Account
7391 , p_source_5 IN NUMBER
7392 --Distribution Source Type
7393 , p_source_20 IN VARCHAR2
7394 --Distribution Line Identifier
7395 , p_source_22 IN NUMBER
7396 --Distribution Type
7397 , p_source_23 IN VARCHAR2
7398 --Entered Amount
7399 , p_source_24 IN NUMBER
7400 --Currency Code
7401 , p_source_25 IN VARCHAR2
7402 --Exchange Date
7403 , p_source_26 IN DATE
7404 --Exchange Rate
7405 , p_source_27 IN NUMBER
7406 --Exchange Rate Type
7407 , p_source_28 IN VARCHAR2
7408 --Applied To Document Accounting Amount
7409 , p_source_29 IN NUMBER
7410 --Bill To Customer Account Identifier
7411 , p_source_30 IN NUMBER
7412 --Bill To Customer Site Use Identifier
7413 , p_source_31 IN NUMBER
7414 --SLA Party Type
7415 , p_source_32 IN VARCHAR2
7416 )
7417 IS
7418
7419 l_component_type VARCHAR2(80);
7420 l_component_code VARCHAR2(30);
7421 l_component_type_code VARCHAR2(1);
7422 l_component_appl_id INTEGER;
7423 l_amb_context_code VARCHAR2(30);
7424 l_entity_code VARCHAR2(30);
7425 l_event_class_code VARCHAR2(30);
7426 l_ae_header_id NUMBER;
7427 l_event_type_code VARCHAR2(30);
7428 l_line_definition_code VARCHAR2(30);
7429 l_line_definition_owner_code VARCHAR2(1);
7430 --
7431 -- adr variables
7432 l_segment VARCHAR2(30);
7433 l_ccid NUMBER;
7434 l_adr_transaction_coa_id NUMBER;
7435 l_adr_accounting_coa_id NUMBER;
7436 l_adr_flexfield_segment_code VARCHAR2(30);
7437 l_adr_flex_value_set_id NUMBER;
7438 l_adr_value_type_code VARCHAR2(30);
7439 l_adr_value_combination_id NUMBER;
7440 l_adr_value_segment_code VARCHAR2(30);
7441
7442 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
7443 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
7444 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
7445 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
7446
7447 -- 4262811 Variables ------------------------------------------------------------------------------------------
7448 l_entered_amt_idx NUMBER;
7449 l_accted_amt_idx NUMBER;
7450 l_acc_rev_flag VARCHAR2(1);
7451 l_accrual_line_num NUMBER;
7452 l_tmp_amt NUMBER;
7453 l_acc_rev_natural_side_code VARCHAR2(1);
7454
7455 l_num_entries NUMBER;
7456 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
7457 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
7458 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
7459 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
7460 l_recog_line_1 NUMBER;
7461 l_recog_line_2 NUMBER;
7462
7463 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
7464 l_bflow_applied_to_amt NUMBER; -- 5132302
7465 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
7466
7467 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
7468
7469 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
7470 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
7471
7472 ---------------------------------------------------------------------------------------------------------------
7473
7474
7475 --
7476 -- bulk performance
7477 --
7478 l_balance_type_code VARCHAR2(1);
7479 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
7480 l_log_module VARCHAR2(240);
7481
7482 --
7483 -- Upgrade strategy
7484 --
7485 l_actual_upg_option VARCHAR2(1);
7486 l_enc_upg_option VARCHAR2(1);
7487
7488 --
7489 BEGIN
7490 --
7491 IF g_log_enabled THEN
7492 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_35';
7493 END IF;
7494 --
7495 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7496
7497 trace
7498 (p_msg => 'BEGIN of AcctLineType_35'
7499 ,p_level => C_LEVEL_PROCEDURE
7500 ,p_module => l_log_module);
7501
7502 END IF;
7503 --
7504 l_component_type := 'AMB_JLT';
7505 l_component_code := 'ADJ_NON_REC_TAX';
7506 l_component_type_code := 'S';
7507 l_component_appl_id := 222;
7508 l_amb_context_code := 'DEFAULT';
7509 l_entity_code := 'ADJUSTMENTS';
7510 l_event_class_code := 'ADJUSTMENT';
7511 l_event_type_code := 'ADJUSTMENT_ALL';
7512 l_line_definition_owner_code := 'S';
7513 l_line_definition_code := 'AR_ADJ_DEFAULT_ACCRUAL';
7514 --
7515 l_balance_type_code := 'A';
7516 l_segment := NULL;
7517 l_ccid := NULL;
7518 l_adr_transaction_coa_id := NULL;
7519 l_adr_accounting_coa_id := NULL;
7520 l_adr_flexfield_segment_code := NULL;
7521 l_adr_flex_value_set_id := NULL;
7522 l_adr_value_type_code := NULL;
7523 l_adr_value_combination_id := NULL;
7524 l_adr_value_segment_code := NULL;
7525
7526 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
7527 l_bflow_class_code := ''; -- 4219869 Business Flow
7528 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
7529 l_budgetary_control_flag := 'N';
7530
7531 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7532 l_bflow_applied_to_amt := NULL; -- 5132302
7533 l_entered_amt_idx := NULL; -- 4262811
7534 l_accted_amt_idx := NULL; -- 4262811
7535 l_acc_rev_flag := NULL; -- 4262811
7536 l_accrual_line_num := NULL; -- 4262811
7537 l_tmp_amt := NULL; -- 4262811
7538 --
7539
7540 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
7541 l_balance_type_code <> 'B' THEN
7542 IF NVL(p_source_20,'
7543 ') = 'ADJ_NON_REC_TAX'
7544 THEN
7545
7546 --
7547 XLA_AE_LINES_PKG.SetNewLine;
7548
7549 p_balance_type_code := l_balance_type_code;
7550 -- set the flag so later we will know whether the gain loss line needs to be created
7551
7555
7552 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
7553 p_actual_flag :='A';
7554 END IF;
7556 --
7557 -- bulk performance
7558 --
7559 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
7560 p_header_num => 0); -- 4262811
7561 --
7562 -- set accounting line options
7563 --
7564 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
7565 p_natural_side_code => 'C'
7566 , p_gain_or_loss_flag => 'N'
7567 , p_gl_transfer_mode_code => 'S'
7568 , p_acct_entry_type_code => 'A'
7569 , p_switch_side_flag => 'Y'
7570 , p_merge_duplicate_code => 'A'
7571 );
7572 --
7573 l_acc_rev_natural_side_code := 'D'; -- 4262811
7574 --
7575 --
7576 -- set accounting line type info
7577 --
7578 xla_ae_lines_pkg.SetAcctLineType
7579 (p_component_type => l_component_type
7580 ,p_event_type_code => l_event_type_code
7581 ,p_line_definition_owner_code => l_line_definition_owner_code
7582 ,p_line_definition_code => l_line_definition_code
7583 ,p_accounting_line_code => l_component_code
7584 ,p_accounting_line_type_code => l_component_type_code
7585 ,p_accounting_line_appl_id => l_component_appl_id
7586 ,p_amb_context_code => l_amb_context_code
7587 ,p_entity_code => l_entity_code
7588 ,p_event_class_code => l_event_class_code);
7589 --
7590 -- set accounting class
7591 --
7592 xla_ae_lines_pkg.SetAcctClass(
7593 p_accounting_class_code => 'ADJ_NON_REC_TAX'
7594 , p_ae_header_id => l_ae_header_id
7595 );
7596
7597 --
7598 -- set rounding class
7599 --
7600 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
7601 'RECEIVABLE';
7602
7603 --
7604 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
7605 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
7606 --
7607 -- bulk performance
7608 --
7609 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
7610
7611 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
7612 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
7613
7614 -- 4955764
7615 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7616 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
7617
7618 -- 4458381 Public Sector Enh
7619
7620 --
7621 -- set accounting attributes for the line type
7622 --
7623 l_entered_amt_idx := 3;
7624 l_accted_amt_idx := 8;
7625 l_bflow_applied_to_amt_idx := NULL; -- 5132302
7626 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
7627 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
7628 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
7629 l_rec_acct_attrs.array_char_value(2) := p_source_23;
7630 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
7631 l_rec_acct_attrs.array_num_value(3) := p_source_24;
7632 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
7633 l_rec_acct_attrs.array_char_value(4) := p_source_25;
7634 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
7635 l_rec_acct_attrs.array_date_value(5) := p_source_26;
7636 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
7637 l_rec_acct_attrs.array_num_value(6) := p_source_27;
7638 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
7639 l_rec_acct_attrs.array_char_value(7) := p_source_28;
7640 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
7641 l_rec_acct_attrs.array_num_value(8) := p_source_29;
7642 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
7643 l_rec_acct_attrs.array_num_value(9) := p_source_30;
7644 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
7645 l_rec_acct_attrs.array_num_value(10) := p_source_31;
7646 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
7647 l_rec_acct_attrs.array_char_value(11) := p_source_32;
7648
7649 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
7650 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
7651
7652 ---------------------------------------------------------------------------------------------------------------
7653 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
7654 ---------------------------------------------------------------------------------------------------------------
7655 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
7656
7657 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7658 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
7659
7660 IF xla_accounting_cache_pkg.GetValueChar
7661 (p_source_code => 'LEDGER_CATEGORY_CODE'
7662 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
7663 AND l_bflow_method_code = 'PRIOR_ENTRY'
7664 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
7665 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
7666 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
7667 )
7668 THEN
7669 xla_ae_lines_pkg.BflowUpgEntry
7670 (p_business_method_code => l_bflow_method_code
7671 ,p_business_class_code => l_bflow_class_code
7672 ,p_balance_type => l_balance_type_code);
7673 ELSE
7674 NULL;
7675 -- No business flow processing for business flow method of NONE.
7676 END IF;
7677
7678 --
7679 -- call analytical criteria
7680 --
7681
7682 --
7683 -- call description
7684 --
7685 -- No description or it is inherited.
7686 --
7687 -- call ADRs
7688 -- Bug 4922099
7689 --
7690 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7691 (NVL(l_actual_upg_option, 'N') = 'O') OR
7692 (NVL(l_enc_upg_option, 'N') = 'O')
7693 )
7694 THEN
7695 NULL;
7696 --
7697 --
7698
7699 l_ccid := AcctDerRule_4(
7700 p_application_id => p_application_id
7701 , p_ae_header_id => l_ae_header_id
7702 , p_source_5 => p_source_5
7703 , x_transaction_coa_id => l_adr_transaction_coa_id
7704 , x_accounting_coa_id => l_adr_accounting_coa_id
7705 , x_value_type_code => l_adr_value_type_code
7706 , p_side => 'NA'
7707 );
7708
7709 xla_ae_lines_pkg.set_ccid(
7710 p_code_combination_id => l_ccid
7711 , p_value_type_code => l_adr_value_type_code
7712 , p_transaction_coa_id => l_adr_transaction_coa_id
7713 , p_accounting_coa_id => l_adr_accounting_coa_id
7714 , p_adr_code => 'DIST_CCID'
7715 , p_adr_type_code => 'S'
7716 , p_component_type => l_component_type
7717 , p_component_code => l_component_code
7718 , p_component_type_code => l_component_type_code
7719 , p_component_appl_id => l_component_appl_id
7720 , p_amb_context_code => l_amb_context_code
7721 , p_side => 'NA'
7722 );
7723
7724
7725 --
7726 --
7727 END IF;
7728 --
7729 -- Bug 4922099
7730 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
7731 (NVL(l_enc_upg_option, 'N') = 'O')
7732 ) AND
7733 (l_bflow_method_code = 'PRIOR_ENTRY')
7734 )
7735 THEN
7736 IF
7737 --
7738 1 = 2
7739 --
7740 THEN
7741 xla_accounting_err_pkg.build_message
7742 (p_appli_s_name => 'XLA'
7743 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7744 ,p_token_1 => 'LINE_NUMBER'
7745 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
7746 ,p_token_2 => 'LINE_TYPE_NAME'
7747 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
7748 l_component_type
7749 ,l_component_code
7750 ,l_component_type_code
7751 ,l_component_appl_id
7752 ,l_amb_context_code
7753 ,l_entity_code
7754 ,l_event_class_code
7755 )
7756 ,p_token_3 => 'OWNER'
7757 ,p_value_3 => xla_lookups_pkg.get_meaning(
7758 p_lookup_type => 'XLA_OWNER_TYPE'
7759 ,p_lookup_code => l_component_type_code
7760 )
7761 ,p_token_4 => 'PRODUCT_NAME'
7762 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
7763 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
7764 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
7765 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
7766 ,p_ae_header_id => NULL
7767 );
7768
7769 IF (C_LEVEL_ERROR>= g_log_level) THEN
7770 trace
7771 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
7772 ,p_level => C_LEVEL_ERROR
7773 ,p_module => l_log_module);
7774 END IF;
7775 END IF;
7776 END IF;
7777 --
7778 --
7779 ------------------------------------------------------------------------------------------------
7780 -- 4219869 Business Flow
7781 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
7782 -- Prior Entry. Currently, the following code is always generated.
7783 ------------------------------------------------------------------------------------------------
7784 XLA_AE_LINES_PKG.ValidateCurrentLine;
7785
7786 ------------------------------------------------------------------------------------
7787 -- 4219869 Business Flow
7788 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
7789 ------------------------------------------------------------------------------------
7790 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7791
7792 ----------------------------------------------------------------------------------
7793 -- 4219869 Business Flow
7794 -- Update journal entry status -- Need to generate this within IF <condition>
7795 ----------------------------------------------------------------------------------
7796 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7797 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
7798 ,p_balance_type_code => l_balance_type_code
7799 );
7800
7801 -------------------------------------------------------------------------------------------
7802 -- 4262811 - Generate the Accrual Reversal lines
7803 -------------------------------------------------------------------------------------------
7804 BEGIN
7805 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
7806 (g_array_event(p_event_id).array_value_num('header_index'));
7807 IF l_acc_rev_flag IS NULL THEN
7808 l_acc_rev_flag := 'N';
7809 END IF;
7810 EXCEPTION
7811 WHEN OTHERS THEN
7812 l_acc_rev_flag := 'N';
7813 END;
7814 --
7815 IF (l_acc_rev_flag = 'Y') THEN
7816
7817 -- 4645092 ------------------------------------------------------------------------------
7818 -- To allow MPA report to determine if it should generate report process
7819 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
7820 ------------------------------------------------------------------------------------------
7821
7822 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
7823 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
7824 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
7825 -- call ADRs
7826 -- Bug 4922099
7827 --
7828 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
7829 (NVL(l_actual_upg_option, 'N') = 'O') OR
7830 (NVL(l_enc_upg_option, 'N') = 'O')
7831 )
7832 THEN
7833 NULL;
7834 --
7835 --
7836
7837 l_ccid := AcctDerRule_4(
7838 p_application_id => p_application_id
7839 , p_ae_header_id => l_ae_header_id
7840 , p_source_5 => p_source_5
7841 , x_transaction_coa_id => l_adr_transaction_coa_id
7842 , x_accounting_coa_id => l_adr_accounting_coa_id
7843 , x_value_type_code => l_adr_value_type_code
7844 , p_side => 'NA'
7845 );
7846
7847 xla_ae_lines_pkg.set_ccid(
7848 p_code_combination_id => l_ccid
7849 , p_value_type_code => l_adr_value_type_code
7850 , p_transaction_coa_id => l_adr_transaction_coa_id
7851 , p_accounting_coa_id => l_adr_accounting_coa_id
7852 , p_adr_code => 'DIST_CCID'
7853 , p_adr_type_code => 'S'
7854 , p_component_type => l_component_type
7855 , p_component_code => l_component_code
7856 , p_component_type_code => l_component_type_code
7857 , p_component_appl_id => l_component_appl_id
7858 , p_amb_context_code => l_amb_context_code
7859 , p_side => 'NA'
7860 );
7861
7862
7863 --
7864 --
7865 END IF;
7866
7867 --
7868 -- Update the line information that should be overwritten
7869 --
7870 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
7871 p_header_num => 1);
7872 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
7873
7874 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
7875
7876 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
7877 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
7878 END IF;
7879
7880 --
7881 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
7882 --
7883 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
7884 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
7885 ELSE
7886 ---------------------------------------------------------------------------------------------------
7887 -- 4262811a Switch Sign
7888 ---------------------------------------------------------------------------------------------------
7889 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
7890 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7891 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7892 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
7893 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7894 -- 5132302
7895 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
7896 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
7897
7898 END IF;
7899
7900 -- 4955764
7901 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
7902 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
7903
7904
7905 XLA_AE_LINES_PKG.ValidateCurrentLine;
7906 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
7907
7908 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
7912 END IF;
7909 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
7910 ,p_balance_type_code => l_balance_type_code);
7911
7913
7914 -----------------------------------------------------------------------------------------
7915 -- 4262811 Multiperiod Accounting
7916 -----------------------------------------------------------------------------------------
7917 -- No MPA option is assigned.
7918
7919
7920 END IF;
7921 END IF;
7922 --
7923
7924 --
7925 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
7926 trace
7927 (p_msg => 'END of AcctLineType_35'
7928 ,p_level => C_LEVEL_PROCEDURE
7929 ,p_module => l_log_module);
7930 END IF;
7931 --
7932 EXCEPTION
7933 WHEN xla_exceptions_pkg.application_exception THEN
7934 RAISE;
7935 WHEN OTHERS THEN
7936 xla_exceptions_pkg.raise_message
7937 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_35');
7938 END AcctLineType_35;
7939 --
7940
7941 ---------------------------------------
7942 --
7943 -- PRIVATE FUNCTION
7944 -- AcctLineType_36
7945 --
7946 ---------------------------------------
7947 PROCEDURE AcctLineType_36 (
7948 p_application_id IN NUMBER
7949 ,p_event_id IN NUMBER
7950 ,p_calculate_acctd_flag IN VARCHAR2
7951 ,p_calculate_g_l_flag IN VARCHAR2
7952 ,p_actual_flag IN OUT VARCHAR2
7953 ,p_balance_type_code OUT VARCHAR2
7954 ,p_gain_or_loss_ref OUT VARCHAR2
7955
7956 --Distribution GL Account
7957 , p_source_5 IN NUMBER
7958 --Distribution Source Type
7959 , p_source_20 IN VARCHAR2
7960 --Distribution Line Identifier
7961 , p_source_22 IN NUMBER
7962 --Distribution Type
7963 , p_source_23 IN VARCHAR2
7964 --Entered Amount
7965 , p_source_24 IN NUMBER
7966 --Currency Code
7967 , p_source_25 IN VARCHAR2
7968 --Exchange Date
7969 , p_source_26 IN DATE
7970 --Exchange Rate
7971 , p_source_27 IN NUMBER
7972 --Exchange Rate Type
7973 , p_source_28 IN VARCHAR2
7974 --Applied To Document Accounting Amount
7975 , p_source_29 IN NUMBER
7976 --Bill To Customer Account Identifier
7977 , p_source_30 IN NUMBER
7978 --Bill To Customer Site Use Identifier
7979 , p_source_31 IN NUMBER
7980 --SLA Party Type
7981 , p_source_32 IN VARCHAR2
7982 )
7983 IS
7984
7985 l_component_type VARCHAR2(80);
7986 l_component_code VARCHAR2(30);
7987 l_component_type_code VARCHAR2(1);
7988 l_component_appl_id INTEGER;
7989 l_amb_context_code VARCHAR2(30);
7990 l_entity_code VARCHAR2(30);
7991 l_event_class_code VARCHAR2(30);
7992 l_ae_header_id NUMBER;
7993 l_event_type_code VARCHAR2(30);
7994 l_line_definition_code VARCHAR2(30);
7995 l_line_definition_owner_code VARCHAR2(1);
7996 --
7997 -- adr variables
7998 l_segment VARCHAR2(30);
7999 l_ccid NUMBER;
8000 l_adr_transaction_coa_id NUMBER;
8001 l_adr_accounting_coa_id NUMBER;
8002 l_adr_flexfield_segment_code VARCHAR2(30);
8003 l_adr_flex_value_set_id NUMBER;
8004 l_adr_value_type_code VARCHAR2(30);
8005 l_adr_value_combination_id NUMBER;
8006 l_adr_value_segment_code VARCHAR2(30);
8007
8008 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
8009 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
8010 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
8011 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
8012
8013 -- 4262811 Variables ------------------------------------------------------------------------------------------
8014 l_entered_amt_idx NUMBER;
8015 l_accted_amt_idx NUMBER;
8016 l_acc_rev_flag VARCHAR2(1);
8017 l_accrual_line_num NUMBER;
8018 l_tmp_amt NUMBER;
8019 l_acc_rev_natural_side_code VARCHAR2(1);
8020
8021 l_num_entries NUMBER;
8022 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
8023 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
8024 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
8025 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
8026 l_recog_line_1 NUMBER;
8027 l_recog_line_2 NUMBER;
8028
8029 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
8030 l_bflow_applied_to_amt NUMBER; -- 5132302
8031 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
8032
8033 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
8034
8035 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
8036 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
8037
8038 ---------------------------------------------------------------------------------------------------------------
8039
8040
8041 --
8042 -- bulk performance
8043 --
8044 l_balance_type_code VARCHAR2(1);
8045 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
8046 l_log_module VARCHAR2(240);
8047
8048 --
8049 -- Upgrade strategy
8050 --
8051 l_actual_upg_option VARCHAR2(1);
8052 l_enc_upg_option VARCHAR2(1);
8053
8054 --
8055 BEGIN
8056 --
8057 IF g_log_enabled THEN
8058 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_36';
8059 END IF;
8060 --
8061 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8062
8063 trace
8064 (p_msg => 'BEGIN of AcctLineType_36'
8065 ,p_level => C_LEVEL_PROCEDURE
8066 ,p_module => l_log_module);
8067
8068 END IF;
8069 --
8070 l_component_type := 'AMB_JLT';
8071 l_component_code := 'ADJ_TAX';
8072 l_component_type_code := 'S';
8073 l_component_appl_id := 222;
8074 l_amb_context_code := 'DEFAULT';
8075 l_entity_code := 'ADJUSTMENTS';
8076 l_event_class_code := 'ADJUSTMENT';
8077 l_event_type_code := 'ADJUSTMENT_ALL';
8078 l_line_definition_owner_code := 'S';
8079 l_line_definition_code := 'AR_ADJ_DEFAULT_ACCRUAL';
8080 --
8081 l_balance_type_code := 'A';
8082 l_segment := NULL;
8083 l_ccid := NULL;
8084 l_adr_transaction_coa_id := NULL;
8085 l_adr_accounting_coa_id := NULL;
8086 l_adr_flexfield_segment_code := NULL;
8087 l_adr_flex_value_set_id := NULL;
8088 l_adr_value_type_code := NULL;
8089 l_adr_value_combination_id := NULL;
8090 l_adr_value_segment_code := NULL;
8091
8092 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
8093 l_bflow_class_code := ''; -- 4219869 Business Flow
8094 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
8095 l_budgetary_control_flag := 'N';
8096
8097 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8098 l_bflow_applied_to_amt := NULL; -- 5132302
8099 l_entered_amt_idx := NULL; -- 4262811
8100 l_accted_amt_idx := NULL; -- 4262811
8101 l_acc_rev_flag := NULL; -- 4262811
8102 l_accrual_line_num := NULL; -- 4262811
8103 l_tmp_amt := NULL; -- 4262811
8104 --
8105
8106 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
8107 l_balance_type_code <> 'B' THEN
8108 IF NVL(p_source_20,'
8109 ') = 'TAX'
8110 THEN
8111
8112 --
8113 XLA_AE_LINES_PKG.SetNewLine;
8114
8115 p_balance_type_code := l_balance_type_code;
8116 -- set the flag so later we will know whether the gain loss line needs to be created
8117
8118 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
8119 p_actual_flag :='A';
8120 END IF;
8121
8122 --
8123 -- bulk performance
8124 --
8125 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
8126 p_header_num => 0); -- 4262811
8127 --
8128 -- set accounting line options
8129 --
8130 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
8131 p_natural_side_code => 'C'
8132 , p_gain_or_loss_flag => 'N'
8133 , p_gl_transfer_mode_code => 'S'
8134 , p_acct_entry_type_code => 'A'
8135 , p_switch_side_flag => 'Y'
8136 , p_merge_duplicate_code => 'A'
8137 );
8138 --
8139 l_acc_rev_natural_side_code := 'D'; -- 4262811
8140 --
8141 --
8142 -- set accounting line type info
8143 --
8144 xla_ae_lines_pkg.SetAcctLineType
8145 (p_component_type => l_component_type
8146 ,p_event_type_code => l_event_type_code
8147 ,p_line_definition_owner_code => l_line_definition_owner_code
8148 ,p_line_definition_code => l_line_definition_code
8149 ,p_accounting_line_code => l_component_code
8150 ,p_accounting_line_type_code => l_component_type_code
8151 ,p_accounting_line_appl_id => l_component_appl_id
8152 ,p_amb_context_code => l_amb_context_code
8153 ,p_entity_code => l_entity_code
8154 ,p_event_class_code => l_event_class_code);
8155 --
8156 -- set accounting class
8157 --
8158 xla_ae_lines_pkg.SetAcctClass(
8159 p_accounting_class_code => 'TAX'
8160 , p_ae_header_id => l_ae_header_id
8161 );
8162
8163 --
8164 -- set rounding class
8165 --
8166 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
8167 'RECEIVABLE';
8168
8169 --
8170 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
8171 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
8172 --
8173 -- bulk performance
8174 --
8175 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
8176
8177 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
8178 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
8179
8180 -- 4955764
8181 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8182 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
8183
8184 -- 4458381 Public Sector Enh
8185
8186 --
8187 -- set accounting attributes for the line type
8188 --
8189 l_entered_amt_idx := 3;
8190 l_accted_amt_idx := 8;
8191 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8192 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
8193 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
8194 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
8195 l_rec_acct_attrs.array_char_value(2) := p_source_23;
8196 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
8197 l_rec_acct_attrs.array_num_value(3) := p_source_24;
8198 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
8199 l_rec_acct_attrs.array_char_value(4) := p_source_25;
8200 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
8201 l_rec_acct_attrs.array_date_value(5) := p_source_26;
8202 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
8203 l_rec_acct_attrs.array_num_value(6) := p_source_27;
8207 l_rec_acct_attrs.array_num_value(8) := p_source_29;
8204 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
8205 l_rec_acct_attrs.array_char_value(7) := p_source_28;
8206 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
8208 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
8209 l_rec_acct_attrs.array_num_value(9) := p_source_30;
8210 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
8211 l_rec_acct_attrs.array_num_value(10) := p_source_31;
8212 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
8213 l_rec_acct_attrs.array_char_value(11) := p_source_32;
8214
8215 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
8216 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
8217
8218 ---------------------------------------------------------------------------------------------------------------
8219 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
8220 ---------------------------------------------------------------------------------------------------------------
8221 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
8222
8223 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8224 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8225
8226 IF xla_accounting_cache_pkg.GetValueChar
8227 (p_source_code => 'LEDGER_CATEGORY_CODE'
8228 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
8229 AND l_bflow_method_code = 'PRIOR_ENTRY'
8230 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
8231 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
8232 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
8233 )
8234 THEN
8235 xla_ae_lines_pkg.BflowUpgEntry
8236 (p_business_method_code => l_bflow_method_code
8237 ,p_business_class_code => l_bflow_class_code
8238 ,p_balance_type => l_balance_type_code);
8239 ELSE
8240 NULL;
8241 -- No business flow processing for business flow method of NONE.
8242 END IF;
8243
8244 --
8245 -- call analytical criteria
8246 --
8247
8248 --
8249 -- call description
8250 --
8251 -- No description or it is inherited.
8252 --
8253 -- call ADRs
8254 -- Bug 4922099
8255 --
8256 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8257 (NVL(l_actual_upg_option, 'N') = 'O') OR
8258 (NVL(l_enc_upg_option, 'N') = 'O')
8259 )
8260 THEN
8261 NULL;
8262 --
8263 --
8264
8265 l_ccid := AcctDerRule_4(
8269 , x_transaction_coa_id => l_adr_transaction_coa_id
8266 p_application_id => p_application_id
8267 , p_ae_header_id => l_ae_header_id
8268 , p_source_5 => p_source_5
8270 , x_accounting_coa_id => l_adr_accounting_coa_id
8271 , x_value_type_code => l_adr_value_type_code
8272 , p_side => 'NA'
8273 );
8274
8275 xla_ae_lines_pkg.set_ccid(
8276 p_code_combination_id => l_ccid
8277 , p_value_type_code => l_adr_value_type_code
8278 , p_transaction_coa_id => l_adr_transaction_coa_id
8279 , p_accounting_coa_id => l_adr_accounting_coa_id
8280 , p_adr_code => 'DIST_CCID'
8281 , p_adr_type_code => 'S'
8282 , p_component_type => l_component_type
8283 , p_component_code => l_component_code
8284 , p_component_type_code => l_component_type_code
8285 , p_component_appl_id => l_component_appl_id
8286 , p_amb_context_code => l_amb_context_code
8287 , p_side => 'NA'
8288 );
8289
8290
8291 --
8292 --
8293 END IF;
8294 --
8295 -- Bug 4922099
8296 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
8297 (NVL(l_enc_upg_option, 'N') = 'O')
8298 ) AND
8299 (l_bflow_method_code = 'PRIOR_ENTRY')
8300 )
8301 THEN
8302 IF
8303 --
8304 1 = 2
8305 --
8306 THEN
8307 xla_accounting_err_pkg.build_message
8308 (p_appli_s_name => 'XLA'
8309 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8310 ,p_token_1 => 'LINE_NUMBER'
8311 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
8312 ,p_token_2 => 'LINE_TYPE_NAME'
8316 ,l_component_type_code
8313 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
8314 l_component_type
8315 ,l_component_code
8317 ,l_component_appl_id
8318 ,l_amb_context_code
8319 ,l_entity_code
8320 ,l_event_class_code
8321 )
8322 ,p_token_3 => 'OWNER'
8323 ,p_value_3 => xla_lookups_pkg.get_meaning(
8324 p_lookup_type => 'XLA_OWNER_TYPE'
8325 ,p_lookup_code => l_component_type_code
8326 )
8327 ,p_token_4 => 'PRODUCT_NAME'
8328 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
8329 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
8330 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
8331 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
8332 ,p_ae_header_id => NULL
8333 );
8334
8335 IF (C_LEVEL_ERROR>= g_log_level) THEN
8336 trace
8337 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8338 ,p_level => C_LEVEL_ERROR
8339 ,p_module => l_log_module);
8340 END IF;
8341 END IF;
8342 END IF;
8343 --
8344 --
8345 ------------------------------------------------------------------------------------------------
8346 -- 4219869 Business Flow
8347 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
8348 -- Prior Entry. Currently, the following code is always generated.
8349 ------------------------------------------------------------------------------------------------
8350 XLA_AE_LINES_PKG.ValidateCurrentLine;
8351
8352 ------------------------------------------------------------------------------------
8353 -- 4219869 Business Flow
8354 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
8355 ------------------------------------------------------------------------------------
8356 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8357
8358 ----------------------------------------------------------------------------------
8359 -- 4219869 Business Flow
8360 -- Update journal entry status -- Need to generate this within IF <condition>
8361 ----------------------------------------------------------------------------------
8362 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8363 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
8364 ,p_balance_type_code => l_balance_type_code
8365 );
8366
8367 -------------------------------------------------------------------------------------------
8368 -- 4262811 - Generate the Accrual Reversal lines
8369 -------------------------------------------------------------------------------------------
8370 BEGIN
8371 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
8372 (g_array_event(p_event_id).array_value_num('header_index'));
8373 IF l_acc_rev_flag IS NULL THEN
8374 l_acc_rev_flag := 'N';
8375 END IF;
8376 EXCEPTION
8377 WHEN OTHERS THEN
8378 l_acc_rev_flag := 'N';
8379 END;
8380 --
8381 IF (l_acc_rev_flag = 'Y') THEN
8382
8383 -- 4645092 ------------------------------------------------------------------------------
8384 -- To allow MPA report to determine if it should generate report process
8385 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
8386 ------------------------------------------------------------------------------------------
8387
8388 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
8392 -- Bug 4922099
8389 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
8390 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
8391 -- call ADRs
8393 --
8394 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8395 (NVL(l_actual_upg_option, 'N') = 'O') OR
8396 (NVL(l_enc_upg_option, 'N') = 'O')
8397 )
8398 THEN
8399 NULL;
8400 --
8401 --
8402
8403 l_ccid := AcctDerRule_4(
8404 p_application_id => p_application_id
8405 , p_ae_header_id => l_ae_header_id
8406 , p_source_5 => p_source_5
8407 , x_transaction_coa_id => l_adr_transaction_coa_id
8408 , x_accounting_coa_id => l_adr_accounting_coa_id
8409 , x_value_type_code => l_adr_value_type_code
8410 , p_side => 'NA'
8411 );
8412
8413 xla_ae_lines_pkg.set_ccid(
8414 p_code_combination_id => l_ccid
8415 , p_value_type_code => l_adr_value_type_code
8416 , p_transaction_coa_id => l_adr_transaction_coa_id
8417 , p_accounting_coa_id => l_adr_accounting_coa_id
8418 , p_adr_code => 'DIST_CCID'
8419 , p_adr_type_code => 'S'
8420 , p_component_type => l_component_type
8421 , p_component_code => l_component_code
8422 , p_component_type_code => l_component_type_code
8423 , p_component_appl_id => l_component_appl_id
8424 , p_amb_context_code => l_amb_context_code
8425 , p_side => 'NA'
8426 );
8427
8428
8429 --
8430 --
8431 END IF;
8432
8433 --
8434 -- Update the line information that should be overwritten
8435 --
8436 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
8437 p_header_num => 1);
8438 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
8439
8440 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
8441
8442 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
8443 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
8444 END IF;
8445
8446 --
8447 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
8448 --
8449 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
8450 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
8451 ELSE
8452 ---------------------------------------------------------------------------------------------------
8453 -- 4262811a Switch Sign
8454 ---------------------------------------------------------------------------------------------------
8455 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
8456 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8457 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8458 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
8459 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8460 -- 5132302
8461 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
8462 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
8463
8464 END IF;
8465
8466 -- 4955764
8467 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8468 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
8469
8470
8471 XLA_AE_LINES_PKG.ValidateCurrentLine;
8472 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8473
8474 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8475 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
8476 ,p_balance_type_code => l_balance_type_code);
8477
8478 END IF;
8479
8480 -----------------------------------------------------------------------------------------
8481 -- 4262811 Multiperiod Accounting
8482 -----------------------------------------------------------------------------------------
8483 -- No MPA option is assigned.
8484
8485
8486 END IF;
8487 END IF;
8488 --
8489
8490 --
8491 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8492 trace
8493 (p_msg => 'END of AcctLineType_36'
8494 ,p_level => C_LEVEL_PROCEDURE
8495 ,p_module => l_log_module);
8496 END IF;
8497 --
8498 EXCEPTION
8499 WHEN xla_exceptions_pkg.application_exception THEN
8500 RAISE;
8501 WHEN OTHERS THEN
8502 xla_exceptions_pkg.raise_message
8503 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_36');
8504 END AcctLineType_36;
8505 --
8506
8507 ---------------------------------------
8508 --
8509 -- PRIVATE FUNCTION
8510 -- AcctLineType_37
8511 --
8512 ---------------------------------------
8513 PROCEDURE AcctLineType_37 (
8514 p_application_id IN NUMBER
8518 ,p_actual_flag IN OUT VARCHAR2
8515 ,p_event_id IN NUMBER
8516 ,p_calculate_acctd_flag IN VARCHAR2
8517 ,p_calculate_g_l_flag IN VARCHAR2
8519 ,p_balance_type_code OUT VARCHAR2
8520 ,p_gain_or_loss_ref OUT VARCHAR2
8521
8522 --Transaction Distribution GL Account
8523 , p_source_19 IN NUMBER
8524 --Bill To Customer Account Identifier
8525 , p_source_30 IN NUMBER
8526 --Bill To Customer Site Use Identifier
8527 , p_source_31 IN NUMBER
8528 --SLA Party Type
8529 , p_source_32 IN VARCHAR2
8530 --Transaction Distribution Account Class
8531 , p_source_33 IN VARCHAR2
8532 --Transaction Distribution Identifier
8533 , p_source_34 IN NUMBER
8534 --Transaction Distribution Type
8535 , p_source_35 IN VARCHAR2
8536 --Transaction Distribution Entered Amount
8537 , p_source_36 IN NUMBER
8538 --Transaction Currency Code
8539 , p_source_37 IN VARCHAR2
8540 --Transaction Exchange Date
8541 , p_source_38 IN DATE
8542 --Transaction Exchange Rate
8543 , p_source_39 IN NUMBER
8544 --Transaction Exchange Rate Type
8548 )
8545 , p_source_40 IN VARCHAR2
8546 --Transaction Accounting Amount
8547 , p_source_41 IN NUMBER
8549 IS
8550
8551 l_component_type VARCHAR2(80);
8552 l_component_code VARCHAR2(30);
8553 l_component_type_code VARCHAR2(1);
8554 l_component_appl_id INTEGER;
8555 l_amb_context_code VARCHAR2(30);
8556 l_entity_code VARCHAR2(30);
8557 l_event_class_code VARCHAR2(30);
8558 l_ae_header_id NUMBER;
8559 l_event_type_code VARCHAR2(30);
8560 l_line_definition_code VARCHAR2(30);
8561 l_line_definition_owner_code VARCHAR2(1);
8562 --
8563 -- adr variables
8564 l_segment VARCHAR2(30);
8565 l_ccid NUMBER;
8566 l_adr_transaction_coa_id NUMBER;
8567 l_adr_accounting_coa_id NUMBER;
8568 l_adr_flexfield_segment_code VARCHAR2(30);
8569 l_adr_flex_value_set_id NUMBER;
8570 l_adr_value_type_code VARCHAR2(30);
8571 l_adr_value_combination_id NUMBER;
8572 l_adr_value_segment_code VARCHAR2(30);
8573
8574 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
8575 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
8576 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
8577 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
8578
8579 -- 4262811 Variables ------------------------------------------------------------------------------------------
8580 l_entered_amt_idx NUMBER;
8581 l_accted_amt_idx NUMBER;
8582 l_acc_rev_flag VARCHAR2(1);
8583 l_accrual_line_num NUMBER;
8584 l_tmp_amt NUMBER;
8585 l_acc_rev_natural_side_code VARCHAR2(1);
8586
8587 l_num_entries NUMBER;
8591 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
8588 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
8589 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
8590 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
8592 l_recog_line_1 NUMBER;
8593 l_recog_line_2 NUMBER;
8594
8595 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
8596 l_bflow_applied_to_amt NUMBER; -- 5132302
8597 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
8598
8599 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
8600
8601 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
8602 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
8603
8604 ---------------------------------------------------------------------------------------------------------------
8605
8606
8607 --
8608 -- bulk performance
8609 --
8610 l_balance_type_code VARCHAR2(1);
8611 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
8612 l_log_module VARCHAR2(240);
8613
8614 --
8615 -- Upgrade strategy
8616 --
8617 l_actual_upg_option VARCHAR2(1);
8618 l_enc_upg_option VARCHAR2(1);
8619
8620 --
8621 BEGIN
8622 --
8623 IF g_log_enabled THEN
8624 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_37';
8625 END IF;
8626 --
8627 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
8628
8629 trace
8630 (p_msg => 'BEGIN of AcctLineType_37'
8631 ,p_level => C_LEVEL_PROCEDURE
8632 ,p_module => l_log_module);
8633
8634 END IF;
8635 --
8636 l_component_type := 'AMB_JLT';
8637 l_component_code := 'CB_DEFAULT_REC';
8638 l_component_type_code := 'S';
8639 l_component_appl_id := 222;
8640 l_amb_context_code := 'DEFAULT';
8641 l_entity_code := 'TRANSACTIONS';
8642 l_event_class_code := 'CHARGEBACK';
8643 l_event_type_code := 'CHARGEBACK_ALL';
8644 l_line_definition_owner_code := 'S';
8645 l_line_definition_code := 'AR_CB_DEFAULT_ACCRUAL';
8646 --
8647 l_balance_type_code := 'A';
8648 l_segment := NULL;
8649 l_ccid := NULL;
8650 l_adr_transaction_coa_id := NULL;
8651 l_adr_accounting_coa_id := NULL;
8652 l_adr_flexfield_segment_code := NULL;
8653 l_adr_flex_value_set_id := NULL;
8654 l_adr_value_type_code := NULL;
8655 l_adr_value_combination_id := NULL;
8656 l_adr_value_segment_code := NULL;
8657
8658 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
8659 l_bflow_class_code := ''; -- 4219869 Business Flow
8660 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
8661 l_budgetary_control_flag := 'N';
8662
8663 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8664 l_bflow_applied_to_amt := NULL; -- 5132302
8665 l_entered_amt_idx := NULL; -- 4262811
8666 l_accted_amt_idx := NULL; -- 4262811
8667 l_acc_rev_flag := NULL; -- 4262811
8668 l_accrual_line_num := NULL; -- 4262811
8669 l_tmp_amt := NULL; -- 4262811
8670 --
8671
8672 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
8673 l_balance_type_code <> 'B' THEN
8674 IF NVL(p_source_33,'
8675 ') = 'REC'
8676 THEN
8677
8678 --
8679 XLA_AE_LINES_PKG.SetNewLine;
8680
8681 p_balance_type_code := l_balance_type_code;
8682 -- set the flag so later we will know whether the gain loss line needs to be created
8683
8684 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
8685 p_actual_flag :='A';
8686 END IF;
8687
8688 --
8689 -- bulk performance
8690 --
8691 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
8692 p_header_num => 0); -- 4262811
8693 --
8694 -- set accounting line options
8695 --
8696 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
8697 p_natural_side_code => 'D'
8698 , p_gain_or_loss_flag => 'N'
8699 , p_gl_transfer_mode_code => 'S'
8700 , p_acct_entry_type_code => 'A'
8701 , p_switch_side_flag => 'Y'
8702 , p_merge_duplicate_code => 'A'
8703 );
8704 --
8705 l_acc_rev_natural_side_code := 'C'; -- 4262811
8706 --
8707 --
8708 -- set accounting line type info
8709 --
8710 xla_ae_lines_pkg.SetAcctLineType
8711 (p_component_type => l_component_type
8712 ,p_event_type_code => l_event_type_code
8713 ,p_line_definition_owner_code => l_line_definition_owner_code
8714 ,p_line_definition_code => l_line_definition_code
8715 ,p_accounting_line_code => l_component_code
8716 ,p_accounting_line_type_code => l_component_type_code
8717 ,p_accounting_line_appl_id => l_component_appl_id
8718 ,p_amb_context_code => l_amb_context_code
8719 ,p_entity_code => l_entity_code
8720 ,p_event_class_code => l_event_class_code);
8721 --
8722 -- set accounting class
8723 --
8724 xla_ae_lines_pkg.SetAcctClass(
8725 p_accounting_class_code => 'RECEIVABLE'
8726 , p_ae_header_id => l_ae_header_id
8727 );
8728
8729 --
8730 -- set rounding class
8731 --
8732 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
8733 'RECEIVABLE';
8734
8735 --
8736 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
8737 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
8738 --
8739 -- bulk performance
8740 --
8741 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
8742
8743 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
8744 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
8745
8746 -- 4955764
8747 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
8748 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
8749
8750 -- 4458381 Public Sector Enh
8751
8752 --
8753 -- set accounting attributes for the line type
8754 --
8755 l_entered_amt_idx := 3;
8756 l_accted_amt_idx := 8;
8757 l_bflow_applied_to_amt_idx := NULL; -- 5132302
8758 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
8759 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
8760 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
8761 l_rec_acct_attrs.array_char_value(2) := p_source_35;
8762 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
8763 l_rec_acct_attrs.array_num_value(3) := p_source_36;
8764 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
8765 l_rec_acct_attrs.array_char_value(4) := p_source_37;
8766 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
8767 l_rec_acct_attrs.array_date_value(5) := p_source_38;
8768 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
8769 l_rec_acct_attrs.array_num_value(6) := p_source_39;
8770 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
8771 l_rec_acct_attrs.array_char_value(7) := p_source_40;
8772 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
8773 l_rec_acct_attrs.array_num_value(8) := p_source_41;
8774 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
8775 l_rec_acct_attrs.array_num_value(9) := p_source_30;
8776 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
8777 l_rec_acct_attrs.array_num_value(10) := p_source_31;
8778 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
8779 l_rec_acct_attrs.array_char_value(11) := p_source_32;
8780
8781 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
8782 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
8783
8784 ---------------------------------------------------------------------------------------------------------------
8785 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
8786 ---------------------------------------------------------------------------------------------------------------
8787 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
8788
8789 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8790 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
8791
8792 IF xla_accounting_cache_pkg.GetValueChar
8796 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
8793 (p_source_code => 'LEDGER_CATEGORY_CODE'
8794 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
8795 AND l_bflow_method_code = 'PRIOR_ENTRY'
8797 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
8798 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
8799 )
8800 THEN
8801 xla_ae_lines_pkg.BflowUpgEntry
8802 (p_business_method_code => l_bflow_method_code
8803 ,p_business_class_code => l_bflow_class_code
8804 ,p_balance_type => l_balance_type_code);
8805 ELSE
8806 NULL;
8807 -- No business flow processing for business flow method of NONE.
8808 END IF;
8809
8810 --
8811 -- call analytical criteria
8812 --
8813
8814 --
8815 -- call description
8816 --
8817 -- No description or it is inherited.
8818 --
8819 -- call ADRs
8820 -- Bug 4922099
8821 --
8822 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8823 (NVL(l_actual_upg_option, 'N') = 'O') OR
8824 (NVL(l_enc_upg_option, 'N') = 'O')
8825 )
8826 THEN
8827 NULL;
8828 --
8829 --
8830
8831 l_ccid := AcctDerRule_28(
8832 p_application_id => p_application_id
8833 , p_ae_header_id => l_ae_header_id
8834 , p_source_19 => p_source_19
8835 , x_transaction_coa_id => l_adr_transaction_coa_id
8836 , x_accounting_coa_id => l_adr_accounting_coa_id
8837 , x_value_type_code => l_adr_value_type_code
8838 , p_side => 'NA'
8839 );
8840
8841 xla_ae_lines_pkg.set_ccid(
8842 p_code_combination_id => l_ccid
8843 , p_value_type_code => l_adr_value_type_code
8844 , p_transaction_coa_id => l_adr_transaction_coa_id
8845 , p_accounting_coa_id => l_adr_accounting_coa_id
8846 , p_adr_code => 'TRX_DIST_CCID'
8847 , p_adr_type_code => 'S'
8848 , p_component_type => l_component_type
8849 , p_component_code => l_component_code
8850 , p_component_type_code => l_component_type_code
8851 , p_component_appl_id => l_component_appl_id
8852 , p_amb_context_code => l_amb_context_code
8853 , p_side => 'NA'
8854 );
8855
8856
8857 --
8858 --
8859 END IF;
8860 --
8861 -- Bug 4922099
8862 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
8863 (NVL(l_enc_upg_option, 'N') = 'O')
8864 ) AND
8865 (l_bflow_method_code = 'PRIOR_ENTRY')
8866 )
8867 THEN
8868 IF
8869 --
8870 1 = 2
8871 --
8872 THEN
8873 xla_accounting_err_pkg.build_message
8874 (p_appli_s_name => 'XLA'
8875 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8876 ,p_token_1 => 'LINE_NUMBER'
8877 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
8878 ,p_token_2 => 'LINE_TYPE_NAME'
8882 ,l_component_type_code
8879 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
8880 l_component_type
8881 ,l_component_code
8883 ,l_component_appl_id
8884 ,l_amb_context_code
8885 ,l_entity_code
8886 ,l_event_class_code
8887 )
8888 ,p_token_3 => 'OWNER'
8889 ,p_value_3 => xla_lookups_pkg.get_meaning(
8890 p_lookup_type => 'XLA_OWNER_TYPE'
8891 ,p_lookup_code => l_component_type_code
8892 )
8893 ,p_token_4 => 'PRODUCT_NAME'
8894 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
8895 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
8896 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
8897 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
8898 ,p_ae_header_id => NULL
8899 );
8900
8901 IF (C_LEVEL_ERROR>= g_log_level) THEN
8902 trace
8903 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
8904 ,p_level => C_LEVEL_ERROR
8905 ,p_module => l_log_module);
8906 END IF;
8907 END IF;
8908 END IF;
8909 --
8910 --
8911 ------------------------------------------------------------------------------------------------
8912 -- 4219869 Business Flow
8913 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
8914 -- Prior Entry. Currently, the following code is always generated.
8915 ------------------------------------------------------------------------------------------------
8916 XLA_AE_LINES_PKG.ValidateCurrentLine;
8917
8918 ------------------------------------------------------------------------------------
8919 -- 4219869 Business Flow
8920 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
8921 ------------------------------------------------------------------------------------
8922 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
8923
8924 ----------------------------------------------------------------------------------
8925 -- 4219869 Business Flow
8926 -- Update journal entry status -- Need to generate this within IF <condition>
8927 ----------------------------------------------------------------------------------
8928 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
8929 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
8930 ,p_balance_type_code => l_balance_type_code
8931 );
8932
8933 -------------------------------------------------------------------------------------------
8934 -- 4262811 - Generate the Accrual Reversal lines
8935 -------------------------------------------------------------------------------------------
8936 BEGIN
8937 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
8938 (g_array_event(p_event_id).array_value_num('header_index'));
8939 IF l_acc_rev_flag IS NULL THEN
8940 l_acc_rev_flag := 'N';
8941 END IF;
8942 EXCEPTION
8943 WHEN OTHERS THEN
8944 l_acc_rev_flag := 'N';
8945 END;
8946 --
8947 IF (l_acc_rev_flag = 'Y') THEN
8948
8949 -- 4645092 ------------------------------------------------------------------------------
8950 -- To allow MPA report to determine if it should generate report process
8951 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
8952 ------------------------------------------------------------------------------------------
8953
8954 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
8955 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
8956 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
8957 -- call ADRs
8958 -- Bug 4922099
8959 --
8960 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
8961 (NVL(l_actual_upg_option, 'N') = 'O') OR
8962 (NVL(l_enc_upg_option, 'N') = 'O')
8963 )
8964 THEN
8965 NULL;
8966 --
8967 --
8968
8969 l_ccid := AcctDerRule_28(
8970 p_application_id => p_application_id
8971 , p_ae_header_id => l_ae_header_id
8972 , p_source_19 => p_source_19
8973 , x_transaction_coa_id => l_adr_transaction_coa_id
8974 , x_accounting_coa_id => l_adr_accounting_coa_id
8975 , x_value_type_code => l_adr_value_type_code
8976 , p_side => 'NA'
8977 );
8978
8979 xla_ae_lines_pkg.set_ccid(
8980 p_code_combination_id => l_ccid
8981 , p_value_type_code => l_adr_value_type_code
8982 , p_transaction_coa_id => l_adr_transaction_coa_id
8983 , p_accounting_coa_id => l_adr_accounting_coa_id
8984 , p_adr_code => 'TRX_DIST_CCID'
8985 , p_adr_type_code => 'S'
8986 , p_component_type => l_component_type
8987 , p_component_code => l_component_code
8988 , p_component_type_code => l_component_type_code
8989 , p_component_appl_id => l_component_appl_id
8990 , p_amb_context_code => l_amb_context_code
8991 , p_side => 'NA'
8992 );
8993
8994
8995 --
8996 --
8997 END IF;
8998
8999 --
9000 -- Update the line information that should be overwritten
9001 --
9002 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
9003 p_header_num => 1);
9004 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
9005
9006 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
9007
9008 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
9009 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
9010 END IF;
9011
9012 --
9013 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
9014 --
9015 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
9016 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
9017 ELSE
9018 ---------------------------------------------------------------------------------------------------
9019 -- 4262811a Switch Sign
9020 ---------------------------------------------------------------------------------------------------
9021 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
9022 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9023 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9024 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9025 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9026 -- 5132302
9027 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
9028 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9029
9030 END IF;
9031
9032 -- 4955764
9033 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9034 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
9035
9036
9037 XLA_AE_LINES_PKG.ValidateCurrentLine;
9038 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9039
9040 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9041 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
9042 ,p_balance_type_code => l_balance_type_code);
9043
9044 END IF;
9045
9046 -----------------------------------------------------------------------------------------
9047 -- 4262811 Multiperiod Accounting
9048 -----------------------------------------------------------------------------------------
9049 -- No MPA option is assigned.
9050
9051
9052 END IF;
9053 END IF;
9054 --
9055
9056 --
9057 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9058 trace
9059 (p_msg => 'END of AcctLineType_37'
9060 ,p_level => C_LEVEL_PROCEDURE
9061 ,p_module => l_log_module);
9062 END IF;
9063 --
9064 EXCEPTION
9065 WHEN xla_exceptions_pkg.application_exception THEN
9066 RAISE;
9067 WHEN OTHERS THEN
9068 xla_exceptions_pkg.raise_message
9069 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_37');
9070 END AcctLineType_37;
9071 --
9072
9073 ---------------------------------------
9074 --
9075 -- PRIVATE FUNCTION
9076 -- AcctLineType_38
9077 --
9078 ---------------------------------------
9079 PROCEDURE AcctLineType_38 (
9080 p_application_id IN NUMBER
9081 ,p_event_id IN NUMBER
9082 ,p_calculate_acctd_flag IN VARCHAR2
9083 ,p_calculate_g_l_flag IN VARCHAR2
9084 ,p_actual_flag IN OUT VARCHAR2
9085 ,p_balance_type_code OUT VARCHAR2
9086 ,p_gain_or_loss_ref OUT VARCHAR2
9087
9088 --Transaction Distribution GL Account
9089 , p_source_19 IN NUMBER
9090 --Bill To Customer Account Identifier
9091 , p_source_30 IN NUMBER
9092 --Bill To Customer Site Use Identifier
9093 , p_source_31 IN NUMBER
9094 --SLA Party Type
9095 , p_source_32 IN VARCHAR2
9096 --Transaction Distribution Account Class
9097 , p_source_33 IN VARCHAR2
9098 --Transaction Distribution Identifier
9099 , p_source_34 IN NUMBER
9100 --Transaction Distribution Type
9101 , p_source_35 IN VARCHAR2
9102 --Transaction Distribution Entered Amount
9103 , p_source_36 IN NUMBER
9104 --Transaction Currency Code
9105 , p_source_37 IN VARCHAR2
9106 --Transaction Exchange Date
9107 , p_source_38 IN DATE
9108 --Transaction Exchange Rate
9109 , p_source_39 IN NUMBER
9110 --Transaction Exchange Rate Type
9111 , p_source_40 IN VARCHAR2
9112 --Transaction Accounting Amount
9113 , p_source_41 IN NUMBER
9114 )
9115 IS
9116
9117 l_component_type VARCHAR2(80);
9118 l_component_code VARCHAR2(30);
9119 l_component_type_code VARCHAR2(1);
9120 l_component_appl_id INTEGER;
9121 l_amb_context_code VARCHAR2(30);
9122 l_entity_code VARCHAR2(30);
9123 l_event_class_code VARCHAR2(30);
9124 l_ae_header_id NUMBER;
9125 l_event_type_code VARCHAR2(30);
9126 l_line_definition_code VARCHAR2(30);
9127 l_line_definition_owner_code VARCHAR2(1);
9128 --
9129 -- adr variables
9130 l_segment VARCHAR2(30);
9131 l_ccid NUMBER;
9135 l_adr_flex_value_set_id NUMBER;
9132 l_adr_transaction_coa_id NUMBER;
9133 l_adr_accounting_coa_id NUMBER;
9134 l_adr_flexfield_segment_code VARCHAR2(30);
9136 l_adr_value_type_code VARCHAR2(30);
9137 l_adr_value_combination_id NUMBER;
9138 l_adr_value_segment_code VARCHAR2(30);
9139
9140 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
9141 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
9142 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
9143 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
9144
9145 -- 4262811 Variables ------------------------------------------------------------------------------------------
9146 l_entered_amt_idx NUMBER;
9147 l_accted_amt_idx NUMBER;
9148 l_acc_rev_flag VARCHAR2(1);
9149 l_accrual_line_num NUMBER;
9150 l_tmp_amt NUMBER;
9151 l_acc_rev_natural_side_code VARCHAR2(1);
9152
9153 l_num_entries NUMBER;
9154 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
9155 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
9156 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
9157 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
9158 l_recog_line_1 NUMBER;
9159 l_recog_line_2 NUMBER;
9160
9161 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
9162 l_bflow_applied_to_amt NUMBER; -- 5132302
9163 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
9164
9165 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
9166
9167 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
9168 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
9169
9170 ---------------------------------------------------------------------------------------------------------------
9171
9172
9173 --
9174 -- bulk performance
9175 --
9176 l_balance_type_code VARCHAR2(1);
9177 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
9178 l_log_module VARCHAR2(240);
9179
9180 --
9181 -- Upgrade strategy
9182 --
9183 l_actual_upg_option VARCHAR2(1);
9184 l_enc_upg_option VARCHAR2(1);
9185
9186 --
9187 BEGIN
9188 --
9189 IF g_log_enabled THEN
9190 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_38';
9191 END IF;
9192 --
9193 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9194
9195 trace
9196 (p_msg => 'BEGIN of AcctLineType_38'
9197 ,p_level => C_LEVEL_PROCEDURE
9198 ,p_module => l_log_module);
9199
9200 END IF;
9201 --
9202 l_component_type := 'AMB_JLT';
9203 l_component_code := 'CB_REV';
9204 l_component_type_code := 'S';
9205 l_component_appl_id := 222;
9206 l_amb_context_code := 'DEFAULT';
9207 l_entity_code := 'TRANSACTIONS';
9208 l_event_class_code := 'CHARGEBACK';
9209 l_event_type_code := 'CHARGEBACK_ALL';
9210 l_line_definition_owner_code := 'S';
9211 l_line_definition_code := 'AR_CB_DEFAULT_ACCRUAL';
9212 --
9213 l_balance_type_code := 'A';
9214 l_segment := NULL;
9215 l_ccid := NULL;
9216 l_adr_transaction_coa_id := NULL;
9217 l_adr_accounting_coa_id := NULL;
9218 l_adr_flexfield_segment_code := NULL;
9219 l_adr_flex_value_set_id := NULL;
9220 l_adr_value_type_code := NULL;
9221 l_adr_value_combination_id := NULL;
9222 l_adr_value_segment_code := NULL;
9223
9224 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
9225 l_bflow_class_code := ''; -- 4219869 Business Flow
9226 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
9227 l_budgetary_control_flag := 'N';
9228
9229 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9230 l_bflow_applied_to_amt := NULL; -- 5132302
9231 l_entered_amt_idx := NULL; -- 4262811
9232 l_accted_amt_idx := NULL; -- 4262811
9233 l_acc_rev_flag := NULL; -- 4262811
9234 l_accrual_line_num := NULL; -- 4262811
9235 l_tmp_amt := NULL; -- 4262811
9236 --
9237
9238 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
9239 l_balance_type_code <> 'B' THEN
9240 IF NVL(p_source_33,'
9241 ') = 'REV'
9242 THEN
9243
9244 --
9245 XLA_AE_LINES_PKG.SetNewLine;
9246
9247 p_balance_type_code := l_balance_type_code;
9248 -- set the flag so later we will know whether the gain loss line needs to be created
9249
9250 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
9251 p_actual_flag :='A';
9252 END IF;
9253
9254 --
9255 -- bulk performance
9256 --
9257 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
9258 p_header_num => 0); -- 4262811
9259 --
9260 -- set accounting line options
9261 --
9262 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
9263 p_natural_side_code => 'C'
9264 , p_gain_or_loss_flag => 'N'
9265 , p_gl_transfer_mode_code => 'S'
9266 , p_acct_entry_type_code => 'A'
9267 , p_switch_side_flag => 'Y'
9268 , p_merge_duplicate_code => 'A'
9269 );
9270 --
9271 l_acc_rev_natural_side_code := 'D'; -- 4262811
9272 --
9273 --
9274 -- set accounting line type info
9275 --
9276 xla_ae_lines_pkg.SetAcctLineType
9277 (p_component_type => l_component_type
9278 ,p_event_type_code => l_event_type_code
9279 ,p_line_definition_owner_code => l_line_definition_owner_code
9280 ,p_line_definition_code => l_line_definition_code
9281 ,p_accounting_line_code => l_component_code
9282 ,p_accounting_line_type_code => l_component_type_code
9283 ,p_accounting_line_appl_id => l_component_appl_id
9284 ,p_amb_context_code => l_amb_context_code
9285 ,p_entity_code => l_entity_code
9286 ,p_event_class_code => l_event_class_code);
9287 --
9288 -- set accounting class
9289 --
9290 xla_ae_lines_pkg.SetAcctClass(
9291 p_accounting_class_code => 'REVENUE'
9295 --
9292 , p_ae_header_id => l_ae_header_id
9293 );
9294
9296 -- set rounding class
9297 --
9298 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
9299 'RECEIVABLE';
9300
9301 --
9302 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
9303 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
9304 --
9305 -- bulk performance
9306 --
9307 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
9308
9309 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
9310 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
9311
9312 -- 4955764
9313 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9314 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
9315
9316 -- 4458381 Public Sector Enh
9317
9318 --
9319 -- set accounting attributes for the line type
9320 --
9321 l_entered_amt_idx := 3;
9322 l_accted_amt_idx := 8;
9323 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9324 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
9325 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
9326 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
9327 l_rec_acct_attrs.array_char_value(2) := p_source_35;
9328 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
9329 l_rec_acct_attrs.array_num_value(3) := p_source_36;
9330 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
9331 l_rec_acct_attrs.array_char_value(4) := p_source_37;
9332 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
9333 l_rec_acct_attrs.array_date_value(5) := p_source_38;
9334 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
9335 l_rec_acct_attrs.array_num_value(6) := p_source_39;
9336 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
9337 l_rec_acct_attrs.array_char_value(7) := p_source_40;
9338 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
9339 l_rec_acct_attrs.array_num_value(8) := p_source_41;
9340 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
9341 l_rec_acct_attrs.array_num_value(9) := p_source_30;
9342 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
9343 l_rec_acct_attrs.array_num_value(10) := p_source_31;
9344 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
9345 l_rec_acct_attrs.array_char_value(11) := p_source_32;
9346
9347 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
9348 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
9349
9350 ---------------------------------------------------------------------------------------------------------------
9351 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
9352 ---------------------------------------------------------------------------------------------------------------
9353 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
9354
9355 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9356 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9357
9358 IF xla_accounting_cache_pkg.GetValueChar
9359 (p_source_code => 'LEDGER_CATEGORY_CODE'
9360 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
9361 AND l_bflow_method_code = 'PRIOR_ENTRY'
9362 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
9363 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
9364 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
9365 )
9366 THEN
9367 xla_ae_lines_pkg.BflowUpgEntry
9368 (p_business_method_code => l_bflow_method_code
9369 ,p_business_class_code => l_bflow_class_code
9370 ,p_balance_type => l_balance_type_code);
9371 ELSE
9372 NULL;
9373 -- No business flow processing for business flow method of NONE.
9374 END IF;
9375
9376 --
9377 -- call analytical criteria
9378 --
9379
9380 --
9381 -- call description
9382 --
9383 -- No description or it is inherited.
9384 --
9385 -- call ADRs
9386 -- Bug 4922099
9387 --
9388 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9389 (NVL(l_actual_upg_option, 'N') = 'O') OR
9390 (NVL(l_enc_upg_option, 'N') = 'O')
9391 )
9392 THEN
9393 NULL;
9394 --
9395 --
9396
9397 l_ccid := AcctDerRule_28(
9398 p_application_id => p_application_id
9399 , p_ae_header_id => l_ae_header_id
9400 , p_source_19 => p_source_19
9401 , x_transaction_coa_id => l_adr_transaction_coa_id
9402 , x_accounting_coa_id => l_adr_accounting_coa_id
9403 , x_value_type_code => l_adr_value_type_code
9404 , p_side => 'NA'
9405 );
9406
9407 xla_ae_lines_pkg.set_ccid(
9408 p_code_combination_id => l_ccid
9409 , p_value_type_code => l_adr_value_type_code
9410 , p_transaction_coa_id => l_adr_transaction_coa_id
9411 , p_accounting_coa_id => l_adr_accounting_coa_id
9412 , p_adr_code => 'TRX_DIST_CCID'
9413 , p_adr_type_code => 'S'
9414 , p_component_type => l_component_type
9415 , p_component_code => l_component_code
9416 , p_component_type_code => l_component_type_code
9417 , p_component_appl_id => l_component_appl_id
9418 , p_amb_context_code => l_amb_context_code
9419 , p_side => 'NA'
9420 );
9421
9422
9423 --
9424 --
9425 END IF;
9426 --
9427 -- Bug 4922099
9428 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
9429 (NVL(l_enc_upg_option, 'N') = 'O')
9430 ) AND
9431 (l_bflow_method_code = 'PRIOR_ENTRY')
9432 )
9433 THEN
9434 IF
9435 --
9436 1 = 2
9437 --
9438 THEN
9439 xla_accounting_err_pkg.build_message
9440 (p_appli_s_name => 'XLA'
9444 ,p_token_2 => 'LINE_TYPE_NAME'
9441 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9442 ,p_token_1 => 'LINE_NUMBER'
9443 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
9445 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
9446 l_component_type
9447 ,l_component_code
9451 ,l_entity_code
9448 ,l_component_type_code
9449 ,l_component_appl_id
9450 ,l_amb_context_code
9452 ,l_event_class_code
9453 )
9454 ,p_token_3 => 'OWNER'
9455 ,p_value_3 => xla_lookups_pkg.get_meaning(
9456 p_lookup_type => 'XLA_OWNER_TYPE'
9457 ,p_lookup_code => l_component_type_code
9458 )
9459 ,p_token_4 => 'PRODUCT_NAME'
9460 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
9461 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
9462 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
9463 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
9464 ,p_ae_header_id => NULL
9465 );
9466
9467 IF (C_LEVEL_ERROR>= g_log_level) THEN
9468 trace
9469 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
9470 ,p_level => C_LEVEL_ERROR
9471 ,p_module => l_log_module);
9472 END IF;
9473 END IF;
9474 END IF;
9475 --
9476 --
9477 ------------------------------------------------------------------------------------------------
9478 -- 4219869 Business Flow
9479 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
9480 -- Prior Entry. Currently, the following code is always generated.
9481 ------------------------------------------------------------------------------------------------
9482 XLA_AE_LINES_PKG.ValidateCurrentLine;
9483
9484 ------------------------------------------------------------------------------------
9485 -- 4219869 Business Flow
9486 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
9487 ------------------------------------------------------------------------------------
9488 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9489
9490 ----------------------------------------------------------------------------------
9491 -- 4219869 Business Flow
9492 -- Update journal entry status -- Need to generate this within IF <condition>
9493 ----------------------------------------------------------------------------------
9494 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9495 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
9496 ,p_balance_type_code => l_balance_type_code
9497 );
9498
9499 -------------------------------------------------------------------------------------------
9500 -- 4262811 - Generate the Accrual Reversal lines
9501 -------------------------------------------------------------------------------------------
9502 BEGIN
9503 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
9504 (g_array_event(p_event_id).array_value_num('header_index'));
9505 IF l_acc_rev_flag IS NULL THEN
9506 l_acc_rev_flag := 'N';
9507 END IF;
9508 EXCEPTION
9509 WHEN OTHERS THEN
9510 l_acc_rev_flag := 'N';
9511 END;
9512 --
9513 IF (l_acc_rev_flag = 'Y') THEN
9514
9515 -- 4645092 ------------------------------------------------------------------------------
9516 -- To allow MPA report to determine if it should generate report process
9517 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
9518 ------------------------------------------------------------------------------------------
9519
9520 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
9521 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
9522 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
9523 -- call ADRs
9524 -- Bug 4922099
9525 --
9526 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9527 (NVL(l_actual_upg_option, 'N') = 'O') OR
9528 (NVL(l_enc_upg_option, 'N') = 'O')
9529 )
9530 THEN
9531 NULL;
9532 --
9533 --
9534
9535 l_ccid := AcctDerRule_28(
9536 p_application_id => p_application_id
9537 , p_ae_header_id => l_ae_header_id
9538 , p_source_19 => p_source_19
9539 , x_transaction_coa_id => l_adr_transaction_coa_id
9540 , x_accounting_coa_id => l_adr_accounting_coa_id
9541 , x_value_type_code => l_adr_value_type_code
9542 , p_side => 'NA'
9543 );
9544
9545 xla_ae_lines_pkg.set_ccid(
9546 p_code_combination_id => l_ccid
9547 , p_value_type_code => l_adr_value_type_code
9548 , p_transaction_coa_id => l_adr_transaction_coa_id
9549 , p_accounting_coa_id => l_adr_accounting_coa_id
9553 , p_component_code => l_component_code
9550 , p_adr_code => 'TRX_DIST_CCID'
9551 , p_adr_type_code => 'S'
9552 , p_component_type => l_component_type
9554 , p_component_type_code => l_component_type_code
9555 , p_component_appl_id => l_component_appl_id
9556 , p_amb_context_code => l_amb_context_code
9557 , p_side => 'NA'
9558 );
9559
9560
9561 --
9562 --
9563 END IF;
9564
9565 --
9566 -- Update the line information that should be overwritten
9567 --
9568 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
9569 p_header_num => 1);
9570 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
9571
9572 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
9573
9574 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
9575 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
9576 END IF;
9577
9578 --
9579 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
9580 --
9581 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
9582 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
9583 ELSE
9584 ---------------------------------------------------------------------------------------------------
9585 -- 4262811a Switch Sign
9586 ---------------------------------------------------------------------------------------------------
9587 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
9588 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9589 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9590 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
9591 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9592 -- 5132302
9593 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
9594 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
9595
9596 END IF;
9597
9598 -- 4955764
9599 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9600 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
9601
9602
9603 XLA_AE_LINES_PKG.ValidateCurrentLine;
9604 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
9605
9606 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
9607 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
9608 ,p_balance_type_code => l_balance_type_code);
9609
9610 END IF;
9611
9612 -----------------------------------------------------------------------------------------
9613 -- 4262811 Multiperiod Accounting
9614 -----------------------------------------------------------------------------------------
9615 -- No MPA option is assigned.
9616
9617
9618 END IF;
9619 END IF;
9620 --
9621
9622 --
9623 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9624 trace
9625 (p_msg => 'END of AcctLineType_38'
9626 ,p_level => C_LEVEL_PROCEDURE
9627 ,p_module => l_log_module);
9628 END IF;
9629 --
9630 EXCEPTION
9631 WHEN xla_exceptions_pkg.application_exception THEN
9632 RAISE;
9633 WHEN OTHERS THEN
9634 xla_exceptions_pkg.raise_message
9635 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_38');
9636 END AcctLineType_38;
9637 --
9638
9639 ---------------------------------------
9640 --
9641 -- PRIVATE FUNCTION
9642 -- AcctLineType_39
9643 --
9644 ---------------------------------------
9645 PROCEDURE AcctLineType_39 (
9646 p_application_id IN NUMBER
9647 ,p_event_id IN NUMBER
9648 ,p_calculate_acctd_flag IN VARCHAR2
9649 ,p_calculate_g_l_flag IN VARCHAR2
9650 ,p_actual_flag IN OUT VARCHAR2
9651 ,p_balance_type_code OUT VARCHAR2
9652 ,p_gain_or_loss_ref OUT VARCHAR2
9653
9654 --Distribution GL Account
9655 , p_source_5 IN NUMBER
9656 --Distribution Source Type
9657 , p_source_20 IN VARCHAR2
9658 --Entered Amount
9659 , p_source_24 IN NUMBER
9660 --SLA Party Type
9661 , p_source_32 IN VARCHAR2
9662 --Credit Memo Distribution Identifier
9663 , p_source_42 IN NUMBER
9664 --Credit memo distributions type
9665 , p_source_43 IN VARCHAR2
9666 --Credit Memo Currency Code
9667 , p_source_44 IN VARCHAR2
9668 --Credit Memo Exchange Date
9669 , p_source_45 IN DATE
9670 --Credit Memo Exchange Rate
9671 , p_source_46 IN NUMBER
9672 --Credit Memo Exchange Rate Type
9673 , p_source_47 IN VARCHAR2
9674 --Gain Loss Reference
9675 , p_source_48 IN VARCHAR2
9676 --Credit Memo Accounting Amount
9677 , p_source_49 IN NUMBER
9678 --Credit Memo Bill To Customer Account Identifier
9679 , p_source_50 IN NUMBER
9680 --Credit Memo Bill To Customer Site Use Identifier
9681 , p_source_51 IN NUMBER
9682 --Credit Memo Tax Line Identifier
9683 , p_source_52 IN NUMBER
9684 )
9685 IS
9686
9687 l_component_type VARCHAR2(80);
9688 l_component_code VARCHAR2(30);
9689 l_component_type_code VARCHAR2(1);
9690 l_component_appl_id INTEGER;
9691 l_amb_context_code VARCHAR2(30);
9692 l_entity_code VARCHAR2(30);
9693 l_event_class_code VARCHAR2(30);
9694 l_ae_header_id NUMBER;
9695 l_event_type_code VARCHAR2(30);
9696 l_line_definition_code VARCHAR2(30);
9697 l_line_definition_owner_code VARCHAR2(1);
9698 --
9699 -- adr variables
9700 l_segment VARCHAR2(30);
9701 l_ccid NUMBER;
9702 l_adr_transaction_coa_id NUMBER;
9703 l_adr_accounting_coa_id NUMBER;
9704 l_adr_flexfield_segment_code VARCHAR2(30);
9705 l_adr_flex_value_set_id NUMBER;
9706 l_adr_value_type_code VARCHAR2(30);
9707 l_adr_value_combination_id NUMBER;
9708 l_adr_value_segment_code VARCHAR2(30);
9709
9710 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
9711 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
9712 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
9713 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
9714
9715 -- 4262811 Variables ------------------------------------------------------------------------------------------
9716 l_entered_amt_idx NUMBER;
9720 l_tmp_amt NUMBER;
9717 l_accted_amt_idx NUMBER;
9718 l_acc_rev_flag VARCHAR2(1);
9719 l_accrual_line_num NUMBER;
9721 l_acc_rev_natural_side_code VARCHAR2(1);
9722
9723 l_num_entries NUMBER;
9724 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
9725 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
9726 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
9727 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
9728 l_recog_line_1 NUMBER;
9729 l_recog_line_2 NUMBER;
9730
9731 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
9732 l_bflow_applied_to_amt NUMBER; -- 5132302
9733 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
9734
9735 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
9736
9737 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
9738 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
9739
9740 ---------------------------------------------------------------------------------------------------------------
9741
9742
9743 --
9744 -- bulk performance
9745 --
9746 l_balance_type_code VARCHAR2(1);
9747 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
9748 l_log_module VARCHAR2(240);
9749
9750 --
9751 -- Upgrade strategy
9752 --
9753 l_actual_upg_option VARCHAR2(1);
9754 l_enc_upg_option VARCHAR2(1);
9755
9756 --
9757 BEGIN
9758 --
9759 IF g_log_enabled THEN
9760 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_39';
9761 END IF;
9762 --
9763 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
9764
9765 trace
9766 (p_msg => 'BEGIN of AcctLineType_39'
9767 ,p_level => C_LEVEL_PROCEDURE
9768 ,p_module => l_log_module);
9769
9770 END IF;
9771 --
9772 l_component_type := 'AMB_JLT';
9773 l_component_code := 'CM_APP_DEFAULT_DEFERRED_TAX';
9774 l_component_type_code := 'S';
9775 l_component_appl_id := 222;
9776 l_amb_context_code := 'DEFAULT';
9777 l_entity_code := 'TRANSACTIONS';
9778 l_event_class_code := 'CREDIT_MEMO';
9779 l_event_type_code := 'CREDIT_MEMO_ALL';
9780 l_line_definition_owner_code := 'S';
9781 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
9782 --
9783 l_balance_type_code := 'A';
9784 l_segment := NULL;
9785 l_ccid := NULL;
9786 l_adr_transaction_coa_id := NULL;
9787 l_adr_accounting_coa_id := NULL;
9788 l_adr_flexfield_segment_code := NULL;
9789 l_adr_flex_value_set_id := NULL;
9790 l_adr_value_type_code := NULL;
9791 l_adr_value_combination_id := NULL;
9792 l_adr_value_segment_code := NULL;
9793
9794 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
9795 l_bflow_class_code := ''; -- 4219869 Business Flow
9796 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
9797 l_budgetary_control_flag := 'N';
9798
9799 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9800 l_bflow_applied_to_amt := NULL; -- 5132302
9801 l_entered_amt_idx := NULL; -- 4262811
9802 l_accted_amt_idx := NULL; -- 4262811
9803 l_acc_rev_flag := NULL; -- 4262811
9804 l_accrual_line_num := NULL; -- 4262811
9805 l_tmp_amt := NULL; -- 4262811
9806 --
9807
9808 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
9809 l_balance_type_code <> 'B' THEN
9810 IF NVL(p_source_20,'
9811 ') = 'DEFERRED_TAX'
9812 THEN
9813
9814 --
9815 XLA_AE_LINES_PKG.SetNewLine;
9816
9817 p_balance_type_code := l_balance_type_code;
9818 -- set the flag so later we will know whether the gain loss line needs to be created
9819
9820 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
9821 p_actual_flag :='A';
9825 -- bulk performance
9822 END IF;
9823
9824 --
9826 --
9827 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
9828 p_header_num => 0); -- 4262811
9829 --
9830 -- set accounting line options
9831 --
9832 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
9833 p_natural_side_code => 'C'
9834 , p_gain_or_loss_flag => 'N'
9835 , p_gl_transfer_mode_code => 'S'
9836 , p_acct_entry_type_code => 'A'
9837 , p_switch_side_flag => 'Y'
9838 , p_merge_duplicate_code => 'A'
9839 );
9840 --
9841 l_acc_rev_natural_side_code := 'D'; -- 4262811
9842 --
9843 --
9844 -- set accounting line type info
9845 --
9846 xla_ae_lines_pkg.SetAcctLineType
9847 (p_component_type => l_component_type
9848 ,p_event_type_code => l_event_type_code
9849 ,p_line_definition_owner_code => l_line_definition_owner_code
9850 ,p_line_definition_code => l_line_definition_code
9851 ,p_accounting_line_code => l_component_code
9852 ,p_accounting_line_type_code => l_component_type_code
9853 ,p_accounting_line_appl_id => l_component_appl_id
9854 ,p_amb_context_code => l_amb_context_code
9855 ,p_entity_code => l_entity_code
9856 ,p_event_class_code => l_event_class_code);
9857 --
9858 -- set accounting class
9859 --
9860 xla_ae_lines_pkg.SetAcctClass(
9861 p_accounting_class_code => 'DEFERRED_TAX'
9862 , p_ae_header_id => l_ae_header_id
9863 );
9864
9865 --
9866 -- set rounding class
9867 --
9868 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
9869 'RECEIVABLE';
9870
9871 --
9872 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
9873 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
9874 --
9875 -- bulk performance
9876 --
9877 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
9878
9882 -- 4955764
9879 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
9880 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
9881
9883 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
9884 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
9885
9886 -- 4458381 Public Sector Enh
9887
9888 --
9889 -- set accounting attributes for the line type
9890 --
9891 l_entered_amt_idx := 3;
9892 l_accted_amt_idx := 9;
9893 l_bflow_applied_to_amt_idx := NULL; -- 5132302
9894 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
9895 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
9896 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
9897 l_rec_acct_attrs.array_char_value(2) := p_source_43;
9898 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
9899 l_rec_acct_attrs.array_num_value(3) := p_source_24;
9900 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
9901 l_rec_acct_attrs.array_char_value(4) := p_source_44;
9902 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
9903 l_rec_acct_attrs.array_date_value(5) := p_source_45;
9904 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
9905 l_rec_acct_attrs.array_num_value(6) := p_source_46;
9906 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
9907 l_rec_acct_attrs.array_char_value(7) := p_source_47;
9908 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
9909 l_rec_acct_attrs.array_char_value(8) := p_source_48;
9910 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
9911 l_rec_acct_attrs.array_num_value(9) := p_source_49;
9912 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
9913 l_rec_acct_attrs.array_num_value(10) := p_source_50;
9914 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
9915 l_rec_acct_attrs.array_num_value(11) := p_source_51;
9916 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
9917 l_rec_acct_attrs.array_char_value(12) := p_source_32;
9918 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
9919 l_rec_acct_attrs.array_num_value(13) := p_source_52;
9920
9921 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
9922 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
9923
9924 ---------------------------------------------------------------------------------------------------------------
9925 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
9926 ---------------------------------------------------------------------------------------------------------------
9927 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
9928
9929 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9930 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
9931
9932 IF xla_accounting_cache_pkg.GetValueChar
9933 (p_source_code => 'LEDGER_CATEGORY_CODE'
9934 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
9935 AND l_bflow_method_code = 'PRIOR_ENTRY'
9936 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
9937 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
9938 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
9939 )
9940 THEN
9941 xla_ae_lines_pkg.BflowUpgEntry
9942 (p_business_method_code => l_bflow_method_code
9943 ,p_business_class_code => l_bflow_class_code
9944 ,p_balance_type => l_balance_type_code);
9945 ELSE
9946 NULL;
9947 -- No business flow processing for business flow method of NONE.
9948 END IF;
9949
9950 --
9951 -- call analytical criteria
9952 --
9953
9954 --
9955 -- call description
9956 --
9957 -- No description or it is inherited.
9958 --
9959 -- call ADRs
9960 -- Bug 4922099
9961 --
9962 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
9963 (NVL(l_actual_upg_option, 'N') = 'O') OR
9964 (NVL(l_enc_upg_option, 'N') = 'O')
9965 )
9966 THEN
9967 NULL;
9968 --
9969 --
9970
9971 l_ccid := AcctDerRule_4(
9972 p_application_id => p_application_id
9973 , p_ae_header_id => l_ae_header_id
9974 , p_source_5 => p_source_5
9975 , x_transaction_coa_id => l_adr_transaction_coa_id
9976 , x_accounting_coa_id => l_adr_accounting_coa_id
9977 , x_value_type_code => l_adr_value_type_code
9978 , p_side => 'NA'
9979 );
9980
9981 xla_ae_lines_pkg.set_ccid(
9982 p_code_combination_id => l_ccid
9983 , p_value_type_code => l_adr_value_type_code
9984 , p_transaction_coa_id => l_adr_transaction_coa_id
9985 , p_accounting_coa_id => l_adr_accounting_coa_id
9986 , p_adr_code => 'DIST_CCID'
9987 , p_adr_type_code => 'S'
9988 , p_component_type => l_component_type
9989 , p_component_code => l_component_code
9990 , p_component_type_code => l_component_type_code
9991 , p_component_appl_id => l_component_appl_id
9992 , p_amb_context_code => l_amb_context_code
9993 , p_side => 'NA'
9994 );
9995
9996
9997 --
9998 --
9999 END IF;
10000 --
10001 -- Bug 4922099
10002 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
10003 (NVL(l_enc_upg_option, 'N') = 'O')
10004 ) AND
10005 (l_bflow_method_code = 'PRIOR_ENTRY')
10006 )
10007 THEN
10008 IF
10009 --
10010 1 = 2
10011 --
10012 THEN
10013 xla_accounting_err_pkg.build_message
10014 (p_appli_s_name => 'XLA'
10015 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10016 ,p_token_1 => 'LINE_NUMBER'
10017 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
10018 ,p_token_2 => 'LINE_TYPE_NAME'
10019 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
10023 ,l_component_appl_id
10020 l_component_type
10021 ,l_component_code
10022 ,l_component_type_code
10024 ,l_amb_context_code
10025 ,l_entity_code
10026 ,l_event_class_code
10027 )
10028 ,p_token_3 => 'OWNER'
10029 ,p_value_3 => xla_lookups_pkg.get_meaning(
10030 p_lookup_type => 'XLA_OWNER_TYPE'
10031 ,p_lookup_code => l_component_type_code
10032 )
10033 ,p_token_4 => 'PRODUCT_NAME'
10034 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
10035 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
10036 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
10037 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
10038 ,p_ae_header_id => NULL
10039 );
10040
10041 IF (C_LEVEL_ERROR>= g_log_level) THEN
10042 trace
10043 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10044 ,p_level => C_LEVEL_ERROR
10045 ,p_module => l_log_module);
10046 END IF;
10047 END IF;
10048 END IF;
10049 --
10050 --
10051 ------------------------------------------------------------------------------------------------
10052 -- 4219869 Business Flow
10053 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
10054 -- Prior Entry. Currently, the following code is always generated.
10055 ------------------------------------------------------------------------------------------------
10056 XLA_AE_LINES_PKG.ValidateCurrentLine;
10057
10058 ------------------------------------------------------------------------------------
10059 -- 4219869 Business Flow
10060 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
10061 ------------------------------------------------------------------------------------
10062 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10063
10064 ----------------------------------------------------------------------------------
10065 -- 4219869 Business Flow
10066 -- Update journal entry status -- Need to generate this within IF <condition>
10067 ----------------------------------------------------------------------------------
10068 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10069 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
10073 -------------------------------------------------------------------------------------------
10070 ,p_balance_type_code => l_balance_type_code
10071 );
10072
10074 -- 4262811 - Generate the Accrual Reversal lines
10075 -------------------------------------------------------------------------------------------
10076 BEGIN
10077 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
10078 (g_array_event(p_event_id).array_value_num('header_index'));
10079 IF l_acc_rev_flag IS NULL THEN
10080 l_acc_rev_flag := 'N';
10081 END IF;
10082 EXCEPTION
10083 WHEN OTHERS THEN
10084 l_acc_rev_flag := 'N';
10085 END;
10086 --
10087 IF (l_acc_rev_flag = 'Y') THEN
10088
10089 -- 4645092 ------------------------------------------------------------------------------
10090 -- To allow MPA report to determine if it should generate report process
10091 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
10092 ------------------------------------------------------------------------------------------
10093
10094 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
10095 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
10096 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
10097 -- call ADRs
10098 -- Bug 4922099
10099 --
10100 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10101 (NVL(l_actual_upg_option, 'N') = 'O') OR
10102 (NVL(l_enc_upg_option, 'N') = 'O')
10103 )
10104 THEN
10105 NULL;
10106 --
10107 --
10108
10109 l_ccid := AcctDerRule_4(
10110 p_application_id => p_application_id
10111 , p_ae_header_id => l_ae_header_id
10112 , p_source_5 => p_source_5
10113 , x_transaction_coa_id => l_adr_transaction_coa_id
10114 , x_accounting_coa_id => l_adr_accounting_coa_id
10115 , x_value_type_code => l_adr_value_type_code
10116 , p_side => 'NA'
10117 );
10118
10119 xla_ae_lines_pkg.set_ccid(
10120 p_code_combination_id => l_ccid
10121 , p_value_type_code => l_adr_value_type_code
10122 , p_transaction_coa_id => l_adr_transaction_coa_id
10123 , p_accounting_coa_id => l_adr_accounting_coa_id
10124 , p_adr_code => 'DIST_CCID'
10125 , p_adr_type_code => 'S'
10126 , p_component_type => l_component_type
10127 , p_component_code => l_component_code
10128 , p_component_type_code => l_component_type_code
10129 , p_component_appl_id => l_component_appl_id
10130 , p_amb_context_code => l_amb_context_code
10131 , p_side => 'NA'
10132 );
10133
10134
10135 --
10136 --
10137 END IF;
10138
10139 --
10140 -- Update the line information that should be overwritten
10141 --
10142 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
10143 p_header_num => 1);
10144 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
10145
10149 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
10146 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
10147
10148 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
10150 END IF;
10151
10152 --
10153 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
10154 --
10155 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
10156 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
10157 ELSE
10158 ---------------------------------------------------------------------------------------------------
10159 -- 4262811a Switch Sign
10160 ---------------------------------------------------------------------------------------------------
10161 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
10162 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10163 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10167 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
10164 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10165 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10166 -- 5132302
10168 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10169
10170 END IF;
10171
10172 -- 4955764
10173 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10174 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
10175
10176
10177 XLA_AE_LINES_PKG.ValidateCurrentLine;
10178 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10179
10180 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10181 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
10182 ,p_balance_type_code => l_balance_type_code);
10183
10184 END IF;
10185
10186 -----------------------------------------------------------------------------------------
10187 -- 4262811 Multiperiod Accounting
10188 -----------------------------------------------------------------------------------------
10189 -- No MPA option is assigned.
10190
10191
10192 END IF;
10193 END IF;
10194 --
10195
10196 --
10197 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10198 trace
10199 (p_msg => 'END of AcctLineType_39'
10200 ,p_level => C_LEVEL_PROCEDURE
10201 ,p_module => l_log_module);
10202 END IF;
10203 --
10204 EXCEPTION
10205 WHEN xla_exceptions_pkg.application_exception THEN
10206 RAISE;
10207 WHEN OTHERS THEN
10208 xla_exceptions_pkg.raise_message
10209 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_39');
10210 END AcctLineType_39;
10211 --
10212
10213 ---------------------------------------
10214 --
10215 -- PRIVATE FUNCTION
10216 -- AcctLineType_40
10217 --
10218 ---------------------------------------
10219 PROCEDURE AcctLineType_40 (
10220 p_application_id IN NUMBER
10221 ,p_event_id IN NUMBER
10222 ,p_calculate_acctd_flag IN VARCHAR2
10223 ,p_calculate_g_l_flag IN VARCHAR2
10224 ,p_actual_flag IN OUT VARCHAR2
10225 ,p_balance_type_code OUT VARCHAR2
10226 ,p_gain_or_loss_ref OUT VARCHAR2
10227
10228 --Transaction Type Name
10229 , p_source_1 IN VARCHAR2
10230 --Transaction Number
10231 , p_source_2 IN VARCHAR2
10232 --Transaction Document Sequence Number
10233 , p_source_3 IN NUMBER
10234 --Distribution GL Account
10235 , p_source_5 IN NUMBER
10236 --Distribution Source Type
10237 , p_source_20 IN VARCHAR2
10238 --Entered Amount
10239 , p_source_24 IN NUMBER
10240 --SLA Party Type
10241 , p_source_32 IN VARCHAR2
10242 --Credit Memo Distribution Identifier
10243 , p_source_42 IN NUMBER
10244 --Credit memo distributions type
10245 , p_source_43 IN VARCHAR2
10246 --Credit Memo Currency Code
10247 , p_source_44 IN VARCHAR2
10248 --Credit Memo Exchange Date
10249 , p_source_45 IN DATE
10250 --Credit Memo Exchange Rate
10251 , p_source_46 IN NUMBER
10252 --Credit Memo Exchange Rate Type
10253 , p_source_47 IN VARCHAR2
10254 --Gain Loss Reference
10255 , p_source_48 IN VARCHAR2
10256 --Credit Memo Accounting Amount
10257 , p_source_49 IN NUMBER
10258 --Credit Memo Bill To Customer Account Identifier
10259 , p_source_50 IN NUMBER
10260 --Credit Memo Bill To Customer Site Use Identifier
10261 , p_source_51 IN NUMBER
10262 --Credit Memo Tax Line Identifier
10263 , p_source_52 IN NUMBER
10264 )
10265 IS
10266
10267 l_component_type VARCHAR2(80);
10268 l_component_code VARCHAR2(30);
10269 l_component_type_code VARCHAR2(1);
10270 l_component_appl_id INTEGER;
10271 l_amb_context_code VARCHAR2(30);
10272 l_entity_code VARCHAR2(30);
10273 l_event_class_code VARCHAR2(30);
10274 l_ae_header_id NUMBER;
10275 l_event_type_code VARCHAR2(30);
10276 l_line_definition_code VARCHAR2(30);
10277 l_line_definition_owner_code VARCHAR2(1);
10278 --
10279 -- adr variables
10280 l_segment VARCHAR2(30);
10281 l_ccid NUMBER;
10282 l_adr_transaction_coa_id NUMBER;
10283 l_adr_accounting_coa_id NUMBER;
10284 l_adr_flexfield_segment_code VARCHAR2(30);
10285 l_adr_flex_value_set_id NUMBER;
10286 l_adr_value_type_code VARCHAR2(30);
10287 l_adr_value_combination_id NUMBER;
10288 l_adr_value_segment_code VARCHAR2(30);
10289
10290 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
10291 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
10292 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
10293 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
10294
10295 -- 4262811 Variables ------------------------------------------------------------------------------------------
10296 l_entered_amt_idx NUMBER;
10300 l_tmp_amt NUMBER;
10297 l_accted_amt_idx NUMBER;
10298 l_acc_rev_flag VARCHAR2(1);
10299 l_accrual_line_num NUMBER;
10301 l_acc_rev_natural_side_code VARCHAR2(1);
10302
10303 l_num_entries NUMBER;
10304 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
10305 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
10306 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
10307 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
10308 l_recog_line_1 NUMBER;
10309 l_recog_line_2 NUMBER;
10310
10311 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
10312 l_bflow_applied_to_amt NUMBER; -- 5132302
10313 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
10314
10315 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
10316
10317 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
10318 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
10319
10320 ---------------------------------------------------------------------------------------------------------------
10321
10322
10323 --
10324 -- bulk performance
10325 --
10326 l_balance_type_code VARCHAR2(1);
10327 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
10328 l_log_module VARCHAR2(240);
10329
10330 --
10331 -- Upgrade strategy
10332 --
10333 l_actual_upg_option VARCHAR2(1);
10334 l_enc_upg_option VARCHAR2(1);
10335
10336 --
10337 BEGIN
10338 --
10339 IF g_log_enabled THEN
10340 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_40';
10341 END IF;
10342 --
10343 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10344
10345 trace
10346 (p_msg => 'BEGIN of AcctLineType_40'
10347 ,p_level => C_LEVEL_PROCEDURE
10348 ,p_module => l_log_module);
10349
10350 END IF;
10351 --
10352 l_component_type := 'AMB_JLT';
10353 l_component_code := 'CM_APP_DEFAULT_REC';
10354 l_component_type_code := 'S';
10355 l_component_appl_id := 222;
10356 l_amb_context_code := 'DEFAULT';
10357 l_entity_code := 'TRANSACTIONS';
10358 l_event_class_code := 'CREDIT_MEMO';
10359 l_event_type_code := 'CREDIT_MEMO_ALL';
10360 l_line_definition_owner_code := 'S';
10361 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
10362 --
10363 l_balance_type_code := 'A';
10364 l_segment := NULL;
10365 l_ccid := NULL;
10366 l_adr_transaction_coa_id := NULL;
10367 l_adr_accounting_coa_id := NULL;
10368 l_adr_flexfield_segment_code := NULL;
10369 l_adr_flex_value_set_id := NULL;
10370 l_adr_value_type_code := NULL;
10371 l_adr_value_combination_id := NULL;
10372 l_adr_value_segment_code := NULL;
10373
10374 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
10375 l_bflow_class_code := ''; -- 4219869 Business Flow
10376 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
10377 l_budgetary_control_flag := 'N';
10378
10379 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10380 l_bflow_applied_to_amt := NULL; -- 5132302
10381 l_entered_amt_idx := NULL; -- 4262811
10382 l_accted_amt_idx := NULL; -- 4262811
10383 l_acc_rev_flag := NULL; -- 4262811
10384 l_accrual_line_num := NULL; -- 4262811
10385 l_tmp_amt := NULL; -- 4262811
10386 --
10387
10388 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
10389 l_balance_type_code <> 'B' THEN
10390 IF NVL(p_source_20,'
10391 ') = 'REC'
10392 THEN
10393
10394 --
10395 XLA_AE_LINES_PKG.SetNewLine;
10396
10397 p_balance_type_code := l_balance_type_code;
10398 -- set the flag so later we will know whether the gain loss line needs to be created
10399
10400 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
10401 p_actual_flag :='A';
10402 END IF;
10406 --
10403
10404 --
10405 -- bulk performance
10407 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
10408 p_header_num => 0); -- 4262811
10409 --
10410 -- set accounting line options
10411 --
10412 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
10413 p_natural_side_code => 'C'
10414 , p_gain_or_loss_flag => 'N'
10415 , p_gl_transfer_mode_code => 'S'
10416 , p_acct_entry_type_code => 'A'
10417 , p_switch_side_flag => 'Y'
10418 , p_merge_duplicate_code => 'A'
10419 );
10420 --
10421 l_acc_rev_natural_side_code := 'D'; -- 4262811
10422 --
10423 --
10424 -- set accounting line type info
10425 --
10426 xla_ae_lines_pkg.SetAcctLineType
10427 (p_component_type => l_component_type
10428 ,p_event_type_code => l_event_type_code
10429 ,p_line_definition_owner_code => l_line_definition_owner_code
10430 ,p_line_definition_code => l_line_definition_code
10431 ,p_accounting_line_code => l_component_code
10432 ,p_accounting_line_type_code => l_component_type_code
10433 ,p_accounting_line_appl_id => l_component_appl_id
10434 ,p_amb_context_code => l_amb_context_code
10435 ,p_entity_code => l_entity_code
10436 ,p_event_class_code => l_event_class_code);
10437 --
10438 -- set accounting class
10439 --
10440 xla_ae_lines_pkg.SetAcctClass(
10441 p_accounting_class_code => 'RECEIVABLE'
10442 , p_ae_header_id => l_ae_header_id
10443 );
10444
10445 --
10446 -- set rounding class
10447 --
10448 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
10449 'RECEIVABLE';
10450
10451 --
10452 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
10453 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
10454 --
10455 -- bulk performance
10456 --
10460 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
10457 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
10458
10459 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
10461
10462 -- 4955764
10463 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10464 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
10465
10466 -- 4458381 Public Sector Enh
10467
10468 --
10469 -- set accounting attributes for the line type
10470 --
10471 l_entered_amt_idx := 3;
10472 l_accted_amt_idx := 9;
10473 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10474 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
10475 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
10476 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
10477 l_rec_acct_attrs.array_char_value(2) := p_source_43;
10478 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
10479 l_rec_acct_attrs.array_num_value(3) := p_source_24;
10480 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
10481 l_rec_acct_attrs.array_char_value(4) := p_source_44;
10482 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
10483 l_rec_acct_attrs.array_date_value(5) := p_source_45;
10484 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
10485 l_rec_acct_attrs.array_num_value(6) := p_source_46;
10486 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
10487 l_rec_acct_attrs.array_char_value(7) := p_source_47;
10488 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
10489 l_rec_acct_attrs.array_char_value(8) := p_source_48;
10490 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
10491 l_rec_acct_attrs.array_num_value(9) := p_source_49;
10492 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
10493 l_rec_acct_attrs.array_num_value(10) := p_source_50;
10494 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
10495 l_rec_acct_attrs.array_num_value(11) := p_source_51;
10499 l_rec_acct_attrs.array_num_value(13) := p_source_52;
10496 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
10497 l_rec_acct_attrs.array_char_value(12) := p_source_32;
10498 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
10500
10501 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
10502 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
10503
10504 ---------------------------------------------------------------------------------------------------------------
10505 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
10506 ---------------------------------------------------------------------------------------------------------------
10507 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
10508
10509 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10510 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
10511
10512 IF xla_accounting_cache_pkg.GetValueChar
10513 (p_source_code => 'LEDGER_CATEGORY_CODE'
10514 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
10515 AND l_bflow_method_code = 'PRIOR_ENTRY'
10516 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
10517 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
10518 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
10519 )
10520 THEN
10521 xla_ae_lines_pkg.BflowUpgEntry
10522 (p_business_method_code => l_bflow_method_code
10523 ,p_business_class_code => l_bflow_class_code
10524 ,p_balance_type => l_balance_type_code);
10525 ELSE
10526 NULL;
10527 -- No business flow processing for business flow method of NONE.
10528 END IF;
10529
10530 --
10531 -- call analytical criteria
10532 --
10533
10534 --
10535 -- call description
10536 --
10537
10538 xla_ae_lines_pkg.SetLineDescription(
10539 p_ae_header_id => l_ae_header_id
10540 ,p_description => Description_1 (
10541 p_application_id => p_application_id
10542 , p_ae_header_id => l_ae_header_id
10543 , p_source_1 => p_source_1
10544 , p_source_2 => p_source_2
10545 , p_source_3 => p_source_3
10546 )
10547 );
10548
10549
10550 --
10551 -- call ADRs
10552 -- Bug 4922099
10553 --
10554 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10555 (NVL(l_actual_upg_option, 'N') = 'O') OR
10556 (NVL(l_enc_upg_option, 'N') = 'O')
10557 )
10558 THEN
10559 NULL;
10560 --
10561 --
10562
10563 l_ccid := AcctDerRule_4(
10564 p_application_id => p_application_id
10565 , p_ae_header_id => l_ae_header_id
10566 , p_source_5 => p_source_5
10567 , x_transaction_coa_id => l_adr_transaction_coa_id
10568 , x_accounting_coa_id => l_adr_accounting_coa_id
10569 , x_value_type_code => l_adr_value_type_code
10570 , p_side => 'NA'
10571 );
10572
10573 xla_ae_lines_pkg.set_ccid(
10574 p_code_combination_id => l_ccid
10575 , p_value_type_code => l_adr_value_type_code
10576 , p_transaction_coa_id => l_adr_transaction_coa_id
10577 , p_accounting_coa_id => l_adr_accounting_coa_id
10578 , p_adr_code => 'DIST_CCID'
10579 , p_adr_type_code => 'S'
10580 , p_component_type => l_component_type
10581 , p_component_code => l_component_code
10582 , p_component_type_code => l_component_type_code
10583 , p_component_appl_id => l_component_appl_id
10584 , p_amb_context_code => l_amb_context_code
10585 , p_side => 'NA'
10586 );
10587
10588
10589 --
10590 --
10591 END IF;
10592 --
10593 -- Bug 4922099
10594 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
10595 (NVL(l_enc_upg_option, 'N') = 'O')
10596 ) AND
10597 (l_bflow_method_code = 'PRIOR_ENTRY')
10598 )
10599 THEN
10600 IF
10601 --
10602 1 = 2
10603 --
10604 THEN
10608 ,p_token_1 => 'LINE_NUMBER'
10605 xla_accounting_err_pkg.build_message
10606 (p_appli_s_name => 'XLA'
10607 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10609 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
10610 ,p_token_2 => 'LINE_TYPE_NAME'
10611 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
10612 l_component_type
10613 ,l_component_code
10614 ,l_component_type_code
10615 ,l_component_appl_id
10616 ,l_amb_context_code
10617 ,l_entity_code
10618 ,l_event_class_code
10619 )
10620 ,p_token_3 => 'OWNER'
10621 ,p_value_3 => xla_lookups_pkg.get_meaning(
10622 p_lookup_type => 'XLA_OWNER_TYPE'
10623 ,p_lookup_code => l_component_type_code
10624 )
10625 ,p_token_4 => 'PRODUCT_NAME'
10626 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
10627 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
10628 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
10629 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
10630 ,p_ae_header_id => NULL
10631 );
10632
10633 IF (C_LEVEL_ERROR>= g_log_level) THEN
10634 trace
10635 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
10636 ,p_level => C_LEVEL_ERROR
10637 ,p_module => l_log_module);
10638 END IF;
10639 END IF;
10640 END IF;
10641 --
10642 --
10643 ------------------------------------------------------------------------------------------------
10644 -- 4219869 Business Flow
10645 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
10646 -- Prior Entry. Currently, the following code is always generated.
10647 ------------------------------------------------------------------------------------------------
10648 XLA_AE_LINES_PKG.ValidateCurrentLine;
10649
10650 ------------------------------------------------------------------------------------
10651 -- 4219869 Business Flow
10652 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
10653 ------------------------------------------------------------------------------------
10654 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10655
10656 ----------------------------------------------------------------------------------
10657 -- 4219869 Business Flow
10658 -- Update journal entry status -- Need to generate this within IF <condition>
10659 ----------------------------------------------------------------------------------
10660 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10661 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
10662 ,p_balance_type_code => l_balance_type_code
10663 );
10664
10665 -------------------------------------------------------------------------------------------
10666 -- 4262811 - Generate the Accrual Reversal lines
10667 -------------------------------------------------------------------------------------------
10668 BEGIN
10669 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
10670 (g_array_event(p_event_id).array_value_num('header_index'));
10671 IF l_acc_rev_flag IS NULL THEN
10672 l_acc_rev_flag := 'N';
10673 END IF;
10674 EXCEPTION
10675 WHEN OTHERS THEN
10676 l_acc_rev_flag := 'N';
10677 END;
10678 --
10679 IF (l_acc_rev_flag = 'Y') THEN
10680
10681 -- 4645092 ------------------------------------------------------------------------------
10682 -- To allow MPA report to determine if it should generate report process
10683 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
10684 ------------------------------------------------------------------------------------------
10685
10686 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
10687 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
10688 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
10689 -- call ADRs
10690 -- Bug 4922099
10691 --
10692 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
10696 THEN
10693 (NVL(l_actual_upg_option, 'N') = 'O') OR
10694 (NVL(l_enc_upg_option, 'N') = 'O')
10695 )
10697 NULL;
10698 --
10699 --
10700
10701 l_ccid := AcctDerRule_4(
10702 p_application_id => p_application_id
10703 , p_ae_header_id => l_ae_header_id
10704 , p_source_5 => p_source_5
10705 , x_transaction_coa_id => l_adr_transaction_coa_id
10706 , x_accounting_coa_id => l_adr_accounting_coa_id
10707 , x_value_type_code => l_adr_value_type_code
10708 , p_side => 'NA'
10709 );
10710
10711 xla_ae_lines_pkg.set_ccid(
10712 p_code_combination_id => l_ccid
10713 , p_value_type_code => l_adr_value_type_code
10714 , p_transaction_coa_id => l_adr_transaction_coa_id
10715 , p_accounting_coa_id => l_adr_accounting_coa_id
10716 , p_adr_code => 'DIST_CCID'
10717 , p_adr_type_code => 'S'
10718 , p_component_type => l_component_type
10719 , p_component_code => l_component_code
10720 , p_component_type_code => l_component_type_code
10724 );
10721 , p_component_appl_id => l_component_appl_id
10722 , p_amb_context_code => l_amb_context_code
10723 , p_side => 'NA'
10725
10726
10727 --
10728 --
10729 END IF;
10730
10731 --
10732 -- Update the line information that should be overwritten
10733 --
10734 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
10735 p_header_num => 1);
10736 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
10737
10738 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
10739
10740 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
10741 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
10742 END IF;
10743
10744 --
10745 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
10746 --
10747 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
10748 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
10749 ELSE
10750 ---------------------------------------------------------------------------------------------------
10751 -- 4262811a Switch Sign
10752 ---------------------------------------------------------------------------------------------------
10753 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
10754 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10755 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10756 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
10757 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10758 -- 5132302
10759 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
10760 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
10761
10762 END IF;
10763
10764 -- 4955764
10765 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
10766 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
10767
10768
10769 XLA_AE_LINES_PKG.ValidateCurrentLine;
10770 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
10771
10772 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
10773 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
10774 ,p_balance_type_code => l_balance_type_code);
10775
10776 END IF;
10777
10778 -----------------------------------------------------------------------------------------
10779 -- 4262811 Multiperiod Accounting
10780 -----------------------------------------------------------------------------------------
10781 -- No MPA option is assigned.
10782
10783
10784 END IF;
10785 END IF;
10786 --
10787
10788 --
10789 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10790 trace
10791 (p_msg => 'END of AcctLineType_40'
10792 ,p_level => C_LEVEL_PROCEDURE
10793 ,p_module => l_log_module);
10794 END IF;
10795 --
10796 EXCEPTION
10797 WHEN xla_exceptions_pkg.application_exception THEN
10798 RAISE;
10799 WHEN OTHERS THEN
10800 xla_exceptions_pkg.raise_message
10801 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_40');
10802 END AcctLineType_40;
10803 --
10804
10805 ---------------------------------------
10806 --
10807 -- PRIVATE FUNCTION
10808 -- AcctLineType_41
10809 --
10810 ---------------------------------------
10811 PROCEDURE AcctLineType_41 (
10812 p_application_id IN NUMBER
10813 ,p_event_id IN NUMBER
10814 ,p_calculate_acctd_flag IN VARCHAR2
10815 ,p_calculate_g_l_flag IN VARCHAR2
10816 ,p_actual_flag IN OUT VARCHAR2
10817 ,p_balance_type_code OUT VARCHAR2
10818 ,p_gain_or_loss_ref OUT VARCHAR2
10819
10820 --Distribution GL Account
10821 , p_source_5 IN NUMBER
10822 --Distribution Source Type
10823 , p_source_20 IN VARCHAR2
10824 --Entered Amount
10825 , p_source_24 IN NUMBER
10826 --SLA Party Type
10827 , p_source_32 IN VARCHAR2
10828 --Credit Memo Distribution Identifier
10829 , p_source_42 IN NUMBER
10830 --Credit memo distributions type
10831 , p_source_43 IN VARCHAR2
10832 --Credit Memo Currency Code
10833 , p_source_44 IN VARCHAR2
10834 --Credit Memo Exchange Date
10835 , p_source_45 IN DATE
10836 --Credit Memo Exchange Rate
10837 , p_source_46 IN NUMBER
10838 --Credit Memo Exchange Rate Type
10839 , p_source_47 IN VARCHAR2
10840 --Gain Loss Reference
10841 , p_source_48 IN VARCHAR2
10842 --Credit Memo Accounting Amount
10843 , p_source_49 IN NUMBER
10844 --Credit Memo Bill To Customer Account Identifier
10845 , p_source_50 IN NUMBER
10846 --Credit Memo Bill To Customer Site Use Identifier
10847 , p_source_51 IN NUMBER
10848 --Credit Memo Tax Line Identifier
10849 , p_source_52 IN NUMBER
10850 )
10851 IS
10852
10853 l_component_type VARCHAR2(80);
10854 l_component_code VARCHAR2(30);
10855 l_component_type_code VARCHAR2(1);
10856 l_component_appl_id INTEGER;
10857 l_amb_context_code VARCHAR2(30);
10858 l_entity_code VARCHAR2(30);
10859 l_event_class_code VARCHAR2(30);
10860 l_ae_header_id NUMBER;
10861 l_event_type_code VARCHAR2(30);
10862 l_line_definition_code VARCHAR2(30);
10863 l_line_definition_owner_code VARCHAR2(1);
10864 --
10865 -- adr variables
10866 l_segment VARCHAR2(30);
10867 l_ccid NUMBER;
10868 l_adr_transaction_coa_id NUMBER;
10869 l_adr_accounting_coa_id NUMBER;
10870 l_adr_flexfield_segment_code VARCHAR2(30);
10871 l_adr_flex_value_set_id NUMBER;
10872 l_adr_value_type_code VARCHAR2(30);
10873 l_adr_value_combination_id NUMBER;
10874 l_adr_value_segment_code VARCHAR2(30);
10875
10876 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
10877 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
10878 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
10879 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
10880
10881 -- 4262811 Variables ------------------------------------------------------------------------------------------
10882 l_entered_amt_idx NUMBER;
10883 l_accted_amt_idx NUMBER;
10884 l_acc_rev_flag VARCHAR2(1);
10885 l_accrual_line_num NUMBER;
10886 l_tmp_amt NUMBER;
10887 l_acc_rev_natural_side_code VARCHAR2(1);
10888
10889 l_num_entries NUMBER;
10890 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
10891 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
10892 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
10893 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
10894 l_recog_line_1 NUMBER;
10895 l_recog_line_2 NUMBER;
10896
10897 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
10898 l_bflow_applied_to_amt NUMBER; -- 5132302
10899 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
10900
10901 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
10902
10903 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
10904 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
10905
10906 ---------------------------------------------------------------------------------------------------------------
10907
10908
10909 --
10910 -- bulk performance
10911 --
10912 l_balance_type_code VARCHAR2(1);
10913 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
10914 l_log_module VARCHAR2(240);
10915
10916 --
10917 -- Upgrade strategy
10918 --
10922 --
10919 l_actual_upg_option VARCHAR2(1);
10920 l_enc_upg_option VARCHAR2(1);
10921
10923 BEGIN
10924 --
10925 IF g_log_enabled THEN
10926 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_41';
10927 END IF;
10928 --
10929 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10930
10931 trace
10932 (p_msg => 'BEGIN of AcctLineType_41'
10933 ,p_level => C_LEVEL_PROCEDURE
10934 ,p_module => l_log_module);
10935
10936 END IF;
10937 --
10938 l_component_type := 'AMB_JLT';
10939 l_component_code := 'CM_APP_DEFAULT_TAX';
10940 l_component_type_code := 'S';
10941 l_component_appl_id := 222;
10942 l_amb_context_code := 'DEFAULT';
10943 l_entity_code := 'TRANSACTIONS';
10944 l_event_class_code := 'CREDIT_MEMO';
10945 l_event_type_code := 'CREDIT_MEMO_ALL';
10946 l_line_definition_owner_code := 'S';
10947 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
10948 --
10949 l_balance_type_code := 'A';
10950 l_segment := NULL;
10951 l_ccid := NULL;
10952 l_adr_transaction_coa_id := NULL;
10953 l_adr_accounting_coa_id := NULL;
10954 l_adr_flexfield_segment_code := NULL;
10955 l_adr_flex_value_set_id := NULL;
10956 l_adr_value_type_code := NULL;
10957 l_adr_value_combination_id := NULL;
10958 l_adr_value_segment_code := NULL;
10959
10960 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
10961 l_bflow_class_code := ''; -- 4219869 Business Flow
10962 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
10963 l_budgetary_control_flag := 'N';
10964
10965 l_bflow_applied_to_amt_idx := NULL; -- 5132302
10966 l_bflow_applied_to_amt := NULL; -- 5132302
10967 l_entered_amt_idx := NULL; -- 4262811
10968 l_accted_amt_idx := NULL; -- 4262811
10969 l_acc_rev_flag := NULL; -- 4262811
10970 l_accrual_line_num := NULL; -- 4262811
10971 l_tmp_amt := NULL; -- 4262811
10972 --
10973
10974 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
10975 l_balance_type_code <> 'B' THEN
10976 IF NVL(p_source_20,'
10977 ') = 'TAX'
10978 THEN
10979
10980 --
10981 XLA_AE_LINES_PKG.SetNewLine;
10982
10983 p_balance_type_code := l_balance_type_code;
10984 -- set the flag so later we will know whether the gain loss line needs to be created
10985
10986 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
10987 p_actual_flag :='A';
10988 END IF;
10989
10990 --
10991 -- bulk performance
10992 --
10993 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
10994 p_header_num => 0); -- 4262811
10995 --
10996 -- set accounting line options
10997 --
10998 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
10999 p_natural_side_code => 'C'
11000 , p_gain_or_loss_flag => 'N'
11001 , p_gl_transfer_mode_code => 'S'
11002 , p_acct_entry_type_code => 'A'
11003 , p_switch_side_flag => 'Y'
11004 , p_merge_duplicate_code => 'A'
11005 );
11006 --
11007 l_acc_rev_natural_side_code := 'D'; -- 4262811
11008 --
11009 --
11010 -- set accounting line type info
11011 --
11012 xla_ae_lines_pkg.SetAcctLineType
11013 (p_component_type => l_component_type
11014 ,p_event_type_code => l_event_type_code
11015 ,p_line_definition_owner_code => l_line_definition_owner_code
11016 ,p_line_definition_code => l_line_definition_code
11017 ,p_accounting_line_code => l_component_code
11018 ,p_accounting_line_type_code => l_component_type_code
11019 ,p_accounting_line_appl_id => l_component_appl_id
11020 ,p_amb_context_code => l_amb_context_code
11021 ,p_entity_code => l_entity_code
11022 ,p_event_class_code => l_event_class_code);
11023 --
11024 -- set accounting class
11025 --
11026 xla_ae_lines_pkg.SetAcctClass(
11027 p_accounting_class_code => 'TAX'
11028 , p_ae_header_id => l_ae_header_id
11029 );
11030
11031 --
11032 -- set rounding class
11033 --
11034 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
11035 'RECEIVABLE';
11036
11037 --
11038 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
11039 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
11040 --
11041 -- bulk performance
11042 --
11043 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
11044
11045 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
11046 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
11047
11048 -- 4955764
11049 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11050 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
11051
11052 -- 4458381 Public Sector Enh
11053
11054 --
11055 -- set accounting attributes for the line type
11056 --
11057 l_entered_amt_idx := 3;
11058 l_accted_amt_idx := 9;
11062 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
11059 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11060 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
11061 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
11063 l_rec_acct_attrs.array_char_value(2) := p_source_43;
11064 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
11065 l_rec_acct_attrs.array_num_value(3) := p_source_24;
11066 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
11067 l_rec_acct_attrs.array_char_value(4) := p_source_44;
11068 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
11069 l_rec_acct_attrs.array_date_value(5) := p_source_45;
11070 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
11071 l_rec_acct_attrs.array_num_value(6) := p_source_46;
11072 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
11073 l_rec_acct_attrs.array_char_value(7) := p_source_47;
11074 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
11075 l_rec_acct_attrs.array_char_value(8) := p_source_48;
11076 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
11077 l_rec_acct_attrs.array_num_value(9) := p_source_49;
11078 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
11079 l_rec_acct_attrs.array_num_value(10) := p_source_50;
11080 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
11081 l_rec_acct_attrs.array_num_value(11) := p_source_51;
11082 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
11083 l_rec_acct_attrs.array_char_value(12) := p_source_32;
11084 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
11085 l_rec_acct_attrs.array_num_value(13) := p_source_52;
11086
11087 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
11088 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
11089
11090 ---------------------------------------------------------------------------------------------------------------
11091 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
11092 ---------------------------------------------------------------------------------------------------------------
11093 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
11094
11095 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11096 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11097
11098 IF xla_accounting_cache_pkg.GetValueChar
11099 (p_source_code => 'LEDGER_CATEGORY_CODE'
11100 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
11101 AND l_bflow_method_code = 'PRIOR_ENTRY'
11102 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
11103 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
11104 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
11105 )
11106 THEN
11107 xla_ae_lines_pkg.BflowUpgEntry
11108 (p_business_method_code => l_bflow_method_code
11109 ,p_business_class_code => l_bflow_class_code
11110 ,p_balance_type => l_balance_type_code);
11111 ELSE
11112 NULL;
11113 -- No business flow processing for business flow method of NONE.
11114 END IF;
11115
11116 --
11117 -- call analytical criteria
11118 --
11119
11120 --
11121 -- call description
11122 --
11123 -- No description or it is inherited.
11124 --
11125 -- call ADRs
11126 -- Bug 4922099
11127 --
11128 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11129 (NVL(l_actual_upg_option, 'N') = 'O') OR
11130 (NVL(l_enc_upg_option, 'N') = 'O')
11131 )
11132 THEN
11133 NULL;
11134 --
11135 --
11136
11137 l_ccid := AcctDerRule_4(
11138 p_application_id => p_application_id
11139 , p_ae_header_id => l_ae_header_id
11140 , p_source_5 => p_source_5
11141 , x_transaction_coa_id => l_adr_transaction_coa_id
11142 , x_accounting_coa_id => l_adr_accounting_coa_id
11143 , x_value_type_code => l_adr_value_type_code
11144 , p_side => 'NA'
11145 );
11146
11147 xla_ae_lines_pkg.set_ccid(
11148 p_code_combination_id => l_ccid
11149 , p_value_type_code => l_adr_value_type_code
11150 , p_transaction_coa_id => l_adr_transaction_coa_id
11151 , p_accounting_coa_id => l_adr_accounting_coa_id
11152 , p_adr_code => 'DIST_CCID'
11153 , p_adr_type_code => 'S'
11154 , p_component_type => l_component_type
11155 , p_component_code => l_component_code
11156 , p_component_type_code => l_component_type_code
11157 , p_component_appl_id => l_component_appl_id
11158 , p_amb_context_code => l_amb_context_code
11159 , p_side => 'NA'
11160 );
11161
11162
11163 --
11164 --
11165 END IF;
11166 --
11167 -- Bug 4922099
11168 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
11169 (NVL(l_enc_upg_option, 'N') = 'O')
11170 ) AND
11171 (l_bflow_method_code = 'PRIOR_ENTRY')
11172 )
11173 THEN
11174 IF
11175 --
11176 1 = 2
11177 --
11178 THEN
11179 xla_accounting_err_pkg.build_message
11183 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
11180 (p_appli_s_name => 'XLA'
11181 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11182 ,p_token_1 => 'LINE_NUMBER'
11184 ,p_token_2 => 'LINE_TYPE_NAME'
11185 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
11186 l_component_type
11187 ,l_component_code
11188 ,l_component_type_code
11189 ,l_component_appl_id
11190 ,l_amb_context_code
11191 ,l_entity_code
11192 ,l_event_class_code
11193 )
11194 ,p_token_3 => 'OWNER'
11195 ,p_value_3 => xla_lookups_pkg.get_meaning(
11196 p_lookup_type => 'XLA_OWNER_TYPE'
11197 ,p_lookup_code => l_component_type_code
11198 )
11199 ,p_token_4 => 'PRODUCT_NAME'
11200 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
11201 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
11202 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
11203 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
11204 ,p_ae_header_id => NULL
11205 );
11206
11207 IF (C_LEVEL_ERROR>= g_log_level) THEN
11208 trace
11209 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11210 ,p_level => C_LEVEL_ERROR
11211 ,p_module => l_log_module);
11212 END IF;
11213 END IF;
11214 END IF;
11215 --
11216 --
11217 ------------------------------------------------------------------------------------------------
11218 -- 4219869 Business Flow
11219 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
11220 -- Prior Entry. Currently, the following code is always generated.
11221 ------------------------------------------------------------------------------------------------
11222 XLA_AE_LINES_PKG.ValidateCurrentLine;
11223
11224 ------------------------------------------------------------------------------------
11225 -- 4219869 Business Flow
11226 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
11227 ------------------------------------------------------------------------------------
11228 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11229
11230 ----------------------------------------------------------------------------------
11231 -- 4219869 Business Flow
11232 -- Update journal entry status -- Need to generate this within IF <condition>
11233 ----------------------------------------------------------------------------------
11234 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11235 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
11236 ,p_balance_type_code => l_balance_type_code
11237 );
11238
11239 -------------------------------------------------------------------------------------------
11240 -- 4262811 - Generate the Accrual Reversal lines
11241 -------------------------------------------------------------------------------------------
11242 BEGIN
11243 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
11244 (g_array_event(p_event_id).array_value_num('header_index'));
11245 IF l_acc_rev_flag IS NULL THEN
11246 l_acc_rev_flag := 'N';
11247 END IF;
11248 EXCEPTION
11249 WHEN OTHERS THEN
11250 l_acc_rev_flag := 'N';
11251 END;
11252 --
11253 IF (l_acc_rev_flag = 'Y') THEN
11254
11255 -- 4645092 ------------------------------------------------------------------------------
11256 -- To allow MPA report to determine if it should generate report process
11257 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
11258 ------------------------------------------------------------------------------------------
11259
11260 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
11261 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
11262 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
11263 -- call ADRs
11264 -- Bug 4922099
11265 --
11266 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11267 (NVL(l_actual_upg_option, 'N') = 'O') OR
11268 (NVL(l_enc_upg_option, 'N') = 'O')
11269 )
11270 THEN
11271 NULL;
11272 --
11273 --
11274
11275 l_ccid := AcctDerRule_4(
11276 p_application_id => p_application_id
11277 , p_ae_header_id => l_ae_header_id
11278 , p_source_5 => p_source_5
11279 , x_transaction_coa_id => l_adr_transaction_coa_id
11280 , x_accounting_coa_id => l_adr_accounting_coa_id
11281 , x_value_type_code => l_adr_value_type_code
11282 , p_side => 'NA'
11283 );
11284
11285 xla_ae_lines_pkg.set_ccid(
11286 p_code_combination_id => l_ccid
11287 , p_value_type_code => l_adr_value_type_code
11288 , p_transaction_coa_id => l_adr_transaction_coa_id
11289 , p_accounting_coa_id => l_adr_accounting_coa_id
11290 , p_adr_code => 'DIST_CCID'
11291 , p_adr_type_code => 'S'
11292 , p_component_type => l_component_type
11293 , p_component_code => l_component_code
11294 , p_component_type_code => l_component_type_code
11295 , p_component_appl_id => l_component_appl_id
11296 , p_amb_context_code => l_amb_context_code
11297 , p_side => 'NA'
11298 );
11299
11300
11301 --
11302 --
11303 END IF;
11304
11305 --
11306 -- Update the line information that should be overwritten
11307 --
11308 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
11309 p_header_num => 1);
11310 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
11311
11312 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
11313
11314 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
11315 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
11316 END IF;
11317
11318 --
11319 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
11320 --
11321 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
11322 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
11323 ELSE
11324 ---------------------------------------------------------------------------------------------------
11325 -- 4262811a Switch Sign
11329 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11326 ---------------------------------------------------------------------------------------------------
11327 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
11328 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11330 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11331 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11332 -- 5132302
11333 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
11334 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11335
11336 END IF;
11337
11338 -- 4955764
11339 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11340 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
11341
11342
11343 XLA_AE_LINES_PKG.ValidateCurrentLine;
11344 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11345
11346 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11347 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
11348 ,p_balance_type_code => l_balance_type_code);
11349
11350 END IF;
11351
11352 -----------------------------------------------------------------------------------------
11353 -- 4262811 Multiperiod Accounting
11354 -----------------------------------------------------------------------------------------
11355 -- No MPA option is assigned.
11356
11357
11358 END IF;
11359 END IF;
11360 --
11361
11362 --
11363 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11364 trace
11365 (p_msg => 'END of AcctLineType_41'
11366 ,p_level => C_LEVEL_PROCEDURE
11367 ,p_module => l_log_module);
11368 END IF;
11369 --
11370 EXCEPTION
11371 WHEN xla_exceptions_pkg.application_exception THEN
11372 RAISE;
11373 WHEN OTHERS THEN
11374 xla_exceptions_pkg.raise_message
11375 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_41');
11376 END AcctLineType_41;
11377 --
11378
11379 ---------------------------------------
11380 --
11381 -- PRIVATE FUNCTION
11382 -- AcctLineType_42
11383 --
11384 ---------------------------------------
11385 PROCEDURE AcctLineType_42 (
11386 p_application_id IN NUMBER
11387 ,p_event_id IN NUMBER
11388 ,p_calculate_acctd_flag IN VARCHAR2
11389 ,p_calculate_g_l_flag IN VARCHAR2
11390 ,p_actual_flag IN OUT VARCHAR2
11391 ,p_balance_type_code OUT VARCHAR2
11392 ,p_gain_or_loss_ref OUT VARCHAR2
11393
11394 --Distribution GL Account
11395 , p_source_5 IN NUMBER
11396 --Distribution Source Type
11397 , p_source_20 IN VARCHAR2
11398 --Receivable Activity Type
11399 , p_source_21 IN VARCHAR2
11400 --Entered Amount
11401 , p_source_24 IN NUMBER
11402 --SLA Party Type
11403 , p_source_32 IN VARCHAR2
11404 --Credit Memo Distribution Identifier
11405 , p_source_42 IN NUMBER
11406 --Credit memo distributions type
11407 , p_source_43 IN VARCHAR2
11408 --Credit Memo Currency Code
11409 , p_source_44 IN VARCHAR2
11410 --Credit Memo Exchange Date
11411 , p_source_45 IN DATE
11412 --Credit Memo Exchange Rate
11413 , p_source_46 IN NUMBER
11414 --Credit Memo Exchange Rate Type
11415 , p_source_47 IN VARCHAR2
11416 --Gain Loss Reference
11417 , p_source_48 IN VARCHAR2
11418 --Credit Memo Accounting Amount
11419 , p_source_49 IN NUMBER
11420 --Credit Memo Bill To Customer Account Identifier
11421 , p_source_50 IN NUMBER
11422 --Credit Memo Bill To Customer Site Use Identifier
11423 , p_source_51 IN NUMBER
11424 --Credit Memo Tax Line Identifier
11425 , p_source_52 IN NUMBER
11426 )
11427 IS
11428
11429 l_component_type VARCHAR2(80);
11430 l_component_code VARCHAR2(30);
11431 l_component_type_code VARCHAR2(1);
11432 l_component_appl_id INTEGER;
11433 l_amb_context_code VARCHAR2(30);
11434 l_entity_code VARCHAR2(30);
11435 l_event_class_code VARCHAR2(30);
11436 l_ae_header_id NUMBER;
11437 l_event_type_code VARCHAR2(30);
11438 l_line_definition_code VARCHAR2(30);
11439 l_line_definition_owner_code VARCHAR2(1);
11440 --
11441 -- adr variables
11442 l_segment VARCHAR2(30);
11443 l_ccid NUMBER;
11444 l_adr_transaction_coa_id NUMBER;
11445 l_adr_accounting_coa_id NUMBER;
11446 l_adr_flexfield_segment_code VARCHAR2(30);
11447 l_adr_flex_value_set_id NUMBER;
11448 l_adr_value_type_code VARCHAR2(30);
11449 l_adr_value_combination_id NUMBER;
11450 l_adr_value_segment_code VARCHAR2(30);
11451
11452 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
11453 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
11454 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
11455 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
11456
11460 l_acc_rev_flag VARCHAR2(1);
11457 -- 4262811 Variables ------------------------------------------------------------------------------------------
11458 l_entered_amt_idx NUMBER;
11459 l_accted_amt_idx NUMBER;
11461 l_accrual_line_num NUMBER;
11462 l_tmp_amt NUMBER;
11463 l_acc_rev_natural_side_code VARCHAR2(1);
11464
11465 l_num_entries NUMBER;
11466 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
11467 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
11468 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
11469 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
11470 l_recog_line_1 NUMBER;
11471 l_recog_line_2 NUMBER;
11472
11473 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
11474 l_bflow_applied_to_amt NUMBER; -- 5132302
11475 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
11476
11477 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
11478
11479 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
11480 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
11481
11482 ---------------------------------------------------------------------------------------------------------------
11483
11484
11485 --
11486 -- bulk performance
11487 --
11488 l_balance_type_code VARCHAR2(1);
11489 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
11490 l_log_module VARCHAR2(240);
11491
11492 --
11493 -- Upgrade strategy
11494 --
11495 l_actual_upg_option VARCHAR2(1);
11496 l_enc_upg_option VARCHAR2(1);
11497
11498 --
11499 BEGIN
11500 --
11501 IF g_log_enabled THEN
11502 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_42';
11503 END IF;
11504 --
11505 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11506
11507 trace
11508 (p_msg => 'BEGIN of AcctLineType_42'
11509 ,p_level => C_LEVEL_PROCEDURE
11510 ,p_module => l_log_module);
11511
11512 END IF;
11513 --
11514 l_component_type := 'AMB_JLT';
11515 l_component_code := 'CM_APP_REFUND';
11516 l_component_type_code := 'S';
11517 l_component_appl_id := 222;
11518 l_amb_context_code := 'DEFAULT';
11519 l_entity_code := 'TRANSACTIONS';
11520 l_event_class_code := 'CREDIT_MEMO';
11521 l_event_type_code := 'CREDIT_MEMO_ALL';
11522 l_line_definition_owner_code := 'S';
11523 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
11524 --
11525 l_balance_type_code := 'A';
11526 l_segment := NULL;
11527 l_ccid := NULL;
11528 l_adr_transaction_coa_id := NULL;
11529 l_adr_accounting_coa_id := NULL;
11530 l_adr_flexfield_segment_code := NULL;
11531 l_adr_flex_value_set_id := NULL;
11532 l_adr_value_type_code := NULL;
11533 l_adr_value_combination_id := NULL;
11534 l_adr_value_segment_code := NULL;
11535
11536 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
11537 l_bflow_class_code := ''; -- 4219869 Business Flow
11538 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
11539 l_budgetary_control_flag := 'N';
11540
11541 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11542 l_bflow_applied_to_amt := NULL; -- 5132302
11543 l_entered_amt_idx := NULL; -- 4262811
11544 l_accted_amt_idx := NULL; -- 4262811
11545 l_acc_rev_flag := NULL; -- 4262811
11546 l_accrual_line_num := NULL; -- 4262811
11547 l_tmp_amt := NULL; -- 4262811
11548 --
11549
11550 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
11551 l_balance_type_code <> 'B' THEN
11552 IF (NVL(p_source_20,'
11553 ') = 'ACTIVITY' AND
11554 NVL(p_source_21,'
11555 ') = 'REFUND') OR
11556 (NVL(p_source_20,'
11557 ') = 'ACTIVITY' AND
11558 NVL(p_source_21,'
11559 ') = 'CM_REFUND')
11560 THEN
11561
11562 --
11563 XLA_AE_LINES_PKG.SetNewLine;
11564
11565 p_balance_type_code := l_balance_type_code;
11566 -- set the flag so later we will know whether the gain loss line needs to be created
11567
11568 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
11569 p_actual_flag :='A';
11570 END IF;
11571
11572 --
11573 -- bulk performance
11574 --
11575 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
11576 p_header_num => 0); -- 4262811
11577 --
11578 -- set accounting line options
11579 --
11580 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
11581 p_natural_side_code => 'C'
11582 , p_gain_or_loss_flag => 'N'
11583 , p_gl_transfer_mode_code => 'S'
11584 , p_acct_entry_type_code => 'A'
11585 , p_switch_side_flag => 'Y'
11586 , p_merge_duplicate_code => 'A'
11587 );
11588 --
11589 l_acc_rev_natural_side_code := 'D'; -- 4262811
11590 --
11591 --
11592 -- set accounting line type info
11593 --
11594 xla_ae_lines_pkg.SetAcctLineType
11595 (p_component_type => l_component_type
11596 ,p_event_type_code => l_event_type_code
11597 ,p_line_definition_owner_code => l_line_definition_owner_code
11598 ,p_line_definition_code => l_line_definition_code
11599 ,p_accounting_line_code => l_component_code
11600 ,p_accounting_line_type_code => l_component_type_code
11601 ,p_accounting_line_appl_id => l_component_appl_id
11602 ,p_amb_context_code => l_amb_context_code
11603 ,p_entity_code => l_entity_code
11604 ,p_event_class_code => l_event_class_code);
11605 --
11606 -- set accounting class
11607 --
11608 xla_ae_lines_pkg.SetAcctClass(
11609 p_accounting_class_code => 'REFUND'
11610 , p_ae_header_id => l_ae_header_id
11611 );
11612
11613 --
11614 -- set rounding class
11615 --
11616 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
11617 'REFUND';
11618
11619 --
11620 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
11621 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
11622 --
11623 -- bulk performance
11624 --
11625 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
11626
11627 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
11628 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
11629
11630 -- 4955764
11631 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11632 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
11633
11634 -- 4458381 Public Sector Enh
11635
11636 --
11637 -- set accounting attributes for the line type
11638 --
11639 l_entered_amt_idx := 3;
11640 l_accted_amt_idx := 9;
11641 l_bflow_applied_to_amt_idx := NULL; -- 5132302
11642 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
11643 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
11644 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
11645 l_rec_acct_attrs.array_char_value(2) := p_source_43;
11646 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
11647 l_rec_acct_attrs.array_num_value(3) := p_source_24;
11648 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
11649 l_rec_acct_attrs.array_char_value(4) := p_source_44;
11650 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
11651 l_rec_acct_attrs.array_date_value(5) := p_source_45;
11652 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
11653 l_rec_acct_attrs.array_num_value(6) := p_source_46;
11654 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
11655 l_rec_acct_attrs.array_char_value(7) := p_source_47;
11659 l_rec_acct_attrs.array_num_value(9) := p_source_49;
11656 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
11657 l_rec_acct_attrs.array_char_value(8) := p_source_48;
11658 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
11660 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
11661 l_rec_acct_attrs.array_num_value(10) := p_source_50;
11662 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
11663 l_rec_acct_attrs.array_num_value(11) := p_source_51;
11664 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
11665 l_rec_acct_attrs.array_char_value(12) := p_source_32;
11666 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
11667 l_rec_acct_attrs.array_num_value(13) := p_source_52;
11668
11669 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
11670 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
11671
11672 ---------------------------------------------------------------------------------------------------------------
11673 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
11674 ---------------------------------------------------------------------------------------------------------------
11675 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
11676
11677 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11678 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
11679
11680 IF xla_accounting_cache_pkg.GetValueChar
11681 (p_source_code => 'LEDGER_CATEGORY_CODE'
11682 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
11683 AND l_bflow_method_code = 'PRIOR_ENTRY'
11684 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
11685 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
11686 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
11687 )
11688 THEN
11689 xla_ae_lines_pkg.BflowUpgEntry
11690 (p_business_method_code => l_bflow_method_code
11691 ,p_business_class_code => l_bflow_class_code
11692 ,p_balance_type => l_balance_type_code);
11693 ELSE
11694 NULL;
11695 -- No business flow processing for business flow method of NONE.
11696 END IF;
11697
11698 --
11699 -- call analytical criteria
11700 --
11701
11702 --
11703 -- call description
11704 --
11705 -- No description or it is inherited.
11706 --
11707 -- call ADRs
11708 -- Bug 4922099
11709 --
11710 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11711 (NVL(l_actual_upg_option, 'N') = 'O') OR
11712 (NVL(l_enc_upg_option, 'N') = 'O')
11713 )
11714 THEN
11715 NULL;
11716 --
11717 --
11718
11719 l_ccid := AcctDerRule_4(
11720 p_application_id => p_application_id
11721 , p_ae_header_id => l_ae_header_id
11722 , p_source_5 => p_source_5
11723 , x_transaction_coa_id => l_adr_transaction_coa_id
11724 , x_accounting_coa_id => l_adr_accounting_coa_id
11725 , x_value_type_code => l_adr_value_type_code
11726 , p_side => 'NA'
11727 );
11728
11729 xla_ae_lines_pkg.set_ccid(
11730 p_code_combination_id => l_ccid
11731 , p_value_type_code => l_adr_value_type_code
11732 , p_transaction_coa_id => l_adr_transaction_coa_id
11733 , p_accounting_coa_id => l_adr_accounting_coa_id
11734 , p_adr_code => 'DIST_CCID'
11735 , p_adr_type_code => 'S'
11736 , p_component_type => l_component_type
11737 , p_component_code => l_component_code
11738 , p_component_type_code => l_component_type_code
11739 , p_component_appl_id => l_component_appl_id
11740 , p_amb_context_code => l_amb_context_code
11741 , p_side => 'NA'
11742 );
11743
11744
11745 --
11746 --
11747 END IF;
11748 --
11749 -- Bug 4922099
11750 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
11751 (NVL(l_enc_upg_option, 'N') = 'O')
11752 ) AND
11753 (l_bflow_method_code = 'PRIOR_ENTRY')
11754 )
11755 THEN
11756 IF
11757 --
11758 1 = 2
11759 --
11760 THEN
11761 xla_accounting_err_pkg.build_message
11762 (p_appli_s_name => 'XLA'
11763 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11764 ,p_token_1 => 'LINE_NUMBER'
11765 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
11766 ,p_token_2 => 'LINE_TYPE_NAME'
11767 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
11768 l_component_type
11769 ,l_component_code
11770 ,l_component_type_code
11771 ,l_component_appl_id
11772 ,l_amb_context_code
11773 ,l_entity_code
11777 ,p_value_3 => xla_lookups_pkg.get_meaning(
11774 ,l_event_class_code
11775 )
11776 ,p_token_3 => 'OWNER'
11778 p_lookup_type => 'XLA_OWNER_TYPE'
11779 ,p_lookup_code => l_component_type_code
11780 )
11781 ,p_token_4 => 'PRODUCT_NAME'
11782 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
11783 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
11784 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
11785 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
11786 ,p_ae_header_id => NULL
11787 );
11788
11789 IF (C_LEVEL_ERROR>= g_log_level) THEN
11790 trace
11791 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
11792 ,p_level => C_LEVEL_ERROR
11793 ,p_module => l_log_module);
11794 END IF;
11795 END IF;
11796 END IF;
11797 --
11798 --
11799 ------------------------------------------------------------------------------------------------
11800 -- 4219869 Business Flow
11801 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
11802 -- Prior Entry. Currently, the following code is always generated.
11803 ------------------------------------------------------------------------------------------------
11804 XLA_AE_LINES_PKG.ValidateCurrentLine;
11805
11806 ------------------------------------------------------------------------------------
11807 -- 4219869 Business Flow
11808 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
11809 ------------------------------------------------------------------------------------
11810 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11811
11812 ----------------------------------------------------------------------------------
11813 -- 4219869 Business Flow
11814 -- Update journal entry status -- Need to generate this within IF <condition>
11815 ----------------------------------------------------------------------------------
11816 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11817 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
11818 ,p_balance_type_code => l_balance_type_code
11819 );
11820
11821 -------------------------------------------------------------------------------------------
11822 -- 4262811 - Generate the Accrual Reversal lines
11823 -------------------------------------------------------------------------------------------
11824 BEGIN
11825 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
11826 (g_array_event(p_event_id).array_value_num('header_index'));
11827 IF l_acc_rev_flag IS NULL THEN
11828 l_acc_rev_flag := 'N';
11829 END IF;
11830 EXCEPTION
11831 WHEN OTHERS THEN
11832 l_acc_rev_flag := 'N';
11833 END;
11834 --
11835 IF (l_acc_rev_flag = 'Y') THEN
11836
11837 -- 4645092 ------------------------------------------------------------------------------
11838 -- To allow MPA report to determine if it should generate report process
11839 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
11840 ------------------------------------------------------------------------------------------
11841
11842 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
11843 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
11844 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
11845 -- call ADRs
11846 -- Bug 4922099
11847 --
11848 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
11849 (NVL(l_actual_upg_option, 'N') = 'O') OR
11850 (NVL(l_enc_upg_option, 'N') = 'O')
11851 )
11852 THEN
11853 NULL;
11854 --
11855 --
11856
11857 l_ccid := AcctDerRule_4(
11858 p_application_id => p_application_id
11859 , p_ae_header_id => l_ae_header_id
11860 , p_source_5 => p_source_5
11861 , x_transaction_coa_id => l_adr_transaction_coa_id
11862 , x_accounting_coa_id => l_adr_accounting_coa_id
11863 , x_value_type_code => l_adr_value_type_code
11864 , p_side => 'NA'
11865 );
11866
11867 xla_ae_lines_pkg.set_ccid(
11868 p_code_combination_id => l_ccid
11869 , p_value_type_code => l_adr_value_type_code
11870 , p_transaction_coa_id => l_adr_transaction_coa_id
11871 , p_accounting_coa_id => l_adr_accounting_coa_id
11872 , p_adr_code => 'DIST_CCID'
11873 , p_adr_type_code => 'S'
11874 , p_component_type => l_component_type
11875 , p_component_code => l_component_code
11876 , p_component_type_code => l_component_type_code
11877 , p_component_appl_id => l_component_appl_id
11878 , p_amb_context_code => l_amb_context_code
11879 , p_side => 'NA'
11880 );
11881
11882
11886
11883 --
11884 --
11885 END IF;
11887 --
11888 -- Update the line information that should be overwritten
11889 --
11890 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
11891 p_header_num => 1);
11892 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
11893
11894 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
11895
11896 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
11897 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
11898 END IF;
11899
11900 --
11901 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
11902 --
11903 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
11904 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
11905 ELSE
11906 ---------------------------------------------------------------------------------------------------
11907 -- 4262811a Switch Sign
11908 ---------------------------------------------------------------------------------------------------
11909 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
11910 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11911 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11912 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
11913 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11914 -- 5132302
11915 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
11916 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
11917
11918 END IF;
11919
11920 -- 4955764
11921 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
11922 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
11923
11924
11925 XLA_AE_LINES_PKG.ValidateCurrentLine;
11926 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
11927
11928 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
11929 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
11930 ,p_balance_type_code => l_balance_type_code);
11931
11932 END IF;
11933
11934 -----------------------------------------------------------------------------------------
11935 -- 4262811 Multiperiod Accounting
11936 -----------------------------------------------------------------------------------------
11937 -- No MPA option is assigned.
11938
11939
11940 END IF;
11941 END IF;
11942 --
11943
11944 --
11945 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11946 trace
11947 (p_msg => 'END of AcctLineType_42'
11948 ,p_level => C_LEVEL_PROCEDURE
11949 ,p_module => l_log_module);
11950 END IF;
11951 --
11952 EXCEPTION
11953 WHEN xla_exceptions_pkg.application_exception THEN
11954 RAISE;
11955 WHEN OTHERS THEN
11956 xla_exceptions_pkg.raise_message
11957 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_42');
11958 END AcctLineType_42;
11959 --
11960
11961 ---------------------------------------
11962 --
11963 -- PRIVATE FUNCTION
11964 -- AcctLineType_43
11965 --
11966 ---------------------------------------
11967 PROCEDURE AcctLineType_43 (
11968 p_application_id IN NUMBER
11969 ,p_event_id IN NUMBER
11970 ,p_calculate_acctd_flag IN VARCHAR2
11971 ,p_calculate_g_l_flag IN VARCHAR2
11972 ,p_actual_flag IN OUT VARCHAR2
11973 ,p_balance_type_code OUT VARCHAR2
11974 ,p_gain_or_loss_ref OUT VARCHAR2
11975
11976 --Credit Memo Distribution GL Account
11977 , p_source_4 IN NUMBER
11978 --SLA Party Type
11979 , p_source_32 IN VARCHAR2
11980 --Credit Memo Distribution Identifier
11981 , p_source_42 IN NUMBER
11982 --Credit memo distributions type
11983 , p_source_43 IN VARCHAR2
11984 --Credit Memo Currency Code
11985 , p_source_44 IN VARCHAR2
11986 --Credit Memo Exchange Date
11987 , p_source_45 IN DATE
11988 --Credit Memo Exchange Rate
11989 , p_source_46 IN NUMBER
11990 --Credit Memo Exchange Rate Type
11991 , p_source_47 IN VARCHAR2
11992 --Gain Loss Reference
11993 , p_source_48 IN VARCHAR2
11994 --Credit Memo Accounting Amount
11995 , p_source_49 IN NUMBER
11996 --Credit Memo Bill To Customer Account Identifier
11997 , p_source_50 IN NUMBER
11998 --Credit Memo Bill To Customer Site Use Identifier
11999 , p_source_51 IN NUMBER
12000 --Credit Memo Tax Line Identifier
12001 , p_source_52 IN NUMBER
12002 --Credit Memo Distribution Account Class
12003 , p_source_53 IN VARCHAR2
12004 --Credit Memo Distribution Entered Amount
12005 , p_source_54 IN NUMBER
12006 )
12007 IS
12008
12009 l_component_type VARCHAR2(80);
12010 l_component_code VARCHAR2(30);
12014 l_entity_code VARCHAR2(30);
12011 l_component_type_code VARCHAR2(1);
12012 l_component_appl_id INTEGER;
12013 l_amb_context_code VARCHAR2(30);
12015 l_event_class_code VARCHAR2(30);
12016 l_ae_header_id NUMBER;
12017 l_event_type_code VARCHAR2(30);
12018 l_line_definition_code VARCHAR2(30);
12019 l_line_definition_owner_code VARCHAR2(1);
12020 --
12021 -- adr variables
12022 l_segment VARCHAR2(30);
12023 l_ccid NUMBER;
12024 l_adr_transaction_coa_id NUMBER;
12025 l_adr_accounting_coa_id NUMBER;
12026 l_adr_flexfield_segment_code VARCHAR2(30);
12027 l_adr_flex_value_set_id NUMBER;
12028 l_adr_value_type_code VARCHAR2(30);
12029 l_adr_value_combination_id NUMBER;
12030 l_adr_value_segment_code VARCHAR2(30);
12031
12032 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
12033 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
12034 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
12035 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
12036
12037 -- 4262811 Variables ------------------------------------------------------------------------------------------
12038 l_entered_amt_idx NUMBER;
12039 l_accted_amt_idx NUMBER;
12040 l_acc_rev_flag VARCHAR2(1);
12041 l_accrual_line_num NUMBER;
12042 l_tmp_amt NUMBER;
12043 l_acc_rev_natural_side_code VARCHAR2(1);
12044
12045 l_num_entries NUMBER;
12046 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
12047 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
12048 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
12049 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
12050 l_recog_line_1 NUMBER;
12051 l_recog_line_2 NUMBER;
12052
12053 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
12054 l_bflow_applied_to_amt NUMBER; -- 5132302
12055 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
12056
12057 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
12058
12059 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
12060 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
12061
12062 ---------------------------------------------------------------------------------------------------------------
12063
12064
12065 --
12066 -- bulk performance
12067 --
12068 l_balance_type_code VARCHAR2(1);
12069 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
12070 l_log_module VARCHAR2(240);
12071
12072 --
12073 -- Upgrade strategy
12074 --
12075 l_actual_upg_option VARCHAR2(1);
12076 l_enc_upg_option VARCHAR2(1);
12077
12078 --
12079 BEGIN
12080 --
12081 IF g_log_enabled THEN
12082 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_43';
12083 END IF;
12084 --
12085 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12086
12087 trace
12088 (p_msg => 'BEGIN of AcctLineType_43'
12089 ,p_level => C_LEVEL_PROCEDURE
12090 ,p_module => l_log_module);
12091
12092 END IF;
12093 --
12094 l_component_type := 'AMB_JLT';
12095 l_component_code := 'CM_CHARGES';
12096 l_component_type_code := 'S';
12097 l_component_appl_id := 222;
12098 l_amb_context_code := 'DEFAULT';
12099 l_entity_code := 'TRANSACTIONS';
12100 l_event_class_code := 'CREDIT_MEMO';
12101 l_event_type_code := 'CREDIT_MEMO_ALL';
12102 l_line_definition_owner_code := 'S';
12103 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
12104 --
12105 l_balance_type_code := 'A';
12106 l_segment := NULL;
12107 l_ccid := NULL;
12108 l_adr_transaction_coa_id := NULL;
12109 l_adr_accounting_coa_id := NULL;
12110 l_adr_flexfield_segment_code := NULL;
12111 l_adr_flex_value_set_id := NULL;
12112 l_adr_value_type_code := NULL;
12113 l_adr_value_combination_id := NULL;
12114 l_adr_value_segment_code := NULL;
12115
12116 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
12117 l_bflow_class_code := ''; -- 4219869 Business Flow
12118 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
12119 l_budgetary_control_flag := 'N';
12120
12121 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12122 l_bflow_applied_to_amt := NULL; -- 5132302
12123 l_entered_amt_idx := NULL; -- 4262811
12124 l_accted_amt_idx := NULL; -- 4262811
12125 l_acc_rev_flag := NULL; -- 4262811
12126 l_accrual_line_num := NULL; -- 4262811
12127 l_tmp_amt := NULL; -- 4262811
12128 --
12129
12130 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
12131 l_balance_type_code <> 'B' THEN
12132 IF NVL(p_source_53,'
12133 ') = 'CHARGES'
12134 THEN
12135
12136 --
12137 XLA_AE_LINES_PKG.SetNewLine;
12138
12139 p_balance_type_code := l_balance_type_code;
12140 -- set the flag so later we will know whether the gain loss line needs to be created
12141
12142 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
12143 p_actual_flag :='A';
12144 END IF;
12145
12146 --
12147 -- bulk performance
12148 --
12149 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
12150 p_header_num => 0); -- 4262811
12151 --
12152 -- set accounting line options
12153 --
12154 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
12155 p_natural_side_code => 'C'
12156 , p_gain_or_loss_flag => 'N'
12157 , p_gl_transfer_mode_code => 'S'
12158 , p_acct_entry_type_code => 'A'
12159 , p_switch_side_flag => 'Y'
12160 , p_merge_duplicate_code => 'A'
12161 );
12162 --
12163 l_acc_rev_natural_side_code := 'D'; -- 4262811
12164 --
12165 --
12166 -- set accounting line type info
12167 --
12168 xla_ae_lines_pkg.SetAcctLineType
12169 (p_component_type => l_component_type
12170 ,p_event_type_code => l_event_type_code
12171 ,p_line_definition_owner_code => l_line_definition_owner_code
12172 ,p_line_definition_code => l_line_definition_code
12173 ,p_accounting_line_code => l_component_code
12174 ,p_accounting_line_type_code => l_component_type_code
12175 ,p_accounting_line_appl_id => l_component_appl_id
12176 ,p_amb_context_code => l_amb_context_code
12177 ,p_entity_code => l_entity_code
12178 ,p_event_class_code => l_event_class_code);
12179 --
12180 -- set accounting class
12181 --
12182 xla_ae_lines_pkg.SetAcctClass(
12183 p_accounting_class_code => 'CHARGES'
12184 , p_ae_header_id => l_ae_header_id
12185 );
12186
12187 --
12188 -- set rounding class
12189 --
12190 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
12191 'RECEIVABLE';
12192
12193 --
12194 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
12195 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
12196 --
12197 -- bulk performance
12198 --
12199 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
12200
12201 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
12202 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
12203
12204 -- 4955764
12205 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12206 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
12207
12208 -- 4458381 Public Sector Enh
12209
12210 --
12211 -- set accounting attributes for the line type
12212 --
12213 l_entered_amt_idx := 3;
12214 l_accted_amt_idx := 9;
12215 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12216 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
12217 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
12218 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
12219 l_rec_acct_attrs.array_char_value(2) := p_source_43;
12220 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
12221 l_rec_acct_attrs.array_num_value(3) := p_source_54;
12222 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
12223 l_rec_acct_attrs.array_char_value(4) := p_source_44;
12224 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
12225 l_rec_acct_attrs.array_date_value(5) := p_source_45;
12226 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
12227 l_rec_acct_attrs.array_num_value(6) := p_source_46;
12228 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
12229 l_rec_acct_attrs.array_char_value(7) := p_source_47;
12230 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
12231 l_rec_acct_attrs.array_char_value(8) := p_source_48;
12232 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
12233 l_rec_acct_attrs.array_num_value(9) := p_source_49;
12234 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
12235 l_rec_acct_attrs.array_num_value(10) := p_source_50;
12236 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
12237 l_rec_acct_attrs.array_num_value(11) := p_source_51;
12238 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
12239 l_rec_acct_attrs.array_char_value(12) := p_source_32;
12240 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
12241 l_rec_acct_attrs.array_num_value(13) := p_source_52;
12242
12243 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
12244 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
12245
12246 ---------------------------------------------------------------------------------------------------------------
12247 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
12248 ---------------------------------------------------------------------------------------------------------------
12249 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
12250
12251 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12252 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12253
12254 IF xla_accounting_cache_pkg.GetValueChar
12255 (p_source_code => 'LEDGER_CATEGORY_CODE'
12256 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
12257 AND l_bflow_method_code = 'PRIOR_ENTRY'
12258 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
12259 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
12260 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
12261 )
12262 THEN
12263 xla_ae_lines_pkg.BflowUpgEntry
12264 (p_business_method_code => l_bflow_method_code
12265 ,p_business_class_code => l_bflow_class_code
12266 ,p_balance_type => l_balance_type_code);
12267 ELSE
12268 NULL;
12269 -- No business flow processing for business flow method of NONE.
12270 END IF;
12271
12272 --
12273 -- call analytical criteria
12274 --
12275
12276 --
12277 -- call description
12278 --
12279 -- No description or it is inherited.
12280 --
12281 -- call ADRs
12282 -- Bug 4922099
12283 --
12284 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12285 (NVL(l_actual_upg_option, 'N') = 'O') OR
12286 (NVL(l_enc_upg_option, 'N') = 'O')
12287 )
12288 THEN
12289 NULL;
12290 --
12291 --
12292
12293 l_ccid := AcctDerRule_3(
12294 p_application_id => p_application_id
12295 , p_ae_header_id => l_ae_header_id
12296 , p_source_4 => p_source_4
12297 , x_transaction_coa_id => l_adr_transaction_coa_id
12298 , x_accounting_coa_id => l_adr_accounting_coa_id
12299 , x_value_type_code => l_adr_value_type_code
12300 , p_side => 'NA'
12301 );
12302
12303 xla_ae_lines_pkg.set_ccid(
12304 p_code_combination_id => l_ccid
12305 , p_value_type_code => l_adr_value_type_code
12306 , p_transaction_coa_id => l_adr_transaction_coa_id
12307 , p_accounting_coa_id => l_adr_accounting_coa_id
12308 , p_adr_code => 'CM_DIST_CCID'
12309 , p_adr_type_code => 'S'
12310 , p_component_type => l_component_type
12311 , p_component_code => l_component_code
12312 , p_component_type_code => l_component_type_code
12313 , p_component_appl_id => l_component_appl_id
12314 , p_amb_context_code => l_amb_context_code
12315 , p_side => 'NA'
12316 );
12317
12318
12319 --
12320 --
12321 END IF;
12322 --
12323 -- Bug 4922099
12324 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
12325 (NVL(l_enc_upg_option, 'N') = 'O')
12326 ) AND
12327 (l_bflow_method_code = 'PRIOR_ENTRY')
12328 )
12329 THEN
12330 IF
12331 --
12332 1 = 2
12333 --
12334 THEN
12335 xla_accounting_err_pkg.build_message
12336 (p_appli_s_name => 'XLA'
12337 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12338 ,p_token_1 => 'LINE_NUMBER'
12339 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
12340 ,p_token_2 => 'LINE_TYPE_NAME'
12341 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
12342 l_component_type
12343 ,l_component_code
12344 ,l_component_type_code
12345 ,l_component_appl_id
12346 ,l_amb_context_code
12347 ,l_entity_code
12348 ,l_event_class_code
12349 )
12350 ,p_token_3 => 'OWNER'
12351 ,p_value_3 => xla_lookups_pkg.get_meaning(
12352 p_lookup_type => 'XLA_OWNER_TYPE'
12353 ,p_lookup_code => l_component_type_code
12354 )
12355 ,p_token_4 => 'PRODUCT_NAME'
12356 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
12357 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
12358 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
12359 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
12360 ,p_ae_header_id => NULL
12361 );
12362
12363 IF (C_LEVEL_ERROR>= g_log_level) THEN
12364 trace
12365 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12366 ,p_level => C_LEVEL_ERROR
12367 ,p_module => l_log_module);
12368 END IF;
12369 END IF;
12370 END IF;
12371 --
12372 --
12373 ------------------------------------------------------------------------------------------------
12374 -- 4219869 Business Flow
12375 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
12376 -- Prior Entry. Currently, the following code is always generated.
12377 ------------------------------------------------------------------------------------------------
12378 XLA_AE_LINES_PKG.ValidateCurrentLine;
12379
12380 ------------------------------------------------------------------------------------
12381 -- 4219869 Business Flow
12382 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
12383 ------------------------------------------------------------------------------------
12384 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12385
12386 ----------------------------------------------------------------------------------
12387 -- 4219869 Business Flow
12388 -- Update journal entry status -- Need to generate this within IF <condition>
12389 ----------------------------------------------------------------------------------
12393 );
12390 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12391 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
12392 ,p_balance_type_code => l_balance_type_code
12394
12395 -------------------------------------------------------------------------------------------
12396 -- 4262811 - Generate the Accrual Reversal lines
12397 -------------------------------------------------------------------------------------------
12398 BEGIN
12399 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
12400 (g_array_event(p_event_id).array_value_num('header_index'));
12401 IF l_acc_rev_flag IS NULL THEN
12402 l_acc_rev_flag := 'N';
12403 END IF;
12404 EXCEPTION
12405 WHEN OTHERS THEN
12406 l_acc_rev_flag := 'N';
12407 END;
12408 --
12409 IF (l_acc_rev_flag = 'Y') THEN
12410
12411 -- 4645092 ------------------------------------------------------------------------------
12412 -- To allow MPA report to determine if it should generate report process
12413 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
12414 ------------------------------------------------------------------------------------------
12415
12416 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
12417 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
12418 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
12419 -- call ADRs
12420 -- Bug 4922099
12421 --
12422 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12423 (NVL(l_actual_upg_option, 'N') = 'O') OR
12424 (NVL(l_enc_upg_option, 'N') = 'O')
12425 )
12426 THEN
12427 NULL;
12428 --
12429 --
12430
12431 l_ccid := AcctDerRule_3(
12432 p_application_id => p_application_id
12433 , p_ae_header_id => l_ae_header_id
12434 , p_source_4 => p_source_4
12435 , x_transaction_coa_id => l_adr_transaction_coa_id
12436 , x_accounting_coa_id => l_adr_accounting_coa_id
12437 , x_value_type_code => l_adr_value_type_code
12438 , p_side => 'NA'
12439 );
12440
12441 xla_ae_lines_pkg.set_ccid(
12442 p_code_combination_id => l_ccid
12443 , p_value_type_code => l_adr_value_type_code
12444 , p_transaction_coa_id => l_adr_transaction_coa_id
12445 , p_accounting_coa_id => l_adr_accounting_coa_id
12446 , p_adr_code => 'CM_DIST_CCID'
12447 , p_adr_type_code => 'S'
12448 , p_component_type => l_component_type
12449 , p_component_code => l_component_code
12450 , p_component_type_code => l_component_type_code
12451 , p_component_appl_id => l_component_appl_id
12452 , p_amb_context_code => l_amb_context_code
12453 , p_side => 'NA'
12454 );
12455
12456
12457 --
12458 --
12459 END IF;
12460
12461 --
12462 -- Update the line information that should be overwritten
12463 --
12464 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
12465 p_header_num => 1);
12466 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
12467
12468 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
12469
12470 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
12471 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
12472 END IF;
12473
12474 --
12475 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
12476 --
12477 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
12478 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
12479 ELSE
12480 ---------------------------------------------------------------------------------------------------
12481 -- 4262811a Switch Sign
12482 ---------------------------------------------------------------------------------------------------
12483 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
12484 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12485 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12486 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
12487 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12488 -- 5132302
12489 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
12490 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
12491
12492 END IF;
12493
12494 -- 4955764
12495 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12496 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
12497
12498
12499 XLA_AE_LINES_PKG.ValidateCurrentLine;
12500 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12501
12502 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12503 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
12504 ,p_balance_type_code => l_balance_type_code);
12505
12506 END IF;
12507
12508 -----------------------------------------------------------------------------------------
12509 -- 4262811 Multiperiod Accounting
12510 -----------------------------------------------------------------------------------------
12511 -- No MPA option is assigned.
12512
12513
12514 END IF;
12515 END IF;
12516 --
12517
12518 --
12519 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12520 trace
12521 (p_msg => 'END of AcctLineType_43'
12522 ,p_level => C_LEVEL_PROCEDURE
12523 ,p_module => l_log_module);
12524 END IF;
12525 --
12526 EXCEPTION
12527 WHEN xla_exceptions_pkg.application_exception THEN
12528 RAISE;
12529 WHEN OTHERS THEN
12530 xla_exceptions_pkg.raise_message
12531 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_43');
12532 END AcctLineType_43;
12533 --
12534
12535 ---------------------------------------
12536 --
12537 -- PRIVATE FUNCTION
12538 -- AcctLineType_44
12539 --
12540 ---------------------------------------
12541 PROCEDURE AcctLineType_44 (
12542 p_application_id IN NUMBER
12543 ,p_event_id IN NUMBER
12544 ,p_calculate_acctd_flag IN VARCHAR2
12545 ,p_calculate_g_l_flag IN VARCHAR2
12546 ,p_actual_flag IN OUT VARCHAR2
12547 ,p_balance_type_code OUT VARCHAR2
12548 ,p_gain_or_loss_ref OUT VARCHAR2
12549
12550 --Credit Memo Distribution GL Account
12551 , p_source_4 IN NUMBER
12552 --SLA Party Type
12553 , p_source_32 IN VARCHAR2
12554 --Credit Memo Distribution Identifier
12555 , p_source_42 IN NUMBER
12556 --Credit memo distributions type
12557 , p_source_43 IN VARCHAR2
12558 --Credit Memo Currency Code
12559 , p_source_44 IN VARCHAR2
12560 --Credit Memo Exchange Date
12561 , p_source_45 IN DATE
12562 --Credit Memo Exchange Rate
12563 , p_source_46 IN NUMBER
12564 --Credit Memo Exchange Rate Type
12565 , p_source_47 IN VARCHAR2
12566 --Gain Loss Reference
12567 , p_source_48 IN VARCHAR2
12568 --Credit Memo Accounting Amount
12569 , p_source_49 IN NUMBER
12570 --Credit Memo Bill To Customer Account Identifier
12571 , p_source_50 IN NUMBER
12572 --Credit Memo Bill To Customer Site Use Identifier
12573 , p_source_51 IN NUMBER
12574 --Credit Memo Tax Line Identifier
12575 , p_source_52 IN NUMBER
12576 --Credit Memo Distribution Account Class
12577 , p_source_53 IN VARCHAR2
12578 --Credit Memo Distribution Entered Amount
12579 , p_source_54 IN NUMBER
12580 )
12581 IS
12582
12583 l_component_type VARCHAR2(80);
12584 l_component_code VARCHAR2(30);
12585 l_component_type_code VARCHAR2(1);
12586 l_component_appl_id INTEGER;
12587 l_amb_context_code VARCHAR2(30);
12588 l_entity_code VARCHAR2(30);
12589 l_event_class_code VARCHAR2(30);
12590 l_ae_header_id NUMBER;
12591 l_event_type_code VARCHAR2(30);
12592 l_line_definition_code VARCHAR2(30);
12593 l_line_definition_owner_code VARCHAR2(1);
12594 --
12595 -- adr variables
12596 l_segment VARCHAR2(30);
12597 l_ccid NUMBER;
12598 l_adr_transaction_coa_id NUMBER;
12599 l_adr_accounting_coa_id NUMBER;
12600 l_adr_flexfield_segment_code VARCHAR2(30);
12601 l_adr_flex_value_set_id NUMBER;
12602 l_adr_value_type_code VARCHAR2(30);
12603 l_adr_value_combination_id NUMBER;
12604 l_adr_value_segment_code VARCHAR2(30);
12605
12606 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
12607 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
12608 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
12609 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
12610
12611 -- 4262811 Variables ------------------------------------------------------------------------------------------
12612 l_entered_amt_idx NUMBER;
12613 l_accted_amt_idx NUMBER;
12614 l_acc_rev_flag VARCHAR2(1);
12615 l_accrual_line_num NUMBER;
12616 l_tmp_amt NUMBER;
12617 l_acc_rev_natural_side_code VARCHAR2(1);
12618
12619 l_num_entries NUMBER;
12623 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
12620 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
12621 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
12622 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
12624 l_recog_line_1 NUMBER;
12625 l_recog_line_2 NUMBER;
12626
12627 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
12628 l_bflow_applied_to_amt NUMBER; -- 5132302
12629 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
12630
12631 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
12632
12633 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
12634 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
12635
12636 ---------------------------------------------------------------------------------------------------------------
12637
12638
12639 --
12640 -- bulk performance
12641 --
12642 l_balance_type_code VARCHAR2(1);
12643 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
12644 l_log_module VARCHAR2(240);
12645
12646 --
12647 -- Upgrade strategy
12648 --
12649 l_actual_upg_option VARCHAR2(1);
12650 l_enc_upg_option VARCHAR2(1);
12651
12652 --
12653 BEGIN
12654 --
12655 IF g_log_enabled THEN
12656 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_44';
12657 END IF;
12658 --
12659 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12660
12661 trace
12662 (p_msg => 'BEGIN of AcctLineType_44'
12663 ,p_level => C_LEVEL_PROCEDURE
12664 ,p_module => l_log_module);
12665
12666 END IF;
12667 --
12668 l_component_type := 'AMB_JLT';
12669 l_component_code := 'CM_DEFAULT_FREIGHT';
12670 l_component_type_code := 'S';
12671 l_component_appl_id := 222;
12672 l_amb_context_code := 'DEFAULT';
12673 l_entity_code := 'TRANSACTIONS';
12674 l_event_class_code := 'CREDIT_MEMO';
12675 l_event_type_code := 'CREDIT_MEMO_ALL';
12676 l_line_definition_owner_code := 'S';
12677 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
12678 --
12679 l_balance_type_code := 'A';
12680 l_segment := NULL;
12681 l_ccid := NULL;
12682 l_adr_transaction_coa_id := NULL;
12683 l_adr_accounting_coa_id := NULL;
12684 l_adr_flexfield_segment_code := NULL;
12685 l_adr_flex_value_set_id := NULL;
12686 l_adr_value_type_code := NULL;
12687 l_adr_value_combination_id := NULL;
12688 l_adr_value_segment_code := NULL;
12689
12690 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
12691 l_bflow_class_code := ''; -- 4219869 Business Flow
12692 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
12693 l_budgetary_control_flag := 'N';
12694
12695 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12696 l_bflow_applied_to_amt := NULL; -- 5132302
12697 l_entered_amt_idx := NULL; -- 4262811
12698 l_accted_amt_idx := NULL; -- 4262811
12699 l_acc_rev_flag := NULL; -- 4262811
12700 l_accrual_line_num := NULL; -- 4262811
12701 l_tmp_amt := NULL; -- 4262811
12702 --
12703
12704 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
12705 l_balance_type_code <> 'B' THEN
12706 IF NVL(p_source_53,'
12707 ') = 'FREIGHT'
12708 THEN
12709
12710 --
12711 XLA_AE_LINES_PKG.SetNewLine;
12712
12713 p_balance_type_code := l_balance_type_code;
12714 -- set the flag so later we will know whether the gain loss line needs to be created
12715
12716 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
12717 p_actual_flag :='A';
12718 END IF;
12719
12720 --
12721 -- bulk performance
12722 --
12723 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
12724 p_header_num => 0); -- 4262811
12725 --
12726 -- set accounting line options
12727 --
12728 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
12729 p_natural_side_code => 'C'
12730 , p_gain_or_loss_flag => 'N'
12731 , p_gl_transfer_mode_code => 'S'
12732 , p_acct_entry_type_code => 'A'
12733 , p_switch_side_flag => 'Y'
12734 , p_merge_duplicate_code => 'A'
12735 );
12736 --
12737 l_acc_rev_natural_side_code := 'D'; -- 4262811
12738 --
12739 --
12740 -- set accounting line type info
12741 --
12742 xla_ae_lines_pkg.SetAcctLineType
12743 (p_component_type => l_component_type
12744 ,p_event_type_code => l_event_type_code
12745 ,p_line_definition_owner_code => l_line_definition_owner_code
12746 ,p_line_definition_code => l_line_definition_code
12747 ,p_accounting_line_code => l_component_code
12748 ,p_accounting_line_type_code => l_component_type_code
12749 ,p_accounting_line_appl_id => l_component_appl_id
12750 ,p_amb_context_code => l_amb_context_code
12751 ,p_entity_code => l_entity_code
12752 ,p_event_class_code => l_event_class_code);
12753 --
12754 -- set accounting class
12755 --
12756 xla_ae_lines_pkg.SetAcctClass(
12757 p_accounting_class_code => 'FREIGHT'
12758 , p_ae_header_id => l_ae_header_id
12759 );
12760
12761 --
12762 -- set rounding class
12763 --
12764 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
12765 'RECEIVABLE';
12766
12767 --
12768 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
12769 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
12770 --
12771 -- bulk performance
12772 --
12773 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
12774
12775 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
12776 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
12777
12778 -- 4955764
12779 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
12780 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
12781
12782 -- 4458381 Public Sector Enh
12783
12784 --
12785 -- set accounting attributes for the line type
12786 --
12787 l_entered_amt_idx := 3;
12788 l_accted_amt_idx := 9;
12789 l_bflow_applied_to_amt_idx := NULL; -- 5132302
12790 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
12791 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
12792 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
12793 l_rec_acct_attrs.array_char_value(2) := p_source_43;
12794 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
12795 l_rec_acct_attrs.array_num_value(3) := p_source_54;
12796 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
12797 l_rec_acct_attrs.array_char_value(4) := p_source_44;
12798 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
12799 l_rec_acct_attrs.array_date_value(5) := p_source_45;
12800 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
12801 l_rec_acct_attrs.array_num_value(6) := p_source_46;
12802 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
12803 l_rec_acct_attrs.array_char_value(7) := p_source_47;
12804 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
12805 l_rec_acct_attrs.array_char_value(8) := p_source_48;
12806 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
12807 l_rec_acct_attrs.array_num_value(9) := p_source_49;
12808 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
12809 l_rec_acct_attrs.array_num_value(10) := p_source_50;
12810 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
12811 l_rec_acct_attrs.array_num_value(11) := p_source_51;
12812 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
12813 l_rec_acct_attrs.array_char_value(12) := p_source_32;
12814 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
12815 l_rec_acct_attrs.array_num_value(13) := p_source_52;
12816
12817 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
12818 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
12819
12820 ---------------------------------------------------------------------------------------------------------------
12821 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
12822 ---------------------------------------------------------------------------------------------------------------
12823 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
12824
12825 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12826 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
12827
12828 IF xla_accounting_cache_pkg.GetValueChar
12829 (p_source_code => 'LEDGER_CATEGORY_CODE'
12830 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
12831 AND l_bflow_method_code = 'PRIOR_ENTRY'
12832 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
12833 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
12834 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
12835 )
12836 THEN
12837 xla_ae_lines_pkg.BflowUpgEntry
12838 (p_business_method_code => l_bflow_method_code
12839 ,p_business_class_code => l_bflow_class_code
12840 ,p_balance_type => l_balance_type_code);
12841 ELSE
12842 NULL;
12843 -- No business flow processing for business flow method of NONE.
12844 END IF;
12845
12846 --
12847 -- call analytical criteria
12848 --
12849
12850 --
12851 -- call description
12852 --
12853 -- No description or it is inherited.
12854 --
12855 -- call ADRs
12856 -- Bug 4922099
12857 --
12858 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12859 (NVL(l_actual_upg_option, 'N') = 'O') OR
12860 (NVL(l_enc_upg_option, 'N') = 'O')
12861 )
12862 THEN
12863 NULL;
12864 --
12865 --
12866
12867 l_ccid := AcctDerRule_3(
12868 p_application_id => p_application_id
12869 , p_ae_header_id => l_ae_header_id
12870 , p_source_4 => p_source_4
12871 , x_transaction_coa_id => l_adr_transaction_coa_id
12872 , x_accounting_coa_id => l_adr_accounting_coa_id
12873 , x_value_type_code => l_adr_value_type_code
12874 , p_side => 'NA'
12875 );
12876
12877 xla_ae_lines_pkg.set_ccid(
12878 p_code_combination_id => l_ccid
12879 , p_value_type_code => l_adr_value_type_code
12880 , p_transaction_coa_id => l_adr_transaction_coa_id
12881 , p_accounting_coa_id => l_adr_accounting_coa_id
12882 , p_adr_code => 'CM_DIST_CCID'
12883 , p_adr_type_code => 'S'
12884 , p_component_type => l_component_type
12885 , p_component_code => l_component_code
12886 , p_component_type_code => l_component_type_code
12887 , p_component_appl_id => l_component_appl_id
12888 , p_amb_context_code => l_amb_context_code
12889 , p_side => 'NA'
12890 );
12891
12892
12893 --
12894 --
12895 END IF;
12896 --
12897 -- Bug 4922099
12898 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
12899 (NVL(l_enc_upg_option, 'N') = 'O')
12900 ) AND
12901 (l_bflow_method_code = 'PRIOR_ENTRY')
12902 )
12903 THEN
12904 IF
12905 --
12906 1 = 2
12907 --
12908 THEN
12909 xla_accounting_err_pkg.build_message
12910 (p_appli_s_name => 'XLA'
12911 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12912 ,p_token_1 => 'LINE_NUMBER'
12913 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
12914 ,p_token_2 => 'LINE_TYPE_NAME'
12915 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
12916 l_component_type
12917 ,l_component_code
12918 ,l_component_type_code
12919 ,l_component_appl_id
12920 ,l_amb_context_code
12921 ,l_entity_code
12922 ,l_event_class_code
12923 )
12924 ,p_token_3 => 'OWNER'
12925 ,p_value_3 => xla_lookups_pkg.get_meaning(
12926 p_lookup_type => 'XLA_OWNER_TYPE'
12927 ,p_lookup_code => l_component_type_code
12928 )
12929 ,p_token_4 => 'PRODUCT_NAME'
12930 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
12931 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
12932 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
12933 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
12934 ,p_ae_header_id => NULL
12935 );
12936
12937 IF (C_LEVEL_ERROR>= g_log_level) THEN
12938 trace
12939 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
12940 ,p_level => C_LEVEL_ERROR
12941 ,p_module => l_log_module);
12942 END IF;
12943 END IF;
12944 END IF;
12945 --
12946 --
12947 ------------------------------------------------------------------------------------------------
12948 -- 4219869 Business Flow
12949 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
12950 -- Prior Entry. Currently, the following code is always generated.
12951 ------------------------------------------------------------------------------------------------
12952 XLA_AE_LINES_PKG.ValidateCurrentLine;
12953
12954 ------------------------------------------------------------------------------------
12955 -- 4219869 Business Flow
12956 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
12957 ------------------------------------------------------------------------------------
12958 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
12959
12960 ----------------------------------------------------------------------------------
12961 -- 4219869 Business Flow
12962 -- Update journal entry status -- Need to generate this within IF <condition>
12963 ----------------------------------------------------------------------------------
12964 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
12965 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
12966 ,p_balance_type_code => l_balance_type_code
12967 );
12968
12969 -------------------------------------------------------------------------------------------
12970 -- 4262811 - Generate the Accrual Reversal lines
12971 -------------------------------------------------------------------------------------------
12972 BEGIN
12973 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
12974 (g_array_event(p_event_id).array_value_num('header_index'));
12975 IF l_acc_rev_flag IS NULL THEN
12976 l_acc_rev_flag := 'N';
12977 END IF;
12978 EXCEPTION
12979 WHEN OTHERS THEN
12980 l_acc_rev_flag := 'N';
12981 END;
12982 --
12983 IF (l_acc_rev_flag = 'Y') THEN
12984
12985 -- 4645092 ------------------------------------------------------------------------------
12986 -- To allow MPA report to determine if it should generate report process
12987 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
12988 ------------------------------------------------------------------------------------------
12989
12990 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
12991 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
12992 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
12993 -- call ADRs
12994 -- Bug 4922099
12995 --
12996 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
12997 (NVL(l_actual_upg_option, 'N') = 'O') OR
12998 (NVL(l_enc_upg_option, 'N') = 'O')
12999 )
13000 THEN
13001 NULL;
13002 --
13003 --
13004
13005 l_ccid := AcctDerRule_3(
13006 p_application_id => p_application_id
13007 , p_ae_header_id => l_ae_header_id
13008 , p_source_4 => p_source_4
13009 , x_transaction_coa_id => l_adr_transaction_coa_id
13010 , x_accounting_coa_id => l_adr_accounting_coa_id
13011 , x_value_type_code => l_adr_value_type_code
13012 , p_side => 'NA'
13013 );
13014
13015 xla_ae_lines_pkg.set_ccid(
13016 p_code_combination_id => l_ccid
13017 , p_value_type_code => l_adr_value_type_code
13018 , p_transaction_coa_id => l_adr_transaction_coa_id
13019 , p_accounting_coa_id => l_adr_accounting_coa_id
13020 , p_adr_code => 'CM_DIST_CCID'
13021 , p_adr_type_code => 'S'
13022 , p_component_type => l_component_type
13023 , p_component_code => l_component_code
13024 , p_component_type_code => l_component_type_code
13025 , p_component_appl_id => l_component_appl_id
13026 , p_amb_context_code => l_amb_context_code
13027 , p_side => 'NA'
13028 );
13029
13030
13031 --
13032 --
13033 END IF;
13034
13035 --
13036 -- Update the line information that should be overwritten
13037 --
13038 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
13039 p_header_num => 1);
13040 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
13041
13042 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
13043
13044 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
13048 --
13045 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
13046 END IF;
13047
13049 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
13050 --
13051 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
13052 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
13053 ELSE
13054 ---------------------------------------------------------------------------------------------------
13055 -- 4262811a Switch Sign
13056 ---------------------------------------------------------------------------------------------------
13057 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
13058 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13059 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13060 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13061 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13062 -- 5132302
13063 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
13064 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13065
13066 END IF;
13067
13068 -- 4955764
13069 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13070 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
13071
13072
13073 XLA_AE_LINES_PKG.ValidateCurrentLine;
13074 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13075
13076 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13077 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
13078 ,p_balance_type_code => l_balance_type_code);
13079
13080 END IF;
13081
13082 -----------------------------------------------------------------------------------------
13083 -- 4262811 Multiperiod Accounting
13084 -----------------------------------------------------------------------------------------
13085 -- No MPA option is assigned.
13086
13087
13088 END IF;
13089 END IF;
13090 --
13091
13092 --
13093 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13094 trace
13095 (p_msg => 'END of AcctLineType_44'
13096 ,p_level => C_LEVEL_PROCEDURE
13097 ,p_module => l_log_module);
13098 END IF;
13099 --
13100 EXCEPTION
13101 WHEN xla_exceptions_pkg.application_exception THEN
13102 RAISE;
13103 WHEN OTHERS THEN
13104 xla_exceptions_pkg.raise_message
13105 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_44');
13106 END AcctLineType_44;
13107 --
13108
13109 ---------------------------------------
13110 --
13111 -- PRIVATE FUNCTION
13112 -- AcctLineType_45
13113 --
13114 ---------------------------------------
13115 PROCEDURE AcctLineType_45 (
13116 p_application_id IN NUMBER
13117 ,p_event_id IN NUMBER
13118 ,p_calculate_acctd_flag IN VARCHAR2
13119 ,p_calculate_g_l_flag IN VARCHAR2
13120 ,p_actual_flag IN OUT VARCHAR2
13121 ,p_balance_type_code OUT VARCHAR2
13122 ,p_gain_or_loss_ref OUT VARCHAR2
13123
13124 --Credit Memo Distribution GL Account
13125 , p_source_4 IN NUMBER
13126 --SLA Party Type
13127 , p_source_32 IN VARCHAR2
13128 --Credit Memo Distribution Identifier
13129 , p_source_42 IN NUMBER
13130 --Credit memo distributions type
13131 , p_source_43 IN VARCHAR2
13132 --Credit Memo Currency Code
13133 , p_source_44 IN VARCHAR2
13134 --Credit Memo Exchange Date
13135 , p_source_45 IN DATE
13136 --Credit Memo Exchange Rate
13137 , p_source_46 IN NUMBER
13138 --Credit Memo Exchange Rate Type
13139 , p_source_47 IN VARCHAR2
13140 --Gain Loss Reference
13141 , p_source_48 IN VARCHAR2
13142 --Credit Memo Accounting Amount
13143 , p_source_49 IN NUMBER
13144 --Credit Memo Bill To Customer Account Identifier
13145 , p_source_50 IN NUMBER
13146 --Credit Memo Bill To Customer Site Use Identifier
13147 , p_source_51 IN NUMBER
13148 --Credit Memo Tax Line Identifier
13149 , p_source_52 IN NUMBER
13150 --Credit Memo Distribution Account Class
13151 , p_source_53 IN VARCHAR2
13152 --Credit Memo Distribution Entered Amount
13153 , p_source_54 IN NUMBER
13154 )
13155 IS
13156
13157 l_component_type VARCHAR2(80);
13158 l_component_code VARCHAR2(30);
13159 l_component_type_code VARCHAR2(1);
13160 l_component_appl_id INTEGER;
13161 l_amb_context_code VARCHAR2(30);
13162 l_entity_code VARCHAR2(30);
13163 l_event_class_code VARCHAR2(30);
13164 l_ae_header_id NUMBER;
13165 l_event_type_code VARCHAR2(30);
13166 l_line_definition_code VARCHAR2(30);
13167 l_line_definition_owner_code VARCHAR2(1);
13168 --
13169 -- adr variables
13170 l_segment VARCHAR2(30);
13171 l_ccid NUMBER;
13172 l_adr_transaction_coa_id NUMBER;
13173 l_adr_accounting_coa_id NUMBER;
13174 l_adr_flexfield_segment_code VARCHAR2(30);
13175 l_adr_flex_value_set_id NUMBER;
13176 l_adr_value_type_code VARCHAR2(30);
13177 l_adr_value_combination_id NUMBER;
13178 l_adr_value_segment_code VARCHAR2(30);
13179
13180 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
13181 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
13182 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
13183 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
13184
13185 -- 4262811 Variables ------------------------------------------------------------------------------------------
13186 l_entered_amt_idx NUMBER;
13187 l_accted_amt_idx NUMBER;
13188 l_acc_rev_flag VARCHAR2(1);
13189 l_accrual_line_num NUMBER;
13190 l_tmp_amt NUMBER;
13191 l_acc_rev_natural_side_code VARCHAR2(1);
13192
13193 l_num_entries NUMBER;
13194 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
13195 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
13196 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
13197 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
13198 l_recog_line_1 NUMBER;
13199 l_recog_line_2 NUMBER;
13200
13201 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
13202 l_bflow_applied_to_amt NUMBER; -- 5132302
13203 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
13204
13205 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
13206
13207 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
13208 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
13209
13210 ---------------------------------------------------------------------------------------------------------------
13211
13212
13213 --
13214 -- bulk performance
13215 --
13216 l_balance_type_code VARCHAR2(1);
13217 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
13218 l_log_module VARCHAR2(240);
13219
13220 --
13221 -- Upgrade strategy
13222 --
13223 l_actual_upg_option VARCHAR2(1);
13224 l_enc_upg_option VARCHAR2(1);
13225
13226 --
13227 BEGIN
13228 --
13229 IF g_log_enabled THEN
13230 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_45';
13231 END IF;
13232 --
13233 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13234
13235 trace
13236 (p_msg => 'BEGIN of AcctLineType_45'
13237 ,p_level => C_LEVEL_PROCEDURE
13238 ,p_module => l_log_module);
13239
13240 END IF;
13241 --
13242 l_component_type := 'AMB_JLT';
13243 l_component_code := 'CM_DEFAULT_REC';
13244 l_component_type_code := 'S';
13245 l_component_appl_id := 222;
13246 l_amb_context_code := 'DEFAULT';
13247 l_entity_code := 'TRANSACTIONS';
13248 l_event_class_code := 'CREDIT_MEMO';
13249 l_event_type_code := 'CREDIT_MEMO_ALL';
13250 l_line_definition_owner_code := 'S';
13251 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
13252 --
13253 l_balance_type_code := 'A';
13254 l_segment := NULL;
13255 l_ccid := NULL;
13256 l_adr_transaction_coa_id := NULL;
13257 l_adr_accounting_coa_id := NULL;
13258 l_adr_flexfield_segment_code := NULL;
13259 l_adr_flex_value_set_id := NULL;
13260 l_adr_value_type_code := NULL;
13261 l_adr_value_combination_id := NULL;
13262 l_adr_value_segment_code := NULL;
13263
13264 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
13265 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
13266 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
13267 l_budgetary_control_flag := 'N';
13268
13269 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13270 l_bflow_applied_to_amt := NULL; -- 5132302
13271 l_entered_amt_idx := NULL; -- 4262811
13272 l_accted_amt_idx := NULL; -- 4262811
13273 l_acc_rev_flag := NULL; -- 4262811
13274 l_accrual_line_num := NULL; -- 4262811
13275 l_tmp_amt := NULL; -- 4262811
13276 --
13277
13278 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
13279 l_balance_type_code <> 'B' THEN
13280 IF NVL(p_source_53,'
13281 ') = 'REC'
13282 THEN
13283
13284 --
13285 XLA_AE_LINES_PKG.SetNewLine;
13286
13287 p_balance_type_code := l_balance_type_code;
13288 -- set the flag so later we will know whether the gain loss line needs to be created
13289
13290 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
13291 p_actual_flag :='A';
13292 END IF;
13293
13294 --
13295 -- bulk performance
13296 --
13297 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
13298 p_header_num => 0); -- 4262811
13299 --
13300 -- set accounting line options
13301 --
13302 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
13303 p_natural_side_code => 'D'
13304 , p_gain_or_loss_flag => 'N'
13305 , p_gl_transfer_mode_code => 'S'
13306 , p_acct_entry_type_code => 'A'
13307 , p_switch_side_flag => 'Y'
13308 , p_merge_duplicate_code => 'N'
13309 );
13310 --
13311 l_acc_rev_natural_side_code := 'C'; -- 4262811
13312 --
13313 --
13314 -- set accounting line type info
13315 --
13316 xla_ae_lines_pkg.SetAcctLineType
13317 (p_component_type => l_component_type
13318 ,p_event_type_code => l_event_type_code
13319 ,p_line_definition_owner_code => l_line_definition_owner_code
13320 ,p_line_definition_code => l_line_definition_code
13321 ,p_accounting_line_code => l_component_code
13322 ,p_accounting_line_type_code => l_component_type_code
13323 ,p_accounting_line_appl_id => l_component_appl_id
13324 ,p_amb_context_code => l_amb_context_code
13325 ,p_entity_code => l_entity_code
13326 ,p_event_class_code => l_event_class_code);
13327 --
13328 -- set accounting class
13329 --
13330 xla_ae_lines_pkg.SetAcctClass(
13331 p_accounting_class_code => 'RECEIVABLE'
13332 , p_ae_header_id => l_ae_header_id
13333 );
13334
13335 --
13336 -- set rounding class
13337 --
13338 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
13339 'RECEIVABLE';
13340
13341 --
13342 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
13343 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
13344 --
13345 -- bulk performance
13346 --
13347 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
13348
13349 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
13350 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
13351
13352 -- 4955764
13353 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13354 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
13355
13356 -- 4458381 Public Sector Enh
13357
13358 --
13359 -- set accounting attributes for the line type
13360 --
13361 l_entered_amt_idx := 3;
13362 l_accted_amt_idx := 9;
13363 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13364 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
13365 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
13366 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
13367 l_rec_acct_attrs.array_char_value(2) := p_source_43;
13368 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
13369 l_rec_acct_attrs.array_num_value(3) := p_source_54;
13370 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
13371 l_rec_acct_attrs.array_char_value(4) := p_source_44;
13375 l_rec_acct_attrs.array_num_value(6) := p_source_46;
13372 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
13373 l_rec_acct_attrs.array_date_value(5) := p_source_45;
13374 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
13376 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
13377 l_rec_acct_attrs.array_char_value(7) := p_source_47;
13378 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
13379 l_rec_acct_attrs.array_char_value(8) := p_source_48;
13380 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
13381 l_rec_acct_attrs.array_num_value(9) := p_source_49;
13382 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
13383 l_rec_acct_attrs.array_num_value(10) := p_source_50;
13384 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
13385 l_rec_acct_attrs.array_num_value(11) := p_source_51;
13386 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
13387 l_rec_acct_attrs.array_char_value(12) := p_source_32;
13388 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
13389 l_rec_acct_attrs.array_num_value(13) := p_source_52;
13390
13391 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
13392 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
13393
13394 ---------------------------------------------------------------------------------------------------------------
13395 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
13396 ---------------------------------------------------------------------------------------------------------------
13397 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
13398
13399 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13400 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13401
13402 IF xla_accounting_cache_pkg.GetValueChar
13403 (p_source_code => 'LEDGER_CATEGORY_CODE'
13404 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
13405 AND l_bflow_method_code = 'PRIOR_ENTRY'
13406 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
13407 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
13408 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
13409 )
13410 THEN
13411 xla_ae_lines_pkg.BflowUpgEntry
13412 (p_business_method_code => l_bflow_method_code
13413 ,p_business_class_code => l_bflow_class_code
13414 ,p_balance_type => l_balance_type_code);
13415 ELSE
13416 NULL;
13417 -- No business flow processing for business flow method of NONE.
13418 END IF;
13419
13420 --
13421 -- call analytical criteria
13422 --
13423
13424 --
13425 -- call description
13426 --
13427 -- No description or it is inherited.
13428 --
13429 -- call ADRs
13430 -- Bug 4922099
13431 --
13432 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13433 (NVL(l_actual_upg_option, 'N') = 'O') OR
13434 (NVL(l_enc_upg_option, 'N') = 'O')
13435 )
13436 THEN
13437 NULL;
13438 --
13439 --
13440
13441 l_ccid := AcctDerRule_3(
13442 p_application_id => p_application_id
13443 , p_ae_header_id => l_ae_header_id
13444 , p_source_4 => p_source_4
13445 , x_transaction_coa_id => l_adr_transaction_coa_id
13446 , x_accounting_coa_id => l_adr_accounting_coa_id
13447 , x_value_type_code => l_adr_value_type_code
13448 , p_side => 'NA'
13449 );
13450
13451 xla_ae_lines_pkg.set_ccid(
13452 p_code_combination_id => l_ccid
13453 , p_value_type_code => l_adr_value_type_code
13454 , p_transaction_coa_id => l_adr_transaction_coa_id
13455 , p_accounting_coa_id => l_adr_accounting_coa_id
13456 , p_adr_code => 'CM_DIST_CCID'
13457 , p_adr_type_code => 'S'
13458 , p_component_type => l_component_type
13459 , p_component_code => l_component_code
13460 , p_component_type_code => l_component_type_code
13461 , p_component_appl_id => l_component_appl_id
13462 , p_amb_context_code => l_amb_context_code
13463 , p_side => 'NA'
13464 );
13465
13466
13467 --
13468 --
13469 END IF;
13470 --
13471 -- Bug 4922099
13472 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
13473 (NVL(l_enc_upg_option, 'N') = 'O')
13474 ) AND
13475 (l_bflow_method_code = 'PRIOR_ENTRY')
13476 )
13477 THEN
13478 IF
13482 THEN
13479 --
13480 1 = 2
13481 --
13483 xla_accounting_err_pkg.build_message
13484 (p_appli_s_name => 'XLA'
13485 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13486 ,p_token_1 => 'LINE_NUMBER'
13487 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
13488 ,p_token_2 => 'LINE_TYPE_NAME'
13489 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
13490 l_component_type
13491 ,l_component_code
13492 ,l_component_type_code
13493 ,l_component_appl_id
13494 ,l_amb_context_code
13495 ,l_entity_code
13496 ,l_event_class_code
13497 )
13498 ,p_token_3 => 'OWNER'
13499 ,p_value_3 => xla_lookups_pkg.get_meaning(
13500 p_lookup_type => 'XLA_OWNER_TYPE'
13501 ,p_lookup_code => l_component_type_code
13502 )
13503 ,p_token_4 => 'PRODUCT_NAME'
13504 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
13505 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
13506 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
13507 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
13508 ,p_ae_header_id => NULL
13509 );
13510
13511 IF (C_LEVEL_ERROR>= g_log_level) THEN
13512 trace
13513 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
13514 ,p_level => C_LEVEL_ERROR
13515 ,p_module => l_log_module);
13516 END IF;
13517 END IF;
13518 END IF;
13519 --
13520 --
13521 ------------------------------------------------------------------------------------------------
13522 -- 4219869 Business Flow
13523 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
13524 -- Prior Entry. Currently, the following code is always generated.
13525 ------------------------------------------------------------------------------------------------
13526 XLA_AE_LINES_PKG.ValidateCurrentLine;
13527
13528 ------------------------------------------------------------------------------------
13529 -- 4219869 Business Flow
13530 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
13531 ------------------------------------------------------------------------------------
13532 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13533
13534 ----------------------------------------------------------------------------------
13535 -- 4219869 Business Flow
13536 -- Update journal entry status -- Need to generate this within IF <condition>
13537 ----------------------------------------------------------------------------------
13538 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13539 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
13540 ,p_balance_type_code => l_balance_type_code
13541 );
13542
13543 -------------------------------------------------------------------------------------------
13544 -- 4262811 - Generate the Accrual Reversal lines
13545 -------------------------------------------------------------------------------------------
13546 BEGIN
13547 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
13548 (g_array_event(p_event_id).array_value_num('header_index'));
13549 IF l_acc_rev_flag IS NULL THEN
13550 l_acc_rev_flag := 'N';
13551 END IF;
13552 EXCEPTION
13553 WHEN OTHERS THEN
13554 l_acc_rev_flag := 'N';
13555 END;
13556 --
13557 IF (l_acc_rev_flag = 'Y') THEN
13558
13559 -- 4645092 ------------------------------------------------------------------------------
13560 -- To allow MPA report to determine if it should generate report process
13561 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
13562 ------------------------------------------------------------------------------------------
13563
13564 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
13565 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
13566 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
13567 -- call ADRs
13568 -- Bug 4922099
13569 --
13570 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
13571 (NVL(l_actual_upg_option, 'N') = 'O') OR
13572 (NVL(l_enc_upg_option, 'N') = 'O')
13573 )
13574 THEN
13575 NULL;
13576 --
13577 --
13578
13579 l_ccid := AcctDerRule_3(
13580 p_application_id => p_application_id
13581 , p_ae_header_id => l_ae_header_id
13582 , p_source_4 => p_source_4
13583 , x_transaction_coa_id => l_adr_transaction_coa_id
13584 , x_accounting_coa_id => l_adr_accounting_coa_id
13585 , x_value_type_code => l_adr_value_type_code
13586 , p_side => 'NA'
13587 );
13588
13589 xla_ae_lines_pkg.set_ccid(
13590 p_code_combination_id => l_ccid
13591 , p_value_type_code => l_adr_value_type_code
13592 , p_transaction_coa_id => l_adr_transaction_coa_id
13593 , p_accounting_coa_id => l_adr_accounting_coa_id
13594 , p_adr_code => 'CM_DIST_CCID'
13595 , p_adr_type_code => 'S'
13596 , p_component_type => l_component_type
13597 , p_component_code => l_component_code
13598 , p_component_type_code => l_component_type_code
13599 , p_component_appl_id => l_component_appl_id
13600 , p_amb_context_code => l_amb_context_code
13601 , p_side => 'NA'
13602 );
13603
13604
13605 --
13606 --
13607 END IF;
13608
13609 --
13610 -- Update the line information that should be overwritten
13611 --
13612 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
13613 p_header_num => 1);
13614 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
13615
13616 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
13617
13618 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
13619 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
13620 END IF;
13621
13622 --
13623 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
13624 --
13625 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
13626 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
13627 ELSE
13628 ---------------------------------------------------------------------------------------------------
13629 -- 4262811a Switch Sign
13630 ---------------------------------------------------------------------------------------------------
13631 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
13632 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13633 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13634 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
13635 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13636 -- 5132302
13637 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
13638 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
13639
13640 END IF;
13641
13642 -- 4955764
13643 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13644 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
13645
13646
13647 XLA_AE_LINES_PKG.ValidateCurrentLine;
13648 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
13649
13650 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
13651 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
13652 ,p_balance_type_code => l_balance_type_code);
13653
13654 END IF;
13655
13656 -----------------------------------------------------------------------------------------
13657 -- 4262811 Multiperiod Accounting
13658 -----------------------------------------------------------------------------------------
13659 -- No MPA option is assigned.
13660
13661
13662 END IF;
13663 END IF;
13664 --
13665
13666 --
13667 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13668 trace
13669 (p_msg => 'END of AcctLineType_45'
13670 ,p_level => C_LEVEL_PROCEDURE
13671 ,p_module => l_log_module);
13672 END IF;
13676 RAISE;
13673 --
13674 EXCEPTION
13675 WHEN xla_exceptions_pkg.application_exception THEN
13677 WHEN OTHERS THEN
13678 xla_exceptions_pkg.raise_message
13679 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_45');
13680 END AcctLineType_45;
13681 --
13682
13683 ---------------------------------------
13684 --
13685 -- PRIVATE FUNCTION
13686 -- AcctLineType_46
13687 --
13688 ---------------------------------------
13689 PROCEDURE AcctLineType_46 (
13690 p_application_id IN NUMBER
13691 ,p_event_id IN NUMBER
13692 ,p_calculate_acctd_flag IN VARCHAR2
13693 ,p_calculate_g_l_flag IN VARCHAR2
13694 ,p_actual_flag IN OUT VARCHAR2
13695 ,p_balance_type_code OUT VARCHAR2
13696 ,p_gain_or_loss_ref OUT VARCHAR2
13697
13698 --Credit Memo Distribution GL Account
13699 , p_source_4 IN NUMBER
13700 --SLA Party Type
13701 , p_source_32 IN VARCHAR2
13702 --Credit Memo Distribution Identifier
13703 , p_source_42 IN NUMBER
13704 --Credit memo distributions type
13705 , p_source_43 IN VARCHAR2
13706 --Credit Memo Currency Code
13707 , p_source_44 IN VARCHAR2
13708 --Credit Memo Exchange Date
13709 , p_source_45 IN DATE
13710 --Credit Memo Exchange Rate
13711 , p_source_46 IN NUMBER
13712 --Credit Memo Exchange Rate Type
13713 , p_source_47 IN VARCHAR2
13714 --Gain Loss Reference
13715 , p_source_48 IN VARCHAR2
13716 --Credit Memo Accounting Amount
13717 , p_source_49 IN NUMBER
13718 --Credit Memo Bill To Customer Account Identifier
13719 , p_source_50 IN NUMBER
13720 --Credit Memo Bill To Customer Site Use Identifier
13721 , p_source_51 IN NUMBER
13722 --Credit Memo Tax Line Identifier
13723 , p_source_52 IN NUMBER
13724 --Credit Memo Distribution Account Class
13725 , p_source_53 IN VARCHAR2
13726 --Credit Memo Distribution Entered Amount
13727 , p_source_54 IN NUMBER
13728 )
13729 IS
13730
13731 l_component_type VARCHAR2(80);
13732 l_component_code VARCHAR2(30);
13733 l_component_type_code VARCHAR2(1);
13734 l_component_appl_id INTEGER;
13735 l_amb_context_code VARCHAR2(30);
13736 l_entity_code VARCHAR2(30);
13737 l_event_class_code VARCHAR2(30);
13738 l_ae_header_id NUMBER;
13739 l_event_type_code VARCHAR2(30);
13740 l_line_definition_code VARCHAR2(30);
13741 l_line_definition_owner_code VARCHAR2(1);
13742 --
13743 -- adr variables
13744 l_segment VARCHAR2(30);
13745 l_ccid NUMBER;
13746 l_adr_transaction_coa_id NUMBER;
13747 l_adr_accounting_coa_id NUMBER;
13748 l_adr_flexfield_segment_code VARCHAR2(30);
13749 l_adr_flex_value_set_id NUMBER;
13750 l_adr_value_type_code VARCHAR2(30);
13751 l_adr_value_combination_id NUMBER;
13752 l_adr_value_segment_code VARCHAR2(30);
13753
13754 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
13755 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
13756 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
13757 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
13758
13759 -- 4262811 Variables ------------------------------------------------------------------------------------------
13760 l_entered_amt_idx NUMBER;
13761 l_accted_amt_idx NUMBER;
13762 l_acc_rev_flag VARCHAR2(1);
13763 l_accrual_line_num NUMBER;
13764 l_tmp_amt NUMBER;
13765 l_acc_rev_natural_side_code VARCHAR2(1);
13766
13767 l_num_entries NUMBER;
13768 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
13769 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
13770 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
13771 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
13772 l_recog_line_1 NUMBER;
13776 l_bflow_applied_to_amt NUMBER; -- 5132302
13773 l_recog_line_2 NUMBER;
13774
13775 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
13777 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
13778
13779 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
13780
13781 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
13782 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
13783
13784 ---------------------------------------------------------------------------------------------------------------
13785
13786
13787 --
13788 -- bulk performance
13789 --
13790 l_balance_type_code VARCHAR2(1);
13791 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
13792 l_log_module VARCHAR2(240);
13793
13794 --
13795 -- Upgrade strategy
13796 --
13797 l_actual_upg_option VARCHAR2(1);
13798 l_enc_upg_option VARCHAR2(1);
13799
13800 --
13801 BEGIN
13802 --
13803 IF g_log_enabled THEN
13804 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_46';
13805 END IF;
13806 --
13807 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13808
13809 trace
13810 (p_msg => 'BEGIN of AcctLineType_46'
13811 ,p_level => C_LEVEL_PROCEDURE
13812 ,p_module => l_log_module);
13813
13814 END IF;
13815 --
13816 l_component_type := 'AMB_JLT';
13817 l_component_code := 'CM_DEFAULT_REV';
13818 l_component_type_code := 'S';
13819 l_component_appl_id := 222;
13820 l_amb_context_code := 'DEFAULT';
13821 l_entity_code := 'TRANSACTIONS';
13822 l_event_class_code := 'CREDIT_MEMO';
13823 l_event_type_code := 'CREDIT_MEMO_ALL';
13824 l_line_definition_owner_code := 'S';
13825 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
13826 --
13827 l_balance_type_code := 'A';
13828 l_segment := NULL;
13829 l_ccid := NULL;
13830 l_adr_transaction_coa_id := NULL;
13831 l_adr_accounting_coa_id := NULL;
13832 l_adr_flexfield_segment_code := NULL;
13833 l_adr_flex_value_set_id := NULL;
13834 l_adr_value_type_code := NULL;
13835 l_adr_value_combination_id := NULL;
13836 l_adr_value_segment_code := NULL;
13837
13838 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
13839 l_bflow_class_code := ''; -- 4219869 Business Flow
13840 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
13841 l_budgetary_control_flag := 'N';
13842
13843 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13844 l_bflow_applied_to_amt := NULL; -- 5132302
13845 l_entered_amt_idx := NULL; -- 4262811
13846 l_accted_amt_idx := NULL; -- 4262811
13847 l_acc_rev_flag := NULL; -- 4262811
13848 l_accrual_line_num := NULL; -- 4262811
13849 l_tmp_amt := NULL; -- 4262811
13850 --
13851
13852 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
13853 l_balance_type_code <> 'B' THEN
13854 IF NVL(p_source_53,'
13855 ') = 'REV'
13856 THEN
13857
13858 --
13859 XLA_AE_LINES_PKG.SetNewLine;
13860
13861 p_balance_type_code := l_balance_type_code;
13862 -- set the flag so later we will know whether the gain loss line needs to be created
13863
13864 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
13865 p_actual_flag :='A';
13866 END IF;
13867
13868 --
13869 -- bulk performance
13870 --
13871 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
13872 p_header_num => 0); -- 4262811
13873 --
13874 -- set accounting line options
13875 --
13876 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
13877 p_natural_side_code => 'C'
13878 , p_gain_or_loss_flag => 'N'
13879 , p_gl_transfer_mode_code => 'S'
13880 , p_acct_entry_type_code => 'A'
13881 , p_switch_side_flag => 'Y'
13882 , p_merge_duplicate_code => 'A'
13883 );
13884 --
13885 l_acc_rev_natural_side_code := 'D'; -- 4262811
13886 --
13887 --
13888 -- set accounting line type info
13889 --
13890 xla_ae_lines_pkg.SetAcctLineType
13891 (p_component_type => l_component_type
13892 ,p_event_type_code => l_event_type_code
13893 ,p_line_definition_owner_code => l_line_definition_owner_code
13894 ,p_line_definition_code => l_line_definition_code
13895 ,p_accounting_line_code => l_component_code
13896 ,p_accounting_line_type_code => l_component_type_code
13897 ,p_accounting_line_appl_id => l_component_appl_id
13898 ,p_amb_context_code => l_amb_context_code
13899 ,p_entity_code => l_entity_code
13900 ,p_event_class_code => l_event_class_code);
13901 --
13902 -- set accounting class
13903 --
13904 xla_ae_lines_pkg.SetAcctClass(
13905 p_accounting_class_code => 'REVENUE'
13906 , p_ae_header_id => l_ae_header_id
13907 );
13908
13909 --
13910 -- set rounding class
13911 --
13915 --
13912 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
13913 'RECEIVABLE';
13914
13916 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
13917 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
13918 --
13919 -- bulk performance
13920 --
13921 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
13922
13923 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
13924 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
13925
13926 -- 4955764
13927 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
13928 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
13929
13930 -- 4458381 Public Sector Enh
13931
13932 --
13933 -- set accounting attributes for the line type
13934 --
13935 l_entered_amt_idx := 3;
13936 l_accted_amt_idx := 9;
13937 l_bflow_applied_to_amt_idx := NULL; -- 5132302
13938 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
13939 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
13940 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
13941 l_rec_acct_attrs.array_char_value(2) := p_source_43;
13942 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
13943 l_rec_acct_attrs.array_num_value(3) := p_source_54;
13944 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
13945 l_rec_acct_attrs.array_char_value(4) := p_source_44;
13946 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
13947 l_rec_acct_attrs.array_date_value(5) := p_source_45;
13948 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
13949 l_rec_acct_attrs.array_num_value(6) := p_source_46;
13950 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
13951 l_rec_acct_attrs.array_char_value(7) := p_source_47;
13952 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
13953 l_rec_acct_attrs.array_char_value(8) := p_source_48;
13954 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
13955 l_rec_acct_attrs.array_num_value(9) := p_source_49;
13956 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
13957 l_rec_acct_attrs.array_num_value(10) := p_source_50;
13958 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
13959 l_rec_acct_attrs.array_num_value(11) := p_source_51;
13960 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
13961 l_rec_acct_attrs.array_char_value(12) := p_source_32;
13962 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
13963 l_rec_acct_attrs.array_num_value(13) := p_source_52;
13964
13965 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
13966 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
13967
13968 ---------------------------------------------------------------------------------------------------------------
13969 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
13970 ---------------------------------------------------------------------------------------------------------------
13971 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
13972
13973 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13974 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
13975
13976 IF xla_accounting_cache_pkg.GetValueChar
13977 (p_source_code => 'LEDGER_CATEGORY_CODE'
13978 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
13979 AND l_bflow_method_code = 'PRIOR_ENTRY'
13980 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
13981 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
13982 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
13983 )
13984 THEN
13985 xla_ae_lines_pkg.BflowUpgEntry
13986 (p_business_method_code => l_bflow_method_code
13987 ,p_business_class_code => l_bflow_class_code
13988 ,p_balance_type => l_balance_type_code);
13989 ELSE
13990 NULL;
13991 -- No business flow processing for business flow method of NONE.
13992 END IF;
13993
13994 --
13995 -- call analytical criteria
13996 --
13997
13998 --
13999 -- call description
14000 --
14001 -- No description or it is inherited.
14002 --
14003 -- call ADRs
14004 -- Bug 4922099
14005 --
14006 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14007 (NVL(l_actual_upg_option, 'N') = 'O') OR
14008 (NVL(l_enc_upg_option, 'N') = 'O')
14009 )
14010 THEN
14011 NULL;
14012 --
14013 --
14014
14015 l_ccid := AcctDerRule_3(
14016 p_application_id => p_application_id
14017 , p_ae_header_id => l_ae_header_id
14018 , p_source_4 => p_source_4
14019 , x_transaction_coa_id => l_adr_transaction_coa_id
14020 , x_accounting_coa_id => l_adr_accounting_coa_id
14021 , x_value_type_code => l_adr_value_type_code
14022 , p_side => 'NA'
14023 );
14024
14025 xla_ae_lines_pkg.set_ccid(
14026 p_code_combination_id => l_ccid
14027 , p_value_type_code => l_adr_value_type_code
14028 , p_transaction_coa_id => l_adr_transaction_coa_id
14029 , p_accounting_coa_id => l_adr_accounting_coa_id
14030 , p_adr_code => 'CM_DIST_CCID'
14031 , p_adr_type_code => 'S'
14032 , p_component_type => l_component_type
14033 , p_component_code => l_component_code
14034 , p_component_type_code => l_component_type_code
14035 , p_component_appl_id => l_component_appl_id
14036 , p_amb_context_code => l_amb_context_code
14037 , p_side => 'NA'
14038 );
14039
14040
14041 --
14042 --
14043 END IF;
14044 --
14045 -- Bug 4922099
14046 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
14047 (NVL(l_enc_upg_option, 'N') = 'O')
14048 ) AND
14049 (l_bflow_method_code = 'PRIOR_ENTRY')
14050 )
14051 THEN
14052 IF
14053 --
14054 1 = 2
14055 --
14056 THEN
14057 xla_accounting_err_pkg.build_message
14058 (p_appli_s_name => 'XLA'
14059 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14060 ,p_token_1 => 'LINE_NUMBER'
14061 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
14062 ,p_token_2 => 'LINE_TYPE_NAME'
14063 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
14064 l_component_type
14065 ,l_component_code
14066 ,l_component_type_code
14067 ,l_component_appl_id
14068 ,l_amb_context_code
14069 ,l_entity_code
14070 ,l_event_class_code
14071 )
14072 ,p_token_3 => 'OWNER'
14073 ,p_value_3 => xla_lookups_pkg.get_meaning(
14074 p_lookup_type => 'XLA_OWNER_TYPE'
14075 ,p_lookup_code => l_component_type_code
14076 )
14077 ,p_token_4 => 'PRODUCT_NAME'
14078 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
14079 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
14080 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
14081 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
14082 ,p_ae_header_id => NULL
14083 );
14084
14085 IF (C_LEVEL_ERROR>= g_log_level) THEN
14086 trace
14087 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14088 ,p_level => C_LEVEL_ERROR
14089 ,p_module => l_log_module);
14090 END IF;
14091 END IF;
14092 END IF;
14093 --
14094 --
14095 ------------------------------------------------------------------------------------------------
14096 -- 4219869 Business Flow
14097 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
14098 -- Prior Entry. Currently, the following code is always generated.
14099 ------------------------------------------------------------------------------------------------
14100 XLA_AE_LINES_PKG.ValidateCurrentLine;
14101
14102 ------------------------------------------------------------------------------------
14103 -- 4219869 Business Flow
14104 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
14105 ------------------------------------------------------------------------------------
14106 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14107
14108 ----------------------------------------------------------------------------------
14109 -- 4219869 Business Flow
14110 -- Update journal entry status -- Need to generate this within IF <condition>
14111 ----------------------------------------------------------------------------------
14112 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14113 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
14114 ,p_balance_type_code => l_balance_type_code
14115 );
14116
14117 -------------------------------------------------------------------------------------------
14118 -- 4262811 - Generate the Accrual Reversal lines
14119 -------------------------------------------------------------------------------------------
14120 BEGIN
14121 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
14122 (g_array_event(p_event_id).array_value_num('header_index'));
14123 IF l_acc_rev_flag IS NULL THEN
14124 l_acc_rev_flag := 'N';
14125 END IF;
14126 EXCEPTION
14127 WHEN OTHERS THEN
14128 l_acc_rev_flag := 'N';
14129 END;
14130 --
14131 IF (l_acc_rev_flag = 'Y') THEN
14132
14133 -- 4645092 ------------------------------------------------------------------------------
14134 -- To allow MPA report to determine if it should generate report process
14135 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
14136 ------------------------------------------------------------------------------------------
14137
14138 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
14139 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
14140 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
14141 -- call ADRs
14142 -- Bug 4922099
14143 --
14144 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14145 (NVL(l_actual_upg_option, 'N') = 'O') OR
14146 (NVL(l_enc_upg_option, 'N') = 'O')
14147 )
14148 THEN
14149 NULL;
14150 --
14151 --
14152
14153 l_ccid := AcctDerRule_3(
14154 p_application_id => p_application_id
14155 , p_ae_header_id => l_ae_header_id
14156 , p_source_4 => p_source_4
14157 , x_transaction_coa_id => l_adr_transaction_coa_id
14158 , x_accounting_coa_id => l_adr_accounting_coa_id
14159 , x_value_type_code => l_adr_value_type_code
14160 , p_side => 'NA'
14161 );
14162
14163 xla_ae_lines_pkg.set_ccid(
14164 p_code_combination_id => l_ccid
14165 , p_value_type_code => l_adr_value_type_code
14166 , p_transaction_coa_id => l_adr_transaction_coa_id
14167 , p_accounting_coa_id => l_adr_accounting_coa_id
14168 , p_adr_code => 'CM_DIST_CCID'
14169 , p_adr_type_code => 'S'
14170 , p_component_type => l_component_type
14171 , p_component_code => l_component_code
14172 , p_component_type_code => l_component_type_code
14173 , p_component_appl_id => l_component_appl_id
14174 , p_amb_context_code => l_amb_context_code
14175 , p_side => 'NA'
14176 );
14177
14178
14179 --
14180 --
14181 END IF;
14182
14183 --
14184 -- Update the line information that should be overwritten
14185 --
14186 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
14187 p_header_num => 1);
14188 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
14189
14190 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
14191
14192 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
14193 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
14194 END IF;
14195
14196 --
14197 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
14198 --
14199 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
14200 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
14201 ELSE
14202 ---------------------------------------------------------------------------------------------------
14203 -- 4262811a Switch Sign
14204 ---------------------------------------------------------------------------------------------------
14205 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
14206 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14207 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14208 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14209 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14210 -- 5132302
14214 END IF;
14211 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
14212 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14213
14215
14216 -- 4955764
14217 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14218 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
14219
14220
14221 XLA_AE_LINES_PKG.ValidateCurrentLine;
14222 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14223
14224 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14225 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
14226 ,p_balance_type_code => l_balance_type_code);
14227
14228 END IF;
14229
14230 -----------------------------------------------------------------------------------------
14231 -- 4262811 Multiperiod Accounting
14232 -----------------------------------------------------------------------------------------
14233 -- No MPA option is assigned.
14234
14235
14236 END IF;
14237 END IF;
14238 --
14239
14240 --
14241 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14242 trace
14243 (p_msg => 'END of AcctLineType_46'
14244 ,p_level => C_LEVEL_PROCEDURE
14245 ,p_module => l_log_module);
14246 END IF;
14247 --
14248 EXCEPTION
14249 WHEN xla_exceptions_pkg.application_exception THEN
14250 RAISE;
14251 WHEN OTHERS THEN
14252 xla_exceptions_pkg.raise_message
14253 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_46');
14254 END AcctLineType_46;
14255 --
14256
14257 ---------------------------------------
14258 --
14259 -- PRIVATE FUNCTION
14260 -- AcctLineType_47
14261 --
14262 ---------------------------------------
14263 PROCEDURE AcctLineType_47 (
14264 p_application_id IN NUMBER
14265 ,p_event_id IN NUMBER
14266 ,p_calculate_acctd_flag IN VARCHAR2
14267 ,p_calculate_g_l_flag IN VARCHAR2
14268 ,p_actual_flag IN OUT VARCHAR2
14269 ,p_balance_type_code OUT VARCHAR2
14270 ,p_gain_or_loss_ref OUT VARCHAR2
14271
14272 --Credit Memo Distribution GL Account
14273 , p_source_4 IN NUMBER
14274 --SLA Party Type
14275 , p_source_32 IN VARCHAR2
14276 --Credit Memo Distribution Identifier
14277 , p_source_42 IN NUMBER
14278 --Credit memo distributions type
14279 , p_source_43 IN VARCHAR2
14280 --Credit Memo Currency Code
14281 , p_source_44 IN VARCHAR2
14282 --Credit Memo Exchange Date
14283 , p_source_45 IN DATE
14284 --Credit Memo Exchange Rate
14285 , p_source_46 IN NUMBER
14286 --Credit Memo Exchange Rate Type
14287 , p_source_47 IN VARCHAR2
14288 --Gain Loss Reference
14289 , p_source_48 IN VARCHAR2
14290 --Credit Memo Accounting Amount
14291 , p_source_49 IN NUMBER
14292 --Credit Memo Bill To Customer Account Identifier
14293 , p_source_50 IN NUMBER
14294 --Credit Memo Bill To Customer Site Use Identifier
14295 , p_source_51 IN NUMBER
14296 --Credit Memo Tax Line Identifier
14297 , p_source_52 IN NUMBER
14298 --Credit Memo Distribution Account Class
14299 , p_source_53 IN VARCHAR2
14300 --Credit Memo Distribution Entered Amount
14301 , p_source_54 IN NUMBER
14302 )
14303 IS
14304
14305 l_component_type VARCHAR2(80);
14306 l_component_code VARCHAR2(30);
14307 l_component_type_code VARCHAR2(1);
14308 l_component_appl_id INTEGER;
14309 l_amb_context_code VARCHAR2(30);
14310 l_entity_code VARCHAR2(30);
14311 l_event_class_code VARCHAR2(30);
14312 l_ae_header_id NUMBER;
14313 l_event_type_code VARCHAR2(30);
14314 l_line_definition_code VARCHAR2(30);
14315 l_line_definition_owner_code VARCHAR2(1);
14316 --
14317 -- adr variables
14318 l_segment VARCHAR2(30);
14319 l_ccid NUMBER;
14320 l_adr_transaction_coa_id NUMBER;
14321 l_adr_accounting_coa_id NUMBER;
14322 l_adr_flexfield_segment_code VARCHAR2(30);
14323 l_adr_flex_value_set_id NUMBER;
14324 l_adr_value_type_code VARCHAR2(30);
14325 l_adr_value_combination_id NUMBER;
14326 l_adr_value_segment_code VARCHAR2(30);
14327
14328 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
14329 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
14330 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
14331 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
14332
14333 -- 4262811 Variables ------------------------------------------------------------------------------------------
14334 l_entered_amt_idx NUMBER;
14335 l_accted_amt_idx NUMBER;
14336 l_acc_rev_flag VARCHAR2(1);
14337 l_accrual_line_num NUMBER;
14338 l_tmp_amt NUMBER;
14339 l_acc_rev_natural_side_code VARCHAR2(1);
14340
14341 l_num_entries NUMBER;
14342 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
14343 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
14344 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
14345 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
14346 l_recog_line_1 NUMBER;
14347 l_recog_line_2 NUMBER;
14348
14349 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
14350 l_bflow_applied_to_amt NUMBER; -- 5132302
14351 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
14352
14353 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
14354
14355 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
14356 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
14357
14358 ---------------------------------------------------------------------------------------------------------------
14359
14360
14361 --
14362 -- bulk performance
14363 --
14364 l_balance_type_code VARCHAR2(1);
14365 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
14366 l_log_module VARCHAR2(240);
14367
14368 --
14369 -- Upgrade strategy
14370 --
14371 l_actual_upg_option VARCHAR2(1);
14372 l_enc_upg_option VARCHAR2(1);
14373
14374 --
14375 BEGIN
14376 --
14377 IF g_log_enabled THEN
14378 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_47';
14379 END IF;
14380 --
14381 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14382
14383 trace
14384 (p_msg => 'BEGIN of AcctLineType_47'
14385 ,p_level => C_LEVEL_PROCEDURE
14386 ,p_module => l_log_module);
14387
14388 END IF;
14389 --
14390 l_component_type := 'AMB_JLT';
14391 l_component_code := 'CM_DEFAULT_SUSPENSE';
14392 l_component_type_code := 'S';
14393 l_component_appl_id := 222;
14394 l_amb_context_code := 'DEFAULT';
14395 l_entity_code := 'TRANSACTIONS';
14396 l_event_class_code := 'CREDIT_MEMO';
14397 l_event_type_code := 'CREDIT_MEMO_ALL';
14398 l_line_definition_owner_code := 'S';
14399 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
14400 --
14401 l_balance_type_code := 'A';
14402 l_segment := NULL;
14403 l_ccid := NULL;
14404 l_adr_transaction_coa_id := NULL;
14405 l_adr_accounting_coa_id := NULL;
14406 l_adr_flexfield_segment_code := NULL;
14407 l_adr_flex_value_set_id := NULL;
14408 l_adr_value_type_code := NULL;
14409 l_adr_value_combination_id := NULL;
14410 l_adr_value_segment_code := NULL;
14411
14412 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
14413 l_bflow_class_code := ''; -- 4219869 Business Flow
14414 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
14415 l_budgetary_control_flag := 'N';
14416
14417 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14418 l_bflow_applied_to_amt := NULL; -- 5132302
14419 l_entered_amt_idx := NULL; -- 4262811
14420 l_accted_amt_idx := NULL; -- 4262811
14421 l_acc_rev_flag := NULL; -- 4262811
14422 l_accrual_line_num := NULL; -- 4262811
14423 l_tmp_amt := NULL; -- 4262811
14424 --
14425
14426 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
14427 l_balance_type_code <> 'B' THEN
14428 IF NVL(p_source_53,'
14429 ') = 'SUSPENSE'
14430 THEN
14431
14432 --
14433 XLA_AE_LINES_PKG.SetNewLine;
14434
14435 p_balance_type_code := l_balance_type_code;
14436 -- set the flag so later we will know whether the gain loss line needs to be created
14437
14438 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
14439 p_actual_flag :='A';
14440 END IF;
14441
14442 --
14443 -- bulk performance
14444 --
14445 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
14446 p_header_num => 0); -- 4262811
14447 --
14448 -- set accounting line options
14449 --
14450 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
14451 p_natural_side_code => 'C'
14452 , p_gain_or_loss_flag => 'N'
14453 , p_gl_transfer_mode_code => 'S'
14454 , p_acct_entry_type_code => 'A'
14455 , p_switch_side_flag => 'Y'
14456 , p_merge_duplicate_code => 'A'
14457 );
14458 --
14459 l_acc_rev_natural_side_code := 'D'; -- 4262811
14460 --
14461 --
14462 -- set accounting line type info
14463 --
14464 xla_ae_lines_pkg.SetAcctLineType
14465 (p_component_type => l_component_type
14466 ,p_event_type_code => l_event_type_code
14467 ,p_line_definition_owner_code => l_line_definition_owner_code
14468 ,p_line_definition_code => l_line_definition_code
14469 ,p_accounting_line_code => l_component_code
14470 ,p_accounting_line_type_code => l_component_type_code
14471 ,p_accounting_line_appl_id => l_component_appl_id
14472 ,p_amb_context_code => l_amb_context_code
14473 ,p_entity_code => l_entity_code
14474 ,p_event_class_code => l_event_class_code);
14475 --
14476 -- set accounting class
14477 --
14478 xla_ae_lines_pkg.SetAcctClass(
14479 p_accounting_class_code => 'SUSPENSE'
14480 , p_ae_header_id => l_ae_header_id
14481 );
14482
14483 --
14484 -- set rounding class
14485 --
14486 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
14487 'RECEIVABLE';
14488
14489 --
14490 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
14491 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
14492 --
14493 -- bulk performance
14494 --
14495 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
14496
14497 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
14498 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
14499
14500 -- 4955764
14501 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14502 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
14503
14504 -- 4458381 Public Sector Enh
14505
14506 --
14507 -- set accounting attributes for the line type
14508 --
14509 l_entered_amt_idx := 3;
14510 l_accted_amt_idx := 9;
14511 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14512 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
14513 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
14514 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
14515 l_rec_acct_attrs.array_char_value(2) := p_source_43;
14516 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
14517 l_rec_acct_attrs.array_num_value(3) := p_source_54;
14518 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
14519 l_rec_acct_attrs.array_char_value(4) := p_source_44;
14520 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
14521 l_rec_acct_attrs.array_date_value(5) := p_source_45;
14522 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
14523 l_rec_acct_attrs.array_num_value(6) := p_source_46;
14524 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
14525 l_rec_acct_attrs.array_char_value(7) := p_source_47;
14529 l_rec_acct_attrs.array_num_value(9) := p_source_49;
14526 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
14527 l_rec_acct_attrs.array_char_value(8) := p_source_48;
14528 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
14530 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
14531 l_rec_acct_attrs.array_num_value(10) := p_source_50;
14532 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
14533 l_rec_acct_attrs.array_num_value(11) := p_source_51;
14534 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
14535 l_rec_acct_attrs.array_char_value(12) := p_source_32;
14536 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
14537 l_rec_acct_attrs.array_num_value(13) := p_source_52;
14538
14539 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
14540 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
14541
14542 ---------------------------------------------------------------------------------------------------------------
14543 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
14544 ---------------------------------------------------------------------------------------------------------------
14545 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
14546
14547 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
14548 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
14549
14550 IF xla_accounting_cache_pkg.GetValueChar
14551 (p_source_code => 'LEDGER_CATEGORY_CODE'
14552 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
14553 AND l_bflow_method_code = 'PRIOR_ENTRY'
14554 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
14555 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
14556 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
14557 )
14558 THEN
14559 xla_ae_lines_pkg.BflowUpgEntry
14560 (p_business_method_code => l_bflow_method_code
14561 ,p_business_class_code => l_bflow_class_code
14562 ,p_balance_type => l_balance_type_code);
14563 ELSE
14564 NULL;
14565 -- No business flow processing for business flow method of NONE.
14566 END IF;
14567
14568 --
14569 -- call analytical criteria
14570 --
14571
14572 --
14573 -- call description
14574 --
14575 -- No description or it is inherited.
14576 --
14577 -- call ADRs
14578 -- Bug 4922099
14579 --
14580 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14581 (NVL(l_actual_upg_option, 'N') = 'O') OR
14582 (NVL(l_enc_upg_option, 'N') = 'O')
14583 )
14584 THEN
14585 NULL;
14586 --
14587 --
14588
14589 l_ccid := AcctDerRule_3(
14590 p_application_id => p_application_id
14591 , p_ae_header_id => l_ae_header_id
14592 , p_source_4 => p_source_4
14593 , x_transaction_coa_id => l_adr_transaction_coa_id
14594 , x_accounting_coa_id => l_adr_accounting_coa_id
14595 , x_value_type_code => l_adr_value_type_code
14596 , p_side => 'NA'
14597 );
14598
14599 xla_ae_lines_pkg.set_ccid(
14600 p_code_combination_id => l_ccid
14601 , p_value_type_code => l_adr_value_type_code
14602 , p_transaction_coa_id => l_adr_transaction_coa_id
14603 , p_accounting_coa_id => l_adr_accounting_coa_id
14604 , p_adr_code => 'CM_DIST_CCID'
14605 , p_adr_type_code => 'S'
14606 , p_component_type => l_component_type
14607 , p_component_code => l_component_code
14608 , p_component_type_code => l_component_type_code
14609 , p_component_appl_id => l_component_appl_id
14610 , p_amb_context_code => l_amb_context_code
14611 , p_side => 'NA'
14612 );
14613
14614
14615 --
14616 --
14617 END IF;
14618 --
14619 -- Bug 4922099
14620 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
14621 (NVL(l_enc_upg_option, 'N') = 'O')
14622 ) AND
14623 (l_bflow_method_code = 'PRIOR_ENTRY')
14624 )
14625 THEN
14626 IF
14627 --
14628 1 = 2
14629 --
14630 THEN
14631 xla_accounting_err_pkg.build_message
14632 (p_appli_s_name => 'XLA'
14633 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14634 ,p_token_1 => 'LINE_NUMBER'
14635 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
14636 ,p_token_2 => 'LINE_TYPE_NAME'
14637 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
14638 l_component_type
14639 ,l_component_code
14640 ,l_component_type_code
14644 ,l_event_class_code
14641 ,l_component_appl_id
14642 ,l_amb_context_code
14643 ,l_entity_code
14645 )
14646 ,p_token_3 => 'OWNER'
14647 ,p_value_3 => xla_lookups_pkg.get_meaning(
14648 p_lookup_type => 'XLA_OWNER_TYPE'
14649 ,p_lookup_code => l_component_type_code
14650 )
14651 ,p_token_4 => 'PRODUCT_NAME'
14652 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
14653 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
14654 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
14655 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
14656 ,p_ae_header_id => NULL
14657 );
14658
14659 IF (C_LEVEL_ERROR>= g_log_level) THEN
14660 trace
14661 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
14662 ,p_level => C_LEVEL_ERROR
14663 ,p_module => l_log_module);
14664 END IF;
14665 END IF;
14666 END IF;
14667 --
14668 --
14669 ------------------------------------------------------------------------------------------------
14670 -- 4219869 Business Flow
14671 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
14672 -- Prior Entry. Currently, the following code is always generated.
14673 ------------------------------------------------------------------------------------------------
14674 XLA_AE_LINES_PKG.ValidateCurrentLine;
14675
14676 ------------------------------------------------------------------------------------
14677 -- 4219869 Business Flow
14678 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
14679 ------------------------------------------------------------------------------------
14680 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14681
14682 ----------------------------------------------------------------------------------
14683 -- 4219869 Business Flow
14684 -- Update journal entry status -- Need to generate this within IF <condition>
14685 ----------------------------------------------------------------------------------
14686 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14687 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
14688 ,p_balance_type_code => l_balance_type_code
14689 );
14690
14691 -------------------------------------------------------------------------------------------
14692 -- 4262811 - Generate the Accrual Reversal lines
14693 -------------------------------------------------------------------------------------------
14694 BEGIN
14695 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
14696 (g_array_event(p_event_id).array_value_num('header_index'));
14697 IF l_acc_rev_flag IS NULL THEN
14698 l_acc_rev_flag := 'N';
14699 END IF;
14700 EXCEPTION
14701 WHEN OTHERS THEN
14702 l_acc_rev_flag := 'N';
14703 END;
14704 --
14705 IF (l_acc_rev_flag = 'Y') THEN
14706
14707 -- 4645092 ------------------------------------------------------------------------------
14708 -- To allow MPA report to determine if it should generate report process
14709 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
14710 ------------------------------------------------------------------------------------------
14711
14712 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
14713 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
14714 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
14715 -- call ADRs
14716 -- Bug 4922099
14717 --
14718 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
14719 (NVL(l_actual_upg_option, 'N') = 'O') OR
14720 (NVL(l_enc_upg_option, 'N') = 'O')
14721 )
14722 THEN
14723 NULL;
14724 --
14725 --
14726
14727 l_ccid := AcctDerRule_3(
14728 p_application_id => p_application_id
14729 , p_ae_header_id => l_ae_header_id
14730 , p_source_4 => p_source_4
14731 , x_transaction_coa_id => l_adr_transaction_coa_id
14732 , x_accounting_coa_id => l_adr_accounting_coa_id
14733 , x_value_type_code => l_adr_value_type_code
14734 , p_side => 'NA'
14735 );
14736
14737 xla_ae_lines_pkg.set_ccid(
14738 p_code_combination_id => l_ccid
14739 , p_value_type_code => l_adr_value_type_code
14740 , p_transaction_coa_id => l_adr_transaction_coa_id
14741 , p_accounting_coa_id => l_adr_accounting_coa_id
14742 , p_adr_code => 'CM_DIST_CCID'
14743 , p_adr_type_code => 'S'
14744 , p_component_type => l_component_type
14745 , p_component_code => l_component_code
14746 , p_component_type_code => l_component_type_code
14747 , p_component_appl_id => l_component_appl_id
14748 , p_amb_context_code => l_amb_context_code
14749 , p_side => 'NA'
14750 );
14751
14752
14753 --
14754 --
14755 END IF;
14756
14757 --
14758 -- Update the line information that should be overwritten
14759 --
14760 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
14761 p_header_num => 1);
14762 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
14763
14764 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
14765
14766 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
14767 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
14768 END IF;
14769
14770 --
14771 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
14772 --
14773 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
14774 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
14775 ELSE
14776 ---------------------------------------------------------------------------------------------------
14777 -- 4262811a Switch Sign
14778 ---------------------------------------------------------------------------------------------------
14779 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
14780 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14781 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14782 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
14783 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14784 -- 5132302
14785 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
14786 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
14787
14788 END IF;
14789
14790 -- 4955764
14791 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
14792 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
14793
14794
14795 XLA_AE_LINES_PKG.ValidateCurrentLine;
14796 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
14797
14798 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
14799 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
14800 ,p_balance_type_code => l_balance_type_code);
14801
14802 END IF;
14803
14804 -----------------------------------------------------------------------------------------
14805 -- 4262811 Multiperiod Accounting
14806 -----------------------------------------------------------------------------------------
14807 -- No MPA option is assigned.
14808
14809
14810 END IF;
14811 END IF;
14812 --
14813
14814 --
14815 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14816 trace
14817 (p_msg => 'END of AcctLineType_47'
14818 ,p_level => C_LEVEL_PROCEDURE
14819 ,p_module => l_log_module);
14820 END IF;
14821 --
14822 EXCEPTION
14823 WHEN xla_exceptions_pkg.application_exception THEN
14824 RAISE;
14825 WHEN OTHERS THEN
14826 xla_exceptions_pkg.raise_message
14827 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_47');
14828 END AcctLineType_47;
14829 --
14830
14831 ---------------------------------------
14832 --
14833 -- PRIVATE FUNCTION
14834 -- AcctLineType_48
14835 --
14836 ---------------------------------------
14837 PROCEDURE AcctLineType_48 (
14838 p_application_id IN NUMBER
14839 ,p_event_id IN NUMBER
14840 ,p_calculate_acctd_flag IN VARCHAR2
14841 ,p_calculate_g_l_flag IN VARCHAR2
14842 ,p_actual_flag IN OUT VARCHAR2
14843 ,p_balance_type_code OUT VARCHAR2
14844 ,p_gain_or_loss_ref OUT VARCHAR2
14845
14846 --Credit Memo Distribution GL Account
14847 , p_source_4 IN NUMBER
14848 --SLA Party Type
14849 , p_source_32 IN VARCHAR2
14850 --Credit Memo Distribution Identifier
14851 , p_source_42 IN NUMBER
14852 --Credit memo distributions type
14853 , p_source_43 IN VARCHAR2
14854 --Credit Memo Currency Code
14855 , p_source_44 IN VARCHAR2
14856 --Credit Memo Exchange Date
14857 , p_source_45 IN DATE
14858 --Credit Memo Exchange Rate
14859 , p_source_46 IN NUMBER
14860 --Credit Memo Exchange Rate Type
14861 , p_source_47 IN VARCHAR2
14862 --Gain Loss Reference
14863 , p_source_48 IN VARCHAR2
14864 --Credit Memo Accounting Amount
14865 , p_source_49 IN NUMBER
14866 --Credit Memo Bill To Customer Account Identifier
14867 , p_source_50 IN NUMBER
14868 --Credit Memo Bill To Customer Site Use Identifier
14869 , p_source_51 IN NUMBER
14870 --Credit Memo Tax Line Identifier
14871 , p_source_52 IN NUMBER
14872 --Credit Memo Distribution Account Class
14873 , p_source_53 IN VARCHAR2
14874 --Credit Memo Distribution Entered Amount
14875 , p_source_54 IN NUMBER
14876 )
14877 IS
14878
14879 l_component_type VARCHAR2(80);
14880 l_component_code VARCHAR2(30);
14881 l_component_type_code VARCHAR2(1);
14882 l_component_appl_id INTEGER;
14883 l_amb_context_code VARCHAR2(30);
14884 l_entity_code VARCHAR2(30);
14885 l_event_class_code VARCHAR2(30);
14886 l_ae_header_id NUMBER;
14887 l_event_type_code VARCHAR2(30);
14888 l_line_definition_code VARCHAR2(30);
14889 l_line_definition_owner_code VARCHAR2(1);
14890 --
14891 -- adr variables
14892 l_segment VARCHAR2(30);
14893 l_ccid NUMBER;
14894 l_adr_transaction_coa_id NUMBER;
14895 l_adr_accounting_coa_id NUMBER;
14896 l_adr_flexfield_segment_code VARCHAR2(30);
14897 l_adr_flex_value_set_id NUMBER;
14898 l_adr_value_type_code VARCHAR2(30);
14899 l_adr_value_combination_id NUMBER;
14900 l_adr_value_segment_code VARCHAR2(30);
14901
14902 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
14903 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
14904 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
14905 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
14906
14907 -- 4262811 Variables ------------------------------------------------------------------------------------------
14908 l_entered_amt_idx NUMBER;
14909 l_accted_amt_idx NUMBER;
14910 l_acc_rev_flag VARCHAR2(1);
14911 l_accrual_line_num NUMBER;
14912 l_tmp_amt NUMBER;
14913 l_acc_rev_natural_side_code VARCHAR2(1);
14914
14915 l_num_entries NUMBER;
14916 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
14917 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
14918 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
14919 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
14920 l_recog_line_1 NUMBER;
14921 l_recog_line_2 NUMBER;
14922
14923 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
14924 l_bflow_applied_to_amt NUMBER; -- 5132302
14925 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
14926
14927 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
14928
14929 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
14930 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
14931
14932 ---------------------------------------------------------------------------------------------------------------
14933
14934
14935 --
14936 -- bulk performance
14937 --
14938 l_balance_type_code VARCHAR2(1);
14939 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
14940 l_log_module VARCHAR2(240);
14941
14942 --
14943 -- Upgrade strategy
14944 --
14945 l_actual_upg_option VARCHAR2(1);
14946 l_enc_upg_option VARCHAR2(1);
14947
14948 --
14949 BEGIN
14950 --
14951 IF g_log_enabled THEN
14952 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_48';
14953 END IF;
14954 --
14955 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14956
14957 trace
14958 (p_msg => 'BEGIN of AcctLineType_48'
14959 ,p_level => C_LEVEL_PROCEDURE
14960 ,p_module => l_log_module);
14961
14962 END IF;
14963 --
14964 l_component_type := 'AMB_JLT';
14965 l_component_code := 'CM_DEFAULT_TAX';
14966 l_component_type_code := 'S';
14967 l_component_appl_id := 222;
14968 l_amb_context_code := 'DEFAULT';
14969 l_entity_code := 'TRANSACTIONS';
14970 l_event_class_code := 'CREDIT_MEMO';
14971 l_event_type_code := 'CREDIT_MEMO_ALL';
14972 l_line_definition_owner_code := 'S';
14973 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
14974 --
14975 l_balance_type_code := 'A';
14976 l_segment := NULL;
14977 l_ccid := NULL;
14978 l_adr_transaction_coa_id := NULL;
14979 l_adr_accounting_coa_id := NULL;
14980 l_adr_flexfield_segment_code := NULL;
14981 l_adr_flex_value_set_id := NULL;
14982 l_adr_value_type_code := NULL;
14983 l_adr_value_combination_id := NULL;
14984 l_adr_value_segment_code := NULL;
14985
14986 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
14987 l_bflow_class_code := ''; -- 4219869 Business Flow
14988 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
14989 l_budgetary_control_flag := 'N';
14990
14991 l_bflow_applied_to_amt_idx := NULL; -- 5132302
14992 l_bflow_applied_to_amt := NULL; -- 5132302
14993 l_entered_amt_idx := NULL; -- 4262811
14994 l_accted_amt_idx := NULL; -- 4262811
14995 l_acc_rev_flag := NULL; -- 4262811
14996 l_accrual_line_num := NULL; -- 4262811
14997 l_tmp_amt := NULL; -- 4262811
14998 --
14999
15000 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
15001 l_balance_type_code <> 'B' THEN
15002 IF NVL(p_source_53,'
15003 ') = 'TAX'
15004 THEN
15005
15006 --
15007 XLA_AE_LINES_PKG.SetNewLine;
15008
15009 p_balance_type_code := l_balance_type_code;
15010 -- set the flag so later we will know whether the gain loss line needs to be created
15011
15012 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
15013 p_actual_flag :='A';
15014 END IF;
15015
15016 --
15017 -- bulk performance
15018 --
15019 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
15020 p_header_num => 0); -- 4262811
15021 --
15022 -- set accounting line options
15023 --
15024 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
15025 p_natural_side_code => 'C'
15026 , p_gain_or_loss_flag => 'N'
15027 , p_gl_transfer_mode_code => 'S'
15028 , p_acct_entry_type_code => 'A'
15029 , p_switch_side_flag => 'Y'
15030 , p_merge_duplicate_code => 'A'
15031 );
15032 --
15033 l_acc_rev_natural_side_code := 'D'; -- 4262811
15034 --
15035 --
15036 -- set accounting line type info
15037 --
15038 xla_ae_lines_pkg.SetAcctLineType
15039 (p_component_type => l_component_type
15040 ,p_event_type_code => l_event_type_code
15041 ,p_line_definition_owner_code => l_line_definition_owner_code
15042 ,p_line_definition_code => l_line_definition_code
15043 ,p_accounting_line_code => l_component_code
15044 ,p_accounting_line_type_code => l_component_type_code
15045 ,p_accounting_line_appl_id => l_component_appl_id
15046 ,p_amb_context_code => l_amb_context_code
15047 ,p_entity_code => l_entity_code
15048 ,p_event_class_code => l_event_class_code);
15049 --
15050 -- set accounting class
15051 --
15052 xla_ae_lines_pkg.SetAcctClass(
15053 p_accounting_class_code => 'TAX'
15054 , p_ae_header_id => l_ae_header_id
15055 );
15056
15057 --
15058 -- set rounding class
15059 --
15060 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
15061 'RECEIVABLE';
15062
15063 --
15064 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
15065 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
15066 --
15067 -- bulk performance
15068 --
15069 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
15070
15074 -- 4955764
15071 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
15072 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
15073
15075 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15076 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
15077
15078 -- 4458381 Public Sector Enh
15079
15080 --
15081 -- set accounting attributes for the line type
15082 --
15083 l_entered_amt_idx := 3;
15084 l_accted_amt_idx := 9;
15085 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15086 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
15087 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
15088 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
15089 l_rec_acct_attrs.array_char_value(2) := p_source_43;
15090 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
15091 l_rec_acct_attrs.array_num_value(3) := p_source_54;
15092 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
15093 l_rec_acct_attrs.array_char_value(4) := p_source_44;
15094 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
15095 l_rec_acct_attrs.array_date_value(5) := p_source_45;
15096 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
15097 l_rec_acct_attrs.array_num_value(6) := p_source_46;
15098 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
15099 l_rec_acct_attrs.array_char_value(7) := p_source_47;
15100 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
15101 l_rec_acct_attrs.array_char_value(8) := p_source_48;
15102 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
15103 l_rec_acct_attrs.array_num_value(9) := p_source_49;
15104 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
15105 l_rec_acct_attrs.array_num_value(10) := p_source_50;
15106 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
15107 l_rec_acct_attrs.array_num_value(11) := p_source_51;
15108 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
15109 l_rec_acct_attrs.array_char_value(12) := p_source_32;
15110 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
15111 l_rec_acct_attrs.array_num_value(13) := p_source_52;
15112
15113 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
15114 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
15115
15116 ---------------------------------------------------------------------------------------------------------------
15117 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
15118 ---------------------------------------------------------------------------------------------------------------
15119 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
15120
15121 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15122 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15123
15124 IF xla_accounting_cache_pkg.GetValueChar
15125 (p_source_code => 'LEDGER_CATEGORY_CODE'
15126 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
15127 AND l_bflow_method_code = 'PRIOR_ENTRY'
15128 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
15129 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
15130 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
15131 )
15132 THEN
15133 xla_ae_lines_pkg.BflowUpgEntry
15134 (p_business_method_code => l_bflow_method_code
15135 ,p_business_class_code => l_bflow_class_code
15136 ,p_balance_type => l_balance_type_code);
15137 ELSE
15138 NULL;
15139 -- No business flow processing for business flow method of NONE.
15140 END IF;
15141
15142 --
15143 -- call analytical criteria
15144 --
15145
15146 --
15147 -- call description
15148 --
15149 -- No description or it is inherited.
15150 --
15151 -- call ADRs
15152 -- Bug 4922099
15153 --
15154 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15155 (NVL(l_actual_upg_option, 'N') = 'O') OR
15156 (NVL(l_enc_upg_option, 'N') = 'O')
15157 )
15158 THEN
15159 NULL;
15160 --
15161 --
15162
15163 l_ccid := AcctDerRule_3(
15164 p_application_id => p_application_id
15165 , p_ae_header_id => l_ae_header_id
15166 , p_source_4 => p_source_4
15167 , x_transaction_coa_id => l_adr_transaction_coa_id
15168 , x_accounting_coa_id => l_adr_accounting_coa_id
15169 , x_value_type_code => l_adr_value_type_code
15170 , p_side => 'NA'
15171 );
15172
15173 xla_ae_lines_pkg.set_ccid(
15174 p_code_combination_id => l_ccid
15175 , p_value_type_code => l_adr_value_type_code
15176 , p_transaction_coa_id => l_adr_transaction_coa_id
15177 , p_accounting_coa_id => l_adr_accounting_coa_id
15178 , p_adr_code => 'CM_DIST_CCID'
15179 , p_adr_type_code => 'S'
15180 , p_component_type => l_component_type
15181 , p_component_code => l_component_code
15182 , p_component_type_code => l_component_type_code
15183 , p_component_appl_id => l_component_appl_id
15184 , p_amb_context_code => l_amb_context_code
15185 , p_side => 'NA'
15186 );
15187
15188
15189 --
15190 --
15191 END IF;
15192 --
15193 -- Bug 4922099
15194 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
15195 (NVL(l_enc_upg_option, 'N') = 'O')
15196 ) AND
15197 (l_bflow_method_code = 'PRIOR_ENTRY')
15198 )
15199 THEN
15200 IF
15201 --
15202 1 = 2
15203 --
15204 THEN
15205 xla_accounting_err_pkg.build_message
15206 (p_appli_s_name => 'XLA'
15207 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15208 ,p_token_1 => 'LINE_NUMBER'
15209 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
15210 ,p_token_2 => 'LINE_TYPE_NAME'
15211 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
15212 l_component_type
15213 ,l_component_code
15214 ,l_component_type_code
15215 ,l_component_appl_id
15216 ,l_amb_context_code
15217 ,l_entity_code
15218 ,l_event_class_code
15219 )
15220 ,p_token_3 => 'OWNER'
15221 ,p_value_3 => xla_lookups_pkg.get_meaning(
15222 p_lookup_type => 'XLA_OWNER_TYPE'
15223 ,p_lookup_code => l_component_type_code
15224 )
15225 ,p_token_4 => 'PRODUCT_NAME'
15226 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
15227 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
15228 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
15229 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
15230 ,p_ae_header_id => NULL
15231 );
15232
15233 IF (C_LEVEL_ERROR>= g_log_level) THEN
15234 trace
15235 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15236 ,p_level => C_LEVEL_ERROR
15237 ,p_module => l_log_module);
15238 END IF;
15239 END IF;
15240 END IF;
15241 --
15242 --
15243 ------------------------------------------------------------------------------------------------
15244 -- 4219869 Business Flow
15245 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
15246 -- Prior Entry. Currently, the following code is always generated.
15247 ------------------------------------------------------------------------------------------------
15248 XLA_AE_LINES_PKG.ValidateCurrentLine;
15249
15250 ------------------------------------------------------------------------------------
15251 -- 4219869 Business Flow
15252 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
15253 ------------------------------------------------------------------------------------
15254 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15255
15256 ----------------------------------------------------------------------------------
15257 -- 4219869 Business Flow
15258 -- Update journal entry status -- Need to generate this within IF <condition>
15259 ----------------------------------------------------------------------------------
15260 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15261 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
15262 ,p_balance_type_code => l_balance_type_code
15263 );
15264
15265 -------------------------------------------------------------------------------------------
15266 -- 4262811 - Generate the Accrual Reversal lines
15267 -------------------------------------------------------------------------------------------
15268 BEGIN
15269 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
15270 (g_array_event(p_event_id).array_value_num('header_index'));
15271 IF l_acc_rev_flag IS NULL THEN
15272 l_acc_rev_flag := 'N';
15273 END IF;
15274 EXCEPTION
15275 WHEN OTHERS THEN
15276 l_acc_rev_flag := 'N';
15277 END;
15278 --
15279 IF (l_acc_rev_flag = 'Y') THEN
15280
15281 -- 4645092 ------------------------------------------------------------------------------
15282 -- To allow MPA report to determine if it should generate report process
15283 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
15284 ------------------------------------------------------------------------------------------
15285
15286 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
15287 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
15288 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
15289 -- call ADRs
15290 -- Bug 4922099
15291 --
15292 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15293 (NVL(l_actual_upg_option, 'N') = 'O') OR
15294 (NVL(l_enc_upg_option, 'N') = 'O')
15295 )
15296 THEN
15297 NULL;
15298 --
15299 --
15300
15301 l_ccid := AcctDerRule_3(
15302 p_application_id => p_application_id
15303 , p_ae_header_id => l_ae_header_id
15304 , p_source_4 => p_source_4
15305 , x_transaction_coa_id => l_adr_transaction_coa_id
15306 , x_accounting_coa_id => l_adr_accounting_coa_id
15307 , x_value_type_code => l_adr_value_type_code
15308 , p_side => 'NA'
15309 );
15310
15311 xla_ae_lines_pkg.set_ccid(
15312 p_code_combination_id => l_ccid
15313 , p_value_type_code => l_adr_value_type_code
15314 , p_transaction_coa_id => l_adr_transaction_coa_id
15315 , p_accounting_coa_id => l_adr_accounting_coa_id
15316 , p_adr_code => 'CM_DIST_CCID'
15317 , p_adr_type_code => 'S'
15318 , p_component_type => l_component_type
15319 , p_component_code => l_component_code
15320 , p_component_type_code => l_component_type_code
15321 , p_component_appl_id => l_component_appl_id
15322 , p_amb_context_code => l_amb_context_code
15323 , p_side => 'NA'
15324 );
15325
15326
15327 --
15328 --
15329 END IF;
15330
15331 --
15332 -- Update the line information that should be overwritten
15333 --
15334 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
15335 p_header_num => 1);
15336 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
15337
15338 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
15339
15340 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
15341 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
15342 END IF;
15343
15344 --
15345 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
15346 --
15347 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
15348 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
15349 ELSE
15350 ---------------------------------------------------------------------------------------------------
15351 -- 4262811a Switch Sign
15352 ---------------------------------------------------------------------------------------------------
15353 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
15354 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15355 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15356 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15357 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15358 -- 5132302
15359 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
15360 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15361
15362 END IF;
15363
15364 -- 4955764
15365 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15366 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
15367
15368
15369 XLA_AE_LINES_PKG.ValidateCurrentLine;
15370 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15371
15372 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15373 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
15374 ,p_balance_type_code => l_balance_type_code);
15375
15376 END IF;
15377
15378 -----------------------------------------------------------------------------------------
15379 -- 4262811 Multiperiod Accounting
15380 -----------------------------------------------------------------------------------------
15381 -- No MPA option is assigned.
15382
15383
15384 END IF;
15385 END IF;
15386 --
15387
15388 --
15389 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15390 trace
15391 (p_msg => 'END of AcctLineType_48'
15392 ,p_level => C_LEVEL_PROCEDURE
15393 ,p_module => l_log_module);
15394 END IF;
15395 --
15396 EXCEPTION
15397 WHEN xla_exceptions_pkg.application_exception THEN
15398 RAISE;
15399 WHEN OTHERS THEN
15400 xla_exceptions_pkg.raise_message
15401 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_48');
15402 END AcctLineType_48;
15403 --
15404
15405 ---------------------------------------
15406 --
15407 -- PRIVATE FUNCTION
15408 -- AcctLineType_49
15409 --
15410 ---------------------------------------
15411 PROCEDURE AcctLineType_49 (
15412 p_application_id IN NUMBER
15413 ,p_event_id IN NUMBER
15414 ,p_calculate_acctd_flag IN VARCHAR2
15415 ,p_calculate_g_l_flag IN VARCHAR2
15416 ,p_actual_flag IN OUT VARCHAR2
15417 ,p_balance_type_code OUT VARCHAR2
15418 ,p_gain_or_loss_ref OUT VARCHAR2
15419
15420 --System Gain Account
15421 , p_source_7 IN NUMBER
15422 --System Loss Account
15423 , p_source_8 IN NUMBER
15424 --SLA Party Type
15425 , p_source_32 IN VARCHAR2
15426 --Credit Memo Distribution Identifier
15427 , p_source_42 IN NUMBER
15428 --Credit memo distributions type
15429 , p_source_43 IN VARCHAR2
15430 --Gain Loss Reference
15431 , p_source_48 IN VARCHAR2
15432 --Credit Memo Accounting Amount
15433 , p_source_49 IN NUMBER
15434 --Credit Memo Bill To Customer Account Identifier
15435 , p_source_50 IN NUMBER
15436 --Credit Memo Bill To Customer Site Use Identifier
15437 , p_source_51 IN NUMBER
15438 --Credit Memo Tax Line Identifier
15439 , p_source_52 IN NUMBER
15440 )
15441 IS
15442
15443 l_component_type VARCHAR2(80);
15444 l_component_code VARCHAR2(30);
15445 l_component_type_code VARCHAR2(1);
15446 l_component_appl_id INTEGER;
15447 l_amb_context_code VARCHAR2(30);
15448 l_entity_code VARCHAR2(30);
15449 l_event_class_code VARCHAR2(30);
15450 l_ae_header_id NUMBER;
15451 l_event_type_code VARCHAR2(30);
15452 l_line_definition_code VARCHAR2(30);
15453 l_line_definition_owner_code VARCHAR2(1);
15454 --
15455 -- adr variables
15456 l_segment VARCHAR2(30);
15457 l_ccid NUMBER;
15458 l_adr_transaction_coa_id NUMBER;
15459 l_adr_accounting_coa_id NUMBER;
15460 l_adr_flexfield_segment_code VARCHAR2(30);
15461 l_adr_flex_value_set_id NUMBER;
15462 l_adr_value_type_code VARCHAR2(30);
15463 l_adr_value_combination_id NUMBER;
15464 l_adr_value_segment_code VARCHAR2(30);
15465
15466 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
15467 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
15468 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
15469 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
15470
15471 -- 4262811 Variables ------------------------------------------------------------------------------------------
15472 l_entered_amt_idx NUMBER;
15473 l_accted_amt_idx NUMBER;
15474 l_acc_rev_flag VARCHAR2(1);
15475 l_accrual_line_num NUMBER;
15476 l_tmp_amt NUMBER;
15477 l_acc_rev_natural_side_code VARCHAR2(1);
15478
15479 l_num_entries NUMBER;
15480 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
15481 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
15482 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
15483 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
15484 l_recog_line_1 NUMBER;
15485 l_recog_line_2 NUMBER;
15486
15487 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
15488 l_bflow_applied_to_amt NUMBER; -- 5132302
15489 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
15490
15491 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
15492
15493 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
15494 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
15495
15496 ---------------------------------------------------------------------------------------------------------------
15497
15498
15499 --
15500 -- bulk performance
15501 --
15502 l_balance_type_code VARCHAR2(1);
15503 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
15504 l_log_module VARCHAR2(240);
15505
15506 --
15507 -- Upgrade strategy
15508 --
15509 l_actual_upg_option VARCHAR2(1);
15510 l_enc_upg_option VARCHAR2(1);
15511
15512 --
15513 BEGIN
15514 --
15515 IF g_log_enabled THEN
15516 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_49';
15517 END IF;
15518 --
15519 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15520
15521 trace
15522 (p_msg => 'BEGIN of AcctLineType_49'
15523 ,p_level => C_LEVEL_PROCEDURE
15524 ,p_module => l_log_module);
15525
15526 END IF;
15527 --
15528 l_component_type := 'AMB_JLT';
15529 l_component_code := 'CM_EXCH_GAIN_LOSS';
15530 l_component_type_code := 'S';
15531 l_component_appl_id := 222;
15532 l_amb_context_code := 'DEFAULT';
15533 l_entity_code := 'TRANSACTIONS';
15534 l_event_class_code := 'CREDIT_MEMO';
15535 l_event_type_code := 'CREDIT_MEMO_ALL';
15536 l_line_definition_owner_code := 'S';
15537 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
15538 --
15539 l_balance_type_code := 'A';
15540 l_segment := NULL;
15541 l_ccid := NULL;
15542 l_adr_transaction_coa_id := NULL;
15543 l_adr_accounting_coa_id := NULL;
15544 l_adr_flexfield_segment_code := NULL;
15545 l_adr_flex_value_set_id := NULL;
15546 l_adr_value_type_code := NULL;
15547 l_adr_value_combination_id := NULL;
15548 l_adr_value_segment_code := NULL;
15549
15550 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
15551 l_bflow_class_code := ''; -- 4219869 Business Flow
15552 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
15553 l_budgetary_control_flag := 'N';
15554
15555 l_bflow_applied_to_amt_idx := NULL; -- 5132302
15556 l_bflow_applied_to_amt := NULL; -- 5132302
15557 l_entered_amt_idx := NULL; -- 4262811
15558 l_accted_amt_idx := NULL; -- 4262811
15559 l_acc_rev_flag := NULL; -- 4262811
15560 l_accrual_line_num := NULL; -- 4262811
15561 l_tmp_amt := NULL; -- 4262811
15562 --
15563 IF NOT ((p_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
15564 (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
15565 return;
15566 END IF;
15567
15568 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
15569 l_balance_type_code <> 'B' 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' ) THEN
15578 p_actual_flag :='G';
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 => 'G'
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 => ''
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
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
15611 ,p_amb_context_code => l_amb_context_code
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 => 'EXCHANGE_GAIN_LOSS'
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 'EXCHANGE_GAIN_LOSS';
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 := NULL;
15649 l_accted_amt_idx := 4;
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_42);
15653 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
15654 l_rec_acct_attrs.array_char_value(2) := p_source_43;
15655 l_rec_acct_attrs.array_acct_attr_code(3) := 'GAIN_LOSS_REFERENCE';
15656 l_rec_acct_attrs.array_char_value(3) := p_source_48;
15657 l_rec_acct_attrs.array_acct_attr_code(4) := 'LEDGER_AMOUNT';
15658 l_rec_acct_attrs.array_num_value(4) := p_source_49;
15659 l_rec_acct_attrs.array_acct_attr_code(5) := 'PARTY_ID';
15660 l_rec_acct_attrs.array_num_value(5) := p_source_50;
15661 l_rec_acct_attrs.array_acct_attr_code(6) := 'PARTY_SITE_ID';
15662 l_rec_acct_attrs.array_num_value(6) := p_source_51;
15663 l_rec_acct_attrs.array_acct_attr_code(7) := 'PARTY_TYPE';
15664 l_rec_acct_attrs.array_char_value(7) := p_source_32;
15665 l_rec_acct_attrs.array_acct_attr_code(8) := 'TAX_LINE_REF_ID';
15666 l_rec_acct_attrs.array_num_value(8) := p_source_52;
15667
15668 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
15669 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
15670
15671 ---------------------------------------------------------------------------------------------------------------
15672 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
15673 ---------------------------------------------------------------------------------------------------------------
15674 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
15675
15676 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15677 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
15678
15679 IF xla_accounting_cache_pkg.GetValueChar
15680 (p_source_code => 'LEDGER_CATEGORY_CODE'
15681 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
15682 AND l_bflow_method_code = 'PRIOR_ENTRY'
15683 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
15684 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
15685 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
15686 )
15687 THEN
15688 xla_ae_lines_pkg.BflowUpgEntry
15689 (p_business_method_code => l_bflow_method_code
15690 ,p_business_class_code => l_bflow_class_code
15691 ,p_balance_type => l_balance_type_code);
15692 ELSE
15693 NULL;
15694 -- No business flow processing for business flow method of NONE.
15695 END IF;
15696
15697 --
15698 -- call analytical criteria
15699 --
15700
15701 --
15702 -- call description
15703 --
15704 -- No description or it is inherited.
15705 --
15706 -- call ADRs
15707 -- Bug 4922099
15708 --
15709 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15710 (NVL(l_actual_upg_option, 'N') = 'O') OR
15711 (NVL(l_enc_upg_option, 'N') = 'O')
15712 )
15713 THEN
15714 NULL;
15715 --
15716 --
15717
15718 l_ccid := AcctDerRule_26(
15719 p_application_id => p_application_id
15720 , p_ae_header_id => l_ae_header_id
15721 , p_source_7 => p_source_7
15722 , x_transaction_coa_id => l_adr_transaction_coa_id
15723 , x_accounting_coa_id => l_adr_accounting_coa_id
15724 , x_value_type_code => l_adr_value_type_code
15725 , p_side => 'CREDIT'
15726 );
15727
15728 xla_ae_lines_pkg.set_ccid(
15729 p_code_combination_id => l_ccid
15730 , p_value_type_code => l_adr_value_type_code
15731 , p_transaction_coa_id => l_adr_transaction_coa_id
15732 , p_accounting_coa_id => l_adr_accounting_coa_id
15733 , p_adr_code => 'SYS_GAIN_CCID'
15734 , p_adr_type_code => 'S'
15735 , p_component_type => l_component_type
15736 , p_component_code => l_component_code
15737 , p_component_type_code => l_component_type_code
15738 , p_component_appl_id => l_component_appl_id
15739 , p_amb_context_code => l_amb_context_code
15740 , p_side => 'CREDIT'
15741 );
15742
15743
15744 l_ccid := AcctDerRule_27(
15745 p_application_id => p_application_id
15746 , p_ae_header_id => l_ae_header_id
15747 , p_source_8 => p_source_8
15748 , x_transaction_coa_id => l_adr_transaction_coa_id
15749 , x_accounting_coa_id => l_adr_accounting_coa_id
15750 , x_value_type_code => l_adr_value_type_code
15751 , p_side => 'DEBIT'
15752 );
15753
15754 xla_ae_lines_pkg.set_ccid(
15755 p_code_combination_id => l_ccid
15756 , p_value_type_code => l_adr_value_type_code
15757 , p_transaction_coa_id => l_adr_transaction_coa_id
15758 , p_accounting_coa_id => l_adr_accounting_coa_id
15759 , p_adr_code => 'SYS_LOSS_CCID'
15760 , p_adr_type_code => 'S'
15761 , p_component_type => l_component_type
15762 , p_component_code => l_component_code
15763 , p_component_type_code => l_component_type_code
15764 , p_component_appl_id => l_component_appl_id
15765 , p_amb_context_code => l_amb_context_code
15766 , p_side => 'DEBIT'
15767 );
15768
15769
15770 --
15771 --
15772 END IF;
15773 --
15774 -- Bug 4922099
15775 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
15776 (NVL(l_enc_upg_option, 'N') = 'O')
15777 ) AND
15778 (l_bflow_method_code = 'PRIOR_ENTRY')
15779 )
15780 THEN
15781 IF
15782 --
15783 1 = 2
15784 --
15785 THEN
15786 xla_accounting_err_pkg.build_message
15787 (p_appli_s_name => 'XLA'
15788 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15789 ,p_token_1 => 'LINE_NUMBER'
15790 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
15791 ,p_token_2 => 'LINE_TYPE_NAME'
15792 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
15793 l_component_type
15794 ,l_component_code
15795 ,l_component_type_code
15796 ,l_component_appl_id
15797 ,l_amb_context_code
15798 ,l_entity_code
15799 ,l_event_class_code
15800 )
15801 ,p_token_3 => 'OWNER'
15802 ,p_value_3 => xla_lookups_pkg.get_meaning(
15803 p_lookup_type => 'XLA_OWNER_TYPE'
15804 ,p_lookup_code => l_component_type_code
15805 )
15806 ,p_token_4 => 'PRODUCT_NAME'
15807 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
15808 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
15809 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
15810 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
15811 ,p_ae_header_id => NULL
15812 );
15813
15814 IF (C_LEVEL_ERROR>= g_log_level) THEN
15815 trace
15816 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
15817 ,p_level => C_LEVEL_ERROR
15818 ,p_module => l_log_module);
15819 END IF;
15820 END IF;
15821 END IF;
15822 --
15823 --
15824 ------------------------------------------------------------------------------------------------
15825 -- 4219869 Business Flow
15826 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
15827 -- Prior Entry. Currently, the following code is always generated.
15828 ------------------------------------------------------------------------------------------------
15829 XLA_AE_LINES_PKG.ValidateCurrentLine;
15830
15831 ------------------------------------------------------------------------------------
15832 -- 4219869 Business Flow
15833 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
15834 ------------------------------------------------------------------------------------
15835 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15836
15837 ----------------------------------------------------------------------------------
15838 -- 4219869 Business Flow
15839 -- Update journal entry status -- Need to generate this within IF <condition>
15840 ----------------------------------------------------------------------------------
15841 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15842 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
15843 ,p_balance_type_code => l_balance_type_code
15844 );
15845
15846 -------------------------------------------------------------------------------------------
15847 -- 4262811 - Generate the Accrual Reversal lines
15848 -------------------------------------------------------------------------------------------
15849 BEGIN
15850 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
15851 (g_array_event(p_event_id).array_value_num('header_index'));
15852 IF l_acc_rev_flag IS NULL THEN
15853 l_acc_rev_flag := 'N';
15854 END IF;
15855 EXCEPTION
15856 WHEN OTHERS THEN
15857 l_acc_rev_flag := 'N';
15858 END;
15859 --
15860 IF (l_acc_rev_flag = 'Y') THEN
15861
15862 -- 4645092 ------------------------------------------------------------------------------
15863 -- To allow MPA report to determine if it should generate report process
15864 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
15865 ------------------------------------------------------------------------------------------
15866
15867 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
15868 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
15869 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
15870 -- call ADRs
15871 -- Bug 4922099
15872 --
15873 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
15874 (NVL(l_actual_upg_option, 'N') = 'O') OR
15875 (NVL(l_enc_upg_option, 'N') = 'O')
15876 )
15877 THEN
15878 NULL;
15879 --
15880 --
15881
15882 l_ccid := AcctDerRule_26(
15883 p_application_id => p_application_id
15884 , p_ae_header_id => l_ae_header_id
15885 , p_source_7 => p_source_7
15886 , x_transaction_coa_id => l_adr_transaction_coa_id
15887 , x_accounting_coa_id => l_adr_accounting_coa_id
15888 , x_value_type_code => l_adr_value_type_code
15889 , p_side => 'CREDIT'
15890 );
15891
15892 xla_ae_lines_pkg.set_ccid(
15893 p_code_combination_id => l_ccid
15894 , p_value_type_code => l_adr_value_type_code
15895 , p_transaction_coa_id => l_adr_transaction_coa_id
15896 , p_accounting_coa_id => l_adr_accounting_coa_id
15897 , p_adr_code => 'SYS_GAIN_CCID'
15898 , p_adr_type_code => 'S'
15899 , p_component_type => l_component_type
15900 , p_component_code => l_component_code
15901 , p_component_type_code => l_component_type_code
15902 , p_component_appl_id => l_component_appl_id
15903 , p_amb_context_code => l_amb_context_code
15904 , p_side => 'CREDIT'
15905 );
15906
15907
15908 l_ccid := AcctDerRule_27(
15909 p_application_id => p_application_id
15910 , p_ae_header_id => l_ae_header_id
15911 , p_source_8 => p_source_8
15912 , x_transaction_coa_id => l_adr_transaction_coa_id
15913 , x_accounting_coa_id => l_adr_accounting_coa_id
15914 , x_value_type_code => l_adr_value_type_code
15915 , p_side => 'DEBIT'
15916 );
15917
15918 xla_ae_lines_pkg.set_ccid(
15919 p_code_combination_id => l_ccid
15920 , p_value_type_code => l_adr_value_type_code
15921 , p_transaction_coa_id => l_adr_transaction_coa_id
15922 , p_accounting_coa_id => l_adr_accounting_coa_id
15923 , p_adr_code => 'SYS_LOSS_CCID'
15924 , p_adr_type_code => 'S'
15925 , p_component_type => l_component_type
15926 , p_component_code => l_component_code
15927 , p_component_type_code => l_component_type_code
15928 , p_component_appl_id => l_component_appl_id
15929 , p_amb_context_code => l_amb_context_code
15930 , p_side => 'DEBIT'
15931 );
15932
15933
15934 --
15935 --
15936 END IF;
15937
15938 --
15939 -- Update the line information that should be overwritten
15940 --
15941 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
15942 p_header_num => 1);
15943 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
15944
15945 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
15946
15947 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
15948 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
15949 END IF;
15950
15951 --
15952 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
15953 --
15954 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
15955 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
15956 ELSE
15957 ---------------------------------------------------------------------------------------------------
15958 -- 4262811a Switch Sign
15959 ---------------------------------------------------------------------------------------------------
15960 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
15961 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15962 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15963 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
15964 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15965 -- 5132302
15966 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
15967 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
15968
15969 END IF;
15970
15971 -- 4955764
15972 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
15973 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
15974
15975
15976 XLA_AE_LINES_PKG.ValidateCurrentLine;
15977 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
15978
15979 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
15980 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
15981 ,p_balance_type_code => l_balance_type_code);
15982
15983 END IF;
15984
15985 -----------------------------------------------------------------------------------------
15986 -- 4262811 Multiperiod Accounting
15987 -----------------------------------------------------------------------------------------
15988 -- No MPA option is assigned.
15989
15990
15991 END IF;
15992 --
15993
15994 --
15995 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15996 trace
15997 (p_msg => 'END of AcctLineType_49'
15998 ,p_level => C_LEVEL_PROCEDURE
15999 ,p_module => l_log_module);
16000 END IF;
16001 --
16002 EXCEPTION
16003 WHEN xla_exceptions_pkg.application_exception THEN
16004 RAISE;
16005 WHEN OTHERS THEN
16006 xla_exceptions_pkg.raise_message
16007 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_49');
16008 END AcctLineType_49;
16009 --
16010
16011 ---------------------------------------
16012 --
16013 -- PRIVATE FUNCTION
16014 -- AcctLineType_50
16015 --
16016 ---------------------------------------
16017 PROCEDURE AcctLineType_50 (
16018 p_application_id IN NUMBER
16019 ,p_event_id IN NUMBER
16020 ,p_calculate_acctd_flag IN VARCHAR2
16021 ,p_calculate_g_l_flag IN VARCHAR2
16022 ,p_actual_flag IN OUT VARCHAR2
16023 ,p_balance_type_code OUT VARCHAR2
16024 ,p_gain_or_loss_ref OUT VARCHAR2
16025
16026 --Credit Memo Distribution GL Account
16027 , p_source_4 IN NUMBER
16028 --SLA Party Type
16029 , p_source_32 IN VARCHAR2
16030 --Credit Memo Distribution Identifier
16031 , p_source_42 IN NUMBER
16032 --Credit memo distributions type
16033 , p_source_43 IN VARCHAR2
16034 --Credit Memo Currency Code
16035 , p_source_44 IN VARCHAR2
16036 --Credit Memo Exchange Date
16037 , p_source_45 IN DATE
16038 --Credit Memo Exchange Rate
16039 , p_source_46 IN NUMBER
16040 --Credit Memo Exchange Rate Type
16041 , p_source_47 IN VARCHAR2
16042 --Gain Loss Reference
16043 , p_source_48 IN VARCHAR2
16044 --Credit Memo Accounting Amount
16045 , p_source_49 IN NUMBER
16046 --Credit Memo Bill To Customer Account Identifier
16047 , p_source_50 IN NUMBER
16048 --Credit Memo Bill To Customer Site Use Identifier
16049 , p_source_51 IN NUMBER
16050 --Credit Memo Tax Line Identifier
16051 , p_source_52 IN NUMBER
16052 --Credit Memo Distribution Account Class
16053 , p_source_53 IN VARCHAR2
16054 --Credit Memo Distribution Entered Amount
16055 , p_source_54 IN NUMBER
16056 )
16057 IS
16058
16059 l_component_type VARCHAR2(80);
16060 l_component_code VARCHAR2(30);
16061 l_component_type_code VARCHAR2(1);
16062 l_component_appl_id INTEGER;
16063 l_amb_context_code VARCHAR2(30);
16064 l_entity_code VARCHAR2(30);
16065 l_event_class_code VARCHAR2(30);
16066 l_ae_header_id NUMBER;
16067 l_event_type_code VARCHAR2(30);
16068 l_line_definition_code VARCHAR2(30);
16069 l_line_definition_owner_code VARCHAR2(1);
16070 --
16071 -- adr variables
16072 l_segment VARCHAR2(30);
16073 l_ccid NUMBER;
16074 l_adr_transaction_coa_id NUMBER;
16075 l_adr_accounting_coa_id NUMBER;
16076 l_adr_flexfield_segment_code VARCHAR2(30);
16077 l_adr_flex_value_set_id NUMBER;
16078 l_adr_value_type_code VARCHAR2(30);
16079 l_adr_value_combination_id NUMBER;
16080 l_adr_value_segment_code VARCHAR2(30);
16081
16082 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
16083 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
16084 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
16085 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
16086
16087 -- 4262811 Variables ------------------------------------------------------------------------------------------
16088 l_entered_amt_idx NUMBER;
16089 l_accted_amt_idx NUMBER;
16090 l_acc_rev_flag VARCHAR2(1);
16091 l_accrual_line_num NUMBER;
16092 l_tmp_amt NUMBER;
16093 l_acc_rev_natural_side_code VARCHAR2(1);
16094
16095 l_num_entries NUMBER;
16096 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
16097 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
16098 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
16099 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
16100 l_recog_line_1 NUMBER;
16101 l_recog_line_2 NUMBER;
16102
16103 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
16104 l_bflow_applied_to_amt NUMBER; -- 5132302
16105 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
16106
16107 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
16108
16109 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
16110 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
16111
16112 ---------------------------------------------------------------------------------------------------------------
16113
16114
16115 --
16116 -- bulk performance
16117 --
16118 l_balance_type_code VARCHAR2(1);
16119 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
16120 l_log_module VARCHAR2(240);
16121
16122 --
16123 -- Upgrade strategy
16124 --
16125 l_actual_upg_option VARCHAR2(1);
16126 l_enc_upg_option VARCHAR2(1);
16127
16128 --
16129 BEGIN
16130 --
16131 IF g_log_enabled THEN
16132 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_50';
16133 END IF;
16134 --
16135 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16136
16137 trace
16138 (p_msg => 'BEGIN of AcctLineType_50'
16139 ,p_level => C_LEVEL_PROCEDURE
16140 ,p_module => l_log_module);
16141
16142 END IF;
16143 --
16144 l_component_type := 'AMB_JLT';
16145 l_component_code := 'CM_ROUND';
16146 l_component_type_code := 'S';
16147 l_component_appl_id := 222;
16148 l_amb_context_code := 'DEFAULT';
16149 l_entity_code := 'TRANSACTIONS';
16150 l_event_class_code := 'CREDIT_MEMO';
16151 l_event_type_code := 'CREDIT_MEMO_ALL';
16152 l_line_definition_owner_code := 'S';
16156 l_segment := NULL;
16153 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
16154 --
16155 l_balance_type_code := 'A';
16157 l_ccid := NULL;
16158 l_adr_transaction_coa_id := NULL;
16159 l_adr_accounting_coa_id := NULL;
16160 l_adr_flexfield_segment_code := NULL;
16161 l_adr_flex_value_set_id := NULL;
16162 l_adr_value_type_code := NULL;
16163 l_adr_value_combination_id := NULL;
16164 l_adr_value_segment_code := NULL;
16165
16166 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
16167 l_bflow_class_code := ''; -- 4219869 Business Flow
16168 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
16169 l_budgetary_control_flag := 'N';
16170
16171 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16172 l_bflow_applied_to_amt := NULL; -- 5132302
16173 l_entered_amt_idx := NULL; -- 4262811
16174 l_accted_amt_idx := NULL; -- 4262811
16175 l_acc_rev_flag := NULL; -- 4262811
16176 l_accrual_line_num := NULL; -- 4262811
16177 l_tmp_amt := NULL; -- 4262811
16178 --
16179
16180 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
16181 l_balance_type_code <> 'B' THEN
16182 IF NVL(p_source_53,'
16183 ') = 'ROUND'
16184 THEN
16185
16186 --
16187 XLA_AE_LINES_PKG.SetNewLine;
16188
16189 p_balance_type_code := l_balance_type_code;
16190 -- set the flag so later we will know whether the gain loss line needs to be created
16191
16192 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
16193 p_actual_flag :='A';
16194 END IF;
16195
16196 --
16197 -- bulk performance
16198 --
16199 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
16200 p_header_num => 0); -- 4262811
16201 --
16202 -- set accounting line options
16203 --
16204 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
16205 p_natural_side_code => 'C'
16206 , p_gain_or_loss_flag => 'N'
16207 , p_gl_transfer_mode_code => 'S'
16208 , p_acct_entry_type_code => 'A'
16209 , p_switch_side_flag => 'Y'
16210 , p_merge_duplicate_code => 'A'
16211 );
16212 --
16213 l_acc_rev_natural_side_code := 'D'; -- 4262811
16214 --
16215 --
16216 -- set accounting line type info
16217 --
16218 xla_ae_lines_pkg.SetAcctLineType
16219 (p_component_type => l_component_type
16220 ,p_event_type_code => l_event_type_code
16221 ,p_line_definition_owner_code => l_line_definition_owner_code
16222 ,p_line_definition_code => l_line_definition_code
16223 ,p_accounting_line_code => l_component_code
16224 ,p_accounting_line_type_code => l_component_type_code
16225 ,p_accounting_line_appl_id => l_component_appl_id
16226 ,p_amb_context_code => l_amb_context_code
16227 ,p_entity_code => l_entity_code
16228 ,p_event_class_code => l_event_class_code);
16229 --
16230 -- set accounting class
16231 --
16232 xla_ae_lines_pkg.SetAcctClass(
16233 p_accounting_class_code => 'ROUNDING'
16234 , p_ae_header_id => l_ae_header_id
16235 );
16236
16237 --
16238 -- set rounding class
16239 --
16240 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
16241 'RECEIVABLE';
16242
16243 --
16244 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
16245 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
16246 --
16247 -- bulk performance
16248 --
16249 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
16250
16251 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
16252 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
16253
16254 -- 4955764
16255 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16256 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
16257
16258 -- 4458381 Public Sector Enh
16259
16260 --
16261 -- set accounting attributes for the line type
16262 --
16263 l_entered_amt_idx := 3;
16264 l_accted_amt_idx := 9;
16265 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16266 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
16267 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
16268 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
16269 l_rec_acct_attrs.array_char_value(2) := p_source_43;
16270 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
16271 l_rec_acct_attrs.array_num_value(3) := p_source_54;
16272 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
16273 l_rec_acct_attrs.array_char_value(4) := p_source_44;
16274 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
16275 l_rec_acct_attrs.array_date_value(5) := p_source_45;
16276 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
16277 l_rec_acct_attrs.array_num_value(6) := p_source_46;
16278 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
16279 l_rec_acct_attrs.array_char_value(7) := p_source_47;
16280 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
16281 l_rec_acct_attrs.array_char_value(8) := p_source_48;
16282 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
16283 l_rec_acct_attrs.array_num_value(9) := p_source_49;
16284 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
16285 l_rec_acct_attrs.array_num_value(10) := p_source_50;
16286 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
16287 l_rec_acct_attrs.array_num_value(11) := p_source_51;
16288 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
16289 l_rec_acct_attrs.array_char_value(12) := p_source_32;
16290 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
16291 l_rec_acct_attrs.array_num_value(13) := p_source_52;
16292
16293 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
16294 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
16295
16296 ---------------------------------------------------------------------------------------------------------------
16297 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
16298 ---------------------------------------------------------------------------------------------------------------
16299 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
16300
16301 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16302 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16303
16304 IF xla_accounting_cache_pkg.GetValueChar
16305 (p_source_code => 'LEDGER_CATEGORY_CODE'
16306 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
16307 AND l_bflow_method_code = 'PRIOR_ENTRY'
16308 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
16309 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
16310 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
16311 )
16312 THEN
16313 xla_ae_lines_pkg.BflowUpgEntry
16314 (p_business_method_code => l_bflow_method_code
16315 ,p_business_class_code => l_bflow_class_code
16316 ,p_balance_type => l_balance_type_code);
16317 ELSE
16318 NULL;
16319 -- No business flow processing for business flow method of NONE.
16320 END IF;
16321
16322 --
16323 -- call analytical criteria
16324 --
16325
16326 --
16327 -- call description
16328 --
16329 -- No description or it is inherited.
16330 --
16331 -- call ADRs
16332 -- Bug 4922099
16333 --
16334 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16335 (NVL(l_actual_upg_option, 'N') = 'O') OR
16336 (NVL(l_enc_upg_option, 'N') = 'O')
16337 )
16338 THEN
16339 NULL;
16340 --
16341 --
16342
16343 l_ccid := AcctDerRule_3(
16344 p_application_id => p_application_id
16345 , p_ae_header_id => l_ae_header_id
16346 , p_source_4 => p_source_4
16347 , x_transaction_coa_id => l_adr_transaction_coa_id
16348 , x_accounting_coa_id => l_adr_accounting_coa_id
16349 , x_value_type_code => l_adr_value_type_code
16350 , p_side => 'NA'
16351 );
16352
16353 xla_ae_lines_pkg.set_ccid(
16354 p_code_combination_id => l_ccid
16355 , p_value_type_code => l_adr_value_type_code
16356 , p_transaction_coa_id => l_adr_transaction_coa_id
16357 , p_accounting_coa_id => l_adr_accounting_coa_id
16358 , p_adr_code => 'CM_DIST_CCID'
16359 , p_adr_type_code => 'S'
16360 , p_component_type => l_component_type
16361 , p_component_code => l_component_code
16362 , p_component_type_code => l_component_type_code
16363 , p_component_appl_id => l_component_appl_id
16364 , p_amb_context_code => l_amb_context_code
16365 , p_side => 'NA'
16366 );
16367
16368
16369 --
16370 --
16371 END IF;
16372 --
16373 -- Bug 4922099
16374 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
16375 (NVL(l_enc_upg_option, 'N') = 'O')
16376 ) AND
16377 (l_bflow_method_code = 'PRIOR_ENTRY')
16378 )
16379 THEN
16380 IF
16381 --
16382 1 = 2
16383 --
16384 THEN
16385 xla_accounting_err_pkg.build_message
16386 (p_appli_s_name => 'XLA'
16387 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16388 ,p_token_1 => 'LINE_NUMBER'
16389 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
16390 ,p_token_2 => 'LINE_TYPE_NAME'
16391 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
16392 l_component_type
16393 ,l_component_code
16394 ,l_component_type_code
16395 ,l_component_appl_id
16396 ,l_amb_context_code
16397 ,l_entity_code
16398 ,l_event_class_code
16399 )
16400 ,p_token_3 => 'OWNER'
16401 ,p_value_3 => xla_lookups_pkg.get_meaning(
16402 p_lookup_type => 'XLA_OWNER_TYPE'
16403 ,p_lookup_code => l_component_type_code
16404 )
16405 ,p_token_4 => 'PRODUCT_NAME'
16406 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
16407 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
16408 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
16409 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
16410 ,p_ae_header_id => NULL
16411 );
16412
16413 IF (C_LEVEL_ERROR>= g_log_level) THEN
16414 trace
16415 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16416 ,p_level => C_LEVEL_ERROR
16417 ,p_module => l_log_module);
16418 END IF;
16419 END IF;
16420 END IF;
16421 --
16422 --
16423 ------------------------------------------------------------------------------------------------
16424 -- 4219869 Business Flow
16425 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
16426 -- Prior Entry. Currently, the following code is always generated.
16427 ------------------------------------------------------------------------------------------------
16428 XLA_AE_LINES_PKG.ValidateCurrentLine;
16429
16430 ------------------------------------------------------------------------------------
16431 -- 4219869 Business Flow
16432 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
16433 ------------------------------------------------------------------------------------
16434 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
16435
16436 ----------------------------------------------------------------------------------
16437 -- 4219869 Business Flow
16438 -- Update journal entry status -- Need to generate this within IF <condition>
16439 ----------------------------------------------------------------------------------
16440 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
16441 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
16442 ,p_balance_type_code => l_balance_type_code
16443 );
16444
16445 -------------------------------------------------------------------------------------------
16446 -- 4262811 - Generate the Accrual Reversal lines
16447 -------------------------------------------------------------------------------------------
16448 BEGIN
16449 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
16450 (g_array_event(p_event_id).array_value_num('header_index'));
16451 IF l_acc_rev_flag IS NULL THEN
16452 l_acc_rev_flag := 'N';
16453 END IF;
16454 EXCEPTION
16455 WHEN OTHERS THEN
16456 l_acc_rev_flag := 'N';
16457 END;
16458 --
16459 IF (l_acc_rev_flag = 'Y') THEN
16460
16461 -- 4645092 ------------------------------------------------------------------------------
16462 -- To allow MPA report to determine if it should generate report process
16463 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
16464 ------------------------------------------------------------------------------------------
16465
16466 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
16467 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
16468 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
16469 -- call ADRs
16470 -- Bug 4922099
16471 --
16472 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16473 (NVL(l_actual_upg_option, 'N') = 'O') OR
16474 (NVL(l_enc_upg_option, 'N') = 'O')
16475 )
16476 THEN
16477 NULL;
16478 --
16479 --
16480
16481 l_ccid := AcctDerRule_3(
16482 p_application_id => p_application_id
16483 , p_ae_header_id => l_ae_header_id
16484 , p_source_4 => p_source_4
16485 , x_transaction_coa_id => l_adr_transaction_coa_id
16486 , x_accounting_coa_id => l_adr_accounting_coa_id
16487 , x_value_type_code => l_adr_value_type_code
16488 , p_side => 'NA'
16489 );
16490
16491 xla_ae_lines_pkg.set_ccid(
16492 p_code_combination_id => l_ccid
16493 , p_value_type_code => l_adr_value_type_code
16494 , p_transaction_coa_id => l_adr_transaction_coa_id
16495 , p_accounting_coa_id => l_adr_accounting_coa_id
16496 , p_adr_code => 'CM_DIST_CCID'
16497 , p_adr_type_code => 'S'
16498 , p_component_type => l_component_type
16499 , p_component_code => l_component_code
16500 , p_component_type_code => l_component_type_code
16501 , p_component_appl_id => l_component_appl_id
16502 , p_amb_context_code => l_amb_context_code
16503 , p_side => 'NA'
16504 );
16505
16506
16507 --
16508 --
16509 END IF;
16510
16511 --
16512 -- Update the line information that should be overwritten
16513 --
16514 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
16515 p_header_num => 1);
16516 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
16517
16518 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
16519
16520 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
16521 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
16522 END IF;
16523
16524 --
16525 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
16526 --
16527 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
16528 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
16529 ELSE
16530 ---------------------------------------------------------------------------------------------------
16531 -- 4262811a Switch Sign
16532 ---------------------------------------------------------------------------------------------------
16533 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
16534 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16535 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16536 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
16537 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16538 -- 5132302
16539 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
16540 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
16541
16542 END IF;
16543
16544 -- 4955764
16545 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16546 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
16547
16548
16549 XLA_AE_LINES_PKG.ValidateCurrentLine;
16550 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
16551
16552 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
16553 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
16554 ,p_balance_type_code => l_balance_type_code);
16555
16556 END IF;
16557
16558 -----------------------------------------------------------------------------------------
16559 -- 4262811 Multiperiod Accounting
16560 -----------------------------------------------------------------------------------------
16561 -- No MPA option is assigned.
16562
16563
16564 END IF;
16565 END IF;
16566 --
16567
16568 --
16569 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16570 trace
16571 (p_msg => 'END of AcctLineType_50'
16572 ,p_level => C_LEVEL_PROCEDURE
16573 ,p_module => l_log_module);
16574 END IF;
16575 --
16576 EXCEPTION
16577 WHEN xla_exceptions_pkg.application_exception THEN
16578 RAISE;
16579 WHEN OTHERS THEN
16580 xla_exceptions_pkg.raise_message
16581 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_50');
16582 END AcctLineType_50;
16583 --
16584
16585 ---------------------------------------
16586 --
16587 -- PRIVATE FUNCTION
16588 -- AcctLineType_51
16589 --
16590 ---------------------------------------
16591 PROCEDURE AcctLineType_51 (
16592 p_application_id IN NUMBER
16593 ,p_event_id IN NUMBER
16594 ,p_calculate_acctd_flag IN VARCHAR2
16595 ,p_calculate_g_l_flag IN VARCHAR2
16596 ,p_actual_flag IN OUT VARCHAR2
16597 ,p_balance_type_code OUT VARCHAR2
16598 ,p_gain_or_loss_ref OUT VARCHAR2
16599
16600 --Credit Memo Distribution GL Account
16601 , p_source_4 IN NUMBER
16602 --SLA Party Type
16603 , p_source_32 IN VARCHAR2
16604 --Credit Memo Distribution Identifier
16605 , p_source_42 IN NUMBER
16606 --Credit memo distributions type
16607 , p_source_43 IN VARCHAR2
16608 --Credit Memo Currency Code
16609 , p_source_44 IN VARCHAR2
16610 --Credit Memo Exchange Date
16611 , p_source_45 IN DATE
16612 --Credit Memo Exchange Rate
16613 , p_source_46 IN NUMBER
16614 --Credit Memo Exchange Rate Type
16615 , p_source_47 IN VARCHAR2
16616 --Gain Loss Reference
16617 , p_source_48 IN VARCHAR2
16618 --Credit Memo Accounting Amount
16619 , p_source_49 IN NUMBER
16620 --Credit Memo Bill To Customer Account Identifier
16621 , p_source_50 IN NUMBER
16622 --Credit Memo Bill To Customer Site Use Identifier
16623 , p_source_51 IN NUMBER
16624 --Credit Memo Tax Line Identifier
16625 , p_source_52 IN NUMBER
16626 --Credit Memo Distribution Account Class
16627 , p_source_53 IN VARCHAR2
16628 --Credit Memo Distribution Entered Amount
16629 , p_source_54 IN NUMBER
16630 )
16631 IS
16632
16636 l_component_appl_id INTEGER;
16633 l_component_type VARCHAR2(80);
16634 l_component_code VARCHAR2(30);
16635 l_component_type_code VARCHAR2(1);
16637 l_amb_context_code VARCHAR2(30);
16638 l_entity_code VARCHAR2(30);
16639 l_event_class_code VARCHAR2(30);
16640 l_ae_header_id NUMBER;
16641 l_event_type_code VARCHAR2(30);
16642 l_line_definition_code VARCHAR2(30);
16643 l_line_definition_owner_code VARCHAR2(1);
16644 --
16645 -- adr variables
16646 l_segment VARCHAR2(30);
16647 l_ccid NUMBER;
16648 l_adr_transaction_coa_id NUMBER;
16649 l_adr_accounting_coa_id NUMBER;
16650 l_adr_flexfield_segment_code VARCHAR2(30);
16651 l_adr_flex_value_set_id NUMBER;
16652 l_adr_value_type_code VARCHAR2(30);
16653 l_adr_value_combination_id NUMBER;
16654 l_adr_value_segment_code VARCHAR2(30);
16655
16656 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
16657 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
16658 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
16659 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
16660
16661 -- 4262811 Variables ------------------------------------------------------------------------------------------
16662 l_entered_amt_idx NUMBER;
16663 l_accted_amt_idx NUMBER;
16664 l_acc_rev_flag VARCHAR2(1);
16665 l_accrual_line_num NUMBER;
16666 l_tmp_amt NUMBER;
16667 l_acc_rev_natural_side_code VARCHAR2(1);
16668
16669 l_num_entries NUMBER;
16670 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
16671 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
16672 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
16673 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
16674 l_recog_line_1 NUMBER;
16675 l_recog_line_2 NUMBER;
16676
16677 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
16678 l_bflow_applied_to_amt NUMBER; -- 5132302
16679 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
16680
16681 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
16682
16683 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
16684 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
16685
16686 ---------------------------------------------------------------------------------------------------------------
16687
16688
16689 --
16690 -- bulk performance
16691 --
16692 l_balance_type_code VARCHAR2(1);
16693 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
16694 l_log_module VARCHAR2(240);
16695
16696 --
16697 -- Upgrade strategy
16698 --
16699 l_actual_upg_option VARCHAR2(1);
16700 l_enc_upg_option VARCHAR2(1);
16701
16702 --
16703 BEGIN
16704 --
16705 IF g_log_enabled THEN
16706 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_51';
16707 END IF;
16708 --
16709 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
16710
16711 trace
16712 (p_msg => 'BEGIN of AcctLineType_51'
16713 ,p_level => C_LEVEL_PROCEDURE
16714 ,p_module => l_log_module);
16715
16716 END IF;
16717 --
16718 l_component_type := 'AMB_JLT';
16719 l_component_code := 'CM_UNBILL';
16720 l_component_type_code := 'S';
16721 l_component_appl_id := 222;
16722 l_amb_context_code := 'DEFAULT';
16723 l_entity_code := 'TRANSACTIONS';
16724 l_event_class_code := 'CREDIT_MEMO';
16725 l_event_type_code := 'CREDIT_MEMO_ALL';
16726 l_line_definition_owner_code := 'S';
16727 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
16728 --
16729 l_balance_type_code := 'A';
16730 l_segment := NULL;
16731 l_ccid := NULL;
16732 l_adr_transaction_coa_id := NULL;
16733 l_adr_accounting_coa_id := NULL;
16734 l_adr_flexfield_segment_code := NULL;
16735 l_adr_flex_value_set_id := NULL;
16736 l_adr_value_type_code := NULL;
16737 l_adr_value_combination_id := NULL;
16738 l_adr_value_segment_code := NULL;
16739
16740 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
16741 l_bflow_class_code := ''; -- 4219869 Business Flow
16742 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
16743 l_budgetary_control_flag := 'N';
16744
16745 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16746 l_bflow_applied_to_amt := NULL; -- 5132302
16747 l_entered_amt_idx := NULL; -- 4262811
16748 l_accted_amt_idx := NULL; -- 4262811
16749 l_acc_rev_flag := NULL; -- 4262811
16750 l_accrual_line_num := NULL; -- 4262811
16751 l_tmp_amt := NULL; -- 4262811
16752 --
16753
16754 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
16755 l_balance_type_code <> 'B' THEN
16756 IF NVL(p_source_53,'
16757 ') = 'UNBILL'
16758 THEN
16759
16760 --
16761 XLA_AE_LINES_PKG.SetNewLine;
16762
16763 p_balance_type_code := l_balance_type_code;
16764 -- set the flag so later we will know whether the gain loss line needs to be created
16765
16769
16766 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
16767 p_actual_flag :='A';
16768 END IF;
16770 --
16771 -- bulk performance
16772 --
16773 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
16774 p_header_num => 0); -- 4262811
16775 --
16776 -- set accounting line options
16777 --
16778 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
16779 p_natural_side_code => 'C'
16780 , p_gain_or_loss_flag => 'N'
16781 , p_gl_transfer_mode_code => 'S'
16782 , p_acct_entry_type_code => 'A'
16783 , p_switch_side_flag => 'Y'
16784 , p_merge_duplicate_code => 'A'
16785 );
16786 --
16787 l_acc_rev_natural_side_code := 'D'; -- 4262811
16788 --
16789 --
16790 -- set accounting line type info
16791 --
16792 xla_ae_lines_pkg.SetAcctLineType
16793 (p_component_type => l_component_type
16794 ,p_event_type_code => l_event_type_code
16795 ,p_line_definition_owner_code => l_line_definition_owner_code
16796 ,p_line_definition_code => l_line_definition_code
16797 ,p_accounting_line_code => l_component_code
16798 ,p_accounting_line_type_code => l_component_type_code
16799 ,p_accounting_line_appl_id => l_component_appl_id
16800 ,p_amb_context_code => l_amb_context_code
16801 ,p_entity_code => l_entity_code
16802 ,p_event_class_code => l_event_class_code);
16803 --
16804 -- set accounting class
16805 --
16806 xla_ae_lines_pkg.SetAcctClass(
16807 p_accounting_class_code => 'UNBILL'
16808 , p_ae_header_id => l_ae_header_id
16809 );
16810
16811 --
16812 -- set rounding class
16813 --
16814 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
16815 'RECEIVABLE';
16816
16817 --
16818 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
16819 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
16820 --
16821 -- bulk performance
16822 --
16823 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
16824
16825 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
16826 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
16827
16828 -- 4955764
16829 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
16830 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
16831
16832 -- 4458381 Public Sector Enh
16833
16834 --
16835 -- set accounting attributes for the line type
16836 --
16837 l_entered_amt_idx := 3;
16838 l_accted_amt_idx := 9;
16839 l_bflow_applied_to_amt_idx := NULL; -- 5132302
16840 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
16841 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
16842 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
16843 l_rec_acct_attrs.array_char_value(2) := p_source_43;
16844 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
16845 l_rec_acct_attrs.array_num_value(3) := p_source_54;
16846 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
16847 l_rec_acct_attrs.array_char_value(4) := p_source_44;
16848 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
16849 l_rec_acct_attrs.array_date_value(5) := p_source_45;
16850 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
16851 l_rec_acct_attrs.array_num_value(6) := p_source_46;
16852 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
16853 l_rec_acct_attrs.array_char_value(7) := p_source_47;
16854 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
16855 l_rec_acct_attrs.array_char_value(8) := p_source_48;
16856 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
16857 l_rec_acct_attrs.array_num_value(9) := p_source_49;
16858 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
16859 l_rec_acct_attrs.array_num_value(10) := p_source_50;
16860 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
16861 l_rec_acct_attrs.array_num_value(11) := p_source_51;
16862 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
16863 l_rec_acct_attrs.array_char_value(12) := p_source_32;
16864 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
16865 l_rec_acct_attrs.array_num_value(13) := p_source_52;
16866
16867 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
16868 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
16869
16870 ---------------------------------------------------------------------------------------------------------------
16871 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
16872 ---------------------------------------------------------------------------------------------------------------
16873 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
16874
16875 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16876 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
16877
16878 IF xla_accounting_cache_pkg.GetValueChar
16879 (p_source_code => 'LEDGER_CATEGORY_CODE'
16883 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
16880 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
16881 AND l_bflow_method_code = 'PRIOR_ENTRY'
16882 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
16884 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
16885 )
16886 THEN
16887 xla_ae_lines_pkg.BflowUpgEntry
16888 (p_business_method_code => l_bflow_method_code
16889 ,p_business_class_code => l_bflow_class_code
16890 ,p_balance_type => l_balance_type_code);
16891 ELSE
16892 NULL;
16893 -- No business flow processing for business flow method of NONE.
16894 END IF;
16895
16896 --
16897 -- call analytical criteria
16898 --
16899
16900 --
16901 -- call description
16902 --
16903 -- No description or it is inherited.
16904 --
16905 -- call ADRs
16906 -- Bug 4922099
16907 --
16908 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
16909 (NVL(l_actual_upg_option, 'N') = 'O') OR
16910 (NVL(l_enc_upg_option, 'N') = 'O')
16911 )
16912 THEN
16913 NULL;
16914 --
16915 --
16916
16917 l_ccid := AcctDerRule_3(
16918 p_application_id => p_application_id
16919 , p_ae_header_id => l_ae_header_id
16920 , p_source_4 => p_source_4
16921 , x_transaction_coa_id => l_adr_transaction_coa_id
16922 , x_accounting_coa_id => l_adr_accounting_coa_id
16923 , x_value_type_code => l_adr_value_type_code
16924 , p_side => 'NA'
16925 );
16926
16927 xla_ae_lines_pkg.set_ccid(
16928 p_code_combination_id => l_ccid
16929 , p_value_type_code => l_adr_value_type_code
16930 , p_transaction_coa_id => l_adr_transaction_coa_id
16931 , p_accounting_coa_id => l_adr_accounting_coa_id
16932 , p_adr_code => 'CM_DIST_CCID'
16933 , p_adr_type_code => 'S'
16934 , p_component_type => l_component_type
16935 , p_component_code => l_component_code
16936 , p_component_type_code => l_component_type_code
16937 , p_component_appl_id => l_component_appl_id
16938 , p_amb_context_code => l_amb_context_code
16939 , p_side => 'NA'
16940 );
16941
16942
16943 --
16944 --
16945 END IF;
16946 --
16947 -- Bug 4922099
16948 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
16949 (NVL(l_enc_upg_option, 'N') = 'O')
16950 ) AND
16951 (l_bflow_method_code = 'PRIOR_ENTRY')
16952 )
16953 THEN
16954 IF
16955 --
16956 1 = 2
16957 --
16958 THEN
16959 xla_accounting_err_pkg.build_message
16960 (p_appli_s_name => 'XLA'
16961 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16962 ,p_token_1 => 'LINE_NUMBER'
16963 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
16964 ,p_token_2 => 'LINE_TYPE_NAME'
16965 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
16966 l_component_type
16967 ,l_component_code
16968 ,l_component_type_code
16969 ,l_component_appl_id
16970 ,l_amb_context_code
16971 ,l_entity_code
16972 ,l_event_class_code
16973 )
16974 ,p_token_3 => 'OWNER'
16975 ,p_value_3 => xla_lookups_pkg.get_meaning(
16976 p_lookup_type => 'XLA_OWNER_TYPE'
16977 ,p_lookup_code => l_component_type_code
16978 )
16979 ,p_token_4 => 'PRODUCT_NAME'
16980 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
16981 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
16982 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
16983 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
16984 ,p_ae_header_id => NULL
16985 );
16986
16987 IF (C_LEVEL_ERROR>= g_log_level) THEN
16988 trace
16989 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
16990 ,p_level => C_LEVEL_ERROR
16991 ,p_module => l_log_module);
16992 END IF;
16993 END IF;
16994 END IF;
16995 --
16996 --
16997 ------------------------------------------------------------------------------------------------
17001 ------------------------------------------------------------------------------------------------
16998 -- 4219869 Business Flow
16999 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
17000 -- Prior Entry. Currently, the following code is always generated.
17002 XLA_AE_LINES_PKG.ValidateCurrentLine;
17003
17004 ------------------------------------------------------------------------------------
17005 -- 4219869 Business Flow
17006 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
17007 ------------------------------------------------------------------------------------
17008 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17009
17010 ----------------------------------------------------------------------------------
17011 -- 4219869 Business Flow
17012 -- Update journal entry status -- Need to generate this within IF <condition>
17013 ----------------------------------------------------------------------------------
17014 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17015 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
17016 ,p_balance_type_code => l_balance_type_code
17017 );
17018
17019 -------------------------------------------------------------------------------------------
17020 -- 4262811 - Generate the Accrual Reversal lines
17021 -------------------------------------------------------------------------------------------
17022 BEGIN
17023 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
17024 (g_array_event(p_event_id).array_value_num('header_index'));
17025 IF l_acc_rev_flag IS NULL THEN
17026 l_acc_rev_flag := 'N';
17027 END IF;
17028 EXCEPTION
17029 WHEN OTHERS THEN
17030 l_acc_rev_flag := 'N';
17031 END;
17032 --
17033 IF (l_acc_rev_flag = 'Y') THEN
17034
17035 -- 4645092 ------------------------------------------------------------------------------
17036 -- To allow MPA report to determine if it should generate report process
17037 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
17038 ------------------------------------------------------------------------------------------
17039
17040 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
17041 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
17042 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
17043 -- call ADRs
17044 -- Bug 4922099
17045 --
17046 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17047 (NVL(l_actual_upg_option, 'N') = 'O') OR
17048 (NVL(l_enc_upg_option, 'N') = 'O')
17049 )
17050 THEN
17051 NULL;
17052 --
17053 --
17054
17055 l_ccid := AcctDerRule_3(
17056 p_application_id => p_application_id
17057 , p_ae_header_id => l_ae_header_id
17058 , p_source_4 => p_source_4
17059 , x_transaction_coa_id => l_adr_transaction_coa_id
17060 , x_accounting_coa_id => l_adr_accounting_coa_id
17061 , x_value_type_code => l_adr_value_type_code
17062 , p_side => 'NA'
17063 );
17064
17065 xla_ae_lines_pkg.set_ccid(
17066 p_code_combination_id => l_ccid
17067 , p_value_type_code => l_adr_value_type_code
17068 , p_transaction_coa_id => l_adr_transaction_coa_id
17069 , p_accounting_coa_id => l_adr_accounting_coa_id
17070 , p_adr_code => 'CM_DIST_CCID'
17071 , p_adr_type_code => 'S'
17072 , p_component_type => l_component_type
17073 , p_component_code => l_component_code
17074 , p_component_type_code => l_component_type_code
17075 , p_component_appl_id => l_component_appl_id
17076 , p_amb_context_code => l_amb_context_code
17077 , p_side => 'NA'
17078 );
17079
17080
17081 --
17082 --
17083 END IF;
17084
17085 --
17086 -- Update the line information that should be overwritten
17087 --
17088 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
17089 p_header_num => 1);
17090 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
17091
17092 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
17093
17094 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
17095 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
17096 END IF;
17097
17098 --
17099 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
17100 --
17101 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
17102 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
17103 ELSE
17104 ---------------------------------------------------------------------------------------------------
17105 -- 4262811a Switch Sign
17106 ---------------------------------------------------------------------------------------------------
17107 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
17108 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17109 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17110 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17111 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17112 -- 5132302
17113 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
17114 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17115
17116 END IF;
17117
17118 -- 4955764
17119 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17120 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
17121
17122
17123 XLA_AE_LINES_PKG.ValidateCurrentLine;
17124 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17125
17126 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17127 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
17128 ,p_balance_type_code => l_balance_type_code);
17129
17130 END IF;
17131
17132 -----------------------------------------------------------------------------------------
17133 -- 4262811 Multiperiod Accounting
17134 -----------------------------------------------------------------------------------------
17135 -- No MPA option is assigned.
17136
17137
17138 END IF;
17139 END IF;
17140 --
17141
17142 --
17143 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17144 trace
17145 (p_msg => 'END of AcctLineType_51'
17146 ,p_level => C_LEVEL_PROCEDURE
17147 ,p_module => l_log_module);
17148 END IF;
17149 --
17150 EXCEPTION
17151 WHEN xla_exceptions_pkg.application_exception THEN
17152 RAISE;
17153 WHEN OTHERS THEN
17154 xla_exceptions_pkg.raise_message
17155 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_51');
17156 END AcctLineType_51;
17157 --
17158
17159 ---------------------------------------
17160 --
17161 -- PRIVATE FUNCTION
17162 -- AcctLineType_52
17163 --
17164 ---------------------------------------
17165 PROCEDURE AcctLineType_52 (
17166 p_application_id IN NUMBER
17167 ,p_event_id IN NUMBER
17168 ,p_calculate_acctd_flag IN VARCHAR2
17169 ,p_calculate_g_l_flag IN VARCHAR2
17170 ,p_actual_flag IN OUT VARCHAR2
17171 ,p_balance_type_code OUT VARCHAR2
17172 ,p_gain_or_loss_ref OUT VARCHAR2
17173
17174 --Credit Memo Distribution GL Account
17175 , p_source_4 IN NUMBER
17176 --SLA Party Type
17177 , p_source_32 IN VARCHAR2
17178 --Credit Memo Distribution Identifier
17179 , p_source_42 IN NUMBER
17180 --Credit memo distributions type
17181 , p_source_43 IN VARCHAR2
17182 --Credit Memo Currency Code
17183 , p_source_44 IN VARCHAR2
17184 --Credit Memo Exchange Date
17185 , p_source_45 IN DATE
17186 --Credit Memo Exchange Rate
17187 , p_source_46 IN NUMBER
17188 --Credit Memo Exchange Rate Type
17189 , p_source_47 IN VARCHAR2
17190 --Gain Loss Reference
17191 , p_source_48 IN VARCHAR2
17192 --Credit Memo Accounting Amount
17193 , p_source_49 IN NUMBER
17194 --Credit Memo Bill To Customer Account Identifier
17195 , p_source_50 IN NUMBER
17196 --Credit Memo Bill To Customer Site Use Identifier
17197 , p_source_51 IN NUMBER
17198 --Credit Memo Tax Line Identifier
17199 , p_source_52 IN NUMBER
17200 --Credit Memo Distribution Account Class
17201 , p_source_53 IN VARCHAR2
17202 --Credit Memo Distribution Entered Amount
17203 , p_source_54 IN NUMBER
17204 )
17205 IS
17206
17207 l_component_type VARCHAR2(80);
17208 l_component_code VARCHAR2(30);
17209 l_component_type_code VARCHAR2(1);
17210 l_component_appl_id INTEGER;
17211 l_amb_context_code VARCHAR2(30);
17212 l_entity_code VARCHAR2(30);
17213 l_event_class_code VARCHAR2(30);
17214 l_ae_header_id NUMBER;
17215 l_event_type_code VARCHAR2(30);
17216 l_line_definition_code VARCHAR2(30);
17217 l_line_definition_owner_code VARCHAR2(1);
17218 --
17219 -- adr variables
17220 l_segment VARCHAR2(30);
17221 l_ccid NUMBER;
17222 l_adr_transaction_coa_id NUMBER;
17223 l_adr_accounting_coa_id NUMBER;
17224 l_adr_flexfield_segment_code VARCHAR2(30);
17225 l_adr_flex_value_set_id NUMBER;
17226 l_adr_value_type_code VARCHAR2(30);
17227 l_adr_value_combination_id NUMBER;
17228 l_adr_value_segment_code VARCHAR2(30);
17229
17230 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
17231 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
17232 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
17233 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
17234
17235 -- 4262811 Variables ------------------------------------------------------------------------------------------
17236 l_entered_amt_idx NUMBER;
17237 l_accted_amt_idx NUMBER;
17238 l_acc_rev_flag VARCHAR2(1);
17239 l_accrual_line_num NUMBER;
17240 l_tmp_amt NUMBER;
17241 l_acc_rev_natural_side_code VARCHAR2(1);
17242
17243 l_num_entries NUMBER;
17244 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
17245 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
17246 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
17247 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
17248 l_recog_line_1 NUMBER;
17249 l_recog_line_2 NUMBER;
17250
17251 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
17252 l_bflow_applied_to_amt NUMBER; -- 5132302
17253 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
17254
17255 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
17256
17257 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
17258 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
17259
17260 ---------------------------------------------------------------------------------------------------------------
17261
17262
17263 --
17264 -- bulk performance
17265 --
17266 l_balance_type_code VARCHAR2(1);
17267 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
17268 l_log_module VARCHAR2(240);
17269
17270 --
17271 -- Upgrade strategy
17272 --
17273 l_actual_upg_option VARCHAR2(1);
17274 l_enc_upg_option VARCHAR2(1);
17275
17276 --
17277 BEGIN
17278 --
17279 IF g_log_enabled THEN
17280 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_52';
17281 END IF;
17282 --
17283 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17284
17285 trace
17286 (p_msg => 'BEGIN of AcctLineType_52'
17287 ,p_level => C_LEVEL_PROCEDURE
17288 ,p_module => l_log_module);
17289
17290 END IF;
17291 --
17292 l_component_type := 'AMB_JLT';
17293 l_component_code := 'CM_UNEARN';
17294 l_component_type_code := 'S';
17295 l_component_appl_id := 222;
17296 l_amb_context_code := 'DEFAULT';
17297 l_entity_code := 'TRANSACTIONS';
17298 l_event_class_code := 'CREDIT_MEMO';
17299 l_event_type_code := 'CREDIT_MEMO_ALL';
17300 l_line_definition_owner_code := 'S';
17301 l_line_definition_code := 'AR_CM_DEFAULT_ACCRUAL';
17302 --
17303 l_balance_type_code := 'A';
17304 l_segment := NULL;
17305 l_ccid := NULL;
17306 l_adr_transaction_coa_id := NULL;
17307 l_adr_accounting_coa_id := NULL;
17308 l_adr_flexfield_segment_code := NULL;
17309 l_adr_flex_value_set_id := NULL;
17310 l_adr_value_type_code := NULL;
17311 l_adr_value_combination_id := NULL;
17312 l_adr_value_segment_code := NULL;
17313
17314 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
17315 l_bflow_class_code := ''; -- 4219869 Business Flow
17316 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
17317 l_budgetary_control_flag := 'N';
17318
17319 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17320 l_bflow_applied_to_amt := NULL; -- 5132302
17321 l_entered_amt_idx := NULL; -- 4262811
17322 l_accted_amt_idx := NULL; -- 4262811
17323 l_acc_rev_flag := NULL; -- 4262811
17324 l_accrual_line_num := NULL; -- 4262811
17325 l_tmp_amt := NULL; -- 4262811
17326 --
17327
17328 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
17329 l_balance_type_code <> 'B' THEN
17330 IF NVL(p_source_53,'
17331 ') = 'UNEARN'
17332 THEN
17333
17334 --
17335 XLA_AE_LINES_PKG.SetNewLine;
17336
17337 p_balance_type_code := l_balance_type_code;
17338 -- set the flag so later we will know whether the gain loss line needs to be created
17339
17340 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
17341 p_actual_flag :='A';
17342 END IF;
17343
17344 --
17345 -- bulk performance
17346 --
17347 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
17348 p_header_num => 0); -- 4262811
17349 --
17353 p_natural_side_code => 'C'
17350 -- set accounting line options
17351 --
17352 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
17354 , p_gain_or_loss_flag => 'N'
17355 , p_gl_transfer_mode_code => 'S'
17356 , p_acct_entry_type_code => 'A'
17357 , p_switch_side_flag => 'Y'
17358 , p_merge_duplicate_code => 'A'
17359 );
17360 --
17361 l_acc_rev_natural_side_code := 'D'; -- 4262811
17362 --
17363 --
17364 -- set accounting line type info
17365 --
17366 xla_ae_lines_pkg.SetAcctLineType
17367 (p_component_type => l_component_type
17368 ,p_event_type_code => l_event_type_code
17369 ,p_line_definition_owner_code => l_line_definition_owner_code
17370 ,p_line_definition_code => l_line_definition_code
17371 ,p_accounting_line_code => l_component_code
17372 ,p_accounting_line_type_code => l_component_type_code
17373 ,p_accounting_line_appl_id => l_component_appl_id
17374 ,p_amb_context_code => l_amb_context_code
17375 ,p_entity_code => l_entity_code
17376 ,p_event_class_code => l_event_class_code);
17377 --
17378 -- set accounting class
17379 --
17380 xla_ae_lines_pkg.SetAcctClass(
17381 p_accounting_class_code => 'UNEARNED_REVENUE'
17382 , p_ae_header_id => l_ae_header_id
17383 );
17384
17385 --
17386 -- set rounding class
17387 --
17388 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
17389 'RECEIVABLE';
17390
17391 --
17392 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
17393 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
17394 --
17395 -- bulk performance
17396 --
17397 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
17398
17399 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
17400 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
17401
17402 -- 4955764
17403 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17404 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
17405
17406 -- 4458381 Public Sector Enh
17407
17408 --
17409 -- set accounting attributes for the line type
17410 --
17411 l_entered_amt_idx := 3;
17412 l_accted_amt_idx := 9;
17413 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17414 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
17415 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_42);
17416 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
17417 l_rec_acct_attrs.array_char_value(2) := p_source_43;
17418 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
17419 l_rec_acct_attrs.array_num_value(3) := p_source_54;
17420 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
17421 l_rec_acct_attrs.array_char_value(4) := p_source_44;
17422 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
17423 l_rec_acct_attrs.array_date_value(5) := p_source_45;
17424 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
17425 l_rec_acct_attrs.array_num_value(6) := p_source_46;
17426 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
17427 l_rec_acct_attrs.array_char_value(7) := p_source_47;
17428 l_rec_acct_attrs.array_acct_attr_code(8) := 'GAIN_LOSS_REFERENCE';
17429 l_rec_acct_attrs.array_char_value(8) := p_source_48;
17430 l_rec_acct_attrs.array_acct_attr_code(9) := 'LEDGER_AMOUNT';
17431 l_rec_acct_attrs.array_num_value(9) := p_source_49;
17432 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_ID';
17433 l_rec_acct_attrs.array_num_value(10) := p_source_50;
17434 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_SITE_ID';
17435 l_rec_acct_attrs.array_num_value(11) := p_source_51;
17436 l_rec_acct_attrs.array_acct_attr_code(12) := 'PARTY_TYPE';
17437 l_rec_acct_attrs.array_char_value(12) := p_source_32;
17438 l_rec_acct_attrs.array_acct_attr_code(13) := 'TAX_LINE_REF_ID';
17439 l_rec_acct_attrs.array_num_value(13) := p_source_52;
17440
17441 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
17442 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
17443
17444 ---------------------------------------------------------------------------------------------------------------
17445 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
17446 ---------------------------------------------------------------------------------------------------------------
17447 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
17448
17449 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17450 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
17451
17452 IF xla_accounting_cache_pkg.GetValueChar
17453 (p_source_code => 'LEDGER_CATEGORY_CODE'
17454 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
17455 AND l_bflow_method_code = 'PRIOR_ENTRY'
17456 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
17457 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
17458 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
17459 )
17460 THEN
17461 xla_ae_lines_pkg.BflowUpgEntry
17462 (p_business_method_code => l_bflow_method_code
17463 ,p_business_class_code => l_bflow_class_code
17464 ,p_balance_type => l_balance_type_code);
17465 ELSE
17466 NULL;
17467 -- No business flow processing for business flow method of NONE.
17468 END IF;
17469
17470 --
17471 -- call analytical criteria
17472 --
17473
17474 --
17475 -- call description
17476 --
17477 -- No description or it is inherited.
17478 --
17479 -- call ADRs
17480 -- Bug 4922099
17481 --
17482 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17483 (NVL(l_actual_upg_option, 'N') = 'O') OR
17484 (NVL(l_enc_upg_option, 'N') = 'O')
17485 )
17486 THEN
17487 NULL;
17488 --
17489 --
17490
17491 l_ccid := AcctDerRule_3(
17492 p_application_id => p_application_id
17493 , p_ae_header_id => l_ae_header_id
17494 , p_source_4 => p_source_4
17495 , x_transaction_coa_id => l_adr_transaction_coa_id
17496 , x_accounting_coa_id => l_adr_accounting_coa_id
17497 , x_value_type_code => l_adr_value_type_code
17498 , p_side => 'NA'
17499 );
17500
17501 xla_ae_lines_pkg.set_ccid(
17502 p_code_combination_id => l_ccid
17503 , p_value_type_code => l_adr_value_type_code
17504 , p_transaction_coa_id => l_adr_transaction_coa_id
17505 , p_accounting_coa_id => l_adr_accounting_coa_id
17506 , p_adr_code => 'CM_DIST_CCID'
17507 , p_adr_type_code => 'S'
17508 , p_component_type => l_component_type
17509 , p_component_code => l_component_code
17510 , p_component_type_code => l_component_type_code
17511 , p_component_appl_id => l_component_appl_id
17512 , p_amb_context_code => l_amb_context_code
17513 , p_side => 'NA'
17514 );
17515
17516
17517 --
17518 --
17519 END IF;
17520 --
17521 -- Bug 4922099
17522 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
17523 (NVL(l_enc_upg_option, 'N') = 'O')
17524 ) AND
17525 (l_bflow_method_code = 'PRIOR_ENTRY')
17526 )
17527 THEN
17528 IF
17529 --
17530 1 = 2
17531 --
17532 THEN
17533 xla_accounting_err_pkg.build_message
17534 (p_appli_s_name => 'XLA'
17535 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17536 ,p_token_1 => 'LINE_NUMBER'
17537 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
17538 ,p_token_2 => 'LINE_TYPE_NAME'
17539 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
17540 l_component_type
17541 ,l_component_code
17542 ,l_component_type_code
17543 ,l_component_appl_id
17544 ,l_amb_context_code
17545 ,l_entity_code
17546 ,l_event_class_code
17547 )
17548 ,p_token_3 => 'OWNER'
17549 ,p_value_3 => xla_lookups_pkg.get_meaning(
17550 p_lookup_type => 'XLA_OWNER_TYPE'
17551 ,p_lookup_code => l_component_type_code
17552 )
17553 ,p_token_4 => 'PRODUCT_NAME'
17554 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
17555 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
17556 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
17557 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
17558 ,p_ae_header_id => NULL
17559 );
17560
17561 IF (C_LEVEL_ERROR>= g_log_level) THEN
17562 trace
17563 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
17564 ,p_level => C_LEVEL_ERROR
17565 ,p_module => l_log_module);
17566 END IF;
17567 END IF;
17568 END IF;
17569 --
17570 --
17571 ------------------------------------------------------------------------------------------------
17572 -- 4219869 Business Flow
17573 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
17574 -- Prior Entry. Currently, the following code is always generated.
17575 ------------------------------------------------------------------------------------------------
17576 XLA_AE_LINES_PKG.ValidateCurrentLine;
17577
17578 ------------------------------------------------------------------------------------
17579 -- 4219869 Business Flow
17580 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
17581 ------------------------------------------------------------------------------------
17582 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17583
17584 ----------------------------------------------------------------------------------
17585 -- 4219869 Business Flow
17586 -- Update journal entry status -- Need to generate this within IF <condition>
17587 ----------------------------------------------------------------------------------
17588 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17589 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
17590 ,p_balance_type_code => l_balance_type_code
17591 );
17592
17593 -------------------------------------------------------------------------------------------
17594 -- 4262811 - Generate the Accrual Reversal lines
17595 -------------------------------------------------------------------------------------------
17596 BEGIN
17597 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
17598 (g_array_event(p_event_id).array_value_num('header_index'));
17599 IF l_acc_rev_flag IS NULL THEN
17600 l_acc_rev_flag := 'N';
17601 END IF;
17602 EXCEPTION
17603 WHEN OTHERS THEN
17604 l_acc_rev_flag := 'N';
17605 END;
17606 --
17607 IF (l_acc_rev_flag = 'Y') THEN
17608
17609 -- 4645092 ------------------------------------------------------------------------------
17610 -- To allow MPA report to determine if it should generate report process
17611 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
17612 ------------------------------------------------------------------------------------------
17613
17614 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
17615 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
17616 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
17617 -- call ADRs
17618 -- Bug 4922099
17619 --
17620 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
17621 (NVL(l_actual_upg_option, 'N') = 'O') OR
17622 (NVL(l_enc_upg_option, 'N') = 'O')
17623 )
17624 THEN
17625 NULL;
17626 --
17627 --
17628
17629 l_ccid := AcctDerRule_3(
17630 p_application_id => p_application_id
17631 , p_ae_header_id => l_ae_header_id
17632 , p_source_4 => p_source_4
17633 , x_transaction_coa_id => l_adr_transaction_coa_id
17634 , x_accounting_coa_id => l_adr_accounting_coa_id
17635 , x_value_type_code => l_adr_value_type_code
17636 , p_side => 'NA'
17637 );
17638
17639 xla_ae_lines_pkg.set_ccid(
17640 p_code_combination_id => l_ccid
17641 , p_value_type_code => l_adr_value_type_code
17642 , p_transaction_coa_id => l_adr_transaction_coa_id
17643 , p_accounting_coa_id => l_adr_accounting_coa_id
17644 , p_adr_code => 'CM_DIST_CCID'
17645 , p_adr_type_code => 'S'
17646 , p_component_type => l_component_type
17647 , p_component_code => l_component_code
17648 , p_component_type_code => l_component_type_code
17649 , p_component_appl_id => l_component_appl_id
17650 , p_amb_context_code => l_amb_context_code
17651 , p_side => 'NA'
17652 );
17653
17654
17655 --
17656 --
17657 END IF;
17658
17659 --
17660 -- Update the line information that should be overwritten
17661 --
17662 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
17663 p_header_num => 1);
17664 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
17665
17666 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
17667
17668 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
17669 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
17670 END IF;
17671
17672 --
17673 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
17674 --
17675 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
17676 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
17677 ELSE
17678 ---------------------------------------------------------------------------------------------------
17679 -- 4262811a Switch Sign
17680 ---------------------------------------------------------------------------------------------------
17681 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
17682 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17683 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17684 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
17685 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17686 -- 5132302
17687 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
17688 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
17689
17690 END IF;
17691
17692 -- 4955764
17693 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17694 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
17695
17696
17697 XLA_AE_LINES_PKG.ValidateCurrentLine;
17698 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
17699
17700 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
17701 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
17702 ,p_balance_type_code => l_balance_type_code);
17703
17704 END IF;
17705
17706 -----------------------------------------------------------------------------------------
17707 -- 4262811 Multiperiod Accounting
17708 -----------------------------------------------------------------------------------------
17709 -- No MPA option is assigned.
17710
17711
17712 END IF;
17713 END IF;
17714 --
17715
17716 --
17717 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17718 trace
17719 (p_msg => 'END of AcctLineType_52'
17720 ,p_level => C_LEVEL_PROCEDURE
17721 ,p_module => l_log_module);
17722 END IF;
17723 --
17724 EXCEPTION
17725 WHEN xla_exceptions_pkg.application_exception THEN
17726 RAISE;
17727 WHEN OTHERS THEN
17728 xla_exceptions_pkg.raise_message
17729 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_52');
17733 ---------------------------------------
17730 END AcctLineType_52;
17731 --
17732
17734 --
17735 -- PRIVATE FUNCTION
17736 -- AcctLineType_53
17737 --
17738 ---------------------------------------
17739 PROCEDURE AcctLineType_53 (
17740 p_application_id IN NUMBER
17741 ,p_event_id IN NUMBER
17742 ,p_calculate_acctd_flag IN VARCHAR2
17743 ,p_calculate_g_l_flag IN VARCHAR2
17744 ,p_actual_flag IN OUT VARCHAR2
17745 ,p_balance_type_code OUT VARCHAR2
17746 ,p_gain_or_loss_ref OUT VARCHAR2
17747
17748 --Transaction Distribution GL Account
17749 , p_source_19 IN NUMBER
17750 --Bill To Customer Account Identifier
17751 , p_source_30 IN NUMBER
17752 --Bill To Customer Site Use Identifier
17753 , p_source_31 IN NUMBER
17754 --SLA Party Type
17755 , p_source_32 IN VARCHAR2
17756 --Transaction Distribution Account Class
17757 , p_source_33 IN VARCHAR2
17758 --Transaction Distribution Identifier
17759 , p_source_34 IN NUMBER
17760 --Transaction Distribution Type
17761 , p_source_35 IN VARCHAR2
17762 --Transaction Distribution Entered Amount
17763 , p_source_36 IN NUMBER
17764 --Transaction Currency Code
17765 , p_source_37 IN VARCHAR2
17766 --Transaction Exchange Date
17767 , p_source_38 IN DATE
17768 --Transaction Exchange Rate
17769 , p_source_39 IN NUMBER
17770 --Transaction Exchange Rate Type
17771 , p_source_40 IN VARCHAR2
17772 --Transaction Accounting Amount
17773 , p_source_41 IN NUMBER
17774 )
17775 IS
17776
17777 l_component_type VARCHAR2(80);
17778 l_component_code VARCHAR2(30);
17779 l_component_type_code VARCHAR2(1);
17780 l_component_appl_id INTEGER;
17781 l_amb_context_code VARCHAR2(30);
17782 l_entity_code VARCHAR2(30);
17783 l_event_class_code VARCHAR2(30);
17784 l_ae_header_id NUMBER;
17785 l_event_type_code VARCHAR2(30);
17786 l_line_definition_code VARCHAR2(30);
17787 l_line_definition_owner_code VARCHAR2(1);
17788 --
17789 -- adr variables
17790 l_segment VARCHAR2(30);
17791 l_ccid NUMBER;
17792 l_adr_transaction_coa_id NUMBER;
17793 l_adr_accounting_coa_id NUMBER;
17794 l_adr_flexfield_segment_code VARCHAR2(30);
17795 l_adr_flex_value_set_id NUMBER;
17796 l_adr_value_type_code VARCHAR2(30);
17797 l_adr_value_combination_id NUMBER;
17798 l_adr_value_segment_code VARCHAR2(30);
17799
17800 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
17801 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
17802 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
17803 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
17804
17805 -- 4262811 Variables ------------------------------------------------------------------------------------------
17806 l_entered_amt_idx NUMBER;
17807 l_accted_amt_idx NUMBER;
17808 l_acc_rev_flag VARCHAR2(1);
17809 l_accrual_line_num NUMBER;
17810 l_tmp_amt NUMBER;
17811 l_acc_rev_natural_side_code VARCHAR2(1);
17812
17813 l_num_entries NUMBER;
17814 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
17815 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
17816 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
17817 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
17818 l_recog_line_1 NUMBER;
17819 l_recog_line_2 NUMBER;
17820
17821 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
17822 l_bflow_applied_to_amt NUMBER; -- 5132302
17823 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
17824
17825 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
17826
17827 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
17828 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
17829
17830 ---------------------------------------------------------------------------------------------------------------
17831
17832
17833 --
17834 -- bulk performance
17835 --
17836 l_balance_type_code VARCHAR2(1);
17837 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
17838 l_log_module VARCHAR2(240);
17839
17840 --
17841 -- Upgrade strategy
17842 --
17843 l_actual_upg_option VARCHAR2(1);
17844 l_enc_upg_option VARCHAR2(1);
17845
17846 --
17847 BEGIN
17848 --
17849 IF g_log_enabled THEN
17850 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_53';
17851 END IF;
17852 --
17853 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
17854
17855 trace
17856 (p_msg => 'BEGIN of AcctLineType_53'
17857 ,p_level => C_LEVEL_PROCEDURE
17858 ,p_module => l_log_module);
17859
17860 END IF;
17861 --
17862 l_component_type := 'AMB_JLT';
17863 l_component_code := 'DEP_DEFAULT_REC';
17864 l_component_type_code := 'S';
17865 l_component_appl_id := 222;
17866 l_amb_context_code := 'DEFAULT';
17867 l_entity_code := 'TRANSACTIONS';
17868 l_event_class_code := 'DEPOSIT';
17869 l_event_type_code := 'DEPOSIT_ALL';
17870 l_line_definition_owner_code := 'S';
17871 l_line_definition_code := 'AR_DEP_DEFAULT_ACCRUAL';
17872 --
17873 l_balance_type_code := 'A';
17874 l_segment := NULL;
17875 l_ccid := NULL;
17876 l_adr_transaction_coa_id := NULL;
17877 l_adr_accounting_coa_id := NULL;
17878 l_adr_flexfield_segment_code := NULL;
17879 l_adr_flex_value_set_id := NULL;
17880 l_adr_value_type_code := NULL;
17881 l_adr_value_combination_id := NULL;
17882 l_adr_value_segment_code := NULL;
17883
17884 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
17885 l_bflow_class_code := ''; -- 4219869 Business Flow
17886 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
17887 l_budgetary_control_flag := 'N';
17888
17889 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17890 l_bflow_applied_to_amt := NULL; -- 5132302
17891 l_entered_amt_idx := NULL; -- 4262811
17892 l_accted_amt_idx := NULL; -- 4262811
17893 l_acc_rev_flag := NULL; -- 4262811
17894 l_accrual_line_num := NULL; -- 4262811
17895 l_tmp_amt := NULL; -- 4262811
17896 --
17897
17898 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
17899 l_balance_type_code <> 'B' THEN
17900 IF NVL(p_source_33,'
17901 ') = 'REC'
17902 THEN
17903
17904 --
17905 XLA_AE_LINES_PKG.SetNewLine;
17906
17907 p_balance_type_code := l_balance_type_code;
17908 -- set the flag so later we will know whether the gain loss line needs to be created
17909
17910 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
17911 p_actual_flag :='A';
17912 END IF;
17913
17914 --
17915 -- bulk performance
17916 --
17917 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
17918 p_header_num => 0); -- 4262811
17919 --
17920 -- set accounting line options
17921 --
17922 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
17923 p_natural_side_code => 'D'
17924 , p_gain_or_loss_flag => 'N'
17928 , p_merge_duplicate_code => 'A'
17925 , p_gl_transfer_mode_code => 'S'
17926 , p_acct_entry_type_code => 'A'
17927 , p_switch_side_flag => 'Y'
17929 );
17930 --
17931 l_acc_rev_natural_side_code := 'C'; -- 4262811
17932 --
17933 --
17934 -- set accounting line type info
17935 --
17936 xla_ae_lines_pkg.SetAcctLineType
17937 (p_component_type => l_component_type
17938 ,p_event_type_code => l_event_type_code
17939 ,p_line_definition_owner_code => l_line_definition_owner_code
17940 ,p_line_definition_code => l_line_definition_code
17941 ,p_accounting_line_code => l_component_code
17942 ,p_accounting_line_type_code => l_component_type_code
17943 ,p_accounting_line_appl_id => l_component_appl_id
17944 ,p_amb_context_code => l_amb_context_code
17945 ,p_entity_code => l_entity_code
17946 ,p_event_class_code => l_event_class_code);
17947 --
17948 -- set accounting class
17949 --
17950 xla_ae_lines_pkg.SetAcctClass(
17951 p_accounting_class_code => 'RECEIVABLE'
17952 , p_ae_header_id => l_ae_header_id
17953 );
17954
17955 --
17956 -- set rounding class
17957 --
17958 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
17959 'RECEIVABLE';
17960
17961 --
17962 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
17963 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
17964 --
17965 -- bulk performance
17966 --
17967 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
17968
17969 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
17970 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
17971
17972 -- 4955764
17973 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
17977
17974 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
17975
17976 -- 4458381 Public Sector Enh
17978 --
17979 -- set accounting attributes for the line type
17980 --
17981 l_entered_amt_idx := 3;
17982 l_accted_amt_idx := 8;
17983 l_bflow_applied_to_amt_idx := NULL; -- 5132302
17984 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
17985 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
17986 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
17987 l_rec_acct_attrs.array_char_value(2) := p_source_35;
17988 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
17989 l_rec_acct_attrs.array_num_value(3) := p_source_36;
17990 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
17991 l_rec_acct_attrs.array_char_value(4) := p_source_37;
17992 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
17993 l_rec_acct_attrs.array_date_value(5) := p_source_38;
17994 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
17995 l_rec_acct_attrs.array_num_value(6) := p_source_39;
17996 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
17997 l_rec_acct_attrs.array_char_value(7) := p_source_40;
17998 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
17999 l_rec_acct_attrs.array_num_value(8) := p_source_41;
18000 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
18001 l_rec_acct_attrs.array_num_value(9) := p_source_30;
18002 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
18003 l_rec_acct_attrs.array_num_value(10) := p_source_31;
18004 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
18005 l_rec_acct_attrs.array_char_value(11) := p_source_32;
18006
18007 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
18008 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
18009
18010 ---------------------------------------------------------------------------------------------------------------
18011 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
18012 ---------------------------------------------------------------------------------------------------------------
18013 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
18014
18015 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18016 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18017
18018 IF xla_accounting_cache_pkg.GetValueChar
18019 (p_source_code => 'LEDGER_CATEGORY_CODE'
18020 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
18021 AND l_bflow_method_code = 'PRIOR_ENTRY'
18022 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
18023 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
18024 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
18025 )
18026 THEN
18027 xla_ae_lines_pkg.BflowUpgEntry
18028 (p_business_method_code => l_bflow_method_code
18029 ,p_business_class_code => l_bflow_class_code
18030 ,p_balance_type => l_balance_type_code);
18031 ELSE
18032 NULL;
18033 -- No business flow processing for business flow method of NONE.
18034 END IF;
18035
18036 --
18037 -- call analytical criteria
18038 --
18039
18040 --
18041 -- call description
18042 --
18043 -- No description or it is inherited.
18044 --
18045 -- call ADRs
18046 -- Bug 4922099
18047 --
18048 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18049 (NVL(l_actual_upg_option, 'N') = 'O') OR
18050 (NVL(l_enc_upg_option, 'N') = 'O')
18051 )
18052 THEN
18053 NULL;
18054 --
18055 --
18056
18057 l_ccid := AcctDerRule_28(
18058 p_application_id => p_application_id
18059 , p_ae_header_id => l_ae_header_id
18060 , p_source_19 => p_source_19
18061 , x_transaction_coa_id => l_adr_transaction_coa_id
18062 , x_accounting_coa_id => l_adr_accounting_coa_id
18063 , x_value_type_code => l_adr_value_type_code
18064 , p_side => 'NA'
18065 );
18066
18067 xla_ae_lines_pkg.set_ccid(
18068 p_code_combination_id => l_ccid
18069 , p_value_type_code => l_adr_value_type_code
18070 , p_transaction_coa_id => l_adr_transaction_coa_id
18071 , p_accounting_coa_id => l_adr_accounting_coa_id
18072 , p_adr_code => 'TRX_DIST_CCID'
18073 , p_adr_type_code => 'S'
18074 , p_component_type => l_component_type
18075 , p_component_code => l_component_code
18076 , p_component_type_code => l_component_type_code
18077 , p_component_appl_id => l_component_appl_id
18078 , p_amb_context_code => l_amb_context_code
18079 , p_side => 'NA'
18080 );
18081
18082
18083 --
18084 --
18085 END IF;
18086 --
18087 -- Bug 4922099
18088 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
18089 (NVL(l_enc_upg_option, 'N') = 'O')
18090 ) AND
18091 (l_bflow_method_code = 'PRIOR_ENTRY')
18092 )
18093 THEN
18094 IF
18095 --
18096 1 = 2
18097 --
18098 THEN
18099 xla_accounting_err_pkg.build_message
18103 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
18100 (p_appli_s_name => 'XLA'
18101 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18102 ,p_token_1 => 'LINE_NUMBER'
18104 ,p_token_2 => 'LINE_TYPE_NAME'
18105 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
18106 l_component_type
18107 ,l_component_code
18108 ,l_component_type_code
18109 ,l_component_appl_id
18110 ,l_amb_context_code
18111 ,l_entity_code
18112 ,l_event_class_code
18113 )
18114 ,p_token_3 => 'OWNER'
18115 ,p_value_3 => xla_lookups_pkg.get_meaning(
18116 p_lookup_type => 'XLA_OWNER_TYPE'
18117 ,p_lookup_code => l_component_type_code
18118 )
18119 ,p_token_4 => 'PRODUCT_NAME'
18120 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
18121 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
18122 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
18123 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
18124 ,p_ae_header_id => NULL
18125 );
18126
18127 IF (C_LEVEL_ERROR>= g_log_level) THEN
18128 trace
18129 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18130 ,p_level => C_LEVEL_ERROR
18131 ,p_module => l_log_module);
18132 END IF;
18133 END IF;
18134 END IF;
18135 --
18136 --
18137 ------------------------------------------------------------------------------------------------
18138 -- 4219869 Business Flow
18139 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
18140 -- Prior Entry. Currently, the following code is always generated.
18141 ------------------------------------------------------------------------------------------------
18142 XLA_AE_LINES_PKG.ValidateCurrentLine;
18143
18144 ------------------------------------------------------------------------------------
18145 -- 4219869 Business Flow
18146 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
18147 ------------------------------------------------------------------------------------
18148 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18149
18150 ----------------------------------------------------------------------------------
18151 -- 4219869 Business Flow
18152 -- Update journal entry status -- Need to generate this within IF <condition>
18153 ----------------------------------------------------------------------------------
18154 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18155 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
18156 ,p_balance_type_code => l_balance_type_code
18157 );
18158
18159 -------------------------------------------------------------------------------------------
18160 -- 4262811 - Generate the Accrual Reversal lines
18161 -------------------------------------------------------------------------------------------
18162 BEGIN
18163 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
18164 (g_array_event(p_event_id).array_value_num('header_index'));
18165 IF l_acc_rev_flag IS NULL THEN
18166 l_acc_rev_flag := 'N';
18167 END IF;
18168 EXCEPTION
18169 WHEN OTHERS THEN
18170 l_acc_rev_flag := 'N';
18171 END;
18172 --
18173 IF (l_acc_rev_flag = 'Y') THEN
18174
18175 -- 4645092 ------------------------------------------------------------------------------
18176 -- To allow MPA report to determine if it should generate report process
18177 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
18178 ------------------------------------------------------------------------------------------
18179
18180 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
18181 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
18182 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
18183 -- call ADRs
18184 -- Bug 4922099
18185 --
18186 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18187 (NVL(l_actual_upg_option, 'N') = 'O') OR
18188 (NVL(l_enc_upg_option, 'N') = 'O')
18189 )
18190 THEN
18191 NULL;
18195 l_ccid := AcctDerRule_28(
18192 --
18193 --
18194
18196 p_application_id => p_application_id
18197 , p_ae_header_id => l_ae_header_id
18198 , p_source_19 => p_source_19
18199 , x_transaction_coa_id => l_adr_transaction_coa_id
18200 , x_accounting_coa_id => l_adr_accounting_coa_id
18201 , x_value_type_code => l_adr_value_type_code
18202 , p_side => 'NA'
18203 );
18204
18205 xla_ae_lines_pkg.set_ccid(
18206 p_code_combination_id => l_ccid
18207 , p_value_type_code => l_adr_value_type_code
18208 , p_transaction_coa_id => l_adr_transaction_coa_id
18209 , p_accounting_coa_id => l_adr_accounting_coa_id
18210 , p_adr_code => 'TRX_DIST_CCID'
18211 , p_adr_type_code => 'S'
18212 , p_component_type => l_component_type
18213 , p_component_code => l_component_code
18214 , p_component_type_code => l_component_type_code
18215 , p_component_appl_id => l_component_appl_id
18216 , p_amb_context_code => l_amb_context_code
18217 , p_side => 'NA'
18218 );
18219
18220
18221 --
18222 --
18223 END IF;
18224
18225 --
18226 -- Update the line information that should be overwritten
18227 --
18228 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
18229 p_header_num => 1);
18230 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
18231
18232 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
18233
18234 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
18235 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
18236 END IF;
18237
18238 --
18239 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
18240 --
18241 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
18242 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
18243 ELSE
18244 ---------------------------------------------------------------------------------------------------
18245 -- 4262811a Switch Sign
18246 ---------------------------------------------------------------------------------------------------
18247 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
18248 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18249 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18250 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18251 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18252 -- 5132302
18253 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
18254 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18255
18256 END IF;
18257
18258 -- 4955764
18259 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18260 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
18261
18262
18263 XLA_AE_LINES_PKG.ValidateCurrentLine;
18264 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18265
18266 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18267 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
18268 ,p_balance_type_code => l_balance_type_code);
18269
18270 END IF;
18271
18272 -----------------------------------------------------------------------------------------
18273 -- 4262811 Multiperiod Accounting
18274 -----------------------------------------------------------------------------------------
18275 -- No MPA option is assigned.
18276
18277
18278 END IF;
18279 END IF;
18280 --
18281
18282 --
18283 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18284 trace
18285 (p_msg => 'END of AcctLineType_53'
18286 ,p_level => C_LEVEL_PROCEDURE
18287 ,p_module => l_log_module);
18288 END IF;
18289 --
18290 EXCEPTION
18291 WHEN xla_exceptions_pkg.application_exception THEN
18292 RAISE;
18293 WHEN OTHERS THEN
18294 xla_exceptions_pkg.raise_message
18295 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_53');
18296 END AcctLineType_53;
18297 --
18298
18299 ---------------------------------------
18300 --
18301 -- PRIVATE FUNCTION
18302 -- AcctLineType_54
18303 --
18304 ---------------------------------------
18305 PROCEDURE AcctLineType_54 (
18306 p_application_id IN NUMBER
18307 ,p_event_id IN NUMBER
18308 ,p_calculate_acctd_flag IN VARCHAR2
18309 ,p_calculate_g_l_flag IN VARCHAR2
18310 ,p_actual_flag IN OUT VARCHAR2
18311 ,p_balance_type_code OUT VARCHAR2
18312 ,p_gain_or_loss_ref OUT VARCHAR2
18313
18317 , p_source_30 IN NUMBER
18314 --Transaction Distribution GL Account
18315 , p_source_19 IN NUMBER
18316 --Bill To Customer Account Identifier
18318 --Bill To Customer Site Use Identifier
18319 , p_source_31 IN NUMBER
18320 --SLA Party Type
18321 , p_source_32 IN VARCHAR2
18322 --Transaction Distribution Account Class
18323 , p_source_33 IN VARCHAR2
18324 --Transaction Distribution Identifier
18325 , p_source_34 IN NUMBER
18326 --Transaction Distribution Type
18327 , p_source_35 IN VARCHAR2
18328 --Transaction Distribution Entered Amount
18329 , p_source_36 IN NUMBER
18330 --Transaction Currency Code
18331 , p_source_37 IN VARCHAR2
18332 --Transaction Exchange Date
18333 , p_source_38 IN DATE
18334 --Transaction Exchange Rate
18335 , p_source_39 IN NUMBER
18336 --Transaction Exchange Rate Type
18337 , p_source_40 IN VARCHAR2
18338 --Transaction Accounting Amount
18339 , p_source_41 IN NUMBER
18340 )
18341 IS
18342
18346 l_component_appl_id INTEGER;
18343 l_component_type VARCHAR2(80);
18344 l_component_code VARCHAR2(30);
18345 l_component_type_code VARCHAR2(1);
18347 l_amb_context_code VARCHAR2(30);
18348 l_entity_code VARCHAR2(30);
18349 l_event_class_code VARCHAR2(30);
18350 l_ae_header_id NUMBER;
18351 l_event_type_code VARCHAR2(30);
18352 l_line_definition_code VARCHAR2(30);
18353 l_line_definition_owner_code VARCHAR2(1);
18354 --
18355 -- adr variables
18356 l_segment VARCHAR2(30);
18357 l_ccid NUMBER;
18358 l_adr_transaction_coa_id NUMBER;
18359 l_adr_accounting_coa_id NUMBER;
18360 l_adr_flexfield_segment_code VARCHAR2(30);
18361 l_adr_flex_value_set_id NUMBER;
18362 l_adr_value_type_code VARCHAR2(30);
18363 l_adr_value_combination_id NUMBER;
18364 l_adr_value_segment_code VARCHAR2(30);
18365
18366 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
18367 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
18368 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
18369 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
18370
18371 -- 4262811 Variables ------------------------------------------------------------------------------------------
18372 l_entered_amt_idx NUMBER;
18373 l_accted_amt_idx NUMBER;
18374 l_acc_rev_flag VARCHAR2(1);
18375 l_accrual_line_num NUMBER;
18376 l_tmp_amt NUMBER;
18377 l_acc_rev_natural_side_code VARCHAR2(1);
18378
18379 l_num_entries NUMBER;
18380 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
18381 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
18382 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
18383 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
18384 l_recog_line_1 NUMBER;
18385 l_recog_line_2 NUMBER;
18386
18387 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
18388 l_bflow_applied_to_amt NUMBER; -- 5132302
18389 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
18390
18391 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
18392
18393 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
18394 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
18395
18396 ---------------------------------------------------------------------------------------------------------------
18397
18398
18399 --
18400 -- bulk performance
18401 --
18402 l_balance_type_code VARCHAR2(1);
18403 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
18404 l_log_module VARCHAR2(240);
18405
18406 --
18407 -- Upgrade strategy
18408 --
18409 l_actual_upg_option VARCHAR2(1);
18410 l_enc_upg_option VARCHAR2(1);
18411
18412 --
18413 BEGIN
18414 --
18415 IF g_log_enabled THEN
18416 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_54';
18417 END IF;
18418 --
18419 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18420
18421 trace
18425
18422 (p_msg => 'BEGIN of AcctLineType_54'
18423 ,p_level => C_LEVEL_PROCEDURE
18424 ,p_module => l_log_module);
18426 END IF;
18427 --
18428 l_component_type := 'AMB_JLT';
18429 l_component_code := 'DEP_OFFSET';
18430 l_component_type_code := 'S';
18431 l_component_appl_id := 222;
18432 l_amb_context_code := 'DEFAULT';
18433 l_entity_code := 'TRANSACTIONS';
18434 l_event_class_code := 'DEPOSIT';
18435 l_event_type_code := 'DEPOSIT_ALL';
18436 l_line_definition_owner_code := 'S';
18437 l_line_definition_code := 'AR_DEP_DEFAULT_ACCRUAL';
18438 --
18439 l_balance_type_code := 'A';
18440 l_segment := NULL;
18441 l_ccid := NULL;
18442 l_adr_transaction_coa_id := NULL;
18443 l_adr_accounting_coa_id := NULL;
18444 l_adr_flexfield_segment_code := NULL;
18445 l_adr_flex_value_set_id := NULL;
18446 l_adr_value_type_code := NULL;
18447 l_adr_value_combination_id := NULL;
18448 l_adr_value_segment_code := NULL;
18449
18450 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
18451 l_bflow_class_code := ''; -- 4219869 Business Flow
18452 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
18453 l_budgetary_control_flag := 'N';
18454
18455 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18456 l_bflow_applied_to_amt := NULL; -- 5132302
18457 l_entered_amt_idx := NULL; -- 4262811
18458 l_accted_amt_idx := NULL; -- 4262811
18459 l_acc_rev_flag := NULL; -- 4262811
18460 l_accrual_line_num := NULL; -- 4262811
18461 l_tmp_amt := NULL; -- 4262811
18462 --
18463
18464 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
18465 l_balance_type_code <> 'B' THEN
18466 IF NVL(p_source_33,'
18467 ') = 'REV'
18468 THEN
18469
18470 --
18471 XLA_AE_LINES_PKG.SetNewLine;
18472
18473 p_balance_type_code := l_balance_type_code;
18474 -- set the flag so later we will know whether the gain loss line needs to be created
18475
18476 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
18477 p_actual_flag :='A';
18478 END IF;
18479
18480 --
18481 -- bulk performance
18482 --
18483 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
18484 p_header_num => 0); -- 4262811
18485 --
18486 -- set accounting line options
18487 --
18488 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
18489 p_natural_side_code => 'C'
18490 , p_gain_or_loss_flag => 'N'
18491 , p_gl_transfer_mode_code => 'S'
18492 , p_acct_entry_type_code => 'A'
18493 , p_switch_side_flag => 'Y'
18494 , p_merge_duplicate_code => 'A'
18495 );
18496 --
18497 l_acc_rev_natural_side_code := 'D'; -- 4262811
18498 --
18499 --
18500 -- set accounting line type info
18501 --
18502 xla_ae_lines_pkg.SetAcctLineType
18503 (p_component_type => l_component_type
18504 ,p_event_type_code => l_event_type_code
18505 ,p_line_definition_owner_code => l_line_definition_owner_code
18506 ,p_line_definition_code => l_line_definition_code
18507 ,p_accounting_line_code => l_component_code
18511 ,p_entity_code => l_entity_code
18508 ,p_accounting_line_type_code => l_component_type_code
18509 ,p_accounting_line_appl_id => l_component_appl_id
18510 ,p_amb_context_code => l_amb_context_code
18512 ,p_event_class_code => l_event_class_code);
18513 --
18514 -- set accounting class
18515 --
18516 xla_ae_lines_pkg.SetAcctClass(
18517 p_accounting_class_code => 'ACCRUAL'
18518 , p_ae_header_id => l_ae_header_id
18519 );
18520
18521 --
18522 -- set rounding class
18523 --
18524 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
18525 'RECEIVABLE';
18526
18527 --
18528 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
18529 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
18530 --
18531 -- bulk performance
18532 --
18533 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
18534
18535 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
18536 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
18537
18538 -- 4955764
18539 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18540 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
18541
18542 -- 4458381 Public Sector Enh
18543
18544 --
18545 -- set accounting attributes for the line type
18546 --
18547 l_entered_amt_idx := 3;
18548 l_accted_amt_idx := 8;
18549 l_bflow_applied_to_amt_idx := NULL; -- 5132302
18550 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
18551 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
18552 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
18553 l_rec_acct_attrs.array_char_value(2) := p_source_35;
18554 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
18555 l_rec_acct_attrs.array_num_value(3) := p_source_36;
18556 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
18557 l_rec_acct_attrs.array_char_value(4) := p_source_37;
18558 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
18559 l_rec_acct_attrs.array_date_value(5) := p_source_38;
18560 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
18561 l_rec_acct_attrs.array_num_value(6) := p_source_39;
18562 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
18563 l_rec_acct_attrs.array_char_value(7) := p_source_40;
18564 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
18565 l_rec_acct_attrs.array_num_value(8) := p_source_41;
18566 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
18567 l_rec_acct_attrs.array_num_value(9) := p_source_30;
18568 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
18569 l_rec_acct_attrs.array_num_value(10) := p_source_31;
18570 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
18571 l_rec_acct_attrs.array_char_value(11) := p_source_32;
18572
18573 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
18574 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
18575
18576 ---------------------------------------------------------------------------------------------------------------
18577 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
18578 ---------------------------------------------------------------------------------------------------------------
18579 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
18580
18581 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18582 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
18583
18584 IF xla_accounting_cache_pkg.GetValueChar
18585 (p_source_code => 'LEDGER_CATEGORY_CODE'
18586 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
18587 AND l_bflow_method_code = 'PRIOR_ENTRY'
18588 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
18589 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
18590 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
18591 )
18592 THEN
18593 xla_ae_lines_pkg.BflowUpgEntry
18594 (p_business_method_code => l_bflow_method_code
18595 ,p_business_class_code => l_bflow_class_code
18596 ,p_balance_type => l_balance_type_code);
18597 ELSE
18598 NULL;
18599 -- No business flow processing for business flow method of NONE.
18600 END IF;
18601
18602 --
18603 -- call analytical criteria
18604 --
18605
18606 --
18607 -- call description
18608 --
18609 -- No description or it is inherited.
18610 --
18611 -- call ADRs
18612 -- Bug 4922099
18613 --
18614 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18615 (NVL(l_actual_upg_option, 'N') = 'O') OR
18616 (NVL(l_enc_upg_option, 'N') = 'O')
18617 )
18618 THEN
18619 NULL;
18620 --
18621 --
18622
18623 l_ccid := AcctDerRule_28(
18624 p_application_id => p_application_id
18625 , p_ae_header_id => l_ae_header_id
18626 , p_source_19 => p_source_19
18627 , x_transaction_coa_id => l_adr_transaction_coa_id
18628 , x_accounting_coa_id => l_adr_accounting_coa_id
18629 , x_value_type_code => l_adr_value_type_code
18630 , p_side => 'NA'
18631 );
18632
18633 xla_ae_lines_pkg.set_ccid(
18634 p_code_combination_id => l_ccid
18635 , p_value_type_code => l_adr_value_type_code
18636 , p_transaction_coa_id => l_adr_transaction_coa_id
18637 , p_accounting_coa_id => l_adr_accounting_coa_id
18638 , p_adr_code => 'TRX_DIST_CCID'
18639 , p_adr_type_code => 'S'
18640 , p_component_type => l_component_type
18644 , p_amb_context_code => l_amb_context_code
18641 , p_component_code => l_component_code
18642 , p_component_type_code => l_component_type_code
18643 , p_component_appl_id => l_component_appl_id
18645 , p_side => 'NA'
18646 );
18647
18648
18649 --
18650 --
18651 END IF;
18652 --
18653 -- Bug 4922099
18654 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
18655 (NVL(l_enc_upg_option, 'N') = 'O')
18656 ) AND
18657 (l_bflow_method_code = 'PRIOR_ENTRY')
18658 )
18659 THEN
18660 IF
18661 --
18662 1 = 2
18663 --
18664 THEN
18665 xla_accounting_err_pkg.build_message
18666 (p_appli_s_name => 'XLA'
18667 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18668 ,p_token_1 => 'LINE_NUMBER'
18669 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
18670 ,p_token_2 => 'LINE_TYPE_NAME'
18671 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
18672 l_component_type
18673 ,l_component_code
18674 ,l_component_type_code
18675 ,l_component_appl_id
18676 ,l_amb_context_code
18677 ,l_entity_code
18678 ,l_event_class_code
18679 )
18680 ,p_token_3 => 'OWNER'
18681 ,p_value_3 => xla_lookups_pkg.get_meaning(
18682 p_lookup_type => 'XLA_OWNER_TYPE'
18683 ,p_lookup_code => l_component_type_code
18684 )
18685 ,p_token_4 => 'PRODUCT_NAME'
18686 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
18687 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
18688 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
18689 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
18690 ,p_ae_header_id => NULL
18691 );
18692
18693 IF (C_LEVEL_ERROR>= g_log_level) THEN
18694 trace
18695 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
18696 ,p_level => C_LEVEL_ERROR
18697 ,p_module => l_log_module);
18698 END IF;
18699 END IF;
18700 END IF;
18701 --
18702 --
18703 ------------------------------------------------------------------------------------------------
18704 -- 4219869 Business Flow
18705 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
18706 -- Prior Entry. Currently, the following code is always generated.
18707 ------------------------------------------------------------------------------------------------
18708 XLA_AE_LINES_PKG.ValidateCurrentLine;
18709
18710 ------------------------------------------------------------------------------------
18711 -- 4219869 Business Flow
18712 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
18713 ------------------------------------------------------------------------------------
18714 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18715
18716 ----------------------------------------------------------------------------------
18717 -- 4219869 Business Flow
18718 -- Update journal entry status -- Need to generate this within IF <condition>
18719 ----------------------------------------------------------------------------------
18720 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18721 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
18722 ,p_balance_type_code => l_balance_type_code
18723 );
18724
18725 -------------------------------------------------------------------------------------------
18726 -- 4262811 - Generate the Accrual Reversal lines
18727 -------------------------------------------------------------------------------------------
18728 BEGIN
18729 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
18730 (g_array_event(p_event_id).array_value_num('header_index'));
18731 IF l_acc_rev_flag IS NULL THEN
18732 l_acc_rev_flag := 'N';
18733 END IF;
18734 EXCEPTION
18735 WHEN OTHERS THEN
18736 l_acc_rev_flag := 'N';
18737 END;
18738 --
18739 IF (l_acc_rev_flag = 'Y') THEN
18740
18741 -- 4645092 ------------------------------------------------------------------------------
18742 -- To allow MPA report to determine if it should generate report process
18743 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
18744 ------------------------------------------------------------------------------------------
18745
18746 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
18747 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
18748 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
18749 -- call ADRs
18750 -- Bug 4922099
18751 --
18752 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
18753 (NVL(l_actual_upg_option, 'N') = 'O') OR
18754 (NVL(l_enc_upg_option, 'N') = 'O')
18755 )
18756 THEN
18757 NULL;
18758 --
18759 --
18760
18761 l_ccid := AcctDerRule_28(
18762 p_application_id => p_application_id
18763 , p_ae_header_id => l_ae_header_id
18764 , p_source_19 => p_source_19
18765 , x_transaction_coa_id => l_adr_transaction_coa_id
18766 , x_accounting_coa_id => l_adr_accounting_coa_id
18767 , x_value_type_code => l_adr_value_type_code
18768 , p_side => 'NA'
18769 );
18770
18771 xla_ae_lines_pkg.set_ccid(
18772 p_code_combination_id => l_ccid
18773 , p_value_type_code => l_adr_value_type_code
18774 , p_transaction_coa_id => l_adr_transaction_coa_id
18775 , p_accounting_coa_id => l_adr_accounting_coa_id
18776 , p_adr_code => 'TRX_DIST_CCID'
18777 , p_adr_type_code => 'S'
18778 , p_component_type => l_component_type
18779 , p_component_code => l_component_code
18780 , p_component_type_code => l_component_type_code
18781 , p_component_appl_id => l_component_appl_id
18782 , p_amb_context_code => l_amb_context_code
18783 , p_side => 'NA'
18784 );
18785
18786
18787 --
18788 --
18789 END IF;
18790
18791 --
18792 -- Update the line information that should be overwritten
18793 --
18794 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
18795 p_header_num => 1);
18796 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
18797
18798 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
18799
18800 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
18801 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
18802 END IF;
18803
18804 --
18805 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
18806 --
18807 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
18808 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
18809 ELSE
18810 ---------------------------------------------------------------------------------------------------
18811 -- 4262811a Switch Sign
18812 ---------------------------------------------------------------------------------------------------
18813 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
18814 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18815 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18816 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
18817 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18818 -- 5132302
18819 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
18823
18820 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
18821
18822 END IF;
18824 -- 4955764
18825 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
18826 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
18827
18828
18829 XLA_AE_LINES_PKG.ValidateCurrentLine;
18830 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
18831
18832 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
18833 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
18834 ,p_balance_type_code => l_balance_type_code);
18835
18836 END IF;
18837
18838 -----------------------------------------------------------------------------------------
18839 -- 4262811 Multiperiod Accounting
18840 -----------------------------------------------------------------------------------------
18841 -- No MPA option is assigned.
18842
18843
18844 END IF;
18845 END IF;
18846 --
18847
18848 --
18849 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18850 trace
18851 (p_msg => 'END of AcctLineType_54'
18852 ,p_level => C_LEVEL_PROCEDURE
18853 ,p_module => l_log_module);
18854 END IF;
18855 --
18856 EXCEPTION
18857 WHEN xla_exceptions_pkg.application_exception THEN
18858 RAISE;
18859 WHEN OTHERS THEN
18860 xla_exceptions_pkg.raise_message
18861 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_54');
18862 END AcctLineType_54;
18863 --
18864
18865 ---------------------------------------
18866 --
18867 -- PRIVATE FUNCTION
18868 -- AcctLineType_55
18869 --
18870 ---------------------------------------
18871 PROCEDURE AcctLineType_55 (
18872 p_application_id IN NUMBER
18873 ,p_event_id IN NUMBER
18874 ,p_calculate_acctd_flag IN VARCHAR2
18875 ,p_calculate_g_l_flag IN VARCHAR2
18876 ,p_actual_flag IN OUT VARCHAR2
18877 ,p_balance_type_code OUT VARCHAR2
18878 ,p_gain_or_loss_ref OUT VARCHAR2
18879
18880 --Transaction Distribution GL Account
18881 , p_source_19 IN NUMBER
18882 --Bill To Customer Account Identifier
18883 , p_source_30 IN NUMBER
18884 --Bill To Customer Site Use Identifier
18885 , p_source_31 IN NUMBER
18886 --SLA Party Type
18887 , p_source_32 IN VARCHAR2
18888 --Transaction Distribution Account Class
18889 , p_source_33 IN VARCHAR2
18890 --Transaction Distribution Identifier
18891 , p_source_34 IN NUMBER
18892 --Transaction Distribution Type
18893 , p_source_35 IN VARCHAR2
18894 --Transaction Distribution Entered Amount
18895 , p_source_36 IN NUMBER
18896 --Transaction Currency Code
18897 , p_source_37 IN VARCHAR2
18898 --Transaction Exchange Date
18899 , p_source_38 IN DATE
18900 --Transaction Exchange Rate
18901 , p_source_39 IN NUMBER
18902 --Transaction Exchange Rate Type
18903 , p_source_40 IN VARCHAR2
18904 --Transaction Accounting Amount
18905 , p_source_41 IN NUMBER
18906 --Transaction Tax Line Identifier
18907 , p_source_55 IN NUMBER
18908 )
18909 IS
18910
18911 l_component_type VARCHAR2(80);
18912 l_component_code VARCHAR2(30);
18913 l_component_type_code VARCHAR2(1);
18914 l_component_appl_id INTEGER;
18915 l_amb_context_code VARCHAR2(30);
18916 l_entity_code VARCHAR2(30);
18917 l_event_class_code VARCHAR2(30);
18918 l_ae_header_id NUMBER;
18919 l_event_type_code VARCHAR2(30);
18920 l_line_definition_code VARCHAR2(30);
18921 l_line_definition_owner_code VARCHAR2(1);
18922 --
18923 -- adr variables
18924 l_segment VARCHAR2(30);
18925 l_ccid NUMBER;
18926 l_adr_transaction_coa_id NUMBER;
18927 l_adr_accounting_coa_id NUMBER;
18928 l_adr_flexfield_segment_code VARCHAR2(30);
18929 l_adr_flex_value_set_id NUMBER;
18930 l_adr_value_type_code VARCHAR2(30);
18931 l_adr_value_combination_id NUMBER;
18932 l_adr_value_segment_code VARCHAR2(30);
18933
18934 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
18935 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
18936 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
18937 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
18938
18939 -- 4262811 Variables ------------------------------------------------------------------------------------------
18940 l_entered_amt_idx NUMBER;
18941 l_accted_amt_idx NUMBER;
18942 l_acc_rev_flag VARCHAR2(1);
18943 l_accrual_line_num NUMBER;
18944 l_tmp_amt NUMBER;
18945 l_acc_rev_natural_side_code VARCHAR2(1);
18946
18947 l_num_entries NUMBER;
18948 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
18949 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
18950 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
18951 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
18952 l_recog_line_1 NUMBER;
18953 l_recog_line_2 NUMBER;
18954
18955 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
18956 l_bflow_applied_to_amt NUMBER; -- 5132302
18957 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
18958
18962 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
18959 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
18960
18961 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
18963
18964 ---------------------------------------------------------------------------------------------------------------
18965
18966
18967 --
18968 -- bulk performance
18969 --
18970 l_balance_type_code VARCHAR2(1);
18971 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
18972 l_log_module VARCHAR2(240);
18973
18974 --
18975 -- Upgrade strategy
18976 --
18977 l_actual_upg_option VARCHAR2(1);
18978 l_enc_upg_option VARCHAR2(1);
18979
18980 --
18981 BEGIN
18982 --
18983 IF g_log_enabled THEN
18984 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_55';
18985 END IF;
18986 --
18987 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18988
18989 trace
18990 (p_msg => 'BEGIN of AcctLineType_55'
18991 ,p_level => C_LEVEL_PROCEDURE
18992 ,p_module => l_log_module);
18993
18994 END IF;
18995 --
18996 l_component_type := 'AMB_JLT';
18997 l_component_code := 'DM_CHARGES';
18998 l_component_type_code := 'S';
18999 l_component_appl_id := 222;
19000 l_amb_context_code := 'DEFAULT';
19001 l_entity_code := 'TRANSACTIONS';
19002 l_event_class_code := 'DEBIT_MEMO';
19003 l_event_type_code := 'DEBIT_MEMO_ALL';
19004 l_line_definition_owner_code := 'S';
19005 l_line_definition_code := 'AR_DM_DEFAULT_ACCRUAL';
19006 --
19007 l_balance_type_code := 'A';
19008 l_segment := NULL;
19009 l_ccid := NULL;
19010 l_adr_transaction_coa_id := NULL;
19011 l_adr_accounting_coa_id := NULL;
19012 l_adr_flexfield_segment_code := NULL;
19013 l_adr_flex_value_set_id := NULL;
19014 l_adr_value_type_code := NULL;
19015 l_adr_value_combination_id := NULL;
19016 l_adr_value_segment_code := NULL;
19017
19018 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
19019 l_bflow_class_code := ''; -- 4219869 Business Flow
19020 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
19021 l_budgetary_control_flag := 'N';
19022
19023 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19024 l_bflow_applied_to_amt := NULL; -- 5132302
19025 l_entered_amt_idx := NULL; -- 4262811
19026 l_accted_amt_idx := NULL; -- 4262811
19027 l_acc_rev_flag := NULL; -- 4262811
19028 l_accrual_line_num := NULL; -- 4262811
19029 l_tmp_amt := NULL; -- 4262811
19030 --
19031
19032 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
19033 l_balance_type_code <> 'B' THEN
19034 IF NVL(p_source_33,'
19035 ') = 'CHARGES'
19036 THEN
19037
19038 --
19039 XLA_AE_LINES_PKG.SetNewLine;
19040
19041 p_balance_type_code := l_balance_type_code;
19042 -- set the flag so later we will know whether the gain loss line needs to be created
19043
19044 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
19045 p_actual_flag :='A';
19046 END IF;
19047
19048 --
19049 -- bulk performance
19050 --
19051 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
19052 p_header_num => 0); -- 4262811
19053 --
19054 -- set accounting line options
19055 --
19056 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
19057 p_natural_side_code => 'C'
19058 , p_gain_or_loss_flag => 'N'
19059 , p_gl_transfer_mode_code => 'S'
19060 , p_acct_entry_type_code => 'A'
19061 , p_switch_side_flag => 'Y'
19062 , p_merge_duplicate_code => 'A'
19063 );
19064 --
19065 l_acc_rev_natural_side_code := 'D'; -- 4262811
19066 --
19067 --
19068 -- set accounting line type info
19069 --
19070 xla_ae_lines_pkg.SetAcctLineType
19071 (p_component_type => l_component_type
19072 ,p_event_type_code => l_event_type_code
19073 ,p_line_definition_owner_code => l_line_definition_owner_code
19074 ,p_line_definition_code => l_line_definition_code
19075 ,p_accounting_line_code => l_component_code
19076 ,p_accounting_line_type_code => l_component_type_code
19077 ,p_accounting_line_appl_id => l_component_appl_id
19078 ,p_amb_context_code => l_amb_context_code
19079 ,p_entity_code => l_entity_code
19080 ,p_event_class_code => l_event_class_code);
19081 --
19082 -- set accounting class
19083 --
19084 xla_ae_lines_pkg.SetAcctClass(
19085 p_accounting_class_code => 'CHARGES'
19086 , p_ae_header_id => l_ae_header_id
19087 );
19088
19089 --
19090 -- set rounding class
19091 --
19092 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
19093 'RECEIVABLE';
19094
19095 --
19096 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
19097 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
19098 --
19099 -- bulk performance
19100 --
19104 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
19101 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
19102
19103 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
19105
19106 -- 4955764
19107 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19108 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
19109
19110 -- 4458381 Public Sector Enh
19111
19112 --
19113 -- set accounting attributes for the line type
19114 --
19115 l_entered_amt_idx := 3;
19116 l_accted_amt_idx := 8;
19117 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19118 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
19119 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
19120 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
19121 l_rec_acct_attrs.array_char_value(2) := p_source_35;
19122 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
19123 l_rec_acct_attrs.array_num_value(3) := p_source_36;
19124 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
19125 l_rec_acct_attrs.array_char_value(4) := p_source_37;
19126 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
19127 l_rec_acct_attrs.array_date_value(5) := p_source_38;
19128 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
19129 l_rec_acct_attrs.array_num_value(6) := p_source_39;
19130 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
19131 l_rec_acct_attrs.array_char_value(7) := p_source_40;
19132 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
19133 l_rec_acct_attrs.array_num_value(8) := p_source_41;
19134 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
19135 l_rec_acct_attrs.array_num_value(9) := p_source_30;
19136 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
19137 l_rec_acct_attrs.array_num_value(10) := p_source_31;
19138 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
19139 l_rec_acct_attrs.array_char_value(11) := p_source_32;
19140 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
19141 l_rec_acct_attrs.array_num_value(12) := p_source_55;
19142
19143 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
19144 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
19145
19146 ---------------------------------------------------------------------------------------------------------------
19147 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
19148 ---------------------------------------------------------------------------------------------------------------
19149 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
19150
19151 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19152 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19153
19154 IF xla_accounting_cache_pkg.GetValueChar
19155 (p_source_code => 'LEDGER_CATEGORY_CODE'
19156 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
19157 AND l_bflow_method_code = 'PRIOR_ENTRY'
19158 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
19159 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
19160 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
19161 )
19162 THEN
19163 xla_ae_lines_pkg.BflowUpgEntry
19164 (p_business_method_code => l_bflow_method_code
19165 ,p_business_class_code => l_bflow_class_code
19166 ,p_balance_type => l_balance_type_code);
19167 ELSE
19168 NULL;
19169 -- No business flow processing for business flow method of NONE.
19170 END IF;
19171
19172 --
19173 -- call analytical criteria
19174 --
19175
19176 --
19177 -- call description
19178 --
19179 -- No description or it is inherited.
19180 --
19181 -- call ADRs
19182 -- Bug 4922099
19183 --
19184 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19185 (NVL(l_actual_upg_option, 'N') = 'O') OR
19186 (NVL(l_enc_upg_option, 'N') = 'O')
19187 )
19188 THEN
19189 NULL;
19190 --
19191 --
19192
19193 l_ccid := AcctDerRule_28(
19194 p_application_id => p_application_id
19195 , p_ae_header_id => l_ae_header_id
19196 , p_source_19 => p_source_19
19197 , x_transaction_coa_id => l_adr_transaction_coa_id
19198 , x_accounting_coa_id => l_adr_accounting_coa_id
19199 , x_value_type_code => l_adr_value_type_code
19200 , p_side => 'NA'
19201 );
19202
19203 xla_ae_lines_pkg.set_ccid(
19204 p_code_combination_id => l_ccid
19205 , p_value_type_code => l_adr_value_type_code
19206 , p_transaction_coa_id => l_adr_transaction_coa_id
19207 , p_accounting_coa_id => l_adr_accounting_coa_id
19208 , p_adr_code => 'TRX_DIST_CCID'
19209 , p_adr_type_code => 'S'
19210 , p_component_type => l_component_type
19211 , p_component_code => l_component_code
19212 , p_component_type_code => l_component_type_code
19213 , p_component_appl_id => l_component_appl_id
19214 , p_amb_context_code => l_amb_context_code
19215 , p_side => 'NA'
19216 );
19217
19218
19219 --
19223 -- Bug 4922099
19220 --
19221 END IF;
19222 --
19224 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
19225 (NVL(l_enc_upg_option, 'N') = 'O')
19226 ) AND
19227 (l_bflow_method_code = 'PRIOR_ENTRY')
19228 )
19229 THEN
19230 IF
19231 --
19232 1 = 2
19233 --
19234 THEN
19235 xla_accounting_err_pkg.build_message
19236 (p_appli_s_name => 'XLA'
19237 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19238 ,p_token_1 => 'LINE_NUMBER'
19239 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
19240 ,p_token_2 => 'LINE_TYPE_NAME'
19241 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
19242 l_component_type
19243 ,l_component_code
19244 ,l_component_type_code
19245 ,l_component_appl_id
19246 ,l_amb_context_code
19247 ,l_entity_code
19248 ,l_event_class_code
19249 )
19250 ,p_token_3 => 'OWNER'
19251 ,p_value_3 => xla_lookups_pkg.get_meaning(
19252 p_lookup_type => 'XLA_OWNER_TYPE'
19253 ,p_lookup_code => l_component_type_code
19254 )
19255 ,p_token_4 => 'PRODUCT_NAME'
19256 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
19257 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
19258 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
19259 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
19260 ,p_ae_header_id => NULL
19261 );
19262
19263 IF (C_LEVEL_ERROR>= g_log_level) THEN
19264 trace
19265 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19266 ,p_level => C_LEVEL_ERROR
19267 ,p_module => l_log_module);
19268 END IF;
19269 END IF;
19270 END IF;
19271 --
19272 --
19273 ------------------------------------------------------------------------------------------------
19274 -- 4219869 Business Flow
19275 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
19276 -- Prior Entry. Currently, the following code is always generated.
19277 ------------------------------------------------------------------------------------------------
19278 XLA_AE_LINES_PKG.ValidateCurrentLine;
19279
19280 ------------------------------------------------------------------------------------
19281 -- 4219869 Business Flow
19282 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
19283 ------------------------------------------------------------------------------------
19284 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19285
19286 ----------------------------------------------------------------------------------
19287 -- 4219869 Business Flow
19288 -- Update journal entry status -- Need to generate this within IF <condition>
19289 ----------------------------------------------------------------------------------
19290 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19291 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
19292 ,p_balance_type_code => l_balance_type_code
19293 );
19294
19295 -------------------------------------------------------------------------------------------
19296 -- 4262811 - Generate the Accrual Reversal lines
19297 -------------------------------------------------------------------------------------------
19298 BEGIN
19299 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
19300 (g_array_event(p_event_id).array_value_num('header_index'));
19301 IF l_acc_rev_flag IS NULL THEN
19302 l_acc_rev_flag := 'N';
19303 END IF;
19304 EXCEPTION
19305 WHEN OTHERS THEN
19306 l_acc_rev_flag := 'N';
19307 END;
19308 --
19309 IF (l_acc_rev_flag = 'Y') THEN
19310
19311 -- 4645092 ------------------------------------------------------------------------------
19312 -- To allow MPA report to determine if it should generate report process
19313 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
19314 ------------------------------------------------------------------------------------------
19315
19316 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
19317 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
19318 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
19319 -- call ADRs
19320 -- Bug 4922099
19321 --
19322 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19323 (NVL(l_actual_upg_option, 'N') = 'O') OR
19324 (NVL(l_enc_upg_option, 'N') = 'O')
19325 )
19326 THEN
19327 NULL;
19328 --
19329 --
19330
19331 l_ccid := AcctDerRule_28(
19332 p_application_id => p_application_id
19333 , p_ae_header_id => l_ae_header_id
19334 , p_source_19 => p_source_19
19335 , x_transaction_coa_id => l_adr_transaction_coa_id
19336 , x_accounting_coa_id => l_adr_accounting_coa_id
19337 , x_value_type_code => l_adr_value_type_code
19338 , p_side => 'NA'
19339 );
19340
19341 xla_ae_lines_pkg.set_ccid(
19342 p_code_combination_id => l_ccid
19343 , p_value_type_code => l_adr_value_type_code
19344 , p_transaction_coa_id => l_adr_transaction_coa_id
19345 , p_accounting_coa_id => l_adr_accounting_coa_id
19346 , p_adr_code => 'TRX_DIST_CCID'
19347 , p_adr_type_code => 'S'
19348 , p_component_type => l_component_type
19349 , p_component_code => l_component_code
19350 , p_component_type_code => l_component_type_code
19351 , p_component_appl_id => l_component_appl_id
19352 , p_amb_context_code => l_amb_context_code
19353 , p_side => 'NA'
19354 );
19355
19356
19357 --
19358 --
19359 END IF;
19360
19361 --
19362 -- Update the line information that should be overwritten
19363 --
19364 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
19365 p_header_num => 1);
19366 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
19367
19368 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
19369
19370 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
19371 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
19372 END IF;
19373
19374 --
19375 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
19376 --
19377 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
19378 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
19379 ELSE
19380 ---------------------------------------------------------------------------------------------------
19381 -- 4262811a Switch Sign
19382 ---------------------------------------------------------------------------------------------------
19383 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
19384 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19385 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19386 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19387 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19388 -- 5132302
19389 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
19390 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19391
19392 END IF;
19393
19394 -- 4955764
19395 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19396 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
19397
19398
19399 XLA_AE_LINES_PKG.ValidateCurrentLine;
19403 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
19400 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19401
19402 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19404 ,p_balance_type_code => l_balance_type_code);
19405
19406 END IF;
19407
19408 -----------------------------------------------------------------------------------------
19409 -- 4262811 Multiperiod Accounting
19410 -----------------------------------------------------------------------------------------
19411 -- No MPA option is assigned.
19412
19413
19414 END IF;
19415 END IF;
19416 --
19417
19418 --
19419 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19420 trace
19421 (p_msg => 'END of AcctLineType_55'
19422 ,p_level => C_LEVEL_PROCEDURE
19423 ,p_module => l_log_module);
19424 END IF;
19425 --
19426 EXCEPTION
19427 WHEN xla_exceptions_pkg.application_exception THEN
19428 RAISE;
19429 WHEN OTHERS THEN
19430 xla_exceptions_pkg.raise_message
19431 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_55');
19432 END AcctLineType_55;
19433 --
19434
19435 ---------------------------------------
19436 --
19437 -- PRIVATE FUNCTION
19438 -- AcctLineType_56
19439 --
19440 ---------------------------------------
19441 PROCEDURE AcctLineType_56 (
19442 p_application_id IN NUMBER
19443 ,p_event_id IN NUMBER
19444 ,p_calculate_acctd_flag IN VARCHAR2
19445 ,p_calculate_g_l_flag IN VARCHAR2
19446 ,p_actual_flag IN OUT VARCHAR2
19447 ,p_balance_type_code OUT VARCHAR2
19448 ,p_gain_or_loss_ref OUT VARCHAR2
19449
19450 --Transaction Distribution GL Account
19451 , p_source_19 IN NUMBER
19452 --Bill To Customer Account Identifier
19453 , p_source_30 IN NUMBER
19454 --Bill To Customer Site Use Identifier
19455 , p_source_31 IN NUMBER
19456 --SLA Party Type
19457 , p_source_32 IN VARCHAR2
19458 --Transaction Distribution Account Class
19459 , p_source_33 IN VARCHAR2
19460 --Transaction Distribution Identifier
19461 , p_source_34 IN NUMBER
19462 --Transaction Distribution Type
19463 , p_source_35 IN VARCHAR2
19464 --Transaction Distribution Entered Amount
19465 , p_source_36 IN NUMBER
19466 --Transaction Currency Code
19467 , p_source_37 IN VARCHAR2
19468 --Transaction Exchange Date
19469 , p_source_38 IN DATE
19470 --Transaction Exchange Rate
19471 , p_source_39 IN NUMBER
19472 --Transaction Exchange Rate Type
19473 , p_source_40 IN VARCHAR2
19474 --Transaction Accounting Amount
19475 , p_source_41 IN NUMBER
19476 --Transaction Tax Line Identifier
19477 , p_source_55 IN NUMBER
19478 )
19479 IS
19480
19481 l_component_type VARCHAR2(80);
19482 l_component_code VARCHAR2(30);
19483 l_component_type_code VARCHAR2(1);
19484 l_component_appl_id INTEGER;
19485 l_amb_context_code VARCHAR2(30);
19486 l_entity_code VARCHAR2(30);
19487 l_event_class_code VARCHAR2(30);
19488 l_ae_header_id NUMBER;
19489 l_event_type_code VARCHAR2(30);
19490 l_line_definition_code VARCHAR2(30);
19491 l_line_definition_owner_code VARCHAR2(1);
19492 --
19493 -- adr variables
19494 l_segment VARCHAR2(30);
19495 l_ccid NUMBER;
19496 l_adr_transaction_coa_id NUMBER;
19497 l_adr_accounting_coa_id NUMBER;
19498 l_adr_flexfield_segment_code VARCHAR2(30);
19499 l_adr_flex_value_set_id NUMBER;
19500 l_adr_value_type_code VARCHAR2(30);
19501 l_adr_value_combination_id NUMBER;
19502 l_adr_value_segment_code VARCHAR2(30);
19503
19504 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
19505 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
19506 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
19507 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
19508
19509 -- 4262811 Variables ------------------------------------------------------------------------------------------
19510 l_entered_amt_idx NUMBER;
19511 l_accted_amt_idx NUMBER;
19512 l_acc_rev_flag VARCHAR2(1);
19513 l_accrual_line_num NUMBER;
19514 l_tmp_amt NUMBER;
19515 l_acc_rev_natural_side_code VARCHAR2(1);
19516
19517 l_num_entries NUMBER;
19518 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
19519 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
19520 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
19521 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
19522 l_recog_line_1 NUMBER;
19523 l_recog_line_2 NUMBER;
19524
19525 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
19526 l_bflow_applied_to_amt NUMBER; -- 5132302
19527 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
19528
19529 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
19530
19531 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
19532 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
19533
19534 ---------------------------------------------------------------------------------------------------------------
19535
19536
19537 --
19538 -- bulk performance
19539 --
19540 l_balance_type_code VARCHAR2(1);
19541 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
19542 l_log_module VARCHAR2(240);
19543
19544 --
19545 -- Upgrade strategy
19546 --
19547 l_actual_upg_option VARCHAR2(1);
19548 l_enc_upg_option VARCHAR2(1);
19549
19550 --
19551 BEGIN
19552 --
19553 IF g_log_enabled THEN
19554 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_56';
19555 END IF;
19556 --
19557 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19558
19559 trace
19560 (p_msg => 'BEGIN of AcctLineType_56'
19561 ,p_level => C_LEVEL_PROCEDURE
19562 ,p_module => l_log_module);
19563
19564 END IF;
19565 --
19566 l_component_type := 'AMB_JLT';
19567 l_component_code := 'DM_DEFAULT_REC';
19568 l_component_type_code := 'S';
19569 l_component_appl_id := 222;
19570 l_amb_context_code := 'DEFAULT';
19571 l_entity_code := 'TRANSACTIONS';
19572 l_event_class_code := 'DEBIT_MEMO';
19573 l_event_type_code := 'DEBIT_MEMO_ALL';
19574 l_line_definition_owner_code := 'S';
19575 l_line_definition_code := 'AR_DM_DEFAULT_ACCRUAL';
19576 --
19577 l_balance_type_code := 'A';
19578 l_segment := NULL;
19579 l_ccid := NULL;
19580 l_adr_transaction_coa_id := NULL;
19581 l_adr_accounting_coa_id := NULL;
19582 l_adr_flexfield_segment_code := NULL;
19583 l_adr_flex_value_set_id := NULL;
19584 l_adr_value_type_code := NULL;
19585 l_adr_value_combination_id := NULL;
19586 l_adr_value_segment_code := NULL;
19587
19588 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
19589 l_bflow_class_code := ''; -- 4219869 Business Flow
19590 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
19591 l_budgetary_control_flag := 'N';
19592
19593 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19594 l_bflow_applied_to_amt := NULL; -- 5132302
19595 l_entered_amt_idx := NULL; -- 4262811
19596 l_accted_amt_idx := NULL; -- 4262811
19597 l_acc_rev_flag := NULL; -- 4262811
19598 l_accrual_line_num := NULL; -- 4262811
19599 l_tmp_amt := NULL; -- 4262811
19600 --
19601
19602 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
19603 l_balance_type_code <> 'B' THEN
19604 IF NVL(p_source_33,'
19605 ') = 'REC'
19606 THEN
19607
19608 --
19609 XLA_AE_LINES_PKG.SetNewLine;
19610
19611 p_balance_type_code := l_balance_type_code;
19612 -- set the flag so later we will know whether the gain loss line needs to be created
19613
19614 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
19615 p_actual_flag :='A';
19616 END IF;
19617
19618 --
19619 -- bulk performance
19620 --
19621 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
19622 p_header_num => 0); -- 4262811
19623 --
19624 -- set accounting line options
19625 --
19626 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
19627 p_natural_side_code => 'D'
19628 , p_gain_or_loss_flag => 'N'
19629 , p_gl_transfer_mode_code => 'S'
19630 , p_acct_entry_type_code => 'A'
19631 , p_switch_side_flag => 'Y'
19632 , p_merge_duplicate_code => 'A'
19633 );
19634 --
19635 l_acc_rev_natural_side_code := 'C'; -- 4262811
19636 --
19637 --
19638 -- set accounting line type info
19639 --
19640 xla_ae_lines_pkg.SetAcctLineType
19641 (p_component_type => l_component_type
19642 ,p_event_type_code => l_event_type_code
19643 ,p_line_definition_owner_code => l_line_definition_owner_code
19644 ,p_line_definition_code => l_line_definition_code
19645 ,p_accounting_line_code => l_component_code
19646 ,p_accounting_line_type_code => l_component_type_code
19647 ,p_accounting_line_appl_id => l_component_appl_id
19648 ,p_amb_context_code => l_amb_context_code
19649 ,p_entity_code => l_entity_code
19650 ,p_event_class_code => l_event_class_code);
19651 --
19652 -- set accounting class
19653 --
19654 xla_ae_lines_pkg.SetAcctClass(
19655 p_accounting_class_code => 'RECEIVABLE'
19656 , p_ae_header_id => l_ae_header_id
19657 );
19658
19659 --
19663 'RECEIVABLE';
19660 -- set rounding class
19661 --
19662 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
19664
19665 --
19666 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
19667 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
19668 --
19669 -- bulk performance
19670 --
19671 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
19672
19673 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
19674 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
19675
19676 -- 4955764
19677 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19678 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
19679
19680 -- 4458381 Public Sector Enh
19681
19682 --
19683 -- set accounting attributes for the line type
19684 --
19685 l_entered_amt_idx := 3;
19686 l_accted_amt_idx := 8;
19687 l_bflow_applied_to_amt_idx := NULL; -- 5132302
19688 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
19689 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
19690 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
19691 l_rec_acct_attrs.array_char_value(2) := p_source_35;
19692 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
19693 l_rec_acct_attrs.array_num_value(3) := p_source_36;
19694 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
19695 l_rec_acct_attrs.array_char_value(4) := p_source_37;
19696 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
19697 l_rec_acct_attrs.array_date_value(5) := p_source_38;
19698 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
19699 l_rec_acct_attrs.array_num_value(6) := p_source_39;
19700 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
19701 l_rec_acct_attrs.array_char_value(7) := p_source_40;
19702 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
19703 l_rec_acct_attrs.array_num_value(8) := p_source_41;
19704 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
19705 l_rec_acct_attrs.array_num_value(9) := p_source_30;
19706 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
19707 l_rec_acct_attrs.array_num_value(10) := p_source_31;
19708 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
19709 l_rec_acct_attrs.array_char_value(11) := p_source_32;
19710 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
19711 l_rec_acct_attrs.array_num_value(12) := p_source_55;
19712
19713 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
19714 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
19715
19716 ---------------------------------------------------------------------------------------------------------------
19717 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
19718 ---------------------------------------------------------------------------------------------------------------
19719 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
19720
19721 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19722 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
19723
19724 IF xla_accounting_cache_pkg.GetValueChar
19725 (p_source_code => 'LEDGER_CATEGORY_CODE'
19726 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
19727 AND l_bflow_method_code = 'PRIOR_ENTRY'
19728 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
19729 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
19730 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
19731 )
19732 THEN
19733 xla_ae_lines_pkg.BflowUpgEntry
19734 (p_business_method_code => l_bflow_method_code
19735 ,p_business_class_code => l_bflow_class_code
19736 ,p_balance_type => l_balance_type_code);
19737 ELSE
19738 NULL;
19739 -- No business flow processing for business flow method of NONE.
19740 END IF;
19741
19742 --
19743 -- call analytical criteria
19744 --
19745
19746 --
19747 -- call description
19748 --
19749 -- No description or it is inherited.
19750 --
19751 -- call ADRs
19752 -- Bug 4922099
19753 --
19754 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19755 (NVL(l_actual_upg_option, 'N') = 'O') OR
19756 (NVL(l_enc_upg_option, 'N') = 'O')
19757 )
19758 THEN
19759 NULL;
19760 --
19761 --
19762
19763 l_ccid := AcctDerRule_28(
19764 p_application_id => p_application_id
19765 , p_ae_header_id => l_ae_header_id
19766 , p_source_19 => p_source_19
19767 , x_transaction_coa_id => l_adr_transaction_coa_id
19768 , x_accounting_coa_id => l_adr_accounting_coa_id
19769 , x_value_type_code => l_adr_value_type_code
19770 , p_side => 'NA'
19771 );
19772
19773 xla_ae_lines_pkg.set_ccid(
19774 p_code_combination_id => l_ccid
19775 , p_value_type_code => l_adr_value_type_code
19776 , p_transaction_coa_id => l_adr_transaction_coa_id
19777 , p_accounting_coa_id => l_adr_accounting_coa_id
19778 , p_adr_code => 'TRX_DIST_CCID'
19779 , p_adr_type_code => 'S'
19780 , p_component_type => l_component_type
19781 , p_component_code => l_component_code
19782 , p_component_type_code => l_component_type_code
19783 , p_component_appl_id => l_component_appl_id
19784 , p_amb_context_code => l_amb_context_code
19785 , p_side => 'NA'
19786 );
19787
19788
19789 --
19790 --
19791 END IF;
19792 --
19793 -- Bug 4922099
19794 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
19795 (NVL(l_enc_upg_option, 'N') = 'O')
19796 ) AND
19797 (l_bflow_method_code = 'PRIOR_ENTRY')
19798 )
19799 THEN
19800 IF
19801 --
19802 1 = 2
19803 --
19804 THEN
19805 xla_accounting_err_pkg.build_message
19806 (p_appli_s_name => 'XLA'
19807 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19808 ,p_token_1 => 'LINE_NUMBER'
19809 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
19810 ,p_token_2 => 'LINE_TYPE_NAME'
19811 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
19812 l_component_type
19813 ,l_component_code
19814 ,l_component_type_code
19815 ,l_component_appl_id
19816 ,l_amb_context_code
19817 ,l_entity_code
19818 ,l_event_class_code
19819 )
19820 ,p_token_3 => 'OWNER'
19821 ,p_value_3 => xla_lookups_pkg.get_meaning(
19822 p_lookup_type => 'XLA_OWNER_TYPE'
19823 ,p_lookup_code => l_component_type_code
19824 )
19825 ,p_token_4 => 'PRODUCT_NAME'
19826 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
19827 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
19828 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
19829 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
19830 ,p_ae_header_id => NULL
19831 );
19832
19833 IF (C_LEVEL_ERROR>= g_log_level) THEN
19834 trace
19835 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
19836 ,p_level => C_LEVEL_ERROR
19837 ,p_module => l_log_module);
19838 END IF;
19839 END IF;
19840 END IF;
19841 --
19842 --
19843 ------------------------------------------------------------------------------------------------
19844 -- 4219869 Business Flow
19845 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
19846 -- Prior Entry. Currently, the following code is always generated.
19847 ------------------------------------------------------------------------------------------------
19848 XLA_AE_LINES_PKG.ValidateCurrentLine;
19849
19850 ------------------------------------------------------------------------------------
19851 -- 4219869 Business Flow
19852 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
19853 ------------------------------------------------------------------------------------
19854 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19855
19856 ----------------------------------------------------------------------------------
19857 -- 4219869 Business Flow
19858 -- Update journal entry status -- Need to generate this within IF <condition>
19859 ----------------------------------------------------------------------------------
19860 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19861 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
19862 ,p_balance_type_code => l_balance_type_code
19863 );
19864
19865 -------------------------------------------------------------------------------------------
19866 -- 4262811 - Generate the Accrual Reversal lines
19867 -------------------------------------------------------------------------------------------
19868 BEGIN
19869 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
19870 (g_array_event(p_event_id).array_value_num('header_index'));
19871 IF l_acc_rev_flag IS NULL THEN
19872 l_acc_rev_flag := 'N';
19873 END IF;
19874 EXCEPTION
19875 WHEN OTHERS THEN
19876 l_acc_rev_flag := 'N';
19877 END;
19878 --
19879 IF (l_acc_rev_flag = 'Y') THEN
19880
19881 -- 4645092 ------------------------------------------------------------------------------
19882 -- To allow MPA report to determine if it should generate report process
19883 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
19884 ------------------------------------------------------------------------------------------
19885
19886 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
19887 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
19888 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
19889 -- call ADRs
19890 -- Bug 4922099
19891 --
19892 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
19893 (NVL(l_actual_upg_option, 'N') = 'O') OR
19894 (NVL(l_enc_upg_option, 'N') = 'O')
19895 )
19896 THEN
19897 NULL;
19898 --
19899 --
19900
19901 l_ccid := AcctDerRule_28(
19902 p_application_id => p_application_id
19903 , p_ae_header_id => l_ae_header_id
19904 , p_source_19 => p_source_19
19905 , x_transaction_coa_id => l_adr_transaction_coa_id
19906 , x_accounting_coa_id => l_adr_accounting_coa_id
19907 , x_value_type_code => l_adr_value_type_code
19908 , p_side => 'NA'
19909 );
19910
19911 xla_ae_lines_pkg.set_ccid(
19912 p_code_combination_id => l_ccid
19913 , p_value_type_code => l_adr_value_type_code
19914 , p_transaction_coa_id => l_adr_transaction_coa_id
19915 , p_accounting_coa_id => l_adr_accounting_coa_id
19916 , p_adr_code => 'TRX_DIST_CCID'
19917 , p_adr_type_code => 'S'
19918 , p_component_type => l_component_type
19919 , p_component_code => l_component_code
19920 , p_component_type_code => l_component_type_code
19921 , p_component_appl_id => l_component_appl_id
19922 , p_amb_context_code => l_amb_context_code
19923 , p_side => 'NA'
19924 );
19925
19926
19927 --
19928 --
19929 END IF;
19930
19931 --
19932 -- Update the line information that should be overwritten
19933 --
19934 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
19935 p_header_num => 1);
19936 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
19937
19938 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
19939
19940 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
19941 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
19942 END IF;
19943
19944 --
19945 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
19946 --
19947 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
19948 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
19949 ELSE
19950 ---------------------------------------------------------------------------------------------------
19951 -- 4262811a Switch Sign
19952 ---------------------------------------------------------------------------------------------------
19953 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
19954 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19955 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19956 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
19957 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19958 -- 5132302
19959 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
19960 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
19961
19962 END IF;
19963
19964 -- 4955764
19965 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
19966 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
19967
19968
19969 XLA_AE_LINES_PKG.ValidateCurrentLine;
19970 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
19971
19972 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
19973 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
19974 ,p_balance_type_code => l_balance_type_code);
19975
19976 END IF;
19977
19978 -----------------------------------------------------------------------------------------
19979 -- 4262811 Multiperiod Accounting
19980 -----------------------------------------------------------------------------------------
19981 -- No MPA option is assigned.
19982
19983
19984 END IF;
19985 END IF;
19986 --
19987
19988 --
19989 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19990 trace
19991 (p_msg => 'END of AcctLineType_56'
19992 ,p_level => C_LEVEL_PROCEDURE
19993 ,p_module => l_log_module);
19994 END IF;
19995 --
19996 EXCEPTION
19997 WHEN xla_exceptions_pkg.application_exception THEN
19998 RAISE;
19999 WHEN OTHERS THEN
20000 xla_exceptions_pkg.raise_message
20001 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_56');
20002 END AcctLineType_56;
20003 --
20004
20005 ---------------------------------------
20006 --
20007 -- PRIVATE FUNCTION
20008 -- AcctLineType_57
20009 --
20010 ---------------------------------------
20011 PROCEDURE AcctLineType_57 (
20012 p_application_id IN NUMBER
20013 ,p_event_id IN NUMBER
20014 ,p_calculate_acctd_flag IN VARCHAR2
20015 ,p_calculate_g_l_flag IN VARCHAR2
20016 ,p_actual_flag IN OUT VARCHAR2
20017 ,p_balance_type_code OUT VARCHAR2
20018 ,p_gain_or_loss_ref OUT VARCHAR2
20019
20020 --Transaction Distribution GL Account
20021 , p_source_19 IN NUMBER
20022 --Bill To Customer Account Identifier
20023 , p_source_30 IN NUMBER
20024 --Bill To Customer Site Use Identifier
20025 , p_source_31 IN NUMBER
20026 --SLA Party Type
20027 , p_source_32 IN VARCHAR2
20028 --Transaction Distribution Account Class
20029 , p_source_33 IN VARCHAR2
20030 --Transaction Distribution Identifier
20031 , p_source_34 IN NUMBER
20032 --Transaction Distribution Type
20033 , p_source_35 IN VARCHAR2
20034 --Transaction Distribution Entered Amount
20035 , p_source_36 IN NUMBER
20036 --Transaction Currency Code
20037 , p_source_37 IN VARCHAR2
20038 --Transaction Exchange Date
20039 , p_source_38 IN DATE
20040 --Transaction Exchange Rate
20041 , p_source_39 IN NUMBER
20042 --Transaction Exchange Rate Type
20043 , p_source_40 IN VARCHAR2
20044 --Transaction Accounting Amount
20045 , p_source_41 IN NUMBER
20046 --Transaction Tax Line Identifier
20047 , p_source_55 IN NUMBER
20048 )
20049 IS
20050
20051 l_component_type VARCHAR2(80);
20052 l_component_code VARCHAR2(30);
20053 l_component_type_code VARCHAR2(1);
20054 l_component_appl_id INTEGER;
20055 l_amb_context_code VARCHAR2(30);
20056 l_entity_code VARCHAR2(30);
20057 l_event_class_code VARCHAR2(30);
20058 l_ae_header_id NUMBER;
20059 l_event_type_code VARCHAR2(30);
20060 l_line_definition_code VARCHAR2(30);
20061 l_line_definition_owner_code VARCHAR2(1);
20062 --
20063 -- adr variables
20064 l_segment VARCHAR2(30);
20065 l_ccid NUMBER;
20066 l_adr_transaction_coa_id NUMBER;
20067 l_adr_accounting_coa_id NUMBER;
20068 l_adr_flexfield_segment_code VARCHAR2(30);
20069 l_adr_flex_value_set_id NUMBER;
20070 l_adr_value_type_code VARCHAR2(30);
20071 l_adr_value_combination_id NUMBER;
20072 l_adr_value_segment_code VARCHAR2(30);
20073
20074 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
20075 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
20076 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
20077 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
20078
20079 -- 4262811 Variables ------------------------------------------------------------------------------------------
20080 l_entered_amt_idx NUMBER;
20081 l_accted_amt_idx NUMBER;
20082 l_acc_rev_flag VARCHAR2(1);
20083 l_accrual_line_num NUMBER;
20084 l_tmp_amt NUMBER;
20085 l_acc_rev_natural_side_code VARCHAR2(1);
20086
20087 l_num_entries NUMBER;
20088 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
20089 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
20090 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
20091 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
20092 l_recog_line_1 NUMBER;
20093 l_recog_line_2 NUMBER;
20094
20095 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
20096 l_bflow_applied_to_amt NUMBER; -- 5132302
20097 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
20098
20099 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
20100
20101 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
20102 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
20103
20104 ---------------------------------------------------------------------------------------------------------------
20105
20106
20107 --
20108 -- bulk performance
20109 --
20110 l_balance_type_code VARCHAR2(1);
20111 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
20112 l_log_module VARCHAR2(240);
20113
20114 --
20115 -- Upgrade strategy
20116 --
20117 l_actual_upg_option VARCHAR2(1);
20118 l_enc_upg_option VARCHAR2(1);
20119
20120 --
20121 BEGIN
20122 --
20123 IF g_log_enabled THEN
20124 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_57';
20125 END IF;
20126 --
20127 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20128
20129 trace
20130 (p_msg => 'BEGIN of AcctLineType_57'
20131 ,p_level => C_LEVEL_PROCEDURE
20132 ,p_module => l_log_module);
20133
20134 END IF;
20135 --
20136 l_component_type := 'AMB_JLT';
20137 l_component_code := 'DM_FREIGHT';
20138 l_component_type_code := 'S';
20139 l_component_appl_id := 222;
20140 l_amb_context_code := 'DEFAULT';
20141 l_entity_code := 'TRANSACTIONS';
20142 l_event_class_code := 'DEBIT_MEMO';
20143 l_event_type_code := 'DEBIT_MEMO_ALL';
20144 l_line_definition_owner_code := 'S';
20145 l_line_definition_code := 'AR_DM_DEFAULT_ACCRUAL';
20146 --
20147 l_balance_type_code := 'A';
20148 l_segment := NULL;
20149 l_ccid := NULL;
20150 l_adr_transaction_coa_id := NULL;
20151 l_adr_accounting_coa_id := NULL;
20152 l_adr_flexfield_segment_code := NULL;
20153 l_adr_flex_value_set_id := NULL;
20154 l_adr_value_type_code := NULL;
20155 l_adr_value_combination_id := NULL;
20156 l_adr_value_segment_code := NULL;
20157
20158 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
20159 l_bflow_class_code := ''; -- 4219869 Business Flow
20160 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
20161 l_budgetary_control_flag := 'N';
20162
20163 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20164 l_bflow_applied_to_amt := NULL; -- 5132302
20165 l_entered_amt_idx := NULL; -- 4262811
20166 l_accted_amt_idx := NULL; -- 4262811
20167 l_acc_rev_flag := NULL; -- 4262811
20168 l_accrual_line_num := NULL; -- 4262811
20169 l_tmp_amt := NULL; -- 4262811
20170 --
20171
20172 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
20173 l_balance_type_code <> 'B' THEN
20174 IF NVL(p_source_33,'
20175 ') = 'FREIGHT'
20176 THEN
20177
20178 --
20179 XLA_AE_LINES_PKG.SetNewLine;
20180
20181 p_balance_type_code := l_balance_type_code;
20182 -- set the flag so later we will know whether the gain loss line needs to be created
20183
20184 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
20185 p_actual_flag :='A';
20186 END IF;
20187
20188 --
20189 -- bulk performance
20190 --
20191 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
20192 p_header_num => 0); -- 4262811
20193 --
20194 -- set accounting line options
20195 --
20196 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
20197 p_natural_side_code => 'C'
20198 , p_gain_or_loss_flag => 'N'
20199 , p_gl_transfer_mode_code => 'S'
20200 , p_acct_entry_type_code => 'A'
20201 , p_switch_side_flag => 'Y'
20202 , p_merge_duplicate_code => 'A'
20203 );
20204 --
20205 l_acc_rev_natural_side_code := 'D'; -- 4262811
20206 --
20207 --
20208 -- set accounting line type info
20209 --
20210 xla_ae_lines_pkg.SetAcctLineType
20211 (p_component_type => l_component_type
20212 ,p_event_type_code => l_event_type_code
20213 ,p_line_definition_owner_code => l_line_definition_owner_code
20214 ,p_line_definition_code => l_line_definition_code
20215 ,p_accounting_line_code => l_component_code
20216 ,p_accounting_line_type_code => l_component_type_code
20217 ,p_accounting_line_appl_id => l_component_appl_id
20218 ,p_amb_context_code => l_amb_context_code
20219 ,p_entity_code => l_entity_code
20220 ,p_event_class_code => l_event_class_code);
20221 --
20222 -- set accounting class
20223 --
20224 xla_ae_lines_pkg.SetAcctClass(
20225 p_accounting_class_code => 'FREIGHT'
20226 , p_ae_header_id => l_ae_header_id
20227 );
20228
20229 --
20230 -- set rounding class
20231 --
20232 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
20233 'RECEIVABLE';
20234
20235 --
20236 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
20237 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
20238 --
20239 -- bulk performance
20240 --
20241 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
20242
20243 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
20244 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
20245
20246 -- 4955764
20247 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20248 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
20249
20250 -- 4458381 Public Sector Enh
20251
20252 --
20253 -- set accounting attributes for the line type
20254 --
20255 l_entered_amt_idx := 3;
20256 l_accted_amt_idx := 8;
20260 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
20257 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20258 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
20259 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
20261 l_rec_acct_attrs.array_char_value(2) := p_source_35;
20262 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
20263 l_rec_acct_attrs.array_num_value(3) := p_source_36;
20264 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
20265 l_rec_acct_attrs.array_char_value(4) := p_source_37;
20266 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
20267 l_rec_acct_attrs.array_date_value(5) := p_source_38;
20268 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
20269 l_rec_acct_attrs.array_num_value(6) := p_source_39;
20270 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
20271 l_rec_acct_attrs.array_char_value(7) := p_source_40;
20272 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
20273 l_rec_acct_attrs.array_num_value(8) := p_source_41;
20274 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
20275 l_rec_acct_attrs.array_num_value(9) := p_source_30;
20276 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
20277 l_rec_acct_attrs.array_num_value(10) := p_source_31;
20278 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
20279 l_rec_acct_attrs.array_char_value(11) := p_source_32;
20280 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
20281 l_rec_acct_attrs.array_num_value(12) := p_source_55;
20282
20283 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
20284 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
20285
20286 ---------------------------------------------------------------------------------------------------------------
20287 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
20288 ---------------------------------------------------------------------------------------------------------------
20289 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
20290
20291 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20292 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20293
20294 IF xla_accounting_cache_pkg.GetValueChar
20295 (p_source_code => 'LEDGER_CATEGORY_CODE'
20296 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
20297 AND l_bflow_method_code = 'PRIOR_ENTRY'
20298 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
20299 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
20300 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
20301 )
20302 THEN
20303 xla_ae_lines_pkg.BflowUpgEntry
20304 (p_business_method_code => l_bflow_method_code
20305 ,p_business_class_code => l_bflow_class_code
20306 ,p_balance_type => l_balance_type_code);
20307 ELSE
20308 NULL;
20309 -- No business flow processing for business flow method of NONE.
20310 END IF;
20311
20312 --
20313 -- call analytical criteria
20314 --
20315
20316 --
20317 -- call description
20318 --
20319 -- No description or it is inherited.
20320 --
20321 -- call ADRs
20322 -- Bug 4922099
20323 --
20324 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20325 (NVL(l_actual_upg_option, 'N') = 'O') OR
20326 (NVL(l_enc_upg_option, 'N') = 'O')
20327 )
20328 THEN
20329 NULL;
20330 --
20331 --
20332
20333 l_ccid := AcctDerRule_28(
20334 p_application_id => p_application_id
20335 , p_ae_header_id => l_ae_header_id
20336 , p_source_19 => p_source_19
20337 , x_transaction_coa_id => l_adr_transaction_coa_id
20338 , x_accounting_coa_id => l_adr_accounting_coa_id
20339 , x_value_type_code => l_adr_value_type_code
20340 , p_side => 'NA'
20341 );
20342
20343 xla_ae_lines_pkg.set_ccid(
20344 p_code_combination_id => l_ccid
20345 , p_value_type_code => l_adr_value_type_code
20346 , p_transaction_coa_id => l_adr_transaction_coa_id
20347 , p_accounting_coa_id => l_adr_accounting_coa_id
20348 , p_adr_code => 'TRX_DIST_CCID'
20349 , p_adr_type_code => 'S'
20350 , p_component_type => l_component_type
20351 , p_component_code => l_component_code
20352 , p_component_type_code => l_component_type_code
20353 , p_component_appl_id => l_component_appl_id
20354 , p_amb_context_code => l_amb_context_code
20355 , p_side => 'NA'
20356 );
20357
20358
20359 --
20360 --
20361 END IF;
20362 --
20363 -- Bug 4922099
20364 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
20365 (NVL(l_enc_upg_option, 'N') = 'O')
20366 ) AND
20367 (l_bflow_method_code = 'PRIOR_ENTRY')
20368 )
20369 THEN
20370 IF
20371 --
20372 1 = 2
20373 --
20374 THEN
20375 xla_accounting_err_pkg.build_message
20376 (p_appli_s_name => 'XLA'
20377 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20378 ,p_token_1 => 'LINE_NUMBER'
20382 l_component_type
20379 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
20380 ,p_token_2 => 'LINE_TYPE_NAME'
20381 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
20383 ,l_component_code
20384 ,l_component_type_code
20385 ,l_component_appl_id
20386 ,l_amb_context_code
20387 ,l_entity_code
20388 ,l_event_class_code
20389 )
20390 ,p_token_3 => 'OWNER'
20391 ,p_value_3 => xla_lookups_pkg.get_meaning(
20392 p_lookup_type => 'XLA_OWNER_TYPE'
20393 ,p_lookup_code => l_component_type_code
20394 )
20395 ,p_token_4 => 'PRODUCT_NAME'
20396 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
20397 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
20398 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
20399 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
20400 ,p_ae_header_id => NULL
20401 );
20402
20403 IF (C_LEVEL_ERROR>= g_log_level) THEN
20404 trace
20405 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20406 ,p_level => C_LEVEL_ERROR
20407 ,p_module => l_log_module);
20408 END IF;
20409 END IF;
20410 END IF;
20411 --
20412 --
20413 ------------------------------------------------------------------------------------------------
20414 -- 4219869 Business Flow
20415 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
20416 -- Prior Entry. Currently, the following code is always generated.
20417 ------------------------------------------------------------------------------------------------
20418 XLA_AE_LINES_PKG.ValidateCurrentLine;
20419
20420 ------------------------------------------------------------------------------------
20421 -- 4219869 Business Flow
20422 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
20423 ------------------------------------------------------------------------------------
20424 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20425
20426 ----------------------------------------------------------------------------------
20427 -- 4219869 Business Flow
20428 -- Update journal entry status -- Need to generate this within IF <condition>
20429 ----------------------------------------------------------------------------------
20430 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20431 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
20432 ,p_balance_type_code => l_balance_type_code
20433 );
20434
20435 -------------------------------------------------------------------------------------------
20436 -- 4262811 - Generate the Accrual Reversal lines
20437 -------------------------------------------------------------------------------------------
20438 BEGIN
20439 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
20440 (g_array_event(p_event_id).array_value_num('header_index'));
20441 IF l_acc_rev_flag IS NULL THEN
20442 l_acc_rev_flag := 'N';
20443 END IF;
20444 EXCEPTION
20445 WHEN OTHERS THEN
20446 l_acc_rev_flag := 'N';
20447 END;
20448 --
20449 IF (l_acc_rev_flag = 'Y') THEN
20450
20451 -- 4645092 ------------------------------------------------------------------------------
20452 -- To allow MPA report to determine if it should generate report process
20453 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
20454 ------------------------------------------------------------------------------------------
20455
20456 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
20457 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
20458 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
20459 -- call ADRs
20460 -- Bug 4922099
20461 --
20462 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20463 (NVL(l_actual_upg_option, 'N') = 'O') OR
20464 (NVL(l_enc_upg_option, 'N') = 'O')
20465 )
20466 THEN
20467 NULL;
20468 --
20469 --
20470
20471 l_ccid := AcctDerRule_28(
20472 p_application_id => p_application_id
20473 , p_ae_header_id => l_ae_header_id
20474 , p_source_19 => p_source_19
20475 , x_transaction_coa_id => l_adr_transaction_coa_id
20476 , x_accounting_coa_id => l_adr_accounting_coa_id
20477 , x_value_type_code => l_adr_value_type_code
20478 , p_side => 'NA'
20479 );
20480
20484 , p_transaction_coa_id => l_adr_transaction_coa_id
20481 xla_ae_lines_pkg.set_ccid(
20482 p_code_combination_id => l_ccid
20483 , p_value_type_code => l_adr_value_type_code
20485 , p_accounting_coa_id => l_adr_accounting_coa_id
20486 , p_adr_code => 'TRX_DIST_CCID'
20487 , p_adr_type_code => 'S'
20488 , p_component_type => l_component_type
20489 , p_component_code => l_component_code
20490 , p_component_type_code => l_component_type_code
20491 , p_component_appl_id => l_component_appl_id
20492 , p_amb_context_code => l_amb_context_code
20493 , p_side => 'NA'
20494 );
20495
20496
20497 --
20498 --
20499 END IF;
20500
20501 --
20502 -- Update the line information that should be overwritten
20503 --
20504 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
20505 p_header_num => 1);
20506 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
20507
20508 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
20509
20510 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
20511 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
20512 END IF;
20513
20514 --
20515 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
20516 --
20517 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
20518 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
20519 ELSE
20520 ---------------------------------------------------------------------------------------------------
20521 -- 4262811a Switch Sign
20522 ---------------------------------------------------------------------------------------------------
20523 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
20524 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20525 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20526 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
20527 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20528 -- 5132302
20529 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
20530 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
20531
20532 END IF;
20533
20534 -- 4955764
20535 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20536 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
20537
20538
20539 XLA_AE_LINES_PKG.ValidateCurrentLine;
20540 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20541
20542 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
20543 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
20544 ,p_balance_type_code => l_balance_type_code);
20545
20546 END IF;
20547
20548 -----------------------------------------------------------------------------------------
20549 -- 4262811 Multiperiod Accounting
20550 -----------------------------------------------------------------------------------------
20551 -- No MPA option is assigned.
20552
20553
20554 END IF;
20555 END IF;
20556 --
20557
20558 --
20559 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20560 trace
20561 (p_msg => 'END of AcctLineType_57'
20562 ,p_level => C_LEVEL_PROCEDURE
20563 ,p_module => l_log_module);
20564 END IF;
20565 --
20566 EXCEPTION
20567 WHEN xla_exceptions_pkg.application_exception THEN
20568 RAISE;
20569 WHEN OTHERS THEN
20570 xla_exceptions_pkg.raise_message
20571 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_57');
20572 END AcctLineType_57;
20573 --
20574
20575 ---------------------------------------
20576 --
20577 -- PRIVATE FUNCTION
20578 -- AcctLineType_58
20579 --
20580 ---------------------------------------
20581 PROCEDURE AcctLineType_58 (
20582 p_application_id IN NUMBER
20583 ,p_event_id IN NUMBER
20584 ,p_calculate_acctd_flag IN VARCHAR2
20585 ,p_calculate_g_l_flag IN VARCHAR2
20586 ,p_actual_flag IN OUT VARCHAR2
20587 ,p_balance_type_code OUT VARCHAR2
20588 ,p_gain_or_loss_ref OUT VARCHAR2
20589
20590 --Transaction Distribution GL Account
20591 , p_source_19 IN NUMBER
20592 --Bill To Customer Account Identifier
20593 , p_source_30 IN NUMBER
20594 --Bill To Customer Site Use Identifier
20595 , p_source_31 IN NUMBER
20596 --SLA Party Type
20597 , p_source_32 IN VARCHAR2
20598 --Transaction Distribution Account Class
20599 , p_source_33 IN VARCHAR2
20600 --Transaction Distribution Identifier
20601 , p_source_34 IN NUMBER
20602 --Transaction Distribution Type
20603 , p_source_35 IN VARCHAR2
20604 --Transaction Distribution Entered Amount
20605 , p_source_36 IN NUMBER
20606 --Transaction Currency Code
20607 , p_source_37 IN VARCHAR2
20608 --Transaction Exchange Date
20609 , p_source_38 IN DATE
20610 --Transaction Exchange Rate
20611 , p_source_39 IN NUMBER
20612 --Transaction Exchange Rate Type
20613 , p_source_40 IN VARCHAR2
20614 --Transaction Accounting Amount
20615 , p_source_41 IN NUMBER
20616 --Transaction Tax Line Identifier
20617 , p_source_55 IN NUMBER
20618 )
20619 IS
20620
20621 l_component_type VARCHAR2(80);
20622 l_component_code VARCHAR2(30);
20623 l_component_type_code VARCHAR2(1);
20624 l_component_appl_id INTEGER;
20625 l_amb_context_code VARCHAR2(30);
20626 l_entity_code VARCHAR2(30);
20627 l_event_class_code VARCHAR2(30);
20628 l_ae_header_id NUMBER;
20629 l_event_type_code VARCHAR2(30);
20630 l_line_definition_code VARCHAR2(30);
20631 l_line_definition_owner_code VARCHAR2(1);
20632 --
20633 -- adr variables
20634 l_segment VARCHAR2(30);
20635 l_ccid NUMBER;
20636 l_adr_transaction_coa_id NUMBER;
20637 l_adr_accounting_coa_id NUMBER;
20638 l_adr_flexfield_segment_code VARCHAR2(30);
20639 l_adr_flex_value_set_id NUMBER;
20640 l_adr_value_type_code VARCHAR2(30);
20641 l_adr_value_combination_id NUMBER;
20642 l_adr_value_segment_code VARCHAR2(30);
20643
20644 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
20645 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
20646 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
20647 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
20648
20649 -- 4262811 Variables ------------------------------------------------------------------------------------------
20650 l_entered_amt_idx NUMBER;
20651 l_accted_amt_idx NUMBER;
20652 l_acc_rev_flag VARCHAR2(1);
20653 l_accrual_line_num NUMBER;
20654 l_tmp_amt NUMBER;
20655 l_acc_rev_natural_side_code VARCHAR2(1);
20656
20657 l_num_entries NUMBER;
20658 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
20659 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
20660 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
20661 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
20662 l_recog_line_1 NUMBER;
20663 l_recog_line_2 NUMBER;
20664
20665 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
20666 l_bflow_applied_to_amt NUMBER; -- 5132302
20667 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
20668
20669 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
20670
20671 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
20672 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
20673
20674 ---------------------------------------------------------------------------------------------------------------
20675
20676
20677 --
20678 -- bulk performance
20679 --
20680 l_balance_type_code VARCHAR2(1);
20681 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
20682 l_log_module VARCHAR2(240);
20683
20684 --
20685 -- Upgrade strategy
20686 --
20687 l_actual_upg_option VARCHAR2(1);
20688 l_enc_upg_option VARCHAR2(1);
20689
20690 --
20691 BEGIN
20692 --
20693 IF g_log_enabled THEN
20694 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_58';
20695 END IF;
20696 --
20697 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
20698
20699 trace
20700 (p_msg => 'BEGIN of AcctLineType_58'
20701 ,p_level => C_LEVEL_PROCEDURE
20702 ,p_module => l_log_module);
20703
20704 END IF;
20705 --
20706 l_component_type := 'AMB_JLT';
20707 l_component_code := 'DM_REV';
20708 l_component_type_code := 'S';
20709 l_component_appl_id := 222;
20710 l_amb_context_code := 'DEFAULT';
20711 l_entity_code := 'TRANSACTIONS';
20712 l_event_class_code := 'DEBIT_MEMO';
20713 l_event_type_code := 'DEBIT_MEMO_ALL';
20714 l_line_definition_owner_code := 'S';
20715 l_line_definition_code := 'AR_DM_DEFAULT_ACCRUAL';
20716 --
20717 l_balance_type_code := 'A';
20718 l_segment := NULL;
20719 l_ccid := NULL;
20720 l_adr_transaction_coa_id := NULL;
20721 l_adr_accounting_coa_id := NULL;
20722 l_adr_flexfield_segment_code := NULL;
20723 l_adr_flex_value_set_id := NULL;
20724 l_adr_value_type_code := NULL;
20725 l_adr_value_combination_id := NULL;
20726 l_adr_value_segment_code := NULL;
20727
20728 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
20729 l_bflow_class_code := ''; -- 4219869 Business Flow
20730 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
20731 l_budgetary_control_flag := 'N';
20732
20733 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20734 l_bflow_applied_to_amt := NULL; -- 5132302
20735 l_entered_amt_idx := NULL; -- 4262811
20736 l_accted_amt_idx := NULL; -- 4262811
20737 l_acc_rev_flag := NULL; -- 4262811
20738 l_accrual_line_num := NULL; -- 4262811
20739 l_tmp_amt := NULL; -- 4262811
20740 --
20741
20742 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
20743 l_balance_type_code <> 'B' THEN
20744 IF NVL(p_source_33,'
20745 ') = 'REV'
20746 THEN
20747
20748 --
20749 XLA_AE_LINES_PKG.SetNewLine;
20750
20751 p_balance_type_code := l_balance_type_code;
20752 -- set the flag so later we will know whether the gain loss line needs to be created
20753
20754 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
20755 p_actual_flag :='A';
20756 END IF;
20757
20758 --
20759 -- bulk performance
20760 --
20761 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
20762 p_header_num => 0); -- 4262811
20763 --
20764 -- set accounting line options
20765 --
20766 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
20767 p_natural_side_code => 'C'
20768 , p_gain_or_loss_flag => 'N'
20769 , p_gl_transfer_mode_code => 'S'
20770 , p_acct_entry_type_code => 'A'
20771 , p_switch_side_flag => 'Y'
20772 , p_merge_duplicate_code => 'A'
20773 );
20774 --
20775 l_acc_rev_natural_side_code := 'D'; -- 4262811
20776 --
20777 --
20778 -- set accounting line type info
20779 --
20780 xla_ae_lines_pkg.SetAcctLineType
20781 (p_component_type => l_component_type
20782 ,p_event_type_code => l_event_type_code
20783 ,p_line_definition_owner_code => l_line_definition_owner_code
20784 ,p_line_definition_code => l_line_definition_code
20785 ,p_accounting_line_code => l_component_code
20786 ,p_accounting_line_type_code => l_component_type_code
20787 ,p_accounting_line_appl_id => l_component_appl_id
20788 ,p_amb_context_code => l_amb_context_code
20789 ,p_entity_code => l_entity_code
20790 ,p_event_class_code => l_event_class_code);
20791 --
20792 -- set accounting class
20793 --
20794 xla_ae_lines_pkg.SetAcctClass(
20795 p_accounting_class_code => 'REVENUE'
20796 , p_ae_header_id => l_ae_header_id
20797 );
20798
20799 --
20800 -- set rounding class
20801 --
20802 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
20803 'RECEIVABLE';
20804
20805 --
20806 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
20807 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
20808 --
20809 -- bulk performance
20810 --
20814 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
20811 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
20812
20813 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
20815
20816 -- 4955764
20817 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
20818 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
20819
20820 -- 4458381 Public Sector Enh
20821
20822 --
20823 -- set accounting attributes for the line type
20824 --
20825 l_entered_amt_idx := 3;
20826 l_accted_amt_idx := 8;
20827 l_bflow_applied_to_amt_idx := NULL; -- 5132302
20828 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
20829 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
20830 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
20831 l_rec_acct_attrs.array_char_value(2) := p_source_35;
20832 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
20833 l_rec_acct_attrs.array_num_value(3) := p_source_36;
20834 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
20835 l_rec_acct_attrs.array_char_value(4) := p_source_37;
20836 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
20837 l_rec_acct_attrs.array_date_value(5) := p_source_38;
20838 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
20839 l_rec_acct_attrs.array_num_value(6) := p_source_39;
20840 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
20841 l_rec_acct_attrs.array_char_value(7) := p_source_40;
20842 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
20843 l_rec_acct_attrs.array_num_value(8) := p_source_41;
20844 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
20845 l_rec_acct_attrs.array_num_value(9) := p_source_30;
20846 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
20847 l_rec_acct_attrs.array_num_value(10) := p_source_31;
20848 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
20849 l_rec_acct_attrs.array_char_value(11) := p_source_32;
20850 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
20851 l_rec_acct_attrs.array_num_value(12) := p_source_55;
20852
20853 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
20854 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
20855
20856 ---------------------------------------------------------------------------------------------------------------
20857 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
20858 ---------------------------------------------------------------------------------------------------------------
20859 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
20860
20861 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20862 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
20863
20864 IF xla_accounting_cache_pkg.GetValueChar
20865 (p_source_code => 'LEDGER_CATEGORY_CODE'
20866 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
20867 AND l_bflow_method_code = 'PRIOR_ENTRY'
20868 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
20869 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
20870 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
20871 )
20872 THEN
20873 xla_ae_lines_pkg.BflowUpgEntry
20874 (p_business_method_code => l_bflow_method_code
20875 ,p_business_class_code => l_bflow_class_code
20876 ,p_balance_type => l_balance_type_code);
20877 ELSE
20878 NULL;
20879 -- No business flow processing for business flow method of NONE.
20880 END IF;
20881
20882 --
20883 -- call analytical criteria
20884 --
20885
20886 --
20887 -- call description
20888 --
20889 -- No description or it is inherited.
20890 --
20891 -- call ADRs
20892 -- Bug 4922099
20893 --
20894 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
20895 (NVL(l_actual_upg_option, 'N') = 'O') OR
20896 (NVL(l_enc_upg_option, 'N') = 'O')
20897 )
20898 THEN
20899 NULL;
20900 --
20901 --
20902
20903 l_ccid := AcctDerRule_28(
20904 p_application_id => p_application_id
20905 , p_ae_header_id => l_ae_header_id
20906 , p_source_19 => p_source_19
20907 , x_transaction_coa_id => l_adr_transaction_coa_id
20908 , x_accounting_coa_id => l_adr_accounting_coa_id
20909 , x_value_type_code => l_adr_value_type_code
20910 , p_side => 'NA'
20911 );
20912
20913 xla_ae_lines_pkg.set_ccid(
20914 p_code_combination_id => l_ccid
20915 , p_value_type_code => l_adr_value_type_code
20916 , p_transaction_coa_id => l_adr_transaction_coa_id
20917 , p_accounting_coa_id => l_adr_accounting_coa_id
20918 , p_adr_code => 'TRX_DIST_CCID'
20919 , p_adr_type_code => 'S'
20920 , p_component_type => l_component_type
20921 , p_component_code => l_component_code
20922 , p_component_type_code => l_component_type_code
20923 , p_component_appl_id => l_component_appl_id
20924 , p_amb_context_code => l_amb_context_code
20925 , p_side => 'NA'
20926 );
20927
20928
20929 --
20930 --
20931 END IF;
20932 --
20933 -- Bug 4922099
20934 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
20935 (NVL(l_enc_upg_option, 'N') = 'O')
20936 ) AND
20937 (l_bflow_method_code = 'PRIOR_ENTRY')
20938 )
20939 THEN
20940 IF
20941 --
20942 1 = 2
20943 --
20944 THEN
20945 xla_accounting_err_pkg.build_message
20946 (p_appli_s_name => 'XLA'
20947 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20948 ,p_token_1 => 'LINE_NUMBER'
20949 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
20950 ,p_token_2 => 'LINE_TYPE_NAME'
20951 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
20952 l_component_type
20953 ,l_component_code
20954 ,l_component_type_code
20955 ,l_component_appl_id
20956 ,l_amb_context_code
20957 ,l_entity_code
20958 ,l_event_class_code
20959 )
20960 ,p_token_3 => 'OWNER'
20961 ,p_value_3 => xla_lookups_pkg.get_meaning(
20962 p_lookup_type => 'XLA_OWNER_TYPE'
20963 ,p_lookup_code => l_component_type_code
20964 )
20965 ,p_token_4 => 'PRODUCT_NAME'
20966 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
20967 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
20968 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
20969 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
20970 ,p_ae_header_id => NULL
20971 );
20972
20973 IF (C_LEVEL_ERROR>= g_log_level) THEN
20974 trace
20975 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
20976 ,p_level => C_LEVEL_ERROR
20977 ,p_module => l_log_module);
20978 END IF;
20979 END IF;
20980 END IF;
20981 --
20982 --
20983 ------------------------------------------------------------------------------------------------
20984 -- 4219869 Business Flow
20985 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
20986 -- Prior Entry. Currently, the following code is always generated.
20987 ------------------------------------------------------------------------------------------------
20988 XLA_AE_LINES_PKG.ValidateCurrentLine;
20989
20990 ------------------------------------------------------------------------------------
20991 -- 4219869 Business Flow
20992 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
20993 ------------------------------------------------------------------------------------
20994 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
20995
20996 ----------------------------------------------------------------------------------
20997 -- 4219869 Business Flow
20998 -- Update journal entry status -- Need to generate this within IF <condition>
20999 ----------------------------------------------------------------------------------
21000 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21001 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
21002 ,p_balance_type_code => l_balance_type_code
21003 );
21004
21005 -------------------------------------------------------------------------------------------
21006 -- 4262811 - Generate the Accrual Reversal lines
21007 -------------------------------------------------------------------------------------------
21008 BEGIN
21009 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
21010 (g_array_event(p_event_id).array_value_num('header_index'));
21011 IF l_acc_rev_flag IS NULL THEN
21012 l_acc_rev_flag := 'N';
21013 END IF;
21014 EXCEPTION
21015 WHEN OTHERS THEN
21016 l_acc_rev_flag := 'N';
21017 END;
21018 --
21019 IF (l_acc_rev_flag = 'Y') THEN
21020
21021 -- 4645092 ------------------------------------------------------------------------------
21022 -- To allow MPA report to determine if it should generate report process
21023 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
21024 ------------------------------------------------------------------------------------------
21025
21026 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
21027 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
21028 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
21029 -- call ADRs
21030 -- Bug 4922099
21031 --
21032 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21033 (NVL(l_actual_upg_option, 'N') = 'O') OR
21034 (NVL(l_enc_upg_option, 'N') = 'O')
21035 )
21036 THEN
21037 NULL;
21038 --
21039 --
21040
21041 l_ccid := AcctDerRule_28(
21042 p_application_id => p_application_id
21043 , p_ae_header_id => l_ae_header_id
21044 , p_source_19 => p_source_19
21045 , x_transaction_coa_id => l_adr_transaction_coa_id
21046 , x_accounting_coa_id => l_adr_accounting_coa_id
21047 , x_value_type_code => l_adr_value_type_code
21048 , p_side => 'NA'
21049 );
21050
21051 xla_ae_lines_pkg.set_ccid(
21052 p_code_combination_id => l_ccid
21053 , p_value_type_code => l_adr_value_type_code
21054 , p_transaction_coa_id => l_adr_transaction_coa_id
21055 , p_accounting_coa_id => l_adr_accounting_coa_id
21056 , p_adr_code => 'TRX_DIST_CCID'
21057 , p_adr_type_code => 'S'
21058 , p_component_type => l_component_type
21059 , p_component_code => l_component_code
21060 , p_component_type_code => l_component_type_code
21061 , p_component_appl_id => l_component_appl_id
21062 , p_amb_context_code => l_amb_context_code
21063 , p_side => 'NA'
21064 );
21065
21066
21067 --
21068 --
21069 END IF;
21070
21071 --
21072 -- Update the line information that should be overwritten
21073 --
21074 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
21075 p_header_num => 1);
21076 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
21077
21078 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
21079
21080 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
21081 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
21082 END IF;
21083
21084 --
21085 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
21086 --
21087 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
21088 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
21089 ELSE
21090 ---------------------------------------------------------------------------------------------------
21091 -- 4262811a Switch Sign
21092 ---------------------------------------------------------------------------------------------------
21093 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
21094 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21095 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21096 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21097 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21098 -- 5132302
21099 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
21100 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21101
21102 END IF;
21103
21104 -- 4955764
21105 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21106 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
21107
21108
21109 XLA_AE_LINES_PKG.ValidateCurrentLine;
21110 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21111
21112 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21113 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
21114 ,p_balance_type_code => l_balance_type_code);
21115
21116 END IF;
21117
21118 -----------------------------------------------------------------------------------------
21119 -- 4262811 Multiperiod Accounting
21120 -----------------------------------------------------------------------------------------
21121 -- No MPA option is assigned.
21122
21123
21124 END IF;
21125 END IF;
21126 --
21127
21128 --
21129 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21130 trace
21131 (p_msg => 'END of AcctLineType_58'
21132 ,p_level => C_LEVEL_PROCEDURE
21133 ,p_module => l_log_module);
21134 END IF;
21135 --
21136 EXCEPTION
21137 WHEN xla_exceptions_pkg.application_exception THEN
21138 RAISE;
21139 WHEN OTHERS THEN
21140 xla_exceptions_pkg.raise_message
21141 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_58');
21142 END AcctLineType_58;
21143 --
21144
21145 ---------------------------------------
21146 --
21147 -- PRIVATE FUNCTION
21148 -- AcctLineType_59
21149 --
21150 ---------------------------------------
21151 PROCEDURE AcctLineType_59 (
21152 p_application_id IN NUMBER
21153 ,p_event_id IN NUMBER
21154 ,p_calculate_acctd_flag IN VARCHAR2
21155 ,p_calculate_g_l_flag IN VARCHAR2
21156 ,p_actual_flag IN OUT VARCHAR2
21157 ,p_balance_type_code OUT VARCHAR2
21158 ,p_gain_or_loss_ref OUT VARCHAR2
21159
21160 --Transaction Distribution GL Account
21161 , p_source_19 IN NUMBER
21162 --Bill To Customer Account Identifier
21163 , p_source_30 IN NUMBER
21164 --Bill To Customer Site Use Identifier
21165 , p_source_31 IN NUMBER
21166 --SLA Party Type
21167 , p_source_32 IN VARCHAR2
21168 --Transaction Distribution Account Class
21169 , p_source_33 IN VARCHAR2
21170 --Transaction Distribution Identifier
21171 , p_source_34 IN NUMBER
21172 --Transaction Distribution Type
21173 , p_source_35 IN VARCHAR2
21174 --Transaction Distribution Entered Amount
21175 , p_source_36 IN NUMBER
21176 --Transaction Currency Code
21177 , p_source_37 IN VARCHAR2
21178 --Transaction Exchange Date
21179 , p_source_38 IN DATE
21180 --Transaction Exchange Rate
21181 , p_source_39 IN NUMBER
21182 --Transaction Exchange Rate Type
21183 , p_source_40 IN VARCHAR2
21184 --Transaction Accounting Amount
21185 , p_source_41 IN NUMBER
21186 --Transaction Tax Line Identifier
21187 , p_source_55 IN NUMBER
21188 )
21189 IS
21190
21191 l_component_type VARCHAR2(80);
21192 l_component_code VARCHAR2(30);
21193 l_component_type_code VARCHAR2(1);
21194 l_component_appl_id INTEGER;
21195 l_amb_context_code VARCHAR2(30);
21196 l_entity_code VARCHAR2(30);
21197 l_event_class_code VARCHAR2(30);
21198 l_ae_header_id NUMBER;
21199 l_event_type_code VARCHAR2(30);
21200 l_line_definition_code VARCHAR2(30);
21201 l_line_definition_owner_code VARCHAR2(1);
21202 --
21203 -- adr variables
21204 l_segment VARCHAR2(30);
21205 l_ccid NUMBER;
21206 l_adr_transaction_coa_id NUMBER;
21207 l_adr_accounting_coa_id NUMBER;
21208 l_adr_flexfield_segment_code VARCHAR2(30);
21209 l_adr_flex_value_set_id NUMBER;
21210 l_adr_value_type_code VARCHAR2(30);
21211 l_adr_value_combination_id NUMBER;
21212 l_adr_value_segment_code VARCHAR2(30);
21213
21214 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
21215 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
21216 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
21217 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
21218
21222 l_acc_rev_flag VARCHAR2(1);
21219 -- 4262811 Variables ------------------------------------------------------------------------------------------
21220 l_entered_amt_idx NUMBER;
21221 l_accted_amt_idx NUMBER;
21223 l_accrual_line_num NUMBER;
21224 l_tmp_amt NUMBER;
21225 l_acc_rev_natural_side_code VARCHAR2(1);
21226
21227 l_num_entries NUMBER;
21228 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
21229 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
21230 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
21231 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
21232 l_recog_line_1 NUMBER;
21233 l_recog_line_2 NUMBER;
21234
21235 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
21236 l_bflow_applied_to_amt NUMBER; -- 5132302
21237 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
21238
21239 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
21240
21241 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
21242 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
21243
21244 ---------------------------------------------------------------------------------------------------------------
21245
21246
21247 --
21248 -- bulk performance
21249 --
21250 l_balance_type_code VARCHAR2(1);
21251 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
21252 l_log_module VARCHAR2(240);
21253
21254 --
21255 -- Upgrade strategy
21256 --
21257 l_actual_upg_option VARCHAR2(1);
21258 l_enc_upg_option VARCHAR2(1);
21259
21260 --
21261 BEGIN
21262 --
21263 IF g_log_enabled THEN
21264 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_59';
21265 END IF;
21266 --
21267 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21268
21269 trace
21270 (p_msg => 'BEGIN of AcctLineType_59'
21271 ,p_level => C_LEVEL_PROCEDURE
21272 ,p_module => l_log_module);
21273
21274 END IF;
21275 --
21276 l_component_type := 'AMB_JLT';
21277 l_component_code := 'DM_ROUND';
21278 l_component_type_code := 'S';
21279 l_component_appl_id := 222;
21280 l_amb_context_code := 'DEFAULT';
21281 l_entity_code := 'TRANSACTIONS';
21282 l_event_class_code := 'DEBIT_MEMO';
21283 l_event_type_code := 'DEBIT_MEMO_ALL';
21284 l_line_definition_owner_code := 'S';
21285 l_line_definition_code := 'AR_DM_DEFAULT_ACCRUAL';
21286 --
21287 l_balance_type_code := 'A';
21288 l_segment := NULL;
21289 l_ccid := NULL;
21290 l_adr_transaction_coa_id := NULL;
21291 l_adr_accounting_coa_id := NULL;
21292 l_adr_flexfield_segment_code := NULL;
21293 l_adr_flex_value_set_id := NULL;
21294 l_adr_value_type_code := NULL;
21295 l_adr_value_combination_id := NULL;
21296 l_adr_value_segment_code := NULL;
21297
21298 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
21299 l_bflow_class_code := ''; -- 4219869 Business Flow
21300 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
21301 l_budgetary_control_flag := 'N';
21302
21303 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21304 l_bflow_applied_to_amt := NULL; -- 5132302
21305 l_entered_amt_idx := NULL; -- 4262811
21306 l_accted_amt_idx := NULL; -- 4262811
21307 l_acc_rev_flag := NULL; -- 4262811
21308 l_accrual_line_num := NULL; -- 4262811
21309 l_tmp_amt := NULL; -- 4262811
21310 --
21311
21312 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
21313 l_balance_type_code <> 'B' THEN
21314 IF NVL(p_source_33,'
21315 ') = 'ROUND'
21316 THEN
21317
21318 --
21319 XLA_AE_LINES_PKG.SetNewLine;
21320
21321 p_balance_type_code := l_balance_type_code;
21322 -- set the flag so later we will know whether the gain loss line needs to be created
21323
21324 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
21325 p_actual_flag :='A';
21326 END IF;
21327
21328 --
21329 -- bulk performance
21330 --
21331 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
21332 p_header_num => 0); -- 4262811
21333 --
21334 -- set accounting line options
21335 --
21336 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
21337 p_natural_side_code => 'C'
21338 , p_gain_or_loss_flag => 'N'
21339 , p_gl_transfer_mode_code => 'S'
21343 );
21340 , p_acct_entry_type_code => 'A'
21341 , p_switch_side_flag => 'Y'
21342 , p_merge_duplicate_code => 'A'
21344 --
21345 l_acc_rev_natural_side_code := 'D'; -- 4262811
21346 --
21347 --
21348 -- set accounting line type info
21349 --
21350 xla_ae_lines_pkg.SetAcctLineType
21351 (p_component_type => l_component_type
21352 ,p_event_type_code => l_event_type_code
21353 ,p_line_definition_owner_code => l_line_definition_owner_code
21354 ,p_line_definition_code => l_line_definition_code
21355 ,p_accounting_line_code => l_component_code
21356 ,p_accounting_line_type_code => l_component_type_code
21357 ,p_accounting_line_appl_id => l_component_appl_id
21358 ,p_amb_context_code => l_amb_context_code
21359 ,p_entity_code => l_entity_code
21360 ,p_event_class_code => l_event_class_code);
21361 --
21362 -- set accounting class
21363 --
21364 xla_ae_lines_pkg.SetAcctClass(
21365 p_accounting_class_code => 'ROUNDING'
21366 , p_ae_header_id => l_ae_header_id
21367 );
21368
21369 --
21370 -- set rounding class
21371 --
21372 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
21373 'RECEIVABLE';
21374
21375 --
21376 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
21377 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
21378 --
21379 -- bulk performance
21380 --
21381 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
21382
21383 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
21384 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
21385
21386 -- 4955764
21387 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21388 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
21389
21390 -- 4458381 Public Sector Enh
21391
21392 --
21393 -- set accounting attributes for the line type
21394 --
21395 l_entered_amt_idx := 3;
21396 l_accted_amt_idx := 8;
21397 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21398 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
21399 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
21400 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
21401 l_rec_acct_attrs.array_char_value(2) := p_source_35;
21402 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
21403 l_rec_acct_attrs.array_num_value(3) := p_source_36;
21404 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
21405 l_rec_acct_attrs.array_char_value(4) := p_source_37;
21406 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
21407 l_rec_acct_attrs.array_date_value(5) := p_source_38;
21408 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
21409 l_rec_acct_attrs.array_num_value(6) := p_source_39;
21410 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
21411 l_rec_acct_attrs.array_char_value(7) := p_source_40;
21412 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
21413 l_rec_acct_attrs.array_num_value(8) := p_source_41;
21414 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
21415 l_rec_acct_attrs.array_num_value(9) := p_source_30;
21416 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
21417 l_rec_acct_attrs.array_num_value(10) := p_source_31;
21418 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
21419 l_rec_acct_attrs.array_char_value(11) := p_source_32;
21420 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
21421 l_rec_acct_attrs.array_num_value(12) := p_source_55;
21422
21423 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
21424 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
21425
21426 ---------------------------------------------------------------------------------------------------------------
21427 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
21428 ---------------------------------------------------------------------------------------------------------------
21429 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
21430
21431 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21432 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
21433
21434 IF xla_accounting_cache_pkg.GetValueChar
21435 (p_source_code => 'LEDGER_CATEGORY_CODE'
21436 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
21437 AND l_bflow_method_code = 'PRIOR_ENTRY'
21438 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
21439 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
21440 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
21441 )
21442 THEN
21443 xla_ae_lines_pkg.BflowUpgEntry
21444 (p_business_method_code => l_bflow_method_code
21445 ,p_business_class_code => l_bflow_class_code
21446 ,p_balance_type => l_balance_type_code);
21447 ELSE
21448 NULL;
21449 -- No business flow processing for business flow method of NONE.
21450 END IF;
21451
21452 --
21456 --
21453 -- call analytical criteria
21454 --
21455
21457 -- call description
21458 --
21459 -- No description or it is inherited.
21460 --
21461 -- call ADRs
21462 -- Bug 4922099
21463 --
21464 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21465 (NVL(l_actual_upg_option, 'N') = 'O') OR
21466 (NVL(l_enc_upg_option, 'N') = 'O')
21467 )
21468 THEN
21469 NULL;
21470 --
21471 --
21472
21473 l_ccid := AcctDerRule_28(
21474 p_application_id => p_application_id
21475 , p_ae_header_id => l_ae_header_id
21476 , p_source_19 => p_source_19
21477 , x_transaction_coa_id => l_adr_transaction_coa_id
21478 , x_accounting_coa_id => l_adr_accounting_coa_id
21479 , x_value_type_code => l_adr_value_type_code
21480 , p_side => 'NA'
21481 );
21482
21483 xla_ae_lines_pkg.set_ccid(
21484 p_code_combination_id => l_ccid
21485 , p_value_type_code => l_adr_value_type_code
21486 , p_transaction_coa_id => l_adr_transaction_coa_id
21487 , p_accounting_coa_id => l_adr_accounting_coa_id
21488 , p_adr_code => 'TRX_DIST_CCID'
21489 , p_adr_type_code => 'S'
21490 , p_component_type => l_component_type
21491 , p_component_code => l_component_code
21492 , p_component_type_code => l_component_type_code
21493 , p_component_appl_id => l_component_appl_id
21494 , p_amb_context_code => l_amb_context_code
21495 , p_side => 'NA'
21496 );
21497
21498
21499 --
21500 --
21501 END IF;
21502 --
21503 -- Bug 4922099
21504 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
21505 (NVL(l_enc_upg_option, 'N') = 'O')
21506 ) AND
21507 (l_bflow_method_code = 'PRIOR_ENTRY')
21508 )
21509 THEN
21510 IF
21511 --
21512 1 = 2
21513 --
21514 THEN
21515 xla_accounting_err_pkg.build_message
21516 (p_appli_s_name => 'XLA'
21517 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
21518 ,p_token_1 => 'LINE_NUMBER'
21519 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
21520 ,p_token_2 => 'LINE_TYPE_NAME'
21521 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
21522 l_component_type
21523 ,l_component_code
21524 ,l_component_type_code
21525 ,l_component_appl_id
21526 ,l_amb_context_code
21527 ,l_entity_code
21528 ,l_event_class_code
21529 )
21530 ,p_token_3 => 'OWNER'
21531 ,p_value_3 => xla_lookups_pkg.get_meaning(
21532 p_lookup_type => 'XLA_OWNER_TYPE'
21533 ,p_lookup_code => l_component_type_code
21534 )
21535 ,p_token_4 => 'PRODUCT_NAME'
21536 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
21537 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
21538 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
21539 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
21540 ,p_ae_header_id => NULL
21541 );
21542
21543 IF (C_LEVEL_ERROR>= g_log_level) THEN
21544 trace
21545 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
21546 ,p_level => C_LEVEL_ERROR
21547 ,p_module => l_log_module);
21548 END IF;
21549 END IF;
21550 END IF;
21551 --
21552 --
21553 ------------------------------------------------------------------------------------------------
21554 -- 4219869 Business Flow
21555 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
21556 -- Prior Entry. Currently, the following code is always generated.
21557 ------------------------------------------------------------------------------------------------
21558 XLA_AE_LINES_PKG.ValidateCurrentLine;
21559
21560 ------------------------------------------------------------------------------------
21561 -- 4219869 Business Flow
21562 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
21563 ------------------------------------------------------------------------------------
21564 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21565
21569 ----------------------------------------------------------------------------------
21566 ----------------------------------------------------------------------------------
21567 -- 4219869 Business Flow
21568 -- Update journal entry status -- Need to generate this within IF <condition>
21570 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21571 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
21572 ,p_balance_type_code => l_balance_type_code
21573 );
21574
21575 -------------------------------------------------------------------------------------------
21576 -- 4262811 - Generate the Accrual Reversal lines
21577 -------------------------------------------------------------------------------------------
21578 BEGIN
21579 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
21580 (g_array_event(p_event_id).array_value_num('header_index'));
21581 IF l_acc_rev_flag IS NULL THEN
21582 l_acc_rev_flag := 'N';
21583 END IF;
21584 EXCEPTION
21585 WHEN OTHERS THEN
21586 l_acc_rev_flag := 'N';
21587 END;
21588 --
21589 IF (l_acc_rev_flag = 'Y') THEN
21590
21591 -- 4645092 ------------------------------------------------------------------------------
21592 -- To allow MPA report to determine if it should generate report process
21593 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
21594 ------------------------------------------------------------------------------------------
21595
21596 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
21597 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
21598 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
21599 -- call ADRs
21600 -- Bug 4922099
21601 --
21602 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
21603 (NVL(l_actual_upg_option, 'N') = 'O') OR
21604 (NVL(l_enc_upg_option, 'N') = 'O')
21605 )
21606 THEN
21607 NULL;
21608 --
21609 --
21610
21611 l_ccid := AcctDerRule_28(
21612 p_application_id => p_application_id
21613 , p_ae_header_id => l_ae_header_id
21614 , p_source_19 => p_source_19
21615 , x_transaction_coa_id => l_adr_transaction_coa_id
21616 , x_accounting_coa_id => l_adr_accounting_coa_id
21617 , x_value_type_code => l_adr_value_type_code
21618 , p_side => 'NA'
21619 );
21620
21621 xla_ae_lines_pkg.set_ccid(
21622 p_code_combination_id => l_ccid
21623 , p_value_type_code => l_adr_value_type_code
21624 , p_transaction_coa_id => l_adr_transaction_coa_id
21625 , p_accounting_coa_id => l_adr_accounting_coa_id
21626 , p_adr_code => 'TRX_DIST_CCID'
21627 , p_adr_type_code => 'S'
21628 , p_component_type => l_component_type
21629 , p_component_code => l_component_code
21630 , p_component_type_code => l_component_type_code
21631 , p_component_appl_id => l_component_appl_id
21632 , p_amb_context_code => l_amb_context_code
21633 , p_side => 'NA'
21634 );
21635
21636
21637 --
21638 --
21639 END IF;
21640
21641 --
21645 p_header_num => 1);
21642 -- Update the line information that should be overwritten
21643 --
21644 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
21646 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
21647
21648 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
21649
21650 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
21651 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
21652 END IF;
21653
21654 --
21655 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
21656 --
21657 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
21658 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
21659 ELSE
21660 ---------------------------------------------------------------------------------------------------
21661 -- 4262811a Switch Sign
21662 ---------------------------------------------------------------------------------------------------
21663 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
21664 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21665 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21666 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
21667 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21668 -- 5132302
21669 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
21670 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
21671
21672 END IF;
21673
21674 -- 4955764
21675 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21676 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
21677
21678
21679 XLA_AE_LINES_PKG.ValidateCurrentLine;
21680 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
21681
21682 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
21683 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
21684 ,p_balance_type_code => l_balance_type_code);
21685
21686 END IF;
21687
21688 -----------------------------------------------------------------------------------------
21689 -- 4262811 Multiperiod Accounting
21690 -----------------------------------------------------------------------------------------
21691 -- No MPA option is assigned.
21692
21693
21694 END IF;
21695 END IF;
21696 --
21697
21698 --
21699 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21700 trace
21701 (p_msg => 'END of AcctLineType_59'
21702 ,p_level => C_LEVEL_PROCEDURE
21703 ,p_module => l_log_module);
21704 END IF;
21705 --
21706 EXCEPTION
21707 WHEN xla_exceptions_pkg.application_exception THEN
21708 RAISE;
21709 WHEN OTHERS THEN
21710 xla_exceptions_pkg.raise_message
21711 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_59');
21712 END AcctLineType_59;
21713 --
21714
21715 ---------------------------------------
21716 --
21717 -- PRIVATE FUNCTION
21718 -- AcctLineType_60
21719 --
21720 ---------------------------------------
21721 PROCEDURE AcctLineType_60 (
21722 p_application_id IN NUMBER
21723 ,p_event_id IN NUMBER
21724 ,p_calculate_acctd_flag IN VARCHAR2
21725 ,p_calculate_g_l_flag IN VARCHAR2
21726 ,p_actual_flag IN OUT VARCHAR2
21727 ,p_balance_type_code OUT VARCHAR2
21728 ,p_gain_or_loss_ref OUT VARCHAR2
21729
21730 --Transaction Distribution GL Account
21731 , p_source_19 IN NUMBER
21732 --Bill To Customer Account Identifier
21733 , p_source_30 IN NUMBER
21734 --Bill To Customer Site Use Identifier
21735 , p_source_31 IN NUMBER
21736 --SLA Party Type
21737 , p_source_32 IN VARCHAR2
21738 --Transaction Distribution Account Class
21739 , p_source_33 IN VARCHAR2
21740 --Transaction Distribution Identifier
21741 , p_source_34 IN NUMBER
21742 --Transaction Distribution Type
21743 , p_source_35 IN VARCHAR2
21744 --Transaction Distribution Entered Amount
21745 , p_source_36 IN NUMBER
21746 --Transaction Currency Code
21747 , p_source_37 IN VARCHAR2
21748 --Transaction Exchange Date
21749 , p_source_38 IN DATE
21750 --Transaction Exchange Rate
21751 , p_source_39 IN NUMBER
21752 --Transaction Exchange Rate Type
21753 , p_source_40 IN VARCHAR2
21754 --Transaction Accounting Amount
21755 , p_source_41 IN NUMBER
21759 IS
21756 --Transaction Tax Line Identifier
21757 , p_source_55 IN NUMBER
21758 )
21760
21761 l_component_type VARCHAR2(80);
21762 l_component_code VARCHAR2(30);
21763 l_component_type_code VARCHAR2(1);
21764 l_component_appl_id INTEGER;
21765 l_amb_context_code VARCHAR2(30);
21766 l_entity_code VARCHAR2(30);
21767 l_event_class_code VARCHAR2(30);
21768 l_ae_header_id NUMBER;
21769 l_event_type_code VARCHAR2(30);
21770 l_line_definition_code VARCHAR2(30);
21771 l_line_definition_owner_code VARCHAR2(1);
21772 --
21773 -- adr variables
21774 l_segment VARCHAR2(30);
21775 l_ccid NUMBER;
21776 l_adr_transaction_coa_id NUMBER;
21777 l_adr_accounting_coa_id NUMBER;
21778 l_adr_flexfield_segment_code VARCHAR2(30);
21779 l_adr_flex_value_set_id NUMBER;
21780 l_adr_value_type_code VARCHAR2(30);
21781 l_adr_value_combination_id NUMBER;
21782 l_adr_value_segment_code VARCHAR2(30);
21783
21784 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
21785 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
21786 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
21787 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
21788
21789 -- 4262811 Variables ------------------------------------------------------------------------------------------
21793 l_accrual_line_num NUMBER;
21790 l_entered_amt_idx NUMBER;
21791 l_accted_amt_idx NUMBER;
21792 l_acc_rev_flag VARCHAR2(1);
21794 l_tmp_amt NUMBER;
21795 l_acc_rev_natural_side_code VARCHAR2(1);
21796
21797 l_num_entries NUMBER;
21798 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
21799 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
21800 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
21801 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
21802 l_recog_line_1 NUMBER;
21803 l_recog_line_2 NUMBER;
21804
21805 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
21806 l_bflow_applied_to_amt NUMBER; -- 5132302
21807 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
21808
21809 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
21810
21811 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
21812 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
21813
21814 ---------------------------------------------------------------------------------------------------------------
21815
21816
21817 --
21818 -- bulk performance
21819 --
21820 l_balance_type_code VARCHAR2(1);
21821 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
21822 l_log_module VARCHAR2(240);
21823
21824 --
21825 -- Upgrade strategy
21826 --
21827 l_actual_upg_option VARCHAR2(1);
21828 l_enc_upg_option VARCHAR2(1);
21829
21830 --
21831 BEGIN
21832 --
21833 IF g_log_enabled THEN
21834 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_60';
21835 END IF;
21836 --
21837 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
21838
21839 trace
21840 (p_msg => 'BEGIN of AcctLineType_60'
21841 ,p_level => C_LEVEL_PROCEDURE
21842 ,p_module => l_log_module);
21843
21844 END IF;
21845 --
21846 l_component_type := 'AMB_JLT';
21847 l_component_code := 'DM_SUSPENSE';
21848 l_component_type_code := 'S';
21849 l_component_appl_id := 222;
21850 l_amb_context_code := 'DEFAULT';
21851 l_entity_code := 'TRANSACTIONS';
21852 l_event_class_code := 'DEBIT_MEMO';
21853 l_event_type_code := 'DEBIT_MEMO_ALL';
21854 l_line_definition_owner_code := 'S';
21855 l_line_definition_code := 'AR_DM_DEFAULT_ACCRUAL';
21856 --
21857 l_balance_type_code := 'A';
21858 l_segment := NULL;
21859 l_ccid := NULL;
21860 l_adr_transaction_coa_id := NULL;
21861 l_adr_accounting_coa_id := NULL;
21862 l_adr_flexfield_segment_code := NULL;
21863 l_adr_flex_value_set_id := NULL;
21864 l_adr_value_type_code := NULL;
21865 l_adr_value_combination_id := NULL;
21866 l_adr_value_segment_code := NULL;
21867
21871 l_budgetary_control_flag := 'N';
21868 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
21869 l_bflow_class_code := ''; -- 4219869 Business Flow
21870 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
21872
21873 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21874 l_bflow_applied_to_amt := NULL; -- 5132302
21875 l_entered_amt_idx := NULL; -- 4262811
21876 l_accted_amt_idx := NULL; -- 4262811
21877 l_acc_rev_flag := NULL; -- 4262811
21878 l_accrual_line_num := NULL; -- 4262811
21879 l_tmp_amt := NULL; -- 4262811
21880 --
21881
21882 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
21883 l_balance_type_code <> 'B' THEN
21884 IF NVL(p_source_33,'
21885 ') = 'SUSPENSE'
21886 THEN
21887
21888 --
21889 XLA_AE_LINES_PKG.SetNewLine;
21890
21891 p_balance_type_code := l_balance_type_code;
21892 -- set the flag so later we will know whether the gain loss line needs to be created
21893
21894 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
21895 p_actual_flag :='A';
21896 END IF;
21897
21898 --
21899 -- bulk performance
21900 --
21901 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
21902 p_header_num => 0); -- 4262811
21903 --
21904 -- set accounting line options
21905 --
21906 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
21907 p_natural_side_code => 'C'
21908 , p_gain_or_loss_flag => 'N'
21909 , p_gl_transfer_mode_code => 'S'
21910 , p_acct_entry_type_code => 'A'
21911 , p_switch_side_flag => 'Y'
21912 , p_merge_duplicate_code => 'A'
21913 );
21914 --
21915 l_acc_rev_natural_side_code := 'D'; -- 4262811
21916 --
21917 --
21918 -- set accounting line type info
21919 --
21920 xla_ae_lines_pkg.SetAcctLineType
21921 (p_component_type => l_component_type
21922 ,p_event_type_code => l_event_type_code
21923 ,p_line_definition_owner_code => l_line_definition_owner_code
21924 ,p_line_definition_code => l_line_definition_code
21925 ,p_accounting_line_code => l_component_code
21926 ,p_accounting_line_type_code => l_component_type_code
21927 ,p_accounting_line_appl_id => l_component_appl_id
21928 ,p_amb_context_code => l_amb_context_code
21929 ,p_entity_code => l_entity_code
21930 ,p_event_class_code => l_event_class_code);
21931 --
21932 -- set accounting class
21933 --
21934 xla_ae_lines_pkg.SetAcctClass(
21935 p_accounting_class_code => 'SUSPENSE'
21936 , p_ae_header_id => l_ae_header_id
21937 );
21938
21939 --
21940 -- set rounding class
21941 --
21942 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
21943 'RECEIVABLE';
21944
21945 --
21946 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
21947 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
21948 --
21949 -- bulk performance
21950 --
21951 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
21952
21953 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
21954 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
21955
21956 -- 4955764
21957 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
21958 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
21959
21960 -- 4458381 Public Sector Enh
21961
21962 --
21963 -- set accounting attributes for the line type
21964 --
21965 l_entered_amt_idx := 3;
21966 l_accted_amt_idx := 8;
21967 l_bflow_applied_to_amt_idx := NULL; -- 5132302
21968 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
21969 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
21970 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
21971 l_rec_acct_attrs.array_char_value(2) := p_source_35;
21972 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
21973 l_rec_acct_attrs.array_num_value(3) := p_source_36;
21974 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
21975 l_rec_acct_attrs.array_char_value(4) := p_source_37;
21976 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
21977 l_rec_acct_attrs.array_date_value(5) := p_source_38;
21978 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
21979 l_rec_acct_attrs.array_num_value(6) := p_source_39;
21980 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
21981 l_rec_acct_attrs.array_char_value(7) := p_source_40;
21982 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
21983 l_rec_acct_attrs.array_num_value(8) := p_source_41;
21984 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
21985 l_rec_acct_attrs.array_num_value(9) := p_source_30;
21986 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
21987 l_rec_acct_attrs.array_num_value(10) := p_source_31;
21988 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
21989 l_rec_acct_attrs.array_char_value(11) := p_source_32;
21990 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
21991 l_rec_acct_attrs.array_num_value(12) := p_source_55;
21992
21993 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
21994 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
21995
21996 ---------------------------------------------------------------------------------------------------------------
21997 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
21998 ---------------------------------------------------------------------------------------------------------------
21999 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
22000
22001 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22002 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22003
22004 IF xla_accounting_cache_pkg.GetValueChar
22005 (p_source_code => 'LEDGER_CATEGORY_CODE'
22006 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
22007 AND l_bflow_method_code = 'PRIOR_ENTRY'
22008 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
22009 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
22010 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
22011 )
22012 THEN
22013 xla_ae_lines_pkg.BflowUpgEntry
22014 (p_business_method_code => l_bflow_method_code
22015 ,p_business_class_code => l_bflow_class_code
22016 ,p_balance_type => l_balance_type_code);
22017 ELSE
22018 NULL;
22019 -- No business flow processing for business flow method of NONE.
22020 END IF;
22021
22022 --
22023 -- call analytical criteria
22024 --
22025
22026 --
22027 -- call description
22028 --
22029 -- No description or it is inherited.
22030 --
22031 -- call ADRs
22032 -- Bug 4922099
22033 --
22034 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22035 (NVL(l_actual_upg_option, 'N') = 'O') OR
22036 (NVL(l_enc_upg_option, 'N') = 'O')
22037 )
22038 THEN
22039 NULL;
22040 --
22041 --
22042
22043 l_ccid := AcctDerRule_28(
22044 p_application_id => p_application_id
22045 , p_ae_header_id => l_ae_header_id
22046 , p_source_19 => p_source_19
22047 , x_transaction_coa_id => l_adr_transaction_coa_id
22048 , x_accounting_coa_id => l_adr_accounting_coa_id
22049 , x_value_type_code => l_adr_value_type_code
22050 , p_side => 'NA'
22051 );
22052
22053 xla_ae_lines_pkg.set_ccid(
22054 p_code_combination_id => l_ccid
22055 , p_value_type_code => l_adr_value_type_code
22056 , p_transaction_coa_id => l_adr_transaction_coa_id
22057 , p_accounting_coa_id => l_adr_accounting_coa_id
22058 , p_adr_code => 'TRX_DIST_CCID'
22059 , p_adr_type_code => 'S'
22063 , p_component_appl_id => l_component_appl_id
22060 , p_component_type => l_component_type
22061 , p_component_code => l_component_code
22062 , p_component_type_code => l_component_type_code
22064 , p_amb_context_code => l_amb_context_code
22065 , p_side => 'NA'
22066 );
22067
22068
22069 --
22070 --
22071 END IF;
22072 --
22073 -- Bug 4922099
22074 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
22075 (NVL(l_enc_upg_option, 'N') = 'O')
22076 ) AND
22077 (l_bflow_method_code = 'PRIOR_ENTRY')
22078 )
22079 THEN
22080 IF
22081 --
22082 1 = 2
22083 --
22084 THEN
22085 xla_accounting_err_pkg.build_message
22086 (p_appli_s_name => 'XLA'
22087 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22088 ,p_token_1 => 'LINE_NUMBER'
22089 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
22090 ,p_token_2 => 'LINE_TYPE_NAME'
22091 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
22092 l_component_type
22093 ,l_component_code
22094 ,l_component_type_code
22095 ,l_component_appl_id
22096 ,l_amb_context_code
22097 ,l_entity_code
22098 ,l_event_class_code
22099 )
22100 ,p_token_3 => 'OWNER'
22101 ,p_value_3 => xla_lookups_pkg.get_meaning(
22102 p_lookup_type => 'XLA_OWNER_TYPE'
22103 ,p_lookup_code => l_component_type_code
22104 )
22105 ,p_token_4 => 'PRODUCT_NAME'
22106 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
22107 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
22108 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
22109 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
22110 ,p_ae_header_id => NULL
22111 );
22112
22113 IF (C_LEVEL_ERROR>= g_log_level) THEN
22114 trace
22115 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22116 ,p_level => C_LEVEL_ERROR
22117 ,p_module => l_log_module);
22118 END IF;
22119 END IF;
22120 END IF;
22121 --
22122 --
22123 ------------------------------------------------------------------------------------------------
22124 -- 4219869 Business Flow
22125 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
22126 -- Prior Entry. Currently, the following code is always generated.
22127 ------------------------------------------------------------------------------------------------
22128 XLA_AE_LINES_PKG.ValidateCurrentLine;
22129
22130 ------------------------------------------------------------------------------------
22131 -- 4219869 Business Flow
22132 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
22133 ------------------------------------------------------------------------------------
22134 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22135
22136 ----------------------------------------------------------------------------------
22137 -- 4219869 Business Flow
22138 -- Update journal entry status -- Need to generate this within IF <condition>
22139 ----------------------------------------------------------------------------------
22140 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22141 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
22142 ,p_balance_type_code => l_balance_type_code
22143 );
22144
22145 -------------------------------------------------------------------------------------------
22146 -- 4262811 - Generate the Accrual Reversal lines
22147 -------------------------------------------------------------------------------------------
22148 BEGIN
22149 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
22150 (g_array_event(p_event_id).array_value_num('header_index'));
22151 IF l_acc_rev_flag IS NULL THEN
22152 l_acc_rev_flag := 'N';
22153 END IF;
22154 EXCEPTION
22155 WHEN OTHERS THEN
22156 l_acc_rev_flag := 'N';
22157 END;
22158 --
22159 IF (l_acc_rev_flag = 'Y') THEN
22160
22161 -- 4645092 ------------------------------------------------------------------------------
22162 -- To allow MPA report to determine if it should generate report process
22163 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
22164 ------------------------------------------------------------------------------------------
22165
22166 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
22167 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
22168 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
22169 -- call ADRs
22170 -- Bug 4922099
22171 --
22172 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22173 (NVL(l_actual_upg_option, 'N') = 'O') OR
22174 (NVL(l_enc_upg_option, 'N') = 'O')
22175 )
22176 THEN
22177 NULL;
22178 --
22179 --
22180
22181 l_ccid := AcctDerRule_28(
22182 p_application_id => p_application_id
22183 , p_ae_header_id => l_ae_header_id
22184 , p_source_19 => p_source_19
22185 , x_transaction_coa_id => l_adr_transaction_coa_id
22186 , x_accounting_coa_id => l_adr_accounting_coa_id
22187 , x_value_type_code => l_adr_value_type_code
22188 , p_side => 'NA'
22189 );
22190
22191 xla_ae_lines_pkg.set_ccid(
22192 p_code_combination_id => l_ccid
22193 , p_value_type_code => l_adr_value_type_code
22194 , p_transaction_coa_id => l_adr_transaction_coa_id
22195 , p_accounting_coa_id => l_adr_accounting_coa_id
22196 , p_adr_code => 'TRX_DIST_CCID'
22197 , p_adr_type_code => 'S'
22198 , p_component_type => l_component_type
22199 , p_component_code => l_component_code
22200 , p_component_type_code => l_component_type_code
22201 , p_component_appl_id => l_component_appl_id
22202 , p_amb_context_code => l_amb_context_code
22203 , p_side => 'NA'
22204 );
22205
22206
22207 --
22208 --
22209 END IF;
22210
22211 --
22212 -- Update the line information that should be overwritten
22213 --
22214 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
22218 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
22215 p_header_num => 1);
22216 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
22217
22219
22220 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
22221 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
22222 END IF;
22223
22224 --
22225 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
22226 --
22227 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
22228 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
22229 ELSE
22230 ---------------------------------------------------------------------------------------------------
22231 -- 4262811a Switch Sign
22232 ---------------------------------------------------------------------------------------------------
22233 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
22234 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22235 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22236 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22237 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22238 -- 5132302
22239 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
22240 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22241
22242 END IF;
22243
22244 -- 4955764
22245 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22246 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
22247
22248
22249 XLA_AE_LINES_PKG.ValidateCurrentLine;
22250 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22251
22252 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22253 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
22254 ,p_balance_type_code => l_balance_type_code);
22255
22256 END IF;
22257
22258 -----------------------------------------------------------------------------------------
22259 -- 4262811 Multiperiod Accounting
22260 -----------------------------------------------------------------------------------------
22261 -- No MPA option is assigned.
22262
22263
22264 END IF;
22265 END IF;
22266 --
22267
22268 --
22269 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22270 trace
22271 (p_msg => 'END of AcctLineType_60'
22272 ,p_level => C_LEVEL_PROCEDURE
22273 ,p_module => l_log_module);
22274 END IF;
22275 --
22276 EXCEPTION
22277 WHEN xla_exceptions_pkg.application_exception THEN
22278 RAISE;
22279 WHEN OTHERS THEN
22280 xla_exceptions_pkg.raise_message
22281 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_60');
22282 END AcctLineType_60;
22283 --
22284
22285 ---------------------------------------
22286 --
22287 -- PRIVATE FUNCTION
22288 -- AcctLineType_61
22289 --
22290 ---------------------------------------
22291 PROCEDURE AcctLineType_61 (
22292 p_application_id IN NUMBER
22293 ,p_event_id IN NUMBER
22294 ,p_calculate_acctd_flag IN VARCHAR2
22295 ,p_calculate_g_l_flag IN VARCHAR2
22296 ,p_actual_flag IN OUT VARCHAR2
22297 ,p_balance_type_code OUT VARCHAR2
22298 ,p_gain_or_loss_ref OUT VARCHAR2
22299
22300 --Transaction Distribution GL Account
22301 , p_source_19 IN NUMBER
22302 --Bill To Customer Account Identifier
22303 , p_source_30 IN NUMBER
22304 --Bill To Customer Site Use Identifier
22305 , p_source_31 IN NUMBER
22306 --SLA Party Type
22307 , p_source_32 IN VARCHAR2
22308 --Transaction Distribution Account Class
22309 , p_source_33 IN VARCHAR2
22310 --Transaction Distribution Identifier
22311 , p_source_34 IN NUMBER
22312 --Transaction Distribution Type
22313 , p_source_35 IN VARCHAR2
22314 --Transaction Distribution Entered Amount
22315 , p_source_36 IN NUMBER
22316 --Transaction Currency Code
22317 , p_source_37 IN VARCHAR2
22321 , p_source_39 IN NUMBER
22318 --Transaction Exchange Date
22319 , p_source_38 IN DATE
22320 --Transaction Exchange Rate
22322 --Transaction Exchange Rate Type
22323 , p_source_40 IN VARCHAR2
22324 --Transaction Accounting Amount
22325 , p_source_41 IN NUMBER
22326 --Transaction Tax Line Identifier
22327 , p_source_55 IN NUMBER
22328 )
22329 IS
22330
22331 l_component_type VARCHAR2(80);
22332 l_component_code VARCHAR2(30);
22333 l_component_type_code VARCHAR2(1);
22334 l_component_appl_id INTEGER;
22335 l_amb_context_code VARCHAR2(30);
22336 l_entity_code VARCHAR2(30);
22337 l_event_class_code VARCHAR2(30);
22338 l_ae_header_id NUMBER;
22339 l_event_type_code VARCHAR2(30);
22340 l_line_definition_code VARCHAR2(30);
22341 l_line_definition_owner_code VARCHAR2(1);
22342 --
22343 -- adr variables
22344 l_segment VARCHAR2(30);
22345 l_ccid NUMBER;
22346 l_adr_transaction_coa_id NUMBER;
22347 l_adr_accounting_coa_id NUMBER;
22348 l_adr_flexfield_segment_code VARCHAR2(30);
22349 l_adr_flex_value_set_id NUMBER;
22350 l_adr_value_type_code VARCHAR2(30);
22351 l_adr_value_combination_id NUMBER;
22352 l_adr_value_segment_code VARCHAR2(30);
22353
22354 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
22355 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
22356 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
22357 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
22358
22359 -- 4262811 Variables ------------------------------------------------------------------------------------------
22360 l_entered_amt_idx NUMBER;
22361 l_accted_amt_idx NUMBER;
22362 l_acc_rev_flag VARCHAR2(1);
22363 l_accrual_line_num NUMBER;
22367 l_num_entries NUMBER;
22364 l_tmp_amt NUMBER;
22365 l_acc_rev_natural_side_code VARCHAR2(1);
22366
22368 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
22369 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
22370 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
22371 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
22372 l_recog_line_1 NUMBER;
22373 l_recog_line_2 NUMBER;
22374
22375 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
22376 l_bflow_applied_to_amt NUMBER; -- 5132302
22377 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
22378
22379 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
22380
22381 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
22382 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
22383
22384 ---------------------------------------------------------------------------------------------------------------
22385
22386
22387 --
22388 -- bulk performance
22389 --
22390 l_balance_type_code VARCHAR2(1);
22391 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
22392 l_log_module VARCHAR2(240);
22393
22394 --
22395 -- Upgrade strategy
22396 --
22397 l_actual_upg_option VARCHAR2(1);
22398 l_enc_upg_option VARCHAR2(1);
22399
22400 --
22401 BEGIN
22402 --
22403 IF g_log_enabled THEN
22404 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_61';
22405 END IF;
22406 --
22407 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22408
22409 trace
22410 (p_msg => 'BEGIN of AcctLineType_61'
22411 ,p_level => C_LEVEL_PROCEDURE
22412 ,p_module => l_log_module);
22413
22414 END IF;
22415 --
22416 l_component_type := 'AMB_JLT';
22417 l_component_code := 'DM_TAX';
22418 l_component_type_code := 'S';
22419 l_component_appl_id := 222;
22420 l_amb_context_code := 'DEFAULT';
22421 l_entity_code := 'TRANSACTIONS';
22422 l_event_class_code := 'DEBIT_MEMO';
22423 l_event_type_code := 'DEBIT_MEMO_ALL';
22424 l_line_definition_owner_code := 'S';
22425 l_line_definition_code := 'AR_DM_DEFAULT_ACCRUAL';
22426 --
22427 l_balance_type_code := 'A';
22428 l_segment := NULL;
22429 l_ccid := NULL;
22430 l_adr_transaction_coa_id := NULL;
22431 l_adr_accounting_coa_id := NULL;
22432 l_adr_flexfield_segment_code := NULL;
22433 l_adr_flex_value_set_id := NULL;
22434 l_adr_value_type_code := NULL;
22435 l_adr_value_combination_id := NULL;
22436 l_adr_value_segment_code := NULL;
22437
22438 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
22439 l_bflow_class_code := ''; -- 4219869 Business Flow
22440 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
22441 l_budgetary_control_flag := 'N';
22442
22443 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22444 l_bflow_applied_to_amt := NULL; -- 5132302
22445 l_entered_amt_idx := NULL; -- 4262811
22446 l_accted_amt_idx := NULL; -- 4262811
22447 l_acc_rev_flag := NULL; -- 4262811
22448 l_accrual_line_num := NULL; -- 4262811
22449 l_tmp_amt := NULL; -- 4262811
22450 --
22451
22452 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
22453 l_balance_type_code <> 'B' THEN
22454 IF NVL(p_source_33,'
22455 ') = 'TAX'
22456 THEN
22457
22458 --
22459 XLA_AE_LINES_PKG.SetNewLine;
22460
22461 p_balance_type_code := l_balance_type_code;
22462 -- set the flag so later we will know whether the gain loss line needs to be created
22463
22464 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
22465 p_actual_flag :='A';
22466 END IF;
22467
22468 --
22469 -- bulk performance
22470 --
22471 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
22472 p_header_num => 0); -- 4262811
22473 --
22474 -- set accounting line options
22475 --
22476 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
22477 p_natural_side_code => 'C'
22478 , p_gain_or_loss_flag => 'N'
22479 , p_gl_transfer_mode_code => 'S'
22480 , p_acct_entry_type_code => 'A'
22481 , p_switch_side_flag => 'Y'
22482 , p_merge_duplicate_code => 'A'
22483 );
22484 --
22485 l_acc_rev_natural_side_code := 'D'; -- 4262811
22486 --
22487 --
22488 -- set accounting line type info
22489 --
22490 xla_ae_lines_pkg.SetAcctLineType
22491 (p_component_type => l_component_type
22492 ,p_event_type_code => l_event_type_code
22493 ,p_line_definition_owner_code => l_line_definition_owner_code
22494 ,p_line_definition_code => l_line_definition_code
22495 ,p_accounting_line_code => l_component_code
22496 ,p_accounting_line_type_code => l_component_type_code
22497 ,p_accounting_line_appl_id => l_component_appl_id
22498 ,p_amb_context_code => l_amb_context_code
22499 ,p_entity_code => l_entity_code
22500 ,p_event_class_code => l_event_class_code);
22501 --
22502 -- set accounting class
22503 --
22504 xla_ae_lines_pkg.SetAcctClass(
22505 p_accounting_class_code => 'TAX'
22506 , p_ae_header_id => l_ae_header_id
22507 );
22508
22509 --
22510 -- set rounding class
22511 --
22512 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
22513 'RECEIVABLE';
22514
22515 --
22516 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
22517 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
22518 --
22519 -- bulk performance
22520 --
22521 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
22522
22523 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
22524 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
22525
22526 -- 4955764
22527 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22528 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
22529
22530 -- 4458381 Public Sector Enh
22531
22532 --
22533 -- set accounting attributes for the line type
22534 --
22535 l_entered_amt_idx := 3;
22536 l_accted_amt_idx := 8;
22537 l_bflow_applied_to_amt_idx := NULL; -- 5132302
22538 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
22539 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
22540 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
22544 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
22541 l_rec_acct_attrs.array_char_value(2) := p_source_35;
22542 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
22543 l_rec_acct_attrs.array_num_value(3) := p_source_36;
22545 l_rec_acct_attrs.array_char_value(4) := p_source_37;
22546 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
22547 l_rec_acct_attrs.array_date_value(5) := p_source_38;
22548 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
22549 l_rec_acct_attrs.array_num_value(6) := p_source_39;
22550 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
22551 l_rec_acct_attrs.array_char_value(7) := p_source_40;
22552 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
22553 l_rec_acct_attrs.array_num_value(8) := p_source_41;
22554 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
22555 l_rec_acct_attrs.array_num_value(9) := p_source_30;
22556 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
22557 l_rec_acct_attrs.array_num_value(10) := p_source_31;
22558 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
22559 l_rec_acct_attrs.array_char_value(11) := p_source_32;
22560 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
22561 l_rec_acct_attrs.array_num_value(12) := p_source_55;
22562
22563 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
22564 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
22565
22566 ---------------------------------------------------------------------------------------------------------------
22567 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
22568 ---------------------------------------------------------------------------------------------------------------
22569 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
22570
22571 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22572 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
22573
22574 IF xla_accounting_cache_pkg.GetValueChar
22575 (p_source_code => 'LEDGER_CATEGORY_CODE'
22576 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
22577 AND l_bflow_method_code = 'PRIOR_ENTRY'
22578 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
22579 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
22580 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
22581 )
22582 THEN
22583 xla_ae_lines_pkg.BflowUpgEntry
22584 (p_business_method_code => l_bflow_method_code
22585 ,p_business_class_code => l_bflow_class_code
22586 ,p_balance_type => l_balance_type_code);
22587 ELSE
22588 NULL;
22589 -- No business flow processing for business flow method of NONE.
22590 END IF;
22591
22592 --
22593 -- call analytical criteria
22594 --
22595
22596 --
22597 -- call description
22598 --
22599 -- No description or it is inherited.
22600 --
22601 -- call ADRs
22602 -- Bug 4922099
22603 --
22604 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22605 (NVL(l_actual_upg_option, 'N') = 'O') OR
22606 (NVL(l_enc_upg_option, 'N') = 'O')
22607 )
22608 THEN
22609 NULL;
22610 --
22611 --
22612
22613 l_ccid := AcctDerRule_28(
22614 p_application_id => p_application_id
22615 , p_ae_header_id => l_ae_header_id
22616 , p_source_19 => p_source_19
22617 , x_transaction_coa_id => l_adr_transaction_coa_id
22618 , x_accounting_coa_id => l_adr_accounting_coa_id
22619 , x_value_type_code => l_adr_value_type_code
22620 , p_side => 'NA'
22621 );
22622
22623 xla_ae_lines_pkg.set_ccid(
22624 p_code_combination_id => l_ccid
22625 , p_value_type_code => l_adr_value_type_code
22626 , p_transaction_coa_id => l_adr_transaction_coa_id
22627 , p_accounting_coa_id => l_adr_accounting_coa_id
22628 , p_adr_code => 'TRX_DIST_CCID'
22629 , p_adr_type_code => 'S'
22630 , p_component_type => l_component_type
22631 , p_component_code => l_component_code
22632 , p_component_type_code => l_component_type_code
22633 , p_component_appl_id => l_component_appl_id
22634 , p_amb_context_code => l_amb_context_code
22635 , p_side => 'NA'
22636 );
22637
22638
22639 --
22640 --
22641 END IF;
22642 --
22643 -- Bug 4922099
22644 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
22645 (NVL(l_enc_upg_option, 'N') = 'O')
22646 ) AND
22647 (l_bflow_method_code = 'PRIOR_ENTRY')
22648 )
22649 THEN
22650 IF
22651 --
22652 1 = 2
22653 --
22654 THEN
22655 xla_accounting_err_pkg.build_message
22656 (p_appli_s_name => 'XLA'
22657 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22658 ,p_token_1 => 'LINE_NUMBER'
22659 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
22660 ,p_token_2 => 'LINE_TYPE_NAME'
22663 ,l_component_code
22664 ,l_component_type_code
22665 ,l_component_appl_id
22666 ,l_amb_context_code
22667 ,l_entity_code
22668 ,l_event_class_code
22669 )
22670 ,p_token_3 => 'OWNER'
22671 ,p_value_3 => xla_lookups_pkg.get_meaning(
22672 p_lookup_type => 'XLA_OWNER_TYPE'
22673 ,p_lookup_code => l_component_type_code
22674 )
22675 ,p_token_4 => 'PRODUCT_NAME'
22676 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
22677 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
22678 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
22679 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
22680 ,p_ae_header_id => NULL
22681 );
22682
22683 IF (C_LEVEL_ERROR>= g_log_level) THEN
22684 trace
22685 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
22686 ,p_level => C_LEVEL_ERROR
22687 ,p_module => l_log_module);
22688 END IF;
22689 END IF;
22690 END IF;
22691 --
22692 --
22693 ------------------------------------------------------------------------------------------------
22694 -- 4219869 Business Flow
22695 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
22696 -- Prior Entry. Currently, the following code is always generated.
22697 ------------------------------------------------------------------------------------------------
22698 XLA_AE_LINES_PKG.ValidateCurrentLine;
22699
22700 ------------------------------------------------------------------------------------
22701 -- 4219869 Business Flow
22702 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
22703 ------------------------------------------------------------------------------------
22704 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22705
22706 ----------------------------------------------------------------------------------
22707 -- 4219869 Business Flow
22708 -- Update journal entry status -- Need to generate this within IF <condition>
22709 ----------------------------------------------------------------------------------
22710 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22711 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
22712 ,p_balance_type_code => l_balance_type_code
22713 );
22714
22718 BEGIN
22661 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
22662 l_component_type
22715 -------------------------------------------------------------------------------------------
22716 -- 4262811 - Generate the Accrual Reversal lines
22717 -------------------------------------------------------------------------------------------
22719 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
22720 (g_array_event(p_event_id).array_value_num('header_index'));
22721 IF l_acc_rev_flag IS NULL THEN
22722 l_acc_rev_flag := 'N';
22723 END IF;
22724 EXCEPTION
22725 WHEN OTHERS THEN
22726 l_acc_rev_flag := 'N';
22727 END;
22728 --
22729 IF (l_acc_rev_flag = 'Y') THEN
22730
22731 -- 4645092 ------------------------------------------------------------------------------
22732 -- To allow MPA report to determine if it should generate report process
22733 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
22734 ------------------------------------------------------------------------------------------
22735
22736 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
22737 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
22738 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
22739 -- call ADRs
22740 -- Bug 4922099
22741 --
22742 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
22743 (NVL(l_actual_upg_option, 'N') = 'O') OR
22744 (NVL(l_enc_upg_option, 'N') = 'O')
22745 )
22746 THEN
22747 NULL;
22748 --
22749 --
22750
22751 l_ccid := AcctDerRule_28(
22752 p_application_id => p_application_id
22753 , p_ae_header_id => l_ae_header_id
22754 , p_source_19 => p_source_19
22755 , x_transaction_coa_id => l_adr_transaction_coa_id
22756 , x_accounting_coa_id => l_adr_accounting_coa_id
22757 , x_value_type_code => l_adr_value_type_code
22758 , p_side => 'NA'
22759 );
22760
22761 xla_ae_lines_pkg.set_ccid(
22762 p_code_combination_id => l_ccid
22763 , p_value_type_code => l_adr_value_type_code
22764 , p_transaction_coa_id => l_adr_transaction_coa_id
22765 , p_accounting_coa_id => l_adr_accounting_coa_id
22766 , p_adr_code => 'TRX_DIST_CCID'
22767 , p_adr_type_code => 'S'
22768 , p_component_type => l_component_type
22769 , p_component_code => l_component_code
22770 , p_component_type_code => l_component_type_code
22771 , p_component_appl_id => l_component_appl_id
22772 , p_amb_context_code => l_amb_context_code
22773 , p_side => 'NA'
22774 );
22775
22776
22777 --
22778 --
22779 END IF;
22780
22781 --
22782 -- Update the line information that should be overwritten
22783 --
22784 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
22785 p_header_num => 1);
22786 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
22787
22788 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
22789
22790 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
22791 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
22792 END IF;
22793
22794 --
22795 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
22796 --
22797 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
22798 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
22799 ELSE
22800 ---------------------------------------------------------------------------------------------------
22801 -- 4262811a Switch Sign
22802 ---------------------------------------------------------------------------------------------------
22803 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
22804 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22805 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22806 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
22807 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22808 -- 5132302
22809 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
22810 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
22811
22812 END IF;
22813
22814 -- 4955764
22815 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
22816 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
22817
22818
22819 XLA_AE_LINES_PKG.ValidateCurrentLine;
22820 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
22821
22822 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
22823 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
22824 ,p_balance_type_code => l_balance_type_code);
22825
22826 END IF;
22827
22828 -----------------------------------------------------------------------------------------
22829 -- 4262811 Multiperiod Accounting
22830 -----------------------------------------------------------------------------------------
22834 END IF;
22831 -- No MPA option is assigned.
22832
22833
22835 END IF;
22836 --
22837
22838 --
22839 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22840 trace
22841 (p_msg => 'END of AcctLineType_61'
22842 ,p_level => C_LEVEL_PROCEDURE
22843 ,p_module => l_log_module);
22844 END IF;
22845 --
22846 EXCEPTION
22847 WHEN xla_exceptions_pkg.application_exception THEN
22848 RAISE;
22849 WHEN OTHERS THEN
22850 xla_exceptions_pkg.raise_message
22851 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_61');
22852 END AcctLineType_61;
22853 --
22854
22855 ---------------------------------------
22856 --
22857 -- PRIVATE FUNCTION
22858 -- AcctLineType_62
22859 --
22860 ---------------------------------------
22861 PROCEDURE AcctLineType_62 (
22862 p_application_id IN NUMBER
22863 ,p_event_id IN NUMBER
22864 ,p_calculate_acctd_flag IN VARCHAR2
22865 ,p_calculate_g_l_flag IN VARCHAR2
22866 ,p_actual_flag IN OUT VARCHAR2
22867 ,p_balance_type_code OUT VARCHAR2
22868 ,p_gain_or_loss_ref OUT VARCHAR2
22869
22870 --Transaction Distribution GL Account
22871 , p_source_19 IN NUMBER
22872 --Bill To Customer Account Identifier
22873 , p_source_30 IN NUMBER
22874 --Bill To Customer Site Use Identifier
22875 , p_source_31 IN NUMBER
22876 --SLA Party Type
22877 , p_source_32 IN VARCHAR2
22878 --Transaction Distribution Account Class
22879 , p_source_33 IN VARCHAR2
22880 --Transaction Distribution Identifier
22881 , p_source_34 IN NUMBER
22882 --Transaction Distribution Type
22883 , p_source_35 IN VARCHAR2
22884 --Transaction Distribution Entered Amount
22885 , p_source_36 IN NUMBER
22886 --Transaction Currency Code
22887 , p_source_37 IN VARCHAR2
22888 --Transaction Exchange Date
22889 , p_source_38 IN DATE
22890 --Transaction Exchange Rate
22891 , p_source_39 IN NUMBER
22892 --Transaction Exchange Rate Type
22893 , p_source_40 IN VARCHAR2
22894 --Transaction Accounting Amount
22895 , p_source_41 IN NUMBER
22896 --Transaction Tax Line Identifier
22897 , p_source_55 IN NUMBER
22898 )
22899 IS
22900
22901 l_component_type VARCHAR2(80);
22902 l_component_code VARCHAR2(30);
22903 l_component_type_code VARCHAR2(1);
22904 l_component_appl_id INTEGER;
22905 l_amb_context_code VARCHAR2(30);
22906 l_entity_code VARCHAR2(30);
22907 l_event_class_code VARCHAR2(30);
22908 l_ae_header_id NUMBER;
22909 l_event_type_code VARCHAR2(30);
22910 l_line_definition_code VARCHAR2(30);
22911 l_line_definition_owner_code VARCHAR2(1);
22912 --
22913 -- adr variables
22914 l_segment VARCHAR2(30);
22915 l_ccid NUMBER;
22916 l_adr_transaction_coa_id NUMBER;
22917 l_adr_accounting_coa_id NUMBER;
22918 l_adr_flexfield_segment_code VARCHAR2(30);
22919 l_adr_flex_value_set_id NUMBER;
22920 l_adr_value_type_code VARCHAR2(30);
22921 l_adr_value_combination_id NUMBER;
22922 l_adr_value_segment_code VARCHAR2(30);
22923
22924 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
22925 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
22926 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
22927 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
22928
22929 -- 4262811 Variables ------------------------------------------------------------------------------------------
22930 l_entered_amt_idx NUMBER;
22931 l_accted_amt_idx NUMBER;
22932 l_acc_rev_flag VARCHAR2(1);
22933 l_accrual_line_num NUMBER;
22934 l_tmp_amt NUMBER;
22935 l_acc_rev_natural_side_code VARCHAR2(1);
22936
22937 l_num_entries NUMBER;
22938 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
22939 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
22940 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
22941 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
22942 l_recog_line_1 NUMBER;
22943 l_recog_line_2 NUMBER;
22944
22945 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
22946 l_bflow_applied_to_amt NUMBER; -- 5132302
22947 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
22948
22949 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
22950
22951 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
22952 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
22953
22954 ---------------------------------------------------------------------------------------------------------------
22955
22956
22957 --
22958 -- bulk performance
22959 --
22960 l_balance_type_code VARCHAR2(1);
22961 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
22962 l_log_module VARCHAR2(240);
22963
22964 --
22965 -- Upgrade strategy
22966 --
22967 l_actual_upg_option VARCHAR2(1);
22968 l_enc_upg_option VARCHAR2(1);
22969
22970 --
22971 BEGIN
22972 --
22976 --
22973 IF g_log_enabled THEN
22974 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_62';
22975 END IF;
22977 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
22978
22979 trace
22980 (p_msg => 'BEGIN of AcctLineType_62'
22981 ,p_level => C_LEVEL_PROCEDURE
22982 ,p_module => l_log_module);
22983
22984 END IF;
22985 --
22986 l_component_type := 'AMB_JLT';
22987 l_component_code := 'DM_UNBILL';
22988 l_component_type_code := 'S';
22989 l_component_appl_id := 222;
22990 l_amb_context_code := 'DEFAULT';
22991 l_entity_code := 'TRANSACTIONS';
22992 l_event_class_code := 'DEBIT_MEMO';
22993 l_event_type_code := 'DEBIT_MEMO_ALL';
22994 l_line_definition_owner_code := 'S';
22995 l_line_definition_code := 'AR_DM_DEFAULT_ACCRUAL';
22996 --
22997 l_balance_type_code := 'A';
22998 l_segment := NULL;
22999 l_ccid := NULL;
23000 l_adr_transaction_coa_id := NULL;
23001 l_adr_accounting_coa_id := NULL;
23002 l_adr_flexfield_segment_code := NULL;
23003 l_adr_flex_value_set_id := NULL;
23004 l_adr_value_type_code := NULL;
23005 l_adr_value_combination_id := NULL;
23006 l_adr_value_segment_code := NULL;
23007
23008 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
23009 l_bflow_class_code := ''; -- 4219869 Business Flow
23010 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
23011 l_budgetary_control_flag := 'N';
23012
23013 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23014 l_bflow_applied_to_amt := NULL; -- 5132302
23015 l_entered_amt_idx := NULL; -- 4262811
23016 l_accted_amt_idx := NULL; -- 4262811
23017 l_acc_rev_flag := NULL; -- 4262811
23018 l_accrual_line_num := NULL; -- 4262811
23019 l_tmp_amt := NULL; -- 4262811
23020 --
23021
23022 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
23023 l_balance_type_code <> 'B' THEN
23024 IF NVL(p_source_33,'
23025 ') = 'UNBILL'
23026 THEN
23027
23028 --
23029 XLA_AE_LINES_PKG.SetNewLine;
23030
23031 p_balance_type_code := l_balance_type_code;
23032 -- set the flag so later we will know whether the gain loss line needs to be created
23033
23034 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
23035 p_actual_flag :='A';
23036 END IF;
23037
23038 --
23039 -- bulk performance
23040 --
23041 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
23042 p_header_num => 0); -- 4262811
23043 --
23044 -- set accounting line options
23045 --
23046 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
23047 p_natural_side_code => 'D'
23048 , p_gain_or_loss_flag => 'N'
23049 , p_gl_transfer_mode_code => 'S'
23050 , p_acct_entry_type_code => 'A'
23051 , p_switch_side_flag => 'Y'
23052 , p_merge_duplicate_code => 'A'
23053 );
23054 --
23055 l_acc_rev_natural_side_code := 'C'; -- 4262811
23056 --
23057 --
23058 -- set accounting line type info
23059 --
23060 xla_ae_lines_pkg.SetAcctLineType
23061 (p_component_type => l_component_type
23062 ,p_event_type_code => l_event_type_code
23063 ,p_line_definition_owner_code => l_line_definition_owner_code
23064 ,p_line_definition_code => l_line_definition_code
23065 ,p_accounting_line_code => l_component_code
23066 ,p_accounting_line_type_code => l_component_type_code
23067 ,p_accounting_line_appl_id => l_component_appl_id
23068 ,p_amb_context_code => l_amb_context_code
23069 ,p_entity_code => l_entity_code
23070 ,p_event_class_code => l_event_class_code);
23071 --
23072 -- set accounting class
23073 --
23074 xla_ae_lines_pkg.SetAcctClass(
23075 p_accounting_class_code => 'UNBILL'
23076 , p_ae_header_id => l_ae_header_id
23077 );
23078
23079 --
23080 -- set rounding class
23081 --
23082 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
23083 'RECEIVABLE';
23084
23085 --
23086 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
23087 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
23088 --
23089 -- bulk performance
23090 --
23091 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
23092
23093 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
23094 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
23095
23096 -- 4955764
23097 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23098 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
23099
23100 -- 4458381 Public Sector Enh
23101
23102 --
23103 -- set accounting attributes for the line type
23104 --
23105 l_entered_amt_idx := 3;
23106 l_accted_amt_idx := 8;
23107 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23111 l_rec_acct_attrs.array_char_value(2) := p_source_35;
23108 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
23109 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
23110 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
23112 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
23113 l_rec_acct_attrs.array_num_value(3) := p_source_36;
23114 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
23115 l_rec_acct_attrs.array_char_value(4) := p_source_37;
23116 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
23117 l_rec_acct_attrs.array_date_value(5) := p_source_38;
23118 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
23119 l_rec_acct_attrs.array_num_value(6) := p_source_39;
23120 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
23121 l_rec_acct_attrs.array_char_value(7) := p_source_40;
23122 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
23123 l_rec_acct_attrs.array_num_value(8) := p_source_41;
23124 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
23125 l_rec_acct_attrs.array_num_value(9) := p_source_30;
23126 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
23127 l_rec_acct_attrs.array_num_value(10) := p_source_31;
23128 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
23129 l_rec_acct_attrs.array_char_value(11) := p_source_32;
23130 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
23131 l_rec_acct_attrs.array_num_value(12) := p_source_55;
23132
23133 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
23134 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
23135
23136 ---------------------------------------------------------------------------------------------------------------
23137 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
23138 ---------------------------------------------------------------------------------------------------------------
23139 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
23140
23141 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23142 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23143
23144 IF xla_accounting_cache_pkg.GetValueChar
23145 (p_source_code => 'LEDGER_CATEGORY_CODE'
23146 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
23147 AND l_bflow_method_code = 'PRIOR_ENTRY'
23148 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
23149 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
23150 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
23151 )
23152 THEN
23153 xla_ae_lines_pkg.BflowUpgEntry
23154 (p_business_method_code => l_bflow_method_code
23155 ,p_business_class_code => l_bflow_class_code
23156 ,p_balance_type => l_balance_type_code);
23157 ELSE
23158 NULL;
23159 -- No business flow processing for business flow method of NONE.
23160 END IF;
23161
23162 --
23163 -- call analytical criteria
23164 --
23165
23166 --
23167 -- call description
23168 --
23169 -- No description or it is inherited.
23170 --
23171 -- call ADRs
23172 -- Bug 4922099
23173 --
23174 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23175 (NVL(l_actual_upg_option, 'N') = 'O') OR
23176 (NVL(l_enc_upg_option, 'N') = 'O')
23177 )
23178 THEN
23179 NULL;
23180 --
23181 --
23182
23183 l_ccid := AcctDerRule_28(
23184 p_application_id => p_application_id
23185 , p_ae_header_id => l_ae_header_id
23186 , p_source_19 => p_source_19
23187 , x_transaction_coa_id => l_adr_transaction_coa_id
23188 , x_accounting_coa_id => l_adr_accounting_coa_id
23189 , x_value_type_code => l_adr_value_type_code
23190 , p_side => 'NA'
23191 );
23192
23193 xla_ae_lines_pkg.set_ccid(
23194 p_code_combination_id => l_ccid
23195 , p_value_type_code => l_adr_value_type_code
23196 , p_transaction_coa_id => l_adr_transaction_coa_id
23197 , p_accounting_coa_id => l_adr_accounting_coa_id
23198 , p_adr_code => 'TRX_DIST_CCID'
23199 , p_adr_type_code => 'S'
23200 , p_component_type => l_component_type
23201 , p_component_code => l_component_code
23202 , p_component_type_code => l_component_type_code
23203 , p_component_appl_id => l_component_appl_id
23204 , p_amb_context_code => l_amb_context_code
23205 , p_side => 'NA'
23206 );
23207
23208
23209 --
23210 --
23211 END IF;
23212 --
23213 -- Bug 4922099
23214 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
23215 (NVL(l_enc_upg_option, 'N') = 'O')
23216 ) AND
23217 (l_bflow_method_code = 'PRIOR_ENTRY')
23218 )
23219 THEN
23220 IF
23221 --
23222 1 = 2
23223 --
23224 THEN
23225 xla_accounting_err_pkg.build_message
23226 (p_appli_s_name => 'XLA'
23230 ,p_token_2 => 'LINE_TYPE_NAME'
23227 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23228 ,p_token_1 => 'LINE_NUMBER'
23229 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
23231 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
23232 l_component_type
23233 ,l_component_code
23237 ,l_entity_code
23234 ,l_component_type_code
23235 ,l_component_appl_id
23236 ,l_amb_context_code
23238 ,l_event_class_code
23239 )
23240 ,p_token_3 => 'OWNER'
23241 ,p_value_3 => xla_lookups_pkg.get_meaning(
23242 p_lookup_type => 'XLA_OWNER_TYPE'
23243 ,p_lookup_code => l_component_type_code
23244 )
23245 ,p_token_4 => 'PRODUCT_NAME'
23246 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
23247 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
23248 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
23249 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
23250 ,p_ae_header_id => NULL
23251 );
23252
23253 IF (C_LEVEL_ERROR>= g_log_level) THEN
23254 trace
23255 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23256 ,p_level => C_LEVEL_ERROR
23257 ,p_module => l_log_module);
23258 END IF;
23259 END IF;
23260 END IF;
23261 --
23262 --
23263 ------------------------------------------------------------------------------------------------
23264 -- 4219869 Business Flow
23265 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
23266 -- Prior Entry. Currently, the following code is always generated.
23267 ------------------------------------------------------------------------------------------------
23268 XLA_AE_LINES_PKG.ValidateCurrentLine;
23269
23270 ------------------------------------------------------------------------------------
23271 -- 4219869 Business Flow
23272 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
23273 ------------------------------------------------------------------------------------
23274 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23275
23276 ----------------------------------------------------------------------------------
23277 -- 4219869 Business Flow
23278 -- Update journal entry status -- Need to generate this within IF <condition>
23279 ----------------------------------------------------------------------------------
23280 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23281 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
23282 ,p_balance_type_code => l_balance_type_code
23283 );
23284
23285 -------------------------------------------------------------------------------------------
23286 -- 4262811 - Generate the Accrual Reversal lines
23287 -------------------------------------------------------------------------------------------
23288 BEGIN
23289 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
23290 (g_array_event(p_event_id).array_value_num('header_index'));
23291 IF l_acc_rev_flag IS NULL THEN
23292 l_acc_rev_flag := 'N';
23293 END IF;
23294 EXCEPTION
23295 WHEN OTHERS THEN
23296 l_acc_rev_flag := 'N';
23297 END;
23298 --
23299 IF (l_acc_rev_flag = 'Y') THEN
23300
23301 -- 4645092 ------------------------------------------------------------------------------
23302 -- To allow MPA report to determine if it should generate report process
23303 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
23304 ------------------------------------------------------------------------------------------
23305
23306 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
23307 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
23308 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
23309 -- call ADRs
23310 -- Bug 4922099
23311 --
23312 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23313 (NVL(l_actual_upg_option, 'N') = 'O') OR
23314 (NVL(l_enc_upg_option, 'N') = 'O')
23315 )
23316 THEN
23317 NULL;
23318 --
23319 --
23320
23321 l_ccid := AcctDerRule_28(
23322 p_application_id => p_application_id
23323 , p_ae_header_id => l_ae_header_id
23324 , p_source_19 => p_source_19
23325 , x_transaction_coa_id => l_adr_transaction_coa_id
23326 , x_accounting_coa_id => l_adr_accounting_coa_id
23327 , x_value_type_code => l_adr_value_type_code
23328 , p_side => 'NA'
23329 );
23330
23331 xla_ae_lines_pkg.set_ccid(
23332 p_code_combination_id => l_ccid
23333 , p_value_type_code => l_adr_value_type_code
23334 , p_transaction_coa_id => l_adr_transaction_coa_id
23335 , p_accounting_coa_id => l_adr_accounting_coa_id
23336 , p_adr_code => 'TRX_DIST_CCID'
23337 , p_adr_type_code => 'S'
23338 , p_component_type => l_component_type
23339 , p_component_code => l_component_code
23340 , p_component_type_code => l_component_type_code
23341 , p_component_appl_id => l_component_appl_id
23342 , p_amb_context_code => l_amb_context_code
23343 , p_side => 'NA'
23344 );
23345
23346
23347 --
23348 --
23349 END IF;
23350
23351 --
23352 -- Update the line information that should be overwritten
23353 --
23354 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
23355 p_header_num => 1);
23356 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
23357
23358 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
23359
23360 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
23361 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
23362 END IF;
23363
23364 --
23365 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
23366 --
23367 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
23368 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
23369 ELSE
23370 ---------------------------------------------------------------------------------------------------
23371 -- 4262811a Switch Sign
23372 ---------------------------------------------------------------------------------------------------
23373 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
23374 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23375 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23376 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23377 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23378 -- 5132302
23379 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
23380 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23381
23382 END IF;
23383
23384 -- 4955764
23385 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23386 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
23387
23388
23389 XLA_AE_LINES_PKG.ValidateCurrentLine;
23390 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23391
23392 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23393 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
23394 ,p_balance_type_code => l_balance_type_code);
23395
23396 END IF;
23397
23398 -----------------------------------------------------------------------------------------
23399 -- 4262811 Multiperiod Accounting
23400 -----------------------------------------------------------------------------------------
23401 -- No MPA option is assigned.
23402
23403
23404 END IF;
23405 END IF;
23406 --
23407
23408 --
23409 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23410 trace
23411 (p_msg => 'END of AcctLineType_62'
23412 ,p_level => C_LEVEL_PROCEDURE
23413 ,p_module => l_log_module);
23414 END IF;
23415 --
23416 EXCEPTION
23417 WHEN xla_exceptions_pkg.application_exception THEN
23418 RAISE;
23419 WHEN OTHERS THEN
23420 xla_exceptions_pkg.raise_message
23421 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_62');
23422 END AcctLineType_62;
23423 --
23424
23425 ---------------------------------------
23426 --
23427 -- PRIVATE FUNCTION
23428 -- AcctLineType_63
23429 --
23430 ---------------------------------------
23431 PROCEDURE AcctLineType_63 (
23432 p_application_id IN NUMBER
23433 ,p_event_id IN NUMBER
23434 ,p_calculate_acctd_flag IN VARCHAR2
23435 ,p_calculate_g_l_flag IN VARCHAR2
23436 ,p_actual_flag IN OUT VARCHAR2
23437 ,p_balance_type_code OUT VARCHAR2
23438 ,p_gain_or_loss_ref OUT VARCHAR2
23439
23440 --Transaction Distribution GL Account
23441 , p_source_19 IN NUMBER
23442 --Bill To Customer Account Identifier
23443 , p_source_30 IN NUMBER
23444 --Bill To Customer Site Use Identifier
23445 , p_source_31 IN NUMBER
23446 --SLA Party Type
23447 , p_source_32 IN VARCHAR2
23448 --Transaction Distribution Account Class
23449 , p_source_33 IN VARCHAR2
23450 --Transaction Distribution Identifier
23451 , p_source_34 IN NUMBER
23452 --Transaction Distribution Type
23453 , p_source_35 IN VARCHAR2
23454 --Transaction Distribution Entered Amount
23455 , p_source_36 IN NUMBER
23456 --Transaction Currency Code
23457 , p_source_37 IN VARCHAR2
23458 --Transaction Exchange Date
23459 , p_source_38 IN DATE
23460 --Transaction Exchange Rate
23461 , p_source_39 IN NUMBER
23462 --Transaction Exchange Rate Type
23463 , p_source_40 IN VARCHAR2
23464 --Transaction Accounting Amount
23465 , p_source_41 IN NUMBER
23466 --Transaction Tax Line Identifier
23467 , p_source_55 IN NUMBER
23468 )
23469 IS
23470
23471 l_component_type VARCHAR2(80);
23472 l_component_code VARCHAR2(30);
23473 l_component_type_code VARCHAR2(1);
23474 l_component_appl_id INTEGER;
23475 l_amb_context_code VARCHAR2(30);
23476 l_entity_code VARCHAR2(30);
23477 l_event_class_code VARCHAR2(30);
23478 l_ae_header_id NUMBER;
23479 l_event_type_code VARCHAR2(30);
23480 l_line_definition_code VARCHAR2(30);
23481 l_line_definition_owner_code VARCHAR2(1);
23482 --
23483 -- adr variables
23484 l_segment VARCHAR2(30);
23485 l_ccid NUMBER;
23486 l_adr_transaction_coa_id NUMBER;
23487 l_adr_accounting_coa_id NUMBER;
23488 l_adr_flexfield_segment_code VARCHAR2(30);
23489 l_adr_flex_value_set_id NUMBER;
23490 l_adr_value_type_code VARCHAR2(30);
23491 l_adr_value_combination_id NUMBER;
23492 l_adr_value_segment_code VARCHAR2(30);
23493
23494 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
23495 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
23496 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
23497 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
23498
23499 -- 4262811 Variables ------------------------------------------------------------------------------------------
23500 l_entered_amt_idx NUMBER;
23501 l_accted_amt_idx NUMBER;
23502 l_acc_rev_flag VARCHAR2(1);
23503 l_accrual_line_num NUMBER;
23504 l_tmp_amt NUMBER;
23505 l_acc_rev_natural_side_code VARCHAR2(1);
23506
23507 l_num_entries NUMBER;
23508 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
23509 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
23510 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
23511 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
23512 l_recog_line_1 NUMBER;
23513 l_recog_line_2 NUMBER;
23514
23515 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
23516 l_bflow_applied_to_amt NUMBER; -- 5132302
23517 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
23518
23519 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
23520
23521 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
23522 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
23523
23524 ---------------------------------------------------------------------------------------------------------------
23525
23526
23527 --
23528 -- bulk performance
23529 --
23530 l_balance_type_code VARCHAR2(1);
23531 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
23532 l_log_module VARCHAR2(240);
23533
23534 --
23535 -- Upgrade strategy
23536 --
23537 l_actual_upg_option VARCHAR2(1);
23538 l_enc_upg_option VARCHAR2(1);
23539
23540 --
23541 BEGIN
23542 --
23543 IF g_log_enabled THEN
23544 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_63';
23545 END IF;
23546 --
23547 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23548
23549 trace
23550 (p_msg => 'BEGIN of AcctLineType_63'
23551 ,p_level => C_LEVEL_PROCEDURE
23552 ,p_module => l_log_module);
23553
23554 END IF;
23555 --
23556 l_component_type := 'AMB_JLT';
23557 l_component_code := 'DM_UNEARN';
23558 l_component_type_code := 'S';
23559 l_component_appl_id := 222;
23560 l_amb_context_code := 'DEFAULT';
23561 l_entity_code := 'TRANSACTIONS';
23562 l_event_class_code := 'DEBIT_MEMO';
23563 l_event_type_code := 'DEBIT_MEMO_ALL';
23564 l_line_definition_owner_code := 'S';
23565 l_line_definition_code := 'AR_DM_DEFAULT_ACCRUAL';
23566 --
23567 l_balance_type_code := 'A';
23568 l_segment := NULL;
23569 l_ccid := NULL;
23570 l_adr_transaction_coa_id := NULL;
23571 l_adr_accounting_coa_id := NULL;
23572 l_adr_flexfield_segment_code := NULL;
23573 l_adr_flex_value_set_id := NULL;
23574 l_adr_value_type_code := NULL;
23575 l_adr_value_combination_id := NULL;
23576 l_adr_value_segment_code := NULL;
23577
23578 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
23579 l_bflow_class_code := ''; -- 4219869 Business Flow
23580 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
23581 l_budgetary_control_flag := 'N';
23582
23583 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23584 l_bflow_applied_to_amt := NULL; -- 5132302
23585 l_entered_amt_idx := NULL; -- 4262811
23586 l_accted_amt_idx := NULL; -- 4262811
23587 l_acc_rev_flag := NULL; -- 4262811
23588 l_accrual_line_num := NULL; -- 4262811
23589 l_tmp_amt := NULL; -- 4262811
23590 --
23591
23592 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
23593 l_balance_type_code <> 'B' THEN
23594 IF NVL(p_source_33,'
23595 ') = 'UNEARN'
23596 THEN
23597
23598 --
23599 XLA_AE_LINES_PKG.SetNewLine;
23600
23601 p_balance_type_code := l_balance_type_code;
23602 -- set the flag so later we will know whether the gain loss line needs to be created
23603
23604 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
23605 p_actual_flag :='A';
23606 END IF;
23607
23608 --
23609 -- bulk performance
23610 --
23611 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
23612 p_header_num => 0); -- 4262811
23613 --
23614 -- set accounting line options
23615 --
23616 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
23617 p_natural_side_code => 'C'
23618 , p_gain_or_loss_flag => 'N'
23619 , p_gl_transfer_mode_code => 'S'
23620 , p_acct_entry_type_code => 'A'
23621 , p_switch_side_flag => 'Y'
23622 , p_merge_duplicate_code => 'A'
23623 );
23624 --
23625 l_acc_rev_natural_side_code := 'D'; -- 4262811
23626 --
23627 --
23628 -- set accounting line type info
23629 --
23630 xla_ae_lines_pkg.SetAcctLineType
23631 (p_component_type => l_component_type
23632 ,p_event_type_code => l_event_type_code
23633 ,p_line_definition_owner_code => l_line_definition_owner_code
23634 ,p_line_definition_code => l_line_definition_code
23635 ,p_accounting_line_code => l_component_code
23636 ,p_accounting_line_type_code => l_component_type_code
23637 ,p_accounting_line_appl_id => l_component_appl_id
23638 ,p_amb_context_code => l_amb_context_code
23639 ,p_entity_code => l_entity_code
23640 ,p_event_class_code => l_event_class_code);
23641 --
23642 -- set accounting class
23643 --
23644 xla_ae_lines_pkg.SetAcctClass(
23645 p_accounting_class_code => 'UNEARNED_REVENUE'
23646 , p_ae_header_id => l_ae_header_id
23647 );
23648
23649 --
23650 -- set rounding class
23651 --
23652 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
23653 'RECEIVABLE';
23654
23655 --
23656 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
23657 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
23658 --
23659 -- bulk performance
23660 --
23661 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
23662
23663 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
23664 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
23665
23666 -- 4955764
23667 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23668 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
23669
23670 -- 4458381 Public Sector Enh
23671
23672 --
23673 -- set accounting attributes for the line type
23674 --
23675 l_entered_amt_idx := 3;
23676 l_accted_amt_idx := 8;
23677 l_bflow_applied_to_amt_idx := NULL; -- 5132302
23678 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
23679 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
23680 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
23681 l_rec_acct_attrs.array_char_value(2) := p_source_35;
23682 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
23683 l_rec_acct_attrs.array_num_value(3) := p_source_36;
23684 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
23685 l_rec_acct_attrs.array_char_value(4) := p_source_37;
23686 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
23687 l_rec_acct_attrs.array_date_value(5) := p_source_38;
23688 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
23689 l_rec_acct_attrs.array_num_value(6) := p_source_39;
23690 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
23691 l_rec_acct_attrs.array_char_value(7) := p_source_40;
23692 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
23693 l_rec_acct_attrs.array_num_value(8) := p_source_41;
23694 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
23695 l_rec_acct_attrs.array_num_value(9) := p_source_30;
23696 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
23697 l_rec_acct_attrs.array_num_value(10) := p_source_31;
23698 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
23699 l_rec_acct_attrs.array_char_value(11) := p_source_32;
23700 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
23701 l_rec_acct_attrs.array_num_value(12) := p_source_55;
23702
23703 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
23704 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
23705
23706 ---------------------------------------------------------------------------------------------------------------
23707 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
23708 ---------------------------------------------------------------------------------------------------------------
23709 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
23710
23711 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23712 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
23713
23714 IF xla_accounting_cache_pkg.GetValueChar
23715 (p_source_code => 'LEDGER_CATEGORY_CODE'
23716 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
23717 AND l_bflow_method_code = 'PRIOR_ENTRY'
23718 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
23719 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
23720 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
23721 )
23722 THEN
23723 xla_ae_lines_pkg.BflowUpgEntry
23724 (p_business_method_code => l_bflow_method_code
23725 ,p_business_class_code => l_bflow_class_code
23726 ,p_balance_type => l_balance_type_code);
23727 ELSE
23728 NULL;
23729 -- No business flow processing for business flow method of NONE.
23730 END IF;
23731
23732 --
23733 -- call analytical criteria
23734 --
23735
23736 --
23737 -- call description
23738 --
23739 -- No description or it is inherited.
23740 --
23741 -- call ADRs
23742 -- Bug 4922099
23743 --
23744 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23745 (NVL(l_actual_upg_option, 'N') = 'O') OR
23746 (NVL(l_enc_upg_option, 'N') = 'O')
23747 )
23748 THEN
23749 NULL;
23750 --
23751 --
23752
23753 l_ccid := AcctDerRule_28(
23754 p_application_id => p_application_id
23755 , p_ae_header_id => l_ae_header_id
23756 , p_source_19 => p_source_19
23757 , x_transaction_coa_id => l_adr_transaction_coa_id
23758 , x_accounting_coa_id => l_adr_accounting_coa_id
23759 , x_value_type_code => l_adr_value_type_code
23760 , p_side => 'NA'
23761 );
23762
23763 xla_ae_lines_pkg.set_ccid(
23764 p_code_combination_id => l_ccid
23765 , p_value_type_code => l_adr_value_type_code
23766 , p_transaction_coa_id => l_adr_transaction_coa_id
23767 , p_accounting_coa_id => l_adr_accounting_coa_id
23768 , p_adr_code => 'TRX_DIST_CCID'
23769 , p_adr_type_code => 'S'
23770 , p_component_type => l_component_type
23771 , p_component_code => l_component_code
23772 , p_component_type_code => l_component_type_code
23773 , p_component_appl_id => l_component_appl_id
23774 , p_amb_context_code => l_amb_context_code
23775 , p_side => 'NA'
23776 );
23777
23778
23779 --
23780 --
23781 END IF;
23782 --
23783 -- Bug 4922099
23784 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
23785 (NVL(l_enc_upg_option, 'N') = 'O')
23786 ) AND
23787 (l_bflow_method_code = 'PRIOR_ENTRY')
23788 )
23789 THEN
23790 IF
23791 --
23792 1 = 2
23793 --
23794 THEN
23795 xla_accounting_err_pkg.build_message
23796 (p_appli_s_name => 'XLA'
23797 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23798 ,p_token_1 => 'LINE_NUMBER'
23799 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
23800 ,p_token_2 => 'LINE_TYPE_NAME'
23801 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
23802 l_component_type
23803 ,l_component_code
23804 ,l_component_type_code
23805 ,l_component_appl_id
23806 ,l_amb_context_code
23807 ,l_entity_code
23808 ,l_event_class_code
23809 )
23810 ,p_token_3 => 'OWNER'
23811 ,p_value_3 => xla_lookups_pkg.get_meaning(
23812 p_lookup_type => 'XLA_OWNER_TYPE'
23813 ,p_lookup_code => l_component_type_code
23814 )
23815 ,p_token_4 => 'PRODUCT_NAME'
23816 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
23817 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
23818 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
23819 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
23820 ,p_ae_header_id => NULL
23821 );
23822
23823 IF (C_LEVEL_ERROR>= g_log_level) THEN
23824 trace
23825 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
23826 ,p_level => C_LEVEL_ERROR
23827 ,p_module => l_log_module);
23828 END IF;
23829 END IF;
23830 END IF;
23831 --
23832 --
23833 ------------------------------------------------------------------------------------------------
23834 -- 4219869 Business Flow
23835 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
23836 -- Prior Entry. Currently, the following code is always generated.
23837 ------------------------------------------------------------------------------------------------
23838 XLA_AE_LINES_PKG.ValidateCurrentLine;
23839
23840 ------------------------------------------------------------------------------------
23841 -- 4219869 Business Flow
23842 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
23843 ------------------------------------------------------------------------------------
23844 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23845
23846 ----------------------------------------------------------------------------------
23847 -- 4219869 Business Flow
23848 -- Update journal entry status -- Need to generate this within IF <condition>
23849 ----------------------------------------------------------------------------------
23850 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23851 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
23852 ,p_balance_type_code => l_balance_type_code
23853 );
23854
23855 -------------------------------------------------------------------------------------------
23856 -- 4262811 - Generate the Accrual Reversal lines
23857 -------------------------------------------------------------------------------------------
23858 BEGIN
23859 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
23860 (g_array_event(p_event_id).array_value_num('header_index'));
23861 IF l_acc_rev_flag IS NULL THEN
23862 l_acc_rev_flag := 'N';
23863 END IF;
23864 EXCEPTION
23865 WHEN OTHERS THEN
23866 l_acc_rev_flag := 'N';
23867 END;
23868 --
23869 IF (l_acc_rev_flag = 'Y') THEN
23870
23871 -- 4645092 ------------------------------------------------------------------------------
23872 -- To allow MPA report to determine if it should generate report process
23873 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
23874 ------------------------------------------------------------------------------------------
23875
23876 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
23877 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
23878 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
23879 -- call ADRs
23880 -- Bug 4922099
23881 --
23882 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
23883 (NVL(l_actual_upg_option, 'N') = 'O') OR
23884 (NVL(l_enc_upg_option, 'N') = 'O')
23885 )
23886 THEN
23887 NULL;
23888 --
23889 --
23890
23891 l_ccid := AcctDerRule_28(
23892 p_application_id => p_application_id
23893 , p_ae_header_id => l_ae_header_id
23894 , p_source_19 => p_source_19
23895 , x_transaction_coa_id => l_adr_transaction_coa_id
23896 , x_accounting_coa_id => l_adr_accounting_coa_id
23897 , x_value_type_code => l_adr_value_type_code
23898 , p_side => 'NA'
23899 );
23900
23901 xla_ae_lines_pkg.set_ccid(
23902 p_code_combination_id => l_ccid
23903 , p_value_type_code => l_adr_value_type_code
23904 , p_transaction_coa_id => l_adr_transaction_coa_id
23905 , p_accounting_coa_id => l_adr_accounting_coa_id
23906 , p_adr_code => 'TRX_DIST_CCID'
23907 , p_adr_type_code => 'S'
23908 , p_component_type => l_component_type
23909 , p_component_code => l_component_code
23910 , p_component_type_code => l_component_type_code
23911 , p_component_appl_id => l_component_appl_id
23912 , p_amb_context_code => l_amb_context_code
23913 , p_side => 'NA'
23914 );
23915
23916
23917 --
23918 --
23919 END IF;
23920
23921 --
23922 -- Update the line information that should be overwritten
23923 --
23924 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
23925 p_header_num => 1);
23926 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
23927
23928 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
23929
23930 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
23931 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
23932 END IF;
23933
23934 --
23935 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
23936 --
23937 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
23938 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
23939 ELSE
23940 ---------------------------------------------------------------------------------------------------
23941 -- 4262811a Switch Sign
23942 ---------------------------------------------------------------------------------------------------
23943 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
23944 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23945 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23946 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
23947 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23948 -- 5132302
23949 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
23950 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
23951
23952 END IF;
23953
23954 -- 4955764
23955 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
23956 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
23957
23958
23959 XLA_AE_LINES_PKG.ValidateCurrentLine;
23960 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
23961
23962 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
23963 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
23964 ,p_balance_type_code => l_balance_type_code);
23965
23966 END IF;
23967
23968 -----------------------------------------------------------------------------------------
23969 -- 4262811 Multiperiod Accounting
23970 -----------------------------------------------------------------------------------------
23971 -- No MPA option is assigned.
23972
23973
23974 END IF;
23975 END IF;
23976 --
23977
23978 --
23979 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
23980 trace
23981 (p_msg => 'END of AcctLineType_63'
23982 ,p_level => C_LEVEL_PROCEDURE
23983 ,p_module => l_log_module);
23984 END IF;
23985 --
23986 EXCEPTION
23987 WHEN xla_exceptions_pkg.application_exception THEN
23988 RAISE;
23989 WHEN OTHERS THEN
23990 xla_exceptions_pkg.raise_message
23991 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_63');
23992 END AcctLineType_63;
23993 --
23994
23995 ---------------------------------------
23996 --
23997 -- PRIVATE FUNCTION
23998 -- AcctLineType_64
23999 --
24000 ---------------------------------------
24001 PROCEDURE AcctLineType_64 (
24002 p_application_id IN NUMBER
24003 ,p_event_id IN NUMBER
24004 ,p_calculate_acctd_flag IN VARCHAR2
24005 ,p_calculate_g_l_flag IN VARCHAR2
24006 ,p_actual_flag IN OUT VARCHAR2
24007 ,p_balance_type_code OUT VARCHAR2
24008 ,p_gain_or_loss_ref OUT VARCHAR2
24009
24010 --Federal Fund Category
24011 , p_source_9 IN VARCHAR2
24012 --Bill To Customer Classification
24013 , p_source_10 IN VARCHAR2
24014 --Transaction Default Receivable Account
24015 , p_source_16 IN NUMBER
24016 --Bill To Customer Account Identifier
24017 , p_source_30 IN NUMBER
24018 --Bill To Customer Site Use Identifier
24019 , p_source_31 IN NUMBER
24020 --SLA Party Type
24021 , p_source_32 IN VARCHAR2
24022 --Transaction Distribution Account Class
24023 , p_source_33 IN VARCHAR2
24024 --Transaction Distribution Identifier
24025 , p_source_34 IN NUMBER
24026 --Transaction Distribution Type
24027 , p_source_35 IN VARCHAR2
24028 --Transaction Distribution Entered Amount
24029 , p_source_36 IN NUMBER
24030 --Transaction Currency Code
24031 , p_source_37 IN VARCHAR2
24032 --Transaction Exchange Date
24033 , p_source_38 IN DATE
24034 --Transaction Exchange Rate
24035 , p_source_39 IN NUMBER
24036 --Transaction Exchange Rate Type
24037 , p_source_40 IN VARCHAR2
24038 --Transaction Accounting Amount
24039 , p_source_41 IN NUMBER
24040 --Transaction Tax Line Identifier
24041 , p_source_55 IN NUMBER
24042 --Federal Account Valid Flag
24043 , p_source_56 IN VARCHAR2
24044 )
24045 IS
24046
24047 l_component_type VARCHAR2(80);
24048 l_component_code VARCHAR2(30);
24049 l_component_type_code VARCHAR2(1);
24050 l_component_appl_id INTEGER;
24051 l_amb_context_code VARCHAR2(30);
24052 l_entity_code VARCHAR2(30);
24053 l_event_class_code VARCHAR2(30);
24054 l_ae_header_id NUMBER;
24055 l_event_type_code VARCHAR2(30);
24056 l_line_definition_code VARCHAR2(30);
24057 l_line_definition_owner_code VARCHAR2(1);
24058 --
24059 -- adr variables
24060 l_segment VARCHAR2(30);
24061 l_ccid NUMBER;
24062 l_adr_transaction_coa_id NUMBER;
24063 l_adr_accounting_coa_id NUMBER;
24064 l_adr_flexfield_segment_code VARCHAR2(30);
24065 l_adr_flex_value_set_id NUMBER;
24066 l_adr_value_type_code VARCHAR2(30);
24067 l_adr_value_combination_id NUMBER;
24068 l_adr_value_segment_code VARCHAR2(30);
24069
24070 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
24071 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
24072 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
24073 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
24074
24075 -- 4262811 Variables ------------------------------------------------------------------------------------------
24076 l_entered_amt_idx NUMBER;
24077 l_accted_amt_idx NUMBER;
24078 l_acc_rev_flag VARCHAR2(1);
24079 l_accrual_line_num NUMBER;
24080 l_tmp_amt NUMBER;
24081 l_acc_rev_natural_side_code VARCHAR2(1);
24082
24083 l_num_entries NUMBER;
24084 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
24085 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
24086 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
24087 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
24088 l_recog_line_1 NUMBER;
24089 l_recog_line_2 NUMBER;
24090
24091 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
24092 l_bflow_applied_to_amt NUMBER; -- 5132302
24093 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
24094
24095 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
24096
24097 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
24098 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
24099
24100 ---------------------------------------------------------------------------------------------------------------
24101
24102
24103 --
24104 -- bulk performance
24105 --
24106 l_balance_type_code VARCHAR2(1);
24107 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
24108 l_log_module VARCHAR2(240);
24109
24110 --
24111 -- Upgrade strategy
24112 --
24113 l_actual_upg_option VARCHAR2(1);
24114 l_enc_upg_option VARCHAR2(1);
24115
24116 --
24117 BEGIN
24118 --
24119 IF g_log_enabled THEN
24120 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_64';
24121 END IF;
24122 --
24123 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24124
24125 trace
24126 (p_msg => 'BEGIN of AcctLineType_64'
24127 ,p_level => C_LEVEL_PROCEDURE
24128 ,p_module => l_log_module);
24129
24130 END IF;
24131 --
24132 l_component_type := 'AMB_JLT';
24133 l_component_code := 'FV_INV_REIM_ADV_CR';
24134 l_component_type_code := 'S';
24135 l_component_appl_id := 222;
24136 l_amb_context_code := 'DEFAULT';
24137 l_entity_code := 'TRANSACTIONS';
24138 l_event_class_code := 'INVOICE';
24139 l_event_type_code := 'INVOICE_ALL';
24140 l_line_definition_owner_code := 'S';
24141 l_line_definition_code := 'FEDERAL_AR_ACCRUAL_INV_ALL';
24142 --
24143 l_balance_type_code := 'A';
24144 l_segment := NULL;
24145 l_ccid := NULL;
24146 l_adr_transaction_coa_id := NULL;
24147 l_adr_accounting_coa_id := NULL;
24148 l_adr_flexfield_segment_code := NULL;
24149 l_adr_flex_value_set_id := NULL;
24150 l_adr_value_type_code := NULL;
24151 l_adr_value_combination_id := NULL;
24152 l_adr_value_segment_code := NULL;
24153
24154 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
24155 l_bflow_class_code := 'FV_INVOICE_REV_CR'; -- 4219869 Business Flow
24156 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
24157 l_budgetary_control_flag := 'N';
24158
24159 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24160 l_bflow_applied_to_amt := NULL; -- 5132302
24161 l_entered_amt_idx := NULL; -- 4262811
24162 l_accted_amt_idx := NULL; -- 4262811
24163 l_acc_rev_flag := NULL; -- 4262811
24164 l_accrual_line_num := NULL; -- 4262811
24165 l_tmp_amt := NULL; -- 4262811
24166 --
24167
24168 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
24169 l_balance_type_code <> 'B' THEN
24170 IF NVL(p_source_33,'
24171 ') = 'REV' AND
24172 NVL(p_source_9,'
24173 ') = 'Reimbursable' AND
24174 NVL(p_source_56,'
24175 ') = 'Y'
24176 THEN
24177
24178 --
24179 XLA_AE_LINES_PKG.SetNewLine;
24180
24181 p_balance_type_code := l_balance_type_code;
24182 -- set the flag so later we will know whether the gain loss line needs to be created
24183
24184 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
24185 p_actual_flag :='A';
24186 END IF;
24187
24188 --
24189 -- bulk performance
24190 --
24191 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
24192 p_header_num => 0); -- 4262811
24193 --
24194 -- set accounting line options
24195 --
24196 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
24197 p_natural_side_code => 'C'
24198 , p_gain_or_loss_flag => 'N'
24199 , p_gl_transfer_mode_code => 'S'
24200 , p_acct_entry_type_code => 'A'
24201 , p_switch_side_flag => 'Y'
24202 , p_merge_duplicate_code => 'A'
24203 );
24204 --
24205 l_acc_rev_natural_side_code := 'D'; -- 4262811
24206 --
24207 --
24208 -- set accounting line type info
24209 --
24210 xla_ae_lines_pkg.SetAcctLineType
24211 (p_component_type => l_component_type
24212 ,p_event_type_code => l_event_type_code
24213 ,p_line_definition_owner_code => l_line_definition_owner_code
24214 ,p_line_definition_code => l_line_definition_code
24215 ,p_accounting_line_code => l_component_code
24216 ,p_accounting_line_type_code => l_component_type_code
24217 ,p_accounting_line_appl_id => l_component_appl_id
24218 ,p_amb_context_code => l_amb_context_code
24219 ,p_entity_code => l_entity_code
24220 ,p_event_class_code => l_event_class_code);
24221 --
24222 -- set accounting class
24223 --
24224 xla_ae_lines_pkg.SetAcctClass(
24225 p_accounting_class_code => 'FV_REC_CR'
24226 , p_ae_header_id => l_ae_header_id
24227 );
24228
24229 --
24230 -- set rounding class
24231 --
24232 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
24233 'RECEIVABLE';
24234
24235 --
24236 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
24237 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
24238 --
24239 -- bulk performance
24240 --
24241 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
24242
24243 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
24244 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
24245
24246 -- 4955764
24247 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24248 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
24249
24250 -- 4458381 Public Sector Enh
24251
24252 --
24253 -- set accounting attributes for the line type
24254 --
24255 l_entered_amt_idx := 3;
24256 l_accted_amt_idx := 8;
24257 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24258 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
24259 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
24260 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
24261 l_rec_acct_attrs.array_char_value(2) := p_source_35;
24262 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
24263 l_rec_acct_attrs.array_num_value(3) := p_source_36;
24264 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
24265 l_rec_acct_attrs.array_char_value(4) := p_source_37;
24266 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
24267 l_rec_acct_attrs.array_date_value(5) := p_source_38;
24268 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
24269 l_rec_acct_attrs.array_num_value(6) := p_source_39;
24270 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
24271 l_rec_acct_attrs.array_char_value(7) := p_source_40;
24272 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
24273 l_rec_acct_attrs.array_num_value(8) := p_source_41;
24274 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
24275 l_rec_acct_attrs.array_num_value(9) := p_source_30;
24276 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
24277 l_rec_acct_attrs.array_num_value(10) := p_source_31;
24278 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
24279 l_rec_acct_attrs.array_char_value(11) := p_source_32;
24280 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
24281 l_rec_acct_attrs.array_num_value(12) := p_source_55;
24282
24283 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
24284 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
24285
24286 ---------------------------------------------------------------------------------------------------------------
24287 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
24288 ---------------------------------------------------------------------------------------------------------------
24289 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
24290
24291 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24292 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24293
24294 IF xla_accounting_cache_pkg.GetValueChar
24295 (p_source_code => 'LEDGER_CATEGORY_CODE'
24296 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
24297 AND l_bflow_method_code = 'PRIOR_ENTRY'
24298 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
24299 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
24300 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
24301 )
24302 THEN
24303 xla_ae_lines_pkg.BflowUpgEntry
24304 (p_business_method_code => l_bflow_method_code
24305 ,p_business_class_code => l_bflow_class_code
24306 ,p_balance_type => l_balance_type_code);
24307 ELSE
24308 NULL;
24309 -- No business flow processing for business flow method of NONE.
24310 END IF;
24311
24312 --
24313 -- call analytical criteria
24314 --
24315
24316 --
24317 -- call description
24318 --
24319 -- No description or it is inherited.
24320 --
24321 -- call ADRs
24322 -- Bug 4922099
24323 --
24324 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24325 (NVL(l_actual_upg_option, 'N') = 'O') OR
24326 (NVL(l_enc_upg_option, 'N') = 'O')
24327 )
24328 THEN
24329 NULL;
24330 --
24331 --
24332
24333 l_ccid := AcctDerRule_23(
24334 p_application_id => p_application_id
24335 , p_ae_header_id => l_ae_header_id
24336 , p_source_16 => p_source_16
24337 , x_transaction_coa_id => l_adr_transaction_coa_id
24338 , x_accounting_coa_id => l_adr_accounting_coa_id
24339 , x_value_type_code => l_adr_value_type_code
24340 , p_side => 'NA'
24341 );
24342
24343 xla_ae_lines_pkg.set_ccid(
24344 p_code_combination_id => l_ccid
24345 , p_value_type_code => l_adr_value_type_code
24346 , p_transaction_coa_id => l_adr_transaction_coa_id
24347 , p_accounting_coa_id => l_adr_accounting_coa_id
24348 , p_adr_code => 'MFAR_TRX_DEF_REC_CCID'
24349 , p_adr_type_code => 'S'
24350 , p_component_type => l_component_type
24351 , p_component_code => l_component_code
24352 , p_component_type_code => l_component_type_code
24353 , p_component_appl_id => l_component_appl_id
24354 , p_amb_context_code => l_amb_context_code
24355 , p_side => 'NA'
24356 );
24357
24358
24359 l_segment := AcctDerRule_8(
24360 p_application_id => p_application_id
24361 , p_ae_header_id => l_ae_header_id
24362 , p_source_9 => p_source_9
24363 , p_source_10 => p_source_10
24364 , x_transaction_coa_id => l_adr_transaction_coa_id
24365 , x_accounting_coa_id => l_adr_accounting_coa_id
24366 , x_flexfield_segment_code => l_adr_flexfield_segment_code
24367 , x_flex_value_set_id => l_adr_flex_value_set_id
24368 , x_value_type_code => l_adr_value_type_code
24369 , x_value_combination_id => l_adr_value_combination_id
24370 , x_value_segment_code => l_adr_value_segment_code
24371 , p_side => 'NA'
24372 , p_override_seg_flag => 'Y'
24373 );
24374
24375 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
24376
24377 xla_ae_lines_pkg.set_segment(
24378 p_to_segment_code => 'GL_ACCOUNT'
24379 , p_segment_value => l_segment
24380 , p_from_segment_code => l_adr_value_segment_code
24381 , p_from_combination_id => l_adr_value_combination_id
24382 , p_value_type_code => l_adr_value_type_code
24383 , p_transaction_coa_id => l_adr_transaction_coa_id
24384 , p_accounting_coa_id => l_adr_accounting_coa_id
24385 , p_flexfield_segment_code => l_adr_flexfield_segment_code
24386 , p_flex_value_set_id => l_adr_flex_value_set_id
24387 , p_adr_code => 'FV_AR_422X0X_INV_REIM_CR'
24388 , p_adr_type_code => 'S'
24389 , p_component_type => l_component_type
24390 , p_component_code => l_component_code
24391 , p_component_type_code => l_component_type_code
24392 , p_component_appl_id => l_component_appl_id
24396 , p_side => 'NA'
24393 , p_amb_context_code => l_amb_context_code
24394 , p_entity_code => 'TRANSACTIONS'
24395 , p_event_class_code => 'INVOICE'
24397 );
24398
24399 END IF;
24400
24401 --
24402 --
24403 END IF;
24404 --
24405 -- Bug 4922099
24406 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
24407 (NVL(l_enc_upg_option, 'N') = 'O')
24408 ) AND
24409 (l_bflow_method_code = 'PRIOR_ENTRY')
24410 )
24411 THEN
24412 IF
24413 --
24414 1 = 2
24415 --
24416 THEN
24417 xla_accounting_err_pkg.build_message
24418 (p_appli_s_name => 'XLA'
24419 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24420 ,p_token_1 => 'LINE_NUMBER'
24421 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
24422 ,p_token_2 => 'LINE_TYPE_NAME'
24423 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
24424 l_component_type
24425 ,l_component_code
24426 ,l_component_type_code
24427 ,l_component_appl_id
24428 ,l_amb_context_code
24429 ,l_entity_code
24430 ,l_event_class_code
24431 )
24432 ,p_token_3 => 'OWNER'
24433 ,p_value_3 => xla_lookups_pkg.get_meaning(
24434 p_lookup_type => 'XLA_OWNER_TYPE'
24435 ,p_lookup_code => l_component_type_code
24436 )
24437 ,p_token_4 => 'PRODUCT_NAME'
24438 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
24439 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
24440 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
24441 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
24442 ,p_ae_header_id => NULL
24443 );
24444
24445 IF (C_LEVEL_ERROR>= g_log_level) THEN
24446 trace
24447 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
24448 ,p_level => C_LEVEL_ERROR
24449 ,p_module => l_log_module);
24450 END IF;
24451 END IF;
24452 END IF;
24453 --
24454 --
24455 ------------------------------------------------------------------------------------------------
24456 -- 4219869 Business Flow
24457 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
24458 -- Prior Entry. Currently, the following code is always generated.
24459 ------------------------------------------------------------------------------------------------
24460 XLA_AE_LINES_PKG.ValidateCurrentLine;
24461
24462 ------------------------------------------------------------------------------------
24463 -- 4219869 Business Flow
24464 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
24465 ------------------------------------------------------------------------------------
24466 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24467
24468 ----------------------------------------------------------------------------------
24469 -- 4219869 Business Flow
24470 -- Update journal entry status -- Need to generate this within IF <condition>
24471 ----------------------------------------------------------------------------------
24472 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24473 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
24474 ,p_balance_type_code => l_balance_type_code
24475 );
24476
24477 -------------------------------------------------------------------------------------------
24478 -- 4262811 - Generate the Accrual Reversal lines
24479 -------------------------------------------------------------------------------------------
24480 BEGIN
24481 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
24482 (g_array_event(p_event_id).array_value_num('header_index'));
24483 IF l_acc_rev_flag IS NULL THEN
24484 l_acc_rev_flag := 'N';
24485 END IF;
24486 EXCEPTION
24487 WHEN OTHERS THEN
24488 l_acc_rev_flag := 'N';
24489 END;
24490 --
24491 IF (l_acc_rev_flag = 'Y') THEN
24492
24493 -- 4645092 ------------------------------------------------------------------------------
24494 -- To allow MPA report to determine if it should generate report process
24495 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
24496 ------------------------------------------------------------------------------------------
24497
24498 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
24499 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
24500 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
24501 -- call ADRs
24502 -- Bug 4922099
24503 --
24504 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24505 (NVL(l_actual_upg_option, 'N') = 'O') OR
24506 (NVL(l_enc_upg_option, 'N') = 'O')
24507 )
24508 THEN
24509 NULL;
24510 --
24511 --
24512
24513 l_ccid := AcctDerRule_23(
24514 p_application_id => p_application_id
24515 , p_ae_header_id => l_ae_header_id
24516 , p_source_16 => p_source_16
24517 , x_transaction_coa_id => l_adr_transaction_coa_id
24518 , x_accounting_coa_id => l_adr_accounting_coa_id
24519 , x_value_type_code => l_adr_value_type_code
24520 , p_side => 'NA'
24521 );
24522
24523 xla_ae_lines_pkg.set_ccid(
24524 p_code_combination_id => l_ccid
24525 , p_value_type_code => l_adr_value_type_code
24526 , p_transaction_coa_id => l_adr_transaction_coa_id
24527 , p_accounting_coa_id => l_adr_accounting_coa_id
24528 , p_adr_code => 'MFAR_TRX_DEF_REC_CCID'
24529 , p_adr_type_code => 'S'
24530 , p_component_type => l_component_type
24531 , p_component_code => l_component_code
24532 , p_component_type_code => l_component_type_code
24533 , p_component_appl_id => l_component_appl_id
24534 , p_amb_context_code => l_amb_context_code
24535 , p_side => 'NA'
24536 );
24537
24538
24539 l_segment := AcctDerRule_8(
24540 p_application_id => p_application_id
24541 , p_ae_header_id => l_ae_header_id
24542 , p_source_9 => p_source_9
24543 , p_source_10 => p_source_10
24544 , x_transaction_coa_id => l_adr_transaction_coa_id
24545 , x_accounting_coa_id => l_adr_accounting_coa_id
24546 , x_flexfield_segment_code => l_adr_flexfield_segment_code
24547 , x_flex_value_set_id => l_adr_flex_value_set_id
24548 , x_value_type_code => l_adr_value_type_code
24549 , x_value_combination_id => l_adr_value_combination_id
24550 , x_value_segment_code => l_adr_value_segment_code
24551 , p_side => 'NA'
24552 , p_override_seg_flag => 'Y'
24553 );
24554
24555 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
24556
24557 xla_ae_lines_pkg.set_segment(
24558 p_to_segment_code => 'GL_ACCOUNT'
24559 , p_segment_value => l_segment
24560 , p_from_segment_code => l_adr_value_segment_code
24561 , p_from_combination_id => l_adr_value_combination_id
24562 , p_value_type_code => l_adr_value_type_code
24563 , p_transaction_coa_id => l_adr_transaction_coa_id
24564 , p_accounting_coa_id => l_adr_accounting_coa_id
24565 , p_flexfield_segment_code => l_adr_flexfield_segment_code
24566 , p_flex_value_set_id => l_adr_flex_value_set_id
24567 , p_adr_code => 'FV_AR_422X0X_INV_REIM_CR'
24568 , p_adr_type_code => 'S'
24569 , p_component_type => l_component_type
24570 , p_component_code => l_component_code
24571 , p_component_type_code => l_component_type_code
24572 , p_component_appl_id => l_component_appl_id
24573 , p_amb_context_code => l_amb_context_code
24574 , p_entity_code => 'TRANSACTIONS'
24575 , p_event_class_code => 'INVOICE'
24576 , p_side => 'NA'
24577 );
24578
24579 END IF;
24580
24581 --
24582 --
24583 END IF;
24584
24585 --
24586 -- Update the line information that should be overwritten
24587 --
24588 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
24589 p_header_num => 1);
24590 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
24591
24592 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
24593
24594 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
24595 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
24596 END IF;
24597
24598 --
24599 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
24600 --
24601 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
24602 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
24603 ELSE
24604 ---------------------------------------------------------------------------------------------------
24605 -- 4262811a Switch Sign
24606 ---------------------------------------------------------------------------------------------------
24607 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
24608 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24609 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24610 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
24611 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24612 -- 5132302
24613 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
24614 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
24615
24616 END IF;
24617
24618 -- 4955764
24619 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24620 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
24621
24622
24623 XLA_AE_LINES_PKG.ValidateCurrentLine;
24624 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
24625
24626 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
24627 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
24628 ,p_balance_type_code => l_balance_type_code);
24629
24630 END IF;
24631
24632 -----------------------------------------------------------------------------------------
24633 -- 4262811 Multiperiod Accounting
24634 -----------------------------------------------------------------------------------------
24635 -- No MPA option is assigned.
24636
24637
24638 END IF;
24639 END IF;
24640 --
24641
24642 --
24643 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24644 trace
24645 (p_msg => 'END of AcctLineType_64'
24646 ,p_level => C_LEVEL_PROCEDURE
24647 ,p_module => l_log_module);
24648 END IF;
24649 --
24650 EXCEPTION
24651 WHEN xla_exceptions_pkg.application_exception THEN
24652 RAISE;
24653 WHEN OTHERS THEN
24654 xla_exceptions_pkg.raise_message
24655 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_64');
24656 END AcctLineType_64;
24657 --
24658
24659 ---------------------------------------
24660 --
24661 -- PRIVATE FUNCTION
24662 -- AcctLineType_65
24663 --
24664 ---------------------------------------
24665 PROCEDURE AcctLineType_65 (
24666 p_application_id IN NUMBER
24667 ,p_event_id IN NUMBER
24668 ,p_calculate_acctd_flag IN VARCHAR2
24669 ,p_calculate_g_l_flag IN VARCHAR2
24670 ,p_actual_flag IN OUT VARCHAR2
24671 ,p_balance_type_code OUT VARCHAR2
24672 ,p_gain_or_loss_ref OUT VARCHAR2
24673
24674 --Federal Fund Category
24675 , p_source_9 IN VARCHAR2
24676 --Bill To Customer Classification
24677 , p_source_10 IN VARCHAR2
24678 --Transaction Default Receivable Account
24679 , p_source_16 IN NUMBER
24680 --Bill To Customer Account Identifier
24681 , p_source_30 IN NUMBER
24682 --Bill To Customer Site Use Identifier
24683 , p_source_31 IN NUMBER
24684 --SLA Party Type
24685 , p_source_32 IN VARCHAR2
24686 --Transaction Distribution Account Class
24687 , p_source_33 IN VARCHAR2
24688 --Transaction Distribution Identifier
24689 , p_source_34 IN NUMBER
24690 --Transaction Distribution Type
24691 , p_source_35 IN VARCHAR2
24692 --Transaction Distribution Entered Amount
24693 , p_source_36 IN NUMBER
24694 --Transaction Currency Code
24695 , p_source_37 IN VARCHAR2
24696 --Transaction Exchange Date
24697 , p_source_38 IN DATE
24698 --Transaction Exchange Rate
24699 , p_source_39 IN NUMBER
24700 --Transaction Exchange Rate Type
24701 , p_source_40 IN VARCHAR2
24702 --Transaction Accounting Amount
24703 , p_source_41 IN NUMBER
24704 --Transaction Tax Line Identifier
24705 , p_source_55 IN NUMBER
24706 --Federal Account Valid Flag
24707 , p_source_56 IN VARCHAR2
24708 )
24709 IS
24710
24711 l_component_type VARCHAR2(80);
24712 l_component_code VARCHAR2(30);
24713 l_component_type_code VARCHAR2(1);
24714 l_component_appl_id INTEGER;
24715 l_amb_context_code VARCHAR2(30);
24716 l_entity_code VARCHAR2(30);
24717 l_event_class_code VARCHAR2(30);
24718 l_ae_header_id NUMBER;
24719 l_event_type_code VARCHAR2(30);
24720 l_line_definition_code VARCHAR2(30);
24721 l_line_definition_owner_code VARCHAR2(1);
24722 --
24723 -- adr variables
24724 l_segment VARCHAR2(30);
24725 l_ccid NUMBER;
24726 l_adr_transaction_coa_id NUMBER;
24727 l_adr_accounting_coa_id NUMBER;
24728 l_adr_flexfield_segment_code VARCHAR2(30);
24729 l_adr_flex_value_set_id NUMBER;
24730 l_adr_value_type_code VARCHAR2(30);
24731 l_adr_value_combination_id NUMBER;
24732 l_adr_value_segment_code VARCHAR2(30);
24733
24734 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
24735 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
24736 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
24737 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
24738
24739 -- 4262811 Variables ------------------------------------------------------------------------------------------
24740 l_entered_amt_idx NUMBER;
24741 l_accted_amt_idx NUMBER;
24742 l_acc_rev_flag VARCHAR2(1);
24743 l_accrual_line_num NUMBER;
24744 l_tmp_amt NUMBER;
24745 l_acc_rev_natural_side_code VARCHAR2(1);
24746
24747 l_num_entries NUMBER;
24748 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
24749 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
24750 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
24751 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
24752 l_recog_line_1 NUMBER;
24753 l_recog_line_2 NUMBER;
24754
24755 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
24756 l_bflow_applied_to_amt NUMBER; -- 5132302
24757 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
24758
24759 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
24760
24761 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
24762 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
24763
24764 ---------------------------------------------------------------------------------------------------------------
24765
24766
24767 --
24768 -- bulk performance
24769 --
24770 l_balance_type_code VARCHAR2(1);
24771 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
24772 l_log_module VARCHAR2(240);
24773
24774 --
24775 -- Upgrade strategy
24776 --
24777 l_actual_upg_option VARCHAR2(1);
24778 l_enc_upg_option VARCHAR2(1);
24779
24780 --
24781 BEGIN
24782 --
24783 IF g_log_enabled THEN
24784 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_65';
24785 END IF;
24786 --
24787 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
24788
24789 trace
24790 (p_msg => 'BEGIN of AcctLineType_65'
24791 ,p_level => C_LEVEL_PROCEDURE
24792 ,p_module => l_log_module);
24793
24794 END IF;
24795 --
24796 l_component_type := 'AMB_JLT';
24797 l_component_code := 'FV_INV_REIM_ADV_DR';
24798 l_component_type_code := 'S';
24799 l_component_appl_id := 222;
24800 l_amb_context_code := 'DEFAULT';
24801 l_entity_code := 'TRANSACTIONS';
24802 l_event_class_code := 'INVOICE';
24803 l_event_type_code := 'INVOICE_ALL';
24804 l_line_definition_owner_code := 'S';
24805 l_line_definition_code := 'FEDERAL_AR_ACCRUAL_INV_ALL';
24806 --
24807 l_balance_type_code := 'A';
24808 l_segment := NULL;
24809 l_ccid := NULL;
24810 l_adr_transaction_coa_id := NULL;
24811 l_adr_accounting_coa_id := NULL;
24812 l_adr_flexfield_segment_code := NULL;
24813 l_adr_flex_value_set_id := NULL;
24814 l_adr_value_type_code := NULL;
24815 l_adr_value_combination_id := NULL;
24816 l_adr_value_segment_code := NULL;
24817
24818 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
24819 l_bflow_class_code := 'FV_INVOICE_REC_DR'; -- 4219869 Business Flow
24820 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
24821 l_budgetary_control_flag := 'N';
24822
24823 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24824 l_bflow_applied_to_amt := NULL; -- 5132302
24825 l_entered_amt_idx := NULL; -- 4262811
24826 l_accted_amt_idx := NULL; -- 4262811
24827 l_acc_rev_flag := NULL; -- 4262811
24828 l_accrual_line_num := NULL; -- 4262811
24829 l_tmp_amt := NULL; -- 4262811
24830 --
24831
24832 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
24833 l_balance_type_code <> 'B' THEN
24834 IF NVL(p_source_33,'
24835 ') = 'REV' AND
24836 NVL(p_source_9,'
24837 ') = 'Reimbursable' AND
24838 NVL(p_source_56,'
24839 ') = 'Y'
24840 THEN
24841
24842 --
24843 XLA_AE_LINES_PKG.SetNewLine;
24844
24845 p_balance_type_code := l_balance_type_code;
24846 -- set the flag so later we will know whether the gain loss line needs to be created
24847
24848 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
24849 p_actual_flag :='A';
24850 END IF;
24851
24852 --
24853 -- bulk performance
24854 --
24855 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
24856 p_header_num => 0); -- 4262811
24857 --
24858 -- set accounting line options
24859 --
24860 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
24861 p_natural_side_code => 'D'
24862 , p_gain_or_loss_flag => 'N'
24863 , p_gl_transfer_mode_code => 'S'
24864 , p_acct_entry_type_code => 'A'
24865 , p_switch_side_flag => 'Y'
24866 , p_merge_duplicate_code => 'A'
24867 );
24868 --
24869 l_acc_rev_natural_side_code := 'C'; -- 4262811
24870 --
24871 --
24872 -- set accounting line type info
24873 --
24874 xla_ae_lines_pkg.SetAcctLineType
24875 (p_component_type => l_component_type
24876 ,p_event_type_code => l_event_type_code
24877 ,p_line_definition_owner_code => l_line_definition_owner_code
24878 ,p_line_definition_code => l_line_definition_code
24879 ,p_accounting_line_code => l_component_code
24880 ,p_accounting_line_type_code => l_component_type_code
24881 ,p_accounting_line_appl_id => l_component_appl_id
24882 ,p_amb_context_code => l_amb_context_code
24883 ,p_entity_code => l_entity_code
24884 ,p_event_class_code => l_event_class_code);
24885 --
24886 -- set accounting class
24887 --
24888 xla_ae_lines_pkg.SetAcctClass(
24889 p_accounting_class_code => 'FV_REC_DR'
24890 , p_ae_header_id => l_ae_header_id
24891 );
24892
24893 --
24894 -- set rounding class
24895 --
24896 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
24897 'RECEIVABLE';
24898
24899 --
24900 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
24901 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
24902 --
24903 -- bulk performance
24904 --
24905 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
24906
24907 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
24908 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
24909
24910 -- 4955764
24911 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
24912 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
24913
24914 -- 4458381 Public Sector Enh
24915
24916 --
24917 -- set accounting attributes for the line type
24918 --
24919 l_entered_amt_idx := 3;
24920 l_accted_amt_idx := 8;
24921 l_bflow_applied_to_amt_idx := NULL; -- 5132302
24922 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
24923 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
24924 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
24925 l_rec_acct_attrs.array_char_value(2) := p_source_35;
24926 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
24927 l_rec_acct_attrs.array_num_value(3) := p_source_36;
24928 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
24929 l_rec_acct_attrs.array_char_value(4) := p_source_37;
24930 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
24931 l_rec_acct_attrs.array_date_value(5) := p_source_38;
24932 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
24933 l_rec_acct_attrs.array_num_value(6) := p_source_39;
24934 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
24935 l_rec_acct_attrs.array_char_value(7) := p_source_40;
24936 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
24937 l_rec_acct_attrs.array_num_value(8) := p_source_41;
24938 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
24939 l_rec_acct_attrs.array_num_value(9) := p_source_30;
24940 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
24941 l_rec_acct_attrs.array_num_value(10) := p_source_31;
24942 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
24943 l_rec_acct_attrs.array_char_value(11) := p_source_32;
24944 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
24945 l_rec_acct_attrs.array_num_value(12) := p_source_55;
24946
24947 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
24948 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
24949
24950 ---------------------------------------------------------------------------------------------------------------
24951 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
24952 ---------------------------------------------------------------------------------------------------------------
24953 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
24954
24955 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24956 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
24957
24958 IF xla_accounting_cache_pkg.GetValueChar
24959 (p_source_code => 'LEDGER_CATEGORY_CODE'
24960 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
24961 AND l_bflow_method_code = 'PRIOR_ENTRY'
24962 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
24963 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
24964 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
24965 )
24966 THEN
24967 xla_ae_lines_pkg.BflowUpgEntry
24968 (p_business_method_code => l_bflow_method_code
24969 ,p_business_class_code => l_bflow_class_code
24970 ,p_balance_type => l_balance_type_code);
24971 ELSE
24972 NULL;
24973 -- No business flow processing for business flow method of NONE.
24974 END IF;
24975
24976 --
24977 -- call analytical criteria
24978 --
24979
24980 --
24981 -- call description
24982 --
24983 -- No description or it is inherited.
24984 --
24985 -- call ADRs
24986 -- Bug 4922099
24987 --
24988 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
24989 (NVL(l_actual_upg_option, 'N') = 'O') OR
24990 (NVL(l_enc_upg_option, 'N') = 'O')
24991 )
24992 THEN
24993 NULL;
24994 --
24995 --
24996
24997 l_ccid := AcctDerRule_23(
24998 p_application_id => p_application_id
24999 , p_ae_header_id => l_ae_header_id
25000 , p_source_16 => p_source_16
25001 , x_transaction_coa_id => l_adr_transaction_coa_id
25002 , x_accounting_coa_id => l_adr_accounting_coa_id
25003 , x_value_type_code => l_adr_value_type_code
25004 , p_side => 'NA'
25005 );
25006
25007 xla_ae_lines_pkg.set_ccid(
25008 p_code_combination_id => l_ccid
25009 , p_value_type_code => l_adr_value_type_code
25010 , p_transaction_coa_id => l_adr_transaction_coa_id
25011 , p_accounting_coa_id => l_adr_accounting_coa_id
25012 , p_adr_code => 'MFAR_TRX_DEF_REC_CCID'
25013 , p_adr_type_code => 'S'
25014 , p_component_type => l_component_type
25015 , p_component_code => l_component_code
25016 , p_component_type_code => l_component_type_code
25017 , p_component_appl_id => l_component_appl_id
25018 , p_amb_context_code => l_amb_context_code
25019 , p_side => 'NA'
25020 );
25021
25022
25023 l_segment := AcctDerRule_12(
25024 p_application_id => p_application_id
25025 , p_ae_header_id => l_ae_header_id
25026 , p_source_9 => p_source_9
25027 , p_source_10 => p_source_10
25028 , x_transaction_coa_id => l_adr_transaction_coa_id
25029 , x_accounting_coa_id => l_adr_accounting_coa_id
25033 , x_value_combination_id => l_adr_value_combination_id
25030 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25031 , x_flex_value_set_id => l_adr_flex_value_set_id
25032 , x_value_type_code => l_adr_value_type_code
25034 , x_value_segment_code => l_adr_value_segment_code
25035 , p_side => 'NA'
25036 , p_override_seg_flag => 'Y'
25037 );
25038
25039 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25040
25041 xla_ae_lines_pkg.set_segment(
25042 p_to_segment_code => 'GL_ACCOUNT'
25043 , p_segment_value => l_segment
25044 , p_from_segment_code => l_adr_value_segment_code
25045 , p_from_combination_id => l_adr_value_combination_id
25046 , p_value_type_code => l_adr_value_type_code
25047 , p_transaction_coa_id => l_adr_transaction_coa_id
25048 , p_accounting_coa_id => l_adr_accounting_coa_id
25049 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25050 , p_flex_value_set_id => l_adr_flex_value_set_id
25051 , p_adr_code => 'FV_AR_425X0X_INV_REIM_DR'
25052 , p_adr_type_code => 'S'
25053 , p_component_type => l_component_type
25054 , p_component_code => l_component_code
25055 , p_component_type_code => l_component_type_code
25056 , p_component_appl_id => l_component_appl_id
25057 , p_amb_context_code => l_amb_context_code
25058 , p_entity_code => 'TRANSACTIONS'
25059 , p_event_class_code => 'INVOICE'
25060 , p_side => 'NA'
25061 );
25062
25063 END IF;
25064
25065 --
25066 --
25067 END IF;
25068 --
25069 -- Bug 4922099
25070 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
25071 (NVL(l_enc_upg_option, 'N') = 'O')
25072 ) AND
25073 (l_bflow_method_code = 'PRIOR_ENTRY')
25074 )
25075 THEN
25076 IF
25077 --
25078 1 = 2
25079 --
25080 THEN
25081 xla_accounting_err_pkg.build_message
25082 (p_appli_s_name => 'XLA'
25083 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25084 ,p_token_1 => 'LINE_NUMBER'
25085 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
25086 ,p_token_2 => 'LINE_TYPE_NAME'
25087 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
25088 l_component_type
25089 ,l_component_code
25090 ,l_component_type_code
25091 ,l_component_appl_id
25092 ,l_amb_context_code
25093 ,l_entity_code
25094 ,l_event_class_code
25095 )
25096 ,p_token_3 => 'OWNER'
25097 ,p_value_3 => xla_lookups_pkg.get_meaning(
25098 p_lookup_type => 'XLA_OWNER_TYPE'
25099 ,p_lookup_code => l_component_type_code
25100 )
25101 ,p_token_4 => 'PRODUCT_NAME'
25102 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
25103 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
25104 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
25105 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
25106 ,p_ae_header_id => NULL
25107 );
25108
25109 IF (C_LEVEL_ERROR>= g_log_level) THEN
25110 trace
25111 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25112 ,p_level => C_LEVEL_ERROR
25113 ,p_module => l_log_module);
25114 END IF;
25115 END IF;
25116 END IF;
25117 --
25118 --
25119 ------------------------------------------------------------------------------------------------
25120 -- 4219869 Business Flow
25121 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
25122 -- Prior Entry. Currently, the following code is always generated.
25123 ------------------------------------------------------------------------------------------------
25124 XLA_AE_LINES_PKG.ValidateCurrentLine;
25125
25126 ------------------------------------------------------------------------------------
25127 -- 4219869 Business Flow
25128 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
25129 ------------------------------------------------------------------------------------
25130 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25131
25135 ----------------------------------------------------------------------------------
25132 ----------------------------------------------------------------------------------
25133 -- 4219869 Business Flow
25134 -- Update journal entry status -- Need to generate this within IF <condition>
25136 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25137 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
25138 ,p_balance_type_code => l_balance_type_code
25139 );
25140
25141 -------------------------------------------------------------------------------------------
25142 -- 4262811 - Generate the Accrual Reversal lines
25143 -------------------------------------------------------------------------------------------
25144 BEGIN
25145 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
25146 (g_array_event(p_event_id).array_value_num('header_index'));
25147 IF l_acc_rev_flag IS NULL THEN
25148 l_acc_rev_flag := 'N';
25149 END IF;
25150 EXCEPTION
25151 WHEN OTHERS THEN
25152 l_acc_rev_flag := 'N';
25153 END;
25154 --
25155 IF (l_acc_rev_flag = 'Y') THEN
25156
25157 -- 4645092 ------------------------------------------------------------------------------
25158 -- To allow MPA report to determine if it should generate report process
25159 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
25160 ------------------------------------------------------------------------------------------
25161
25162 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
25163 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
25164 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
25165 -- call ADRs
25166 -- Bug 4922099
25167 --
25168 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25169 (NVL(l_actual_upg_option, 'N') = 'O') OR
25170 (NVL(l_enc_upg_option, 'N') = 'O')
25171 )
25172 THEN
25173 NULL;
25174 --
25175 --
25176
25177 l_ccid := AcctDerRule_23(
25178 p_application_id => p_application_id
25179 , p_ae_header_id => l_ae_header_id
25180 , p_source_16 => p_source_16
25181 , x_transaction_coa_id => l_adr_transaction_coa_id
25182 , x_accounting_coa_id => l_adr_accounting_coa_id
25183 , x_value_type_code => l_adr_value_type_code
25184 , p_side => 'NA'
25185 );
25186
25187 xla_ae_lines_pkg.set_ccid(
25188 p_code_combination_id => l_ccid
25189 , p_value_type_code => l_adr_value_type_code
25190 , p_transaction_coa_id => l_adr_transaction_coa_id
25191 , p_accounting_coa_id => l_adr_accounting_coa_id
25192 , p_adr_code => 'MFAR_TRX_DEF_REC_CCID'
25193 , p_adr_type_code => 'S'
25194 , p_component_type => l_component_type
25195 , p_component_code => l_component_code
25196 , p_component_type_code => l_component_type_code
25197 , p_component_appl_id => l_component_appl_id
25198 , p_amb_context_code => l_amb_context_code
25199 , p_side => 'NA'
25200 );
25201
25202
25203 l_segment := AcctDerRule_12(
25204 p_application_id => p_application_id
25205 , p_ae_header_id => l_ae_header_id
25206 , p_source_9 => p_source_9
25207 , p_source_10 => p_source_10
25208 , x_transaction_coa_id => l_adr_transaction_coa_id
25209 , x_accounting_coa_id => l_adr_accounting_coa_id
25210 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25211 , x_flex_value_set_id => l_adr_flex_value_set_id
25212 , x_value_type_code => l_adr_value_type_code
25213 , x_value_combination_id => l_adr_value_combination_id
25214 , x_value_segment_code => l_adr_value_segment_code
25215 , p_side => 'NA'
25216 , p_override_seg_flag => 'Y'
25217 );
25218
25219 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25220
25221 xla_ae_lines_pkg.set_segment(
25222 p_to_segment_code => 'GL_ACCOUNT'
25223 , p_segment_value => l_segment
25224 , p_from_segment_code => l_adr_value_segment_code
25225 , p_from_combination_id => l_adr_value_combination_id
25226 , p_value_type_code => l_adr_value_type_code
25227 , p_transaction_coa_id => l_adr_transaction_coa_id
25228 , p_accounting_coa_id => l_adr_accounting_coa_id
25229 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25230 , p_flex_value_set_id => l_adr_flex_value_set_id
25231 , p_adr_code => 'FV_AR_425X0X_INV_REIM_DR'
25232 , p_adr_type_code => 'S'
25233 , p_component_type => l_component_type
25234 , p_component_code => l_component_code
25235 , p_component_type_code => l_component_type_code
25236 , p_component_appl_id => l_component_appl_id
25237 , p_amb_context_code => l_amb_context_code
25238 , p_entity_code => 'TRANSACTIONS'
25239 , p_event_class_code => 'INVOICE'
25240 , p_side => 'NA'
25241 );
25242
25243 END IF;
25244
25245 --
25246 --
25247 END IF;
25248
25249 --
25250 -- Update the line information that should be overwritten
25251 --
25252 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
25256 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
25253 p_header_num => 1);
25254 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
25255
25257
25258 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
25259 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
25260 END IF;
25261
25262 --
25263 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
25264 --
25265 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
25266 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
25267 ELSE
25268 ---------------------------------------------------------------------------------------------------
25269 -- 4262811a Switch Sign
25270 ---------------------------------------------------------------------------------------------------
25271 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
25272 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25273 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25274 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25275 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25276 -- 5132302
25277 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
25278 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25279
25280 END IF;
25281
25282 -- 4955764
25283 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25284 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
25285
25286
25287 XLA_AE_LINES_PKG.ValidateCurrentLine;
25288 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25289
25290 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25291 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
25292 ,p_balance_type_code => l_balance_type_code);
25293
25294 END IF;
25295
25296 -----------------------------------------------------------------------------------------
25297 -- 4262811 Multiperiod Accounting
25298 -----------------------------------------------------------------------------------------
25299 -- No MPA option is assigned.
25300
25301
25302 END IF;
25303 END IF;
25304 --
25305
25306 --
25307 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25308 trace
25309 (p_msg => 'END of AcctLineType_65'
25310 ,p_level => C_LEVEL_PROCEDURE
25311 ,p_module => l_log_module);
25312 END IF;
25313 --
25314 EXCEPTION
25315 WHEN xla_exceptions_pkg.application_exception THEN
25316 RAISE;
25317 WHEN OTHERS THEN
25318 xla_exceptions_pkg.raise_message
25319 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_65');
25320 END AcctLineType_65;
25321 --
25322
25323 ---------------------------------------
25324 --
25325 -- PRIVATE FUNCTION
25326 -- AcctLineType_66
25327 --
25328 ---------------------------------------
25329 PROCEDURE AcctLineType_66 (
25330 p_application_id IN NUMBER
25331 ,p_event_id IN NUMBER
25332 ,p_calculate_acctd_flag IN VARCHAR2
25333 ,p_calculate_g_l_flag IN VARCHAR2
25334 ,p_actual_flag IN OUT VARCHAR2
25335 ,p_balance_type_code OUT VARCHAR2
25336 ,p_gain_or_loss_ref OUT VARCHAR2
25337
25338 --Distribution GL Account
25339 , p_source_5 IN NUMBER
25340 --Federal Fund Expired Status
25341 , p_source_12 IN VARCHAR2
25342 --Federal Prior Year Flag
25343 , p_source_13 IN VARCHAR2
25344 --Federal Fund Time Frame
25345 , p_source_14 IN VARCHAR2
25346 --Distribution Source Type
25347 , p_source_20 IN VARCHAR2
25348 --Distribution Line Identifier
25349 , p_source_22 IN NUMBER
25350 --Distribution Type
25351 , p_source_23 IN VARCHAR2
25352 --Entered Amount
25353 , p_source_24 IN NUMBER
25354 --Currency Code
25355 , p_source_25 IN VARCHAR2
25356 --Exchange Rate
25357 , p_source_27 IN NUMBER
25358 --Exchange Rate Type
25359 , p_source_28 IN VARCHAR2
25360 --Applied To Document Accounting Amount
25361 , p_source_29 IN NUMBER
25362 --Federal Account Valid Flag
25363 , p_source_56 IN VARCHAR2
25364 --Applied To Document Exchange Date
25365 , p_source_57 IN DATE
25366 )
25367 IS
25368
25369 l_component_type VARCHAR2(80);
25370 l_component_code VARCHAR2(30);
25371 l_component_type_code VARCHAR2(1);
25372 l_component_appl_id INTEGER;
25373 l_amb_context_code VARCHAR2(30);
25374 l_entity_code VARCHAR2(30);
25375 l_event_class_code VARCHAR2(30);
25376 l_ae_header_id NUMBER;
25377 l_event_type_code VARCHAR2(30);
25378 l_line_definition_code VARCHAR2(30);
25379 l_line_definition_owner_code VARCHAR2(1);
25380 --
25381 -- adr variables
25382 l_segment VARCHAR2(30);
25383 l_ccid NUMBER;
25384 l_adr_transaction_coa_id NUMBER;
25388 l_adr_value_type_code VARCHAR2(30);
25385 l_adr_accounting_coa_id NUMBER;
25386 l_adr_flexfield_segment_code VARCHAR2(30);
25387 l_adr_flex_value_set_id NUMBER;
25389 l_adr_value_combination_id NUMBER;
25390 l_adr_value_segment_code VARCHAR2(30);
25391
25392 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
25393 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
25394 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
25395 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
25396
25397 -- 4262811 Variables ------------------------------------------------------------------------------------------
25398 l_entered_amt_idx NUMBER;
25399 l_accted_amt_idx NUMBER;
25400 l_acc_rev_flag VARCHAR2(1);
25401 l_accrual_line_num NUMBER;
25402 l_tmp_amt NUMBER;
25403 l_acc_rev_natural_side_code VARCHAR2(1);
25404
25405 l_num_entries NUMBER;
25406 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
25407 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
25408 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
25409 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
25410 l_recog_line_1 NUMBER;
25411 l_recog_line_2 NUMBER;
25412
25413 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
25414 l_bflow_applied_to_amt NUMBER; -- 5132302
25415 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
25416
25417 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
25418
25419 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
25420 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
25421
25422 ---------------------------------------------------------------------------------------------------------------
25423
25424
25425 --
25426 -- bulk performance
25427 --
25428 l_balance_type_code VARCHAR2(1);
25429 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
25430 l_log_module VARCHAR2(240);
25431
25432 --
25433 -- Upgrade strategy
25434 --
25435 l_actual_upg_option VARCHAR2(1);
25436 l_enc_upg_option VARCHAR2(1);
25437
25438 --
25439 BEGIN
25440 --
25441 IF g_log_enabled THEN
25442 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_66';
25443 END IF;
25444 --
25445 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25446
25447 trace
25448 (p_msg => 'BEGIN of AcctLineType_66'
25449 ,p_level => C_LEVEL_PROCEDURE
25450 ,p_module => l_log_module);
25451
25452 END IF;
25453 --
25454 l_component_type := 'AMB_JLT';
25455 l_component_code := 'FV_MISC_RCT_REF_OEF_CR';
25456 l_component_type_code := 'S';
25457 l_component_appl_id := 222;
25458 l_amb_context_code := 'DEFAULT';
25459 l_entity_code := 'RECEIPTS';
25460 l_event_class_code := 'MISC_RECEIPT';
25461 l_event_type_code := 'MISC_RECEIPT_ALL';
25462 l_line_definition_owner_code := 'S';
25463 l_line_definition_code := 'FEDERAL_AR_MISC_RECEIPTS';
25464 --
25465 l_balance_type_code := 'A';
25466 l_segment := NULL;
25467 l_ccid := NULL;
25468 l_adr_transaction_coa_id := NULL;
25469 l_adr_accounting_coa_id := NULL;
25470 l_adr_flexfield_segment_code := NULL;
25471 l_adr_flex_value_set_id := NULL;
25472 l_adr_value_type_code := NULL;
25473 l_adr_value_combination_id := NULL;
25474 l_adr_value_segment_code := NULL;
25475
25476 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
25477 l_bflow_class_code := ''; -- 4219869 Business Flow
25478 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
25479 l_budgetary_control_flag := 'N';
25480
25481 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25482 l_bflow_applied_to_amt := NULL; -- 5132302
25483 l_entered_amt_idx := NULL; -- 4262811
25484 l_accted_amt_idx := NULL; -- 4262811
25485 l_acc_rev_flag := NULL; -- 4262811
25486 l_accrual_line_num := NULL; -- 4262811
25487 l_tmp_amt := NULL; -- 4262811
25488 --
25489
25490 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
25491 l_balance_type_code <> 'B' THEN
25492 IF NVL(p_source_20,'
25493 ') = 'MISCCASH' AND
25494 NVL(p_source_12,'
25495 ') = 'Expired' AND
25496 NVL(p_source_13,'
25497 ') = 'Y' AND
25498 (NVL(p_source_14,'
25499 ') = 'SINGLE' OR
25500 NVL(p_source_14,'
25501 ') = 'MULTIPLE' OR
25502 NVL(p_source_14,'
25503 ') = 'NO_YEAR') AND
25504 NVL(p_source_56,'
25505 ') = 'Y'
25506 THEN
25507
25508 --
25509 XLA_AE_LINES_PKG.SetNewLine;
25510
25511 p_balance_type_code := l_balance_type_code;
25512 -- set the flag so later we will know whether the gain loss line needs to be created
25513
25514 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
25515 p_actual_flag :='A';
25516 END IF;
25517
25518 --
25519 -- bulk performance
25520 --
25526 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
25521 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
25522 p_header_num => 0); -- 4262811
25523 --
25524 -- set accounting line options
25525 --
25527 p_natural_side_code => 'C'
25528 , p_gain_or_loss_flag => 'N'
25529 , p_gl_transfer_mode_code => 'S'
25530 , p_acct_entry_type_code => 'A'
25531 , p_switch_side_flag => 'Y'
25532 , p_merge_duplicate_code => 'A'
25533 );
25534 --
25535 l_acc_rev_natural_side_code := 'D'; -- 4262811
25536 --
25537 --
25538 -- set accounting line type info
25539 --
25540 xla_ae_lines_pkg.SetAcctLineType
25541 (p_component_type => l_component_type
25542 ,p_event_type_code => l_event_type_code
25543 ,p_line_definition_owner_code => l_line_definition_owner_code
25544 ,p_line_definition_code => l_line_definition_code
25545 ,p_accounting_line_code => l_component_code
25546 ,p_accounting_line_type_code => l_component_type_code
25547 ,p_accounting_line_appl_id => l_component_appl_id
25548 ,p_amb_context_code => l_amb_context_code
25549 ,p_entity_code => l_entity_code
25550 ,p_event_class_code => l_event_class_code);
25551 --
25552 -- set accounting class
25553 --
25554 xla_ae_lines_pkg.SetAcctClass(
25555 p_accounting_class_code => 'FV_MISCCASH_CR'
25556 , p_ae_header_id => l_ae_header_id
25557 );
25558
25559 --
25560 -- set rounding class
25561 --
25562 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
25563 'RECEIVABLE';
25564
25565 --
25566 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
25567 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
25568 --
25569 -- bulk performance
25570 --
25571 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
25572
25573 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
25574 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
25575
25576 -- 4955764
25577 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25578 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
25579
25580 -- 4458381 Public Sector Enh
25581
25582 --
25583 -- set accounting attributes for the line type
25584 --
25585 l_entered_amt_idx := 3;
25586 l_accted_amt_idx := 8;
25587 l_bflow_applied_to_amt_idx := NULL; -- 5132302
25588 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
25589 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
25590 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
25591 l_rec_acct_attrs.array_char_value(2) := p_source_23;
25592 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
25593 l_rec_acct_attrs.array_num_value(3) := p_source_24;
25594 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
25595 l_rec_acct_attrs.array_char_value(4) := p_source_25;
25596 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
25597 l_rec_acct_attrs.array_date_value(5) := p_source_57;
25598 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
25599 l_rec_acct_attrs.array_num_value(6) := p_source_27;
25600 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
25601 l_rec_acct_attrs.array_char_value(7) := p_source_28;
25602 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
25603 l_rec_acct_attrs.array_num_value(8) := p_source_29;
25604
25605 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
25606 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
25607
25608 ---------------------------------------------------------------------------------------------------------------
25609 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
25610 ---------------------------------------------------------------------------------------------------------------
25611 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
25612
25613 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25614 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
25615
25616 IF xla_accounting_cache_pkg.GetValueChar
25617 (p_source_code => 'LEDGER_CATEGORY_CODE'
25618 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
25619 AND l_bflow_method_code = 'PRIOR_ENTRY'
25620 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
25621 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
25622 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
25623 )
25624 THEN
25625 xla_ae_lines_pkg.BflowUpgEntry
25626 (p_business_method_code => l_bflow_method_code
25627 ,p_business_class_code => l_bflow_class_code
25628 ,p_balance_type => l_balance_type_code);
25629 ELSE
25630 NULL;
25631 -- No business flow processing for business flow method of NONE.
25632 END IF;
25633
25634 --
25635 -- call analytical criteria
25636 --
25637
25638 --
25639 -- call description
25640 --
25641 -- No description or it is inherited.
25642 --
25643 -- call ADRs
25644 -- Bug 4922099
25645 --
25646 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25647 (NVL(l_actual_upg_option, 'N') = 'O') OR
25648 (NVL(l_enc_upg_option, 'N') = 'O')
25649 )
25650 THEN
25651 NULL;
25652 --
25653 --
25654
25655 l_ccid := AcctDerRule_4(
25656 p_application_id => p_application_id
25657 , p_ae_header_id => l_ae_header_id
25658 , p_source_5 => p_source_5
25659 , x_transaction_coa_id => l_adr_transaction_coa_id
25660 , x_accounting_coa_id => l_adr_accounting_coa_id
25661 , x_value_type_code => l_adr_value_type_code
25662 , p_side => 'NA'
25663 );
25664
25665 xla_ae_lines_pkg.set_ccid(
25666 p_code_combination_id => l_ccid
25667 , p_value_type_code => l_adr_value_type_code
25671 , p_adr_type_code => 'S'
25668 , p_transaction_coa_id => l_adr_transaction_coa_id
25669 , p_accounting_coa_id => l_adr_accounting_coa_id
25670 , p_adr_code => 'DIST_CCID'
25672 , p_component_type => l_component_type
25673 , p_component_code => l_component_code
25674 , p_component_type_code => l_component_type_code
25675 , p_component_appl_id => l_component_appl_id
25676 , p_amb_context_code => l_amb_context_code
25677 , p_side => 'NA'
25678 );
25679
25680
25681 l_segment := AcctDerRule_15(
25682 p_application_id => p_application_id
25683 , p_ae_header_id => l_ae_header_id
25684 , p_source_12 => p_source_12
25685 , p_source_13 => p_source_13
25686 , p_source_14 => p_source_14
25687 , x_transaction_coa_id => l_adr_transaction_coa_id
25688 , x_accounting_coa_id => l_adr_accounting_coa_id
25689 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25690 , x_flex_value_set_id => l_adr_flex_value_set_id
25691 , x_value_type_code => l_adr_value_type_code
25692 , x_value_combination_id => l_adr_value_combination_id
25693 , x_value_segment_code => l_adr_value_segment_code
25694 , p_side => 'NA'
25695 , p_override_seg_flag => 'Y'
25696 );
25697
25698 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25699
25700 xla_ae_lines_pkg.set_segment(
25701 p_to_segment_code => 'GL_ACCOUNT'
25702 , p_segment_value => l_segment
25703 , p_from_segment_code => l_adr_value_segment_code
25704 , p_from_combination_id => l_adr_value_combination_id
25708 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25705 , p_value_type_code => l_adr_value_type_code
25706 , p_transaction_coa_id => l_adr_transaction_coa_id
25707 , p_accounting_coa_id => l_adr_accounting_coa_id
25709 , p_flex_value_set_id => l_adr_flex_value_set_id
25710 , p_adr_code => 'FV_AR_465002_MISC_RCT_CR'
25711 , p_adr_type_code => 'S'
25712 , p_component_type => l_component_type
25713 , p_component_code => l_component_code
25714 , p_component_type_code => l_component_type_code
25715 , p_component_appl_id => l_component_appl_id
25716 , p_amb_context_code => l_amb_context_code
25717 , p_entity_code => 'RECEIPTS'
25718 , p_event_class_code => 'MISC_RECEIPT'
25719 , p_side => 'NA'
25720 );
25721
25722 END IF;
25723
25724 --
25725 --
25726 END IF;
25727 --
25728 -- Bug 4922099
25729 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
25730 (NVL(l_enc_upg_option, 'N') = 'O')
25731 ) AND
25732 (l_bflow_method_code = 'PRIOR_ENTRY')
25733 )
25734 THEN
25735 IF
25736 --
25737 1 = 2
25738 --
25739 THEN
25740 xla_accounting_err_pkg.build_message
25741 (p_appli_s_name => 'XLA'
25742 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25743 ,p_token_1 => 'LINE_NUMBER'
25744 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
25745 ,p_token_2 => 'LINE_TYPE_NAME'
25746 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
25747 l_component_type
25748 ,l_component_code
25749 ,l_component_type_code
25750 ,l_component_appl_id
25751 ,l_amb_context_code
25752 ,l_entity_code
25753 ,l_event_class_code
25754 )
25755 ,p_token_3 => 'OWNER'
25756 ,p_value_3 => xla_lookups_pkg.get_meaning(
25757 p_lookup_type => 'XLA_OWNER_TYPE'
25758 ,p_lookup_code => l_component_type_code
25759 )
25760 ,p_token_4 => 'PRODUCT_NAME'
25761 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
25762 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
25763 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
25764 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
25765 ,p_ae_header_id => NULL
25766 );
25767
25768 IF (C_LEVEL_ERROR>= g_log_level) THEN
25769 trace
25770 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
25771 ,p_level => C_LEVEL_ERROR
25772 ,p_module => l_log_module);
25773 END IF;
25774 END IF;
25775 END IF;
25776 --
25777 --
25778 ------------------------------------------------------------------------------------------------
25779 -- 4219869 Business Flow
25780 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
25781 -- Prior Entry. Currently, the following code is always generated.
25782 ------------------------------------------------------------------------------------------------
25783 XLA_AE_LINES_PKG.ValidateCurrentLine;
25784
25785 ------------------------------------------------------------------------------------
25786 -- 4219869 Business Flow
25787 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
25788 ------------------------------------------------------------------------------------
25789 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25790
25791 ----------------------------------------------------------------------------------
25792 -- 4219869 Business Flow
25793 -- Update journal entry status -- Need to generate this within IF <condition>
25794 ----------------------------------------------------------------------------------
25795 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25796 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
25797 ,p_balance_type_code => l_balance_type_code
25798 );
25799
25800 -------------------------------------------------------------------------------------------
25801 -- 4262811 - Generate the Accrual Reversal lines
25802 -------------------------------------------------------------------------------------------
25803 BEGIN
25804 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
25805 (g_array_event(p_event_id).array_value_num('header_index'));
25806 IF l_acc_rev_flag IS NULL THEN
25807 l_acc_rev_flag := 'N';
25808 END IF;
25809 EXCEPTION
25810 WHEN OTHERS THEN
25811 l_acc_rev_flag := 'N';
25812 END;
25813 --
25814 IF (l_acc_rev_flag = 'Y') THEN
25815
25816 -- 4645092 ------------------------------------------------------------------------------
25817 -- To allow MPA report to determine if it should generate report process
25818 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
25819 ------------------------------------------------------------------------------------------
25820
25821 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
25822 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
25823 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
25824 -- call ADRs
25825 -- Bug 4922099
25826 --
25827 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
25828 (NVL(l_actual_upg_option, 'N') = 'O') OR
25829 (NVL(l_enc_upg_option, 'N') = 'O')
25830 )
25831 THEN
25832 NULL;
25833 --
25834 --
25835
25836 l_ccid := AcctDerRule_4(
25837 p_application_id => p_application_id
25838 , p_ae_header_id => l_ae_header_id
25839 , p_source_5 => p_source_5
25840 , x_transaction_coa_id => l_adr_transaction_coa_id
25841 , x_accounting_coa_id => l_adr_accounting_coa_id
25842 , x_value_type_code => l_adr_value_type_code
25843 , p_side => 'NA'
25844 );
25845
25846 xla_ae_lines_pkg.set_ccid(
25847 p_code_combination_id => l_ccid
25848 , p_value_type_code => l_adr_value_type_code
25849 , p_transaction_coa_id => l_adr_transaction_coa_id
25850 , p_accounting_coa_id => l_adr_accounting_coa_id
25851 , p_adr_code => 'DIST_CCID'
25852 , p_adr_type_code => 'S'
25853 , p_component_type => l_component_type
25854 , p_component_code => l_component_code
25855 , p_component_type_code => l_component_type_code
25856 , p_component_appl_id => l_component_appl_id
25857 , p_amb_context_code => l_amb_context_code
25858 , p_side => 'NA'
25859 );
25860
25861
25862 l_segment := AcctDerRule_15(
25863 p_application_id => p_application_id
25864 , p_ae_header_id => l_ae_header_id
25865 , p_source_12 => p_source_12
25866 , p_source_13 => p_source_13
25867 , p_source_14 => p_source_14
25868 , x_transaction_coa_id => l_adr_transaction_coa_id
25869 , x_accounting_coa_id => l_adr_accounting_coa_id
25870 , x_flexfield_segment_code => l_adr_flexfield_segment_code
25871 , x_flex_value_set_id => l_adr_flex_value_set_id
25872 , x_value_type_code => l_adr_value_type_code
25873 , x_value_combination_id => l_adr_value_combination_id
25874 , x_value_segment_code => l_adr_value_segment_code
25875 , p_side => 'NA'
25876 , p_override_seg_flag => 'Y'
25877 );
25878
25879 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
25880
25881 xla_ae_lines_pkg.set_segment(
25882 p_to_segment_code => 'GL_ACCOUNT'
25883 , p_segment_value => l_segment
25884 , p_from_segment_code => l_adr_value_segment_code
25885 , p_from_combination_id => l_adr_value_combination_id
25886 , p_value_type_code => l_adr_value_type_code
25890 , p_flex_value_set_id => l_adr_flex_value_set_id
25887 , p_transaction_coa_id => l_adr_transaction_coa_id
25888 , p_accounting_coa_id => l_adr_accounting_coa_id
25889 , p_flexfield_segment_code => l_adr_flexfield_segment_code
25891 , p_adr_code => 'FV_AR_465002_MISC_RCT_CR'
25892 , p_adr_type_code => 'S'
25893 , p_component_type => l_component_type
25894 , p_component_code => l_component_code
25895 , p_component_type_code => l_component_type_code
25896 , p_component_appl_id => l_component_appl_id
25897 , p_amb_context_code => l_amb_context_code
25898 , p_entity_code => 'RECEIPTS'
25899 , p_event_class_code => 'MISC_RECEIPT'
25900 , p_side => 'NA'
25901 );
25902
25903 END IF;
25904
25905 --
25906 --
25907 END IF;
25908
25909 --
25910 -- Update the line information that should be overwritten
25911 --
25912 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
25913 p_header_num => 1);
25914 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
25915
25916 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
25917
25918 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
25919 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
25920 END IF;
25921
25922 --
25923 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
25924 --
25925 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
25926 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
25927 ELSE
25928 ---------------------------------------------------------------------------------------------------
25929 -- 4262811a Switch Sign
25930 ---------------------------------------------------------------------------------------------------
25931 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
25932 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25933 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25934 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
25935 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25936 -- 5132302
25937 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
25938 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
25939
25940 END IF;
25941
25942 -- 4955764
25943 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
25944 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
25945
25946
25947 XLA_AE_LINES_PKG.ValidateCurrentLine;
25948 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
25949
25950 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
25951 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
25952 ,p_balance_type_code => l_balance_type_code);
25953
25954 END IF;
25955
25956 -----------------------------------------------------------------------------------------
25957 -- 4262811 Multiperiod Accounting
25958 -----------------------------------------------------------------------------------------
25959 -- No MPA option is assigned.
25960
25961
25962 END IF;
25963 END IF;
25964 --
25965
25966 --
25967 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
25968 trace
25969 (p_msg => 'END of AcctLineType_66'
25970 ,p_level => C_LEVEL_PROCEDURE
25971 ,p_module => l_log_module);
25972 END IF;
25973 --
25974 EXCEPTION
25975 WHEN xla_exceptions_pkg.application_exception THEN
25976 RAISE;
25977 WHEN OTHERS THEN
25978 xla_exceptions_pkg.raise_message
25979 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_66');
25980 END AcctLineType_66;
25981 --
25982
25983 ---------------------------------------
25984 --
25985 -- PRIVATE FUNCTION
25986 -- AcctLineType_67
25987 --
25988 ---------------------------------------
25989 PROCEDURE AcctLineType_67 (
25990 p_application_id IN NUMBER
25991 ,p_event_id IN NUMBER
25992 ,p_calculate_acctd_flag IN VARCHAR2
25993 ,p_calculate_g_l_flag IN VARCHAR2
25994 ,p_actual_flag IN OUT VARCHAR2
25995 ,p_balance_type_code OUT VARCHAR2
25996 ,p_gain_or_loss_ref OUT VARCHAR2
25997
25998 --Distribution GL Account
25999 , p_source_5 IN NUMBER
26000 --Federal Fund Expired Status
26001 , p_source_12 IN VARCHAR2
26002 --Federal Prior Year Flag
26003 , p_source_13 IN VARCHAR2
26004 --Federal Fund Time Frame
26005 , p_source_14 IN VARCHAR2
26006 --Distribution Source Type
26007 , p_source_20 IN VARCHAR2
26008 --Distribution Line Identifier
26009 , p_source_22 IN NUMBER
26010 --Distribution Type
26011 , p_source_23 IN VARCHAR2
26012 --Entered Amount
26013 , p_source_24 IN NUMBER
26014 --Currency Code
26015 , p_source_25 IN VARCHAR2
26016 --Exchange Rate
26017 , p_source_27 IN NUMBER
26018 --Exchange Rate Type
26019 , p_source_28 IN VARCHAR2
26020 --Applied To Document Accounting Amount
26021 , p_source_29 IN NUMBER
26022 --Federal Account Valid Flag
26023 , p_source_56 IN VARCHAR2
26024 --Applied To Document Exchange Date
26025 , p_source_57 IN DATE
26026 )
26027 IS
26028
26029 l_component_type VARCHAR2(80);
26030 l_component_code VARCHAR2(30);
26031 l_component_type_code VARCHAR2(1);
26032 l_component_appl_id INTEGER;
26033 l_amb_context_code VARCHAR2(30);
26034 l_entity_code VARCHAR2(30);
26035 l_event_class_code VARCHAR2(30);
26036 l_ae_header_id NUMBER;
26037 l_event_type_code VARCHAR2(30);
26038 l_line_definition_code VARCHAR2(30);
26039 l_line_definition_owner_code VARCHAR2(1);
26040 --
26041 -- adr variables
26042 l_segment VARCHAR2(30);
26043 l_ccid NUMBER;
26044 l_adr_transaction_coa_id NUMBER;
26045 l_adr_accounting_coa_id NUMBER;
26046 l_adr_flexfield_segment_code VARCHAR2(30);
26047 l_adr_flex_value_set_id NUMBER;
26048 l_adr_value_type_code VARCHAR2(30);
26049 l_adr_value_combination_id NUMBER;
26050 l_adr_value_segment_code VARCHAR2(30);
26051
26052 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
26053 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
26054 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
26055 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
26056
26057 -- 4262811 Variables ------------------------------------------------------------------------------------------
26058 l_entered_amt_idx NUMBER;
26059 l_accted_amt_idx NUMBER;
26060 l_acc_rev_flag VARCHAR2(1);
26061 l_accrual_line_num NUMBER;
26062 l_tmp_amt NUMBER;
26063 l_acc_rev_natural_side_code VARCHAR2(1);
26064
26065 l_num_entries NUMBER;
26066 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
26067 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
26068 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
26069 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
26070 l_recog_line_1 NUMBER;
26071 l_recog_line_2 NUMBER;
26072
26073 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
26074 l_bflow_applied_to_amt NUMBER; -- 5132302
26075 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
26076
26077 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
26078
26079 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
26080 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
26081
26082 ---------------------------------------------------------------------------------------------------------------
26083
26084
26085 --
26086 -- bulk performance
26087 --
26088 l_balance_type_code VARCHAR2(1);
26089 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
26090 l_log_module VARCHAR2(240);
26091
26092 --
26093 -- Upgrade strategy
26094 --
26095 l_actual_upg_option VARCHAR2(1);
26096 l_enc_upg_option VARCHAR2(1);
26097
26098 --
26099 BEGIN
26100 --
26101 IF g_log_enabled THEN
26102 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_67';
26103 END IF;
26104 --
26105 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26106
26107 trace
26108 (p_msg => 'BEGIN of AcctLineType_67'
26109 ,p_level => C_LEVEL_PROCEDURE
26110 ,p_module => l_log_module);
26111
26112 END IF;
26113 --
26114 l_component_type := 'AMB_JLT';
26115 l_component_code := 'FV_MISC_RCT_REF_OEF_DR';
26116 l_component_type_code := 'S';
26117 l_component_appl_id := 222;
26118 l_amb_context_code := 'DEFAULT';
26119 l_entity_code := 'RECEIPTS';
26120 l_event_class_code := 'MISC_RECEIPT';
26121 l_event_type_code := 'MISC_RECEIPT_ALL';
26122 l_line_definition_owner_code := 'S';
26123 l_line_definition_code := 'FEDERAL_AR_MISC_RECEIPTS';
26124 --
26125 l_balance_type_code := 'A';
26126 l_segment := NULL;
26127 l_ccid := NULL;
26128 l_adr_transaction_coa_id := NULL;
26129 l_adr_accounting_coa_id := NULL;
26130 l_adr_flexfield_segment_code := NULL;
26131 l_adr_flex_value_set_id := NULL;
26132 l_adr_value_type_code := NULL;
26133 l_adr_value_combination_id := NULL;
26134 l_adr_value_segment_code := NULL;
26135
26136 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
26137 l_bflow_class_code := ''; -- 4219869 Business Flow
26138 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
26139 l_budgetary_control_flag := 'N';
26140
26141 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26142 l_bflow_applied_to_amt := NULL; -- 5132302
26143 l_entered_amt_idx := NULL; -- 4262811
26144 l_accted_amt_idx := NULL; -- 4262811
26145 l_acc_rev_flag := NULL; -- 4262811
26146 l_accrual_line_num := NULL; -- 4262811
26147 l_tmp_amt := NULL; -- 4262811
26148 --
26149
26150 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
26151 l_balance_type_code <> 'B' THEN
26152 IF NVL(p_source_20,'
26153 ') = 'MISCCASH' AND
26154 NVL(p_source_12,'
26155 ') = 'Expired' AND
26156 NVL(p_source_13,'
26157 ') = 'Y' AND
26158 (NVL(p_source_14,'
26159 ') = 'SINGLE' OR
26160 NVL(p_source_14,'
26161 ') = 'MULTIPLE' OR
26162 NVL(p_source_14,'
26163 ') = 'NO_YEAR') AND
26164 NVL(p_source_56,'
26165 ') = 'Y'
26166 THEN
26167
26168 --
26169 XLA_AE_LINES_PKG.SetNewLine;
26170
26171 p_balance_type_code := l_balance_type_code;
26172 -- set the flag so later we will know whether the gain loss line needs to be created
26173
26174 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
26175 p_actual_flag :='A';
26176 END IF;
26177
26178 --
26179 -- bulk performance
26180 --
26181 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
26182 p_header_num => 0); -- 4262811
26183 --
26184 -- set accounting line options
26185 --
26186 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
26187 p_natural_side_code => 'D'
26188 , p_gain_or_loss_flag => 'N'
26189 , p_gl_transfer_mode_code => 'S'
26190 , p_acct_entry_type_code => 'A'
26191 , p_switch_side_flag => 'Y'
26192 , p_merge_duplicate_code => 'A'
26193 );
26194 --
26195 l_acc_rev_natural_side_code := 'C'; -- 4262811
26196 --
26197 --
26198 -- set accounting line type info
26199 --
26200 xla_ae_lines_pkg.SetAcctLineType
26201 (p_component_type => l_component_type
26202 ,p_event_type_code => l_event_type_code
26203 ,p_line_definition_owner_code => l_line_definition_owner_code
26204 ,p_line_definition_code => l_line_definition_code
26205 ,p_accounting_line_code => l_component_code
26206 ,p_accounting_line_type_code => l_component_type_code
26207 ,p_accounting_line_appl_id => l_component_appl_id
26208 ,p_amb_context_code => l_amb_context_code
26209 ,p_entity_code => l_entity_code
26210 ,p_event_class_code => l_event_class_code);
26211 --
26212 -- set accounting class
26213 --
26214 xla_ae_lines_pkg.SetAcctClass(
26215 p_accounting_class_code => 'FV_MISCCASH_DR'
26216 , p_ae_header_id => l_ae_header_id
26217 );
26218
26219 --
26220 -- set rounding class
26221 --
26222 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
26223 'RECEIVABLE';
26224
26225 --
26226 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
26227 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
26228 --
26229 -- bulk performance
26230 --
26231 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
26232
26233 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
26234 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
26235
26236 -- 4955764
26237 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26238 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
26239
26240 -- 4458381 Public Sector Enh
26241
26242 --
26243 -- set accounting attributes for the line type
26244 --
26245 l_entered_amt_idx := 3;
26246 l_accted_amt_idx := 8;
26247 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26248 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
26249 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
26250 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
26251 l_rec_acct_attrs.array_char_value(2) := p_source_23;
26252 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
26253 l_rec_acct_attrs.array_num_value(3) := p_source_24;
26254 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
26255 l_rec_acct_attrs.array_char_value(4) := p_source_25;
26256 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
26257 l_rec_acct_attrs.array_date_value(5) := p_source_57;
26258 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
26259 l_rec_acct_attrs.array_num_value(6) := p_source_27;
26260 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
26261 l_rec_acct_attrs.array_char_value(7) := p_source_28;
26262 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
26263 l_rec_acct_attrs.array_num_value(8) := p_source_29;
26264
26265 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
26266 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
26267
26268 ---------------------------------------------------------------------------------------------------------------
26269 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
26270 ---------------------------------------------------------------------------------------------------------------
26271 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
26272
26273 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26274 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26275
26276 IF xla_accounting_cache_pkg.GetValueChar
26277 (p_source_code => 'LEDGER_CATEGORY_CODE'
26278 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
26279 AND l_bflow_method_code = 'PRIOR_ENTRY'
26280 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
26281 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
26282 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
26283 )
26284 THEN
26285 xla_ae_lines_pkg.BflowUpgEntry
26286 (p_business_method_code => l_bflow_method_code
26287 ,p_business_class_code => l_bflow_class_code
26288 ,p_balance_type => l_balance_type_code);
26289 ELSE
26290 NULL;
26291 -- No business flow processing for business flow method of NONE.
26292 END IF;
26293
26294 --
26295 -- call analytical criteria
26296 --
26297
26298 --
26299 -- call description
26300 --
26301 -- No description or it is inherited.
26302 --
26303 -- call ADRs
26304 -- Bug 4922099
26305 --
26306 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26307 (NVL(l_actual_upg_option, 'N') = 'O') OR
26308 (NVL(l_enc_upg_option, 'N') = 'O')
26309 )
26310 THEN
26311 NULL;
26312 --
26313 --
26314
26315 l_ccid := AcctDerRule_4(
26316 p_application_id => p_application_id
26317 , p_ae_header_id => l_ae_header_id
26318 , p_source_5 => p_source_5
26319 , x_transaction_coa_id => l_adr_transaction_coa_id
26320 , x_accounting_coa_id => l_adr_accounting_coa_id
26321 , x_value_type_code => l_adr_value_type_code
26322 , p_side => 'NA'
26323 );
26324
26325 xla_ae_lines_pkg.set_ccid(
26326 p_code_combination_id => l_ccid
26327 , p_value_type_code => l_adr_value_type_code
26328 , p_transaction_coa_id => l_adr_transaction_coa_id
26329 , p_accounting_coa_id => l_adr_accounting_coa_id
26330 , p_adr_code => 'DIST_CCID'
26331 , p_adr_type_code => 'S'
26332 , p_component_type => l_component_type
26333 , p_component_code => l_component_code
26334 , p_component_type_code => l_component_type_code
26335 , p_component_appl_id => l_component_appl_id
26336 , p_amb_context_code => l_amb_context_code
26337 , p_side => 'NA'
26338 );
26339
26340
26341 l_segment := AcctDerRule_20(
26342 p_application_id => p_application_id
26343 , p_ae_header_id => l_ae_header_id
26344 , p_source_12 => p_source_12
26345 , p_source_13 => p_source_13
26346 , p_source_14 => p_source_14
26347 , x_transaction_coa_id => l_adr_transaction_coa_id
26348 , x_accounting_coa_id => l_adr_accounting_coa_id
26349 , x_flexfield_segment_code => l_adr_flexfield_segment_code
26350 , x_flex_value_set_id => l_adr_flex_value_set_id
26351 , x_value_type_code => l_adr_value_type_code
26352 , x_value_combination_id => l_adr_value_combination_id
26353 , x_value_segment_code => l_adr_value_segment_code
26354 , p_side => 'NA'
26355 , p_override_seg_flag => 'Y'
26356 );
26357
26358 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
26359
26360 xla_ae_lines_pkg.set_segment(
26361 p_to_segment_code => 'GL_ACCOUNT'
26362 , p_segment_value => l_segment
26363 , p_from_segment_code => l_adr_value_segment_code
26364 , p_from_combination_id => l_adr_value_combination_id
26365 , p_value_type_code => l_adr_value_type_code
26366 , p_transaction_coa_id => l_adr_transaction_coa_id
26367 , p_accounting_coa_id => l_adr_accounting_coa_id
26368 , p_flexfield_segment_code => l_adr_flexfield_segment_code
26369 , p_flex_value_set_id => l_adr_flex_value_set_id
26370 , p_adr_code => 'FV_AR_497201_MISC_RCT_DR'
26371 , p_adr_type_code => 'S'
26372 , p_component_type => l_component_type
26373 , p_component_code => l_component_code
26374 , p_component_type_code => l_component_type_code
26375 , p_component_appl_id => l_component_appl_id
26376 , p_amb_context_code => l_amb_context_code
26377 , p_entity_code => 'RECEIPTS'
26378 , p_event_class_code => 'MISC_RECEIPT'
26379 , p_side => 'NA'
26380 );
26381
26382 END IF;
26383
26384 --
26385 --
26386 END IF;
26387 --
26388 -- Bug 4922099
26389 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
26390 (NVL(l_enc_upg_option, 'N') = 'O')
26391 ) AND
26392 (l_bflow_method_code = 'PRIOR_ENTRY')
26393 )
26394 THEN
26395 IF
26396 --
26397 1 = 2
26398 --
26399 THEN
26400 xla_accounting_err_pkg.build_message
26401 (p_appli_s_name => 'XLA'
26402 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26403 ,p_token_1 => 'LINE_NUMBER'
26404 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
26405 ,p_token_2 => 'LINE_TYPE_NAME'
26406 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
26407 l_component_type
26408 ,l_component_code
26409 ,l_component_type_code
26410 ,l_component_appl_id
26411 ,l_amb_context_code
26412 ,l_entity_code
26413 ,l_event_class_code
26414 )
26415 ,p_token_3 => 'OWNER'
26416 ,p_value_3 => xla_lookups_pkg.get_meaning(
26417 p_lookup_type => 'XLA_OWNER_TYPE'
26418 ,p_lookup_code => l_component_type_code
26419 )
26420 ,p_token_4 => 'PRODUCT_NAME'
26421 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
26422 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
26423 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
26424 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
26425 ,p_ae_header_id => NULL
26426 );
26427
26428 IF (C_LEVEL_ERROR>= g_log_level) THEN
26429 trace
26430 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
26431 ,p_level => C_LEVEL_ERROR
26432 ,p_module => l_log_module);
26433 END IF;
26434 END IF;
26435 END IF;
26436 --
26437 --
26438 ------------------------------------------------------------------------------------------------
26439 -- 4219869 Business Flow
26440 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
26441 -- Prior Entry. Currently, the following code is always generated.
26442 ------------------------------------------------------------------------------------------------
26443 XLA_AE_LINES_PKG.ValidateCurrentLine;
26444
26445 ------------------------------------------------------------------------------------
26446 -- 4219869 Business Flow
26447 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
26448 ------------------------------------------------------------------------------------
26449 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26450
26451 ----------------------------------------------------------------------------------
26452 -- 4219869 Business Flow
26453 -- Update journal entry status -- Need to generate this within IF <condition>
26454 ----------------------------------------------------------------------------------
26455 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26456 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
26457 ,p_balance_type_code => l_balance_type_code
26458 );
26459
26460 -------------------------------------------------------------------------------------------
26461 -- 4262811 - Generate the Accrual Reversal lines
26462 -------------------------------------------------------------------------------------------
26463 BEGIN
26464 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
26465 (g_array_event(p_event_id).array_value_num('header_index'));
26466 IF l_acc_rev_flag IS NULL THEN
26467 l_acc_rev_flag := 'N';
26468 END IF;
26469 EXCEPTION
26470 WHEN OTHERS THEN
26471 l_acc_rev_flag := 'N';
26472 END;
26473 --
26474 IF (l_acc_rev_flag = 'Y') THEN
26475
26476 -- 4645092 ------------------------------------------------------------------------------
26477 -- To allow MPA report to determine if it should generate report process
26478 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
26479 ------------------------------------------------------------------------------------------
26480
26481 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
26482 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
26483 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
26484 -- call ADRs
26485 -- Bug 4922099
26486 --
26487 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26488 (NVL(l_actual_upg_option, 'N') = 'O') OR
26489 (NVL(l_enc_upg_option, 'N') = 'O')
26490 )
26491 THEN
26492 NULL;
26493 --
26494 --
26495
26496 l_ccid := AcctDerRule_4(
26497 p_application_id => p_application_id
26498 , p_ae_header_id => l_ae_header_id
26499 , p_source_5 => p_source_5
26500 , x_transaction_coa_id => l_adr_transaction_coa_id
26501 , x_accounting_coa_id => l_adr_accounting_coa_id
26502 , x_value_type_code => l_adr_value_type_code
26503 , p_side => 'NA'
26504 );
26505
26506 xla_ae_lines_pkg.set_ccid(
26507 p_code_combination_id => l_ccid
26508 , p_value_type_code => l_adr_value_type_code
26509 , p_transaction_coa_id => l_adr_transaction_coa_id
26510 , p_accounting_coa_id => l_adr_accounting_coa_id
26511 , p_adr_code => 'DIST_CCID'
26512 , p_adr_type_code => 'S'
26513 , p_component_type => l_component_type
26514 , p_component_code => l_component_code
26515 , p_component_type_code => l_component_type_code
26516 , p_component_appl_id => l_component_appl_id
26517 , p_amb_context_code => l_amb_context_code
26518 , p_side => 'NA'
26519 );
26520
26521
26522 l_segment := AcctDerRule_20(
26523 p_application_id => p_application_id
26524 , p_ae_header_id => l_ae_header_id
26525 , p_source_12 => p_source_12
26526 , p_source_13 => p_source_13
26527 , p_source_14 => p_source_14
26528 , x_transaction_coa_id => l_adr_transaction_coa_id
26529 , x_accounting_coa_id => l_adr_accounting_coa_id
26530 , x_flexfield_segment_code => l_adr_flexfield_segment_code
26531 , x_flex_value_set_id => l_adr_flex_value_set_id
26532 , x_value_type_code => l_adr_value_type_code
26533 , x_value_combination_id => l_adr_value_combination_id
26534 , x_value_segment_code => l_adr_value_segment_code
26535 , p_side => 'NA'
26536 , p_override_seg_flag => 'Y'
26537 );
26538
26539 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
26540
26541 xla_ae_lines_pkg.set_segment(
26542 p_to_segment_code => 'GL_ACCOUNT'
26543 , p_segment_value => l_segment
26544 , p_from_segment_code => l_adr_value_segment_code
26545 , p_from_combination_id => l_adr_value_combination_id
26546 , p_value_type_code => l_adr_value_type_code
26547 , p_transaction_coa_id => l_adr_transaction_coa_id
26548 , p_accounting_coa_id => l_adr_accounting_coa_id
26549 , p_flexfield_segment_code => l_adr_flexfield_segment_code
26550 , p_flex_value_set_id => l_adr_flex_value_set_id
26551 , p_adr_code => 'FV_AR_497201_MISC_RCT_DR'
26552 , p_adr_type_code => 'S'
26553 , p_component_type => l_component_type
26554 , p_component_code => l_component_code
26555 , p_component_type_code => l_component_type_code
26556 , p_component_appl_id => l_component_appl_id
26557 , p_amb_context_code => l_amb_context_code
26558 , p_entity_code => 'RECEIPTS'
26559 , p_event_class_code => 'MISC_RECEIPT'
26560 , p_side => 'NA'
26561 );
26562
26563 END IF;
26564
26565 --
26566 --
26567 END IF;
26568
26569 --
26570 -- Update the line information that should be overwritten
26571 --
26572 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
26573 p_header_num => 1);
26574 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
26575
26576 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
26577
26578 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
26579 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
26580 END IF;
26581
26582 --
26583 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
26584 --
26585 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
26586 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
26587 ELSE
26588 ---------------------------------------------------------------------------------------------------
26589 -- 4262811a Switch Sign
26590 ---------------------------------------------------------------------------------------------------
26591 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
26592 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26593 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26594 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
26595 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26596 -- 5132302
26597 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
26598 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
26599
26600 END IF;
26601
26602 -- 4955764
26603 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26604 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
26605
26606
26607 XLA_AE_LINES_PKG.ValidateCurrentLine;
26608 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
26609
26610 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
26611 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
26612 ,p_balance_type_code => l_balance_type_code);
26613
26614 END IF;
26615
26616 -----------------------------------------------------------------------------------------
26617 -- 4262811 Multiperiod Accounting
26618 -----------------------------------------------------------------------------------------
26619 -- No MPA option is assigned.
26620
26621
26622 END IF;
26623 END IF;
26624 --
26625
26626 --
26627 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26628 trace
26629 (p_msg => 'END of AcctLineType_67'
26630 ,p_level => C_LEVEL_PROCEDURE
26631 ,p_module => l_log_module);
26632 END IF;
26633 --
26634 EXCEPTION
26635 WHEN xla_exceptions_pkg.application_exception THEN
26636 RAISE;
26637 WHEN OTHERS THEN
26638 xla_exceptions_pkg.raise_message
26639 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_67');
26640 END AcctLineType_67;
26641 --
26642
26643 ---------------------------------------
26644 --
26645 -- PRIVATE FUNCTION
26646 -- AcctLineType_68
26647 --
26648 ---------------------------------------
26649 PROCEDURE AcctLineType_68 (
26650 p_application_id IN NUMBER
26651 ,p_event_id IN NUMBER
26652 ,p_calculate_acctd_flag IN VARCHAR2
26653 ,p_calculate_g_l_flag IN VARCHAR2
26654 ,p_actual_flag IN OUT VARCHAR2
26655 ,p_balance_type_code OUT VARCHAR2
26656 ,p_gain_or_loss_ref OUT VARCHAR2
26657
26658 --Distribution GL Account
26659 , p_source_5 IN NUMBER
26660 --Federal Fund Expired Status
26661 , p_source_12 IN VARCHAR2
26662 --Federal Prior Year Flag
26663 , p_source_13 IN VARCHAR2
26664 --Federal Fund Time Frame
26665 , p_source_14 IN VARCHAR2
26666 --Federal Apportionment Category
26667 , p_source_15 IN VARCHAR2
26668 --Distribution Source Type
26669 , p_source_20 IN VARCHAR2
26670 --Distribution Line Identifier
26671 , p_source_22 IN NUMBER
26672 --Distribution Type
26673 , p_source_23 IN VARCHAR2
26674 --Entered Amount
26675 , p_source_24 IN NUMBER
26676 --Currency Code
26677 , p_source_25 IN VARCHAR2
26678 --Exchange Rate
26679 , p_source_27 IN NUMBER
26680 --Exchange Rate Type
26681 , p_source_28 IN VARCHAR2
26682 --Applied To Document Accounting Amount
26683 , p_source_29 IN NUMBER
26684 --Federal Account Valid Flag
26685 , p_source_56 IN VARCHAR2
26686 --Applied To Document Exchange Date
26687 , p_source_57 IN DATE
26688 )
26689 IS
26690
26691 l_component_type VARCHAR2(80);
26692 l_component_code VARCHAR2(30);
26693 l_component_type_code VARCHAR2(1);
26694 l_component_appl_id INTEGER;
26695 l_amb_context_code VARCHAR2(30);
26696 l_entity_code VARCHAR2(30);
26697 l_event_class_code VARCHAR2(30);
26698 l_ae_header_id NUMBER;
26699 l_event_type_code VARCHAR2(30);
26700 l_line_definition_code VARCHAR2(30);
26701 l_line_definition_owner_code VARCHAR2(1);
26702 --
26703 -- adr variables
26704 l_segment VARCHAR2(30);
26705 l_ccid NUMBER;
26706 l_adr_transaction_coa_id NUMBER;
26707 l_adr_accounting_coa_id NUMBER;
26708 l_adr_flexfield_segment_code VARCHAR2(30);
26709 l_adr_flex_value_set_id NUMBER;
26710 l_adr_value_type_code VARCHAR2(30);
26711 l_adr_value_combination_id NUMBER;
26712 l_adr_value_segment_code VARCHAR2(30);
26713
26714 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
26715 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
26716 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
26717 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
26718
26719 -- 4262811 Variables ------------------------------------------------------------------------------------------
26720 l_entered_amt_idx NUMBER;
26721 l_accted_amt_idx NUMBER;
26722 l_acc_rev_flag VARCHAR2(1);
26723 l_accrual_line_num NUMBER;
26724 l_tmp_amt NUMBER;
26725 l_acc_rev_natural_side_code VARCHAR2(1);
26726
26727 l_num_entries NUMBER;
26728 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
26729 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
26730 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
26731 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
26732 l_recog_line_1 NUMBER;
26733 l_recog_line_2 NUMBER;
26734
26735 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
26736 l_bflow_applied_to_amt NUMBER; -- 5132302
26737 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
26738
26739 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
26740
26741 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
26742 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
26743
26744 ---------------------------------------------------------------------------------------------------------------
26745
26746
26747 --
26748 -- bulk performance
26749 --
26750 l_balance_type_code VARCHAR2(1);
26751 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
26752 l_log_module VARCHAR2(240);
26753
26754 --
26755 -- Upgrade strategy
26756 --
26757 l_actual_upg_option VARCHAR2(1);
26758 l_enc_upg_option VARCHAR2(1);
26759
26760 --
26761 BEGIN
26762 --
26763 IF g_log_enabled THEN
26764 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_68';
26765 END IF;
26766 --
26767 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
26768
26769 trace
26770 (p_msg => 'BEGIN of AcctLineType_68'
26771 ,p_level => C_LEVEL_PROCEDURE
26772 ,p_module => l_log_module);
26773
26774 END IF;
26775 --
26776 l_component_type := 'AMB_JLT';
26777 l_component_code := 'FV_MISC_RCT_REF_OUFC_CR';
26778 l_component_type_code := 'S';
26779 l_component_appl_id := 222;
26780 l_amb_context_code := 'DEFAULT';
26781 l_entity_code := 'RECEIPTS';
26782 l_event_class_code := 'MISC_RECEIPT';
26783 l_event_type_code := 'MISC_RECEIPT_ALL';
26784 l_line_definition_owner_code := 'S';
26785 l_line_definition_code := 'FEDERAL_AR_MISC_RECEIPTS';
26786 --
26787 l_balance_type_code := 'A';
26788 l_segment := NULL;
26789 l_ccid := NULL;
26790 l_adr_transaction_coa_id := NULL;
26791 l_adr_accounting_coa_id := NULL;
26792 l_adr_flexfield_segment_code := NULL;
26793 l_adr_flex_value_set_id := NULL;
26794 l_adr_value_type_code := NULL;
26795 l_adr_value_combination_id := NULL;
26796 l_adr_value_segment_code := NULL;
26797
26798 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
26799 l_bflow_class_code := ''; -- 4219869 Business Flow
26800 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
26801 l_budgetary_control_flag := 'N';
26802
26803 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26804 l_bflow_applied_to_amt := NULL; -- 5132302
26805 l_entered_amt_idx := NULL; -- 4262811
26806 l_accted_amt_idx := NULL; -- 4262811
26807 l_acc_rev_flag := NULL; -- 4262811
26808 l_accrual_line_num := NULL; -- 4262811
26809 l_tmp_amt := NULL; -- 4262811
26810 --
26811
26812 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
26813 l_balance_type_code <> 'B' THEN
26814 IF NVL(p_source_20,'
26815 ') = 'MISCCASH' AND
26816 NVL(p_source_12,'
26817 ') = 'Unexpired' AND
26818 NVL(p_source_13,'
26819 ') = 'N' AND
26820 (NVL(p_source_15,'
26821 ') = 'A' OR
26822 NVL(p_source_15,'
26823 ') = 'B' OR
26824 NVL(p_source_15,'
26825 ') = 'C') AND
26826 (NVL(p_source_14,'
26827 ') = 'SINGLE' OR
26828 NVL(p_source_14,'
26829 ') = 'MULTIPLE' OR
26830 NVL(p_source_14,'
26831 ') = 'NO_YEAR') AND
26832 NVL(p_source_56,'
26833 ') = 'Y'
26834 THEN
26835
26836 --
26837 XLA_AE_LINES_PKG.SetNewLine;
26838
26839 p_balance_type_code := l_balance_type_code;
26840 -- set the flag so later we will know whether the gain loss line needs to be created
26841
26842 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
26843 p_actual_flag :='A';
26844 END IF;
26845
26846 --
26847 -- bulk performance
26848 --
26849 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
26850 p_header_num => 0); -- 4262811
26851 --
26852 -- set accounting line options
26853 --
26854 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
26855 p_natural_side_code => 'C'
26856 , p_gain_or_loss_flag => 'N'
26857 , p_gl_transfer_mode_code => 'S'
26858 , p_acct_entry_type_code => 'A'
26859 , p_switch_side_flag => 'Y'
26860 , p_merge_duplicate_code => 'A'
26861 );
26862 --
26863 l_acc_rev_natural_side_code := 'D'; -- 4262811
26864 --
26865 --
26866 -- set accounting line type info
26867 --
26868 xla_ae_lines_pkg.SetAcctLineType
26869 (p_component_type => l_component_type
26870 ,p_event_type_code => l_event_type_code
26871 ,p_line_definition_owner_code => l_line_definition_owner_code
26872 ,p_line_definition_code => l_line_definition_code
26873 ,p_accounting_line_code => l_component_code
26874 ,p_accounting_line_type_code => l_component_type_code
26875 ,p_accounting_line_appl_id => l_component_appl_id
26876 ,p_amb_context_code => l_amb_context_code
26877 ,p_entity_code => l_entity_code
26878 ,p_event_class_code => l_event_class_code);
26879 --
26880 -- set accounting class
26881 --
26882 xla_ae_lines_pkg.SetAcctClass(
26883 p_accounting_class_code => 'FV_MISCCASH_CR'
26884 , p_ae_header_id => l_ae_header_id
26885 );
26886
26887 --
26888 -- set rounding class
26889 --
26890 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
26891 'RECEIVABLE';
26892
26893 --
26894 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
26895 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
26896 --
26897 -- bulk performance
26898 --
26899 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
26900
26901 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
26902 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
26903
26904 -- 4955764
26905 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
26906 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
26907
26908 -- 4458381 Public Sector Enh
26909
26910 --
26911 -- set accounting attributes for the line type
26912 --
26913 l_entered_amt_idx := 3;
26914 l_accted_amt_idx := 8;
26915 l_bflow_applied_to_amt_idx := NULL; -- 5132302
26916 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
26917 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
26918 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
26919 l_rec_acct_attrs.array_char_value(2) := p_source_23;
26920 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
26921 l_rec_acct_attrs.array_num_value(3) := p_source_24;
26922 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
26923 l_rec_acct_attrs.array_char_value(4) := p_source_25;
26927 l_rec_acct_attrs.array_num_value(6) := p_source_27;
26924 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
26925 l_rec_acct_attrs.array_date_value(5) := p_source_57;
26926 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
26928 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
26929 l_rec_acct_attrs.array_char_value(7) := p_source_28;
26930 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
26931 l_rec_acct_attrs.array_num_value(8) := p_source_29;
26932
26933 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
26934 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
26935
26936 ---------------------------------------------------------------------------------------------------------------
26937 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
26938 ---------------------------------------------------------------------------------------------------------------
26939 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
26940
26941 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26942 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
26943
26944 IF xla_accounting_cache_pkg.GetValueChar
26945 (p_source_code => 'LEDGER_CATEGORY_CODE'
26946 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
26947 AND l_bflow_method_code = 'PRIOR_ENTRY'
26948 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
26949 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
26950 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
26951 )
26952 THEN
26953 xla_ae_lines_pkg.BflowUpgEntry
26954 (p_business_method_code => l_bflow_method_code
26955 ,p_business_class_code => l_bflow_class_code
26956 ,p_balance_type => l_balance_type_code);
26957 ELSE
26958 NULL;
26959 -- No business flow processing for business flow method of NONE.
26960 END IF;
26961
26962 --
26963 -- call analytical criteria
26964 --
26965
26966 --
26967 -- call description
26968 --
26969 -- No description or it is inherited.
26970 --
26971 -- call ADRs
26972 -- Bug 4922099
26973 --
26974 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
26975 (NVL(l_actual_upg_option, 'N') = 'O') OR
26976 (NVL(l_enc_upg_option, 'N') = 'O')
26977 )
26978 THEN
26979 NULL;
26980 --
26981 --
26982
26983 l_ccid := AcctDerRule_4(
26984 p_application_id => p_application_id
26985 , p_ae_header_id => l_ae_header_id
26986 , p_source_5 => p_source_5
26987 , x_transaction_coa_id => l_adr_transaction_coa_id
26988 , x_accounting_coa_id => l_adr_accounting_coa_id
26989 , x_value_type_code => l_adr_value_type_code
26990 , p_side => 'NA'
26991 );
26992
26993 xla_ae_lines_pkg.set_ccid(
26994 p_code_combination_id => l_ccid
26995 , p_value_type_code => l_adr_value_type_code
26996 , p_transaction_coa_id => l_adr_transaction_coa_id
26997 , p_accounting_coa_id => l_adr_accounting_coa_id
26998 , p_adr_code => 'DIST_CCID'
26999 , p_adr_type_code => 'S'
27000 , p_component_type => l_component_type
27001 , p_component_code => l_component_code
27002 , p_component_type_code => l_component_type_code
27003 , p_component_appl_id => l_component_appl_id
27004 , p_amb_context_code => l_amb_context_code
27005 , p_side => 'NA'
27006 );
27007
27008
27009 l_segment := AcctDerRule_17(
27010 p_application_id => p_application_id
27011 , p_ae_header_id => l_ae_header_id
27012 , p_source_12 => p_source_12
27013 , p_source_13 => p_source_13
27014 , p_source_14 => p_source_14
27015 , p_source_15 => p_source_15
27016 , x_transaction_coa_id => l_adr_transaction_coa_id
27017 , x_accounting_coa_id => l_adr_accounting_coa_id
27018 , x_flexfield_segment_code => l_adr_flexfield_segment_code
27019 , x_flex_value_set_id => l_adr_flex_value_set_id
27020 , x_value_type_code => l_adr_value_type_code
27021 , x_value_combination_id => l_adr_value_combination_id
27022 , x_value_segment_code => l_adr_value_segment_code
27023 , p_side => 'NA'
27024 , p_override_seg_flag => 'Y'
27025 );
27026
27027 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
27028
27029 xla_ae_lines_pkg.set_segment(
27030 p_to_segment_code => 'GL_ACCOUNT'
27031 , p_segment_value => l_segment
27032 , p_from_segment_code => l_adr_value_segment_code
27033 , p_from_combination_id => l_adr_value_combination_id
27034 , p_value_type_code => l_adr_value_type_code
27035 , p_transaction_coa_id => l_adr_transaction_coa_id
27036 , p_accounting_coa_id => l_adr_accounting_coa_id
27037 , p_flexfield_segment_code => l_adr_flexfield_segment_code
27038 , p_flex_value_set_id => l_adr_flex_value_set_id
27039 , p_adr_code => 'FV_AR_46X002_MISC_RCT_CR'
27040 , p_adr_type_code => 'S'
27044 , p_component_appl_id => l_component_appl_id
27041 , p_component_type => l_component_type
27042 , p_component_code => l_component_code
27043 , p_component_type_code => l_component_type_code
27045 , p_amb_context_code => l_amb_context_code
27046 , p_entity_code => 'RECEIPTS'
27047 , p_event_class_code => 'MISC_RECEIPT'
27048 , p_side => 'NA'
27049 );
27050
27051 END IF;
27052
27053 --
27054 --
27055 END IF;
27056 --
27057 -- Bug 4922099
27058 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
27059 (NVL(l_enc_upg_option, 'N') = 'O')
27060 ) AND
27061 (l_bflow_method_code = 'PRIOR_ENTRY')
27062 )
27063 THEN
27064 IF
27065 --
27066 1 = 2
27067 --
27068 THEN
27069 xla_accounting_err_pkg.build_message
27070 (p_appli_s_name => 'XLA'
27071 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27072 ,p_token_1 => 'LINE_NUMBER'
27073 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
27074 ,p_token_2 => 'LINE_TYPE_NAME'
27075 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
27076 l_component_type
27077 ,l_component_code
27078 ,l_component_type_code
27079 ,l_component_appl_id
27080 ,l_amb_context_code
27081 ,l_entity_code
27082 ,l_event_class_code
27083 )
27084 ,p_token_3 => 'OWNER'
27085 ,p_value_3 => xla_lookups_pkg.get_meaning(
27086 p_lookup_type => 'XLA_OWNER_TYPE'
27087 ,p_lookup_code => l_component_type_code
27088 )
27089 ,p_token_4 => 'PRODUCT_NAME'
27090 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
27091 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
27092 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
27093 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
27094 ,p_ae_header_id => NULL
27095 );
27096
27097 IF (C_LEVEL_ERROR>= g_log_level) THEN
27098 trace
27099 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27100 ,p_level => C_LEVEL_ERROR
27101 ,p_module => l_log_module);
27102 END IF;
27103 END IF;
27104 END IF;
27105 --
27106 --
27107 ------------------------------------------------------------------------------------------------
27108 -- 4219869 Business Flow
27109 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
27110 -- Prior Entry. Currently, the following code is always generated.
27111 ------------------------------------------------------------------------------------------------
27112 XLA_AE_LINES_PKG.ValidateCurrentLine;
27113
27114 ------------------------------------------------------------------------------------
27115 -- 4219869 Business Flow
27116 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
27117 ------------------------------------------------------------------------------------
27118 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27119
27120 ----------------------------------------------------------------------------------
27121 -- 4219869 Business Flow
27122 -- Update journal entry status -- Need to generate this within IF <condition>
27123 ----------------------------------------------------------------------------------
27124 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27125 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
27126 ,p_balance_type_code => l_balance_type_code
27127 );
27128
27129 -------------------------------------------------------------------------------------------
27130 -- 4262811 - Generate the Accrual Reversal lines
27131 -------------------------------------------------------------------------------------------
27132 BEGIN
27133 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
27134 (g_array_event(p_event_id).array_value_num('header_index'));
27135 IF l_acc_rev_flag IS NULL THEN
27136 l_acc_rev_flag := 'N';
27137 END IF;
27138 EXCEPTION
27139 WHEN OTHERS THEN
27140 l_acc_rev_flag := 'N';
27141 END;
27142 --
27143 IF (l_acc_rev_flag = 'Y') THEN
27144
27145 -- 4645092 ------------------------------------------------------------------------------
27146 -- To allow MPA report to determine if it should generate report process
27147 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
27148 ------------------------------------------------------------------------------------------
27149
27150 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
27151 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
27152 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
27153 -- call ADRs
27154 -- Bug 4922099
27155 --
27156 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27157 (NVL(l_actual_upg_option, 'N') = 'O') OR
27158 (NVL(l_enc_upg_option, 'N') = 'O')
27159 )
27160 THEN
27161 NULL;
27162 --
27163 --
27164
27165 l_ccid := AcctDerRule_4(
27166 p_application_id => p_application_id
27167 , p_ae_header_id => l_ae_header_id
27168 , p_source_5 => p_source_5
27169 , x_transaction_coa_id => l_adr_transaction_coa_id
27170 , x_accounting_coa_id => l_adr_accounting_coa_id
27171 , x_value_type_code => l_adr_value_type_code
27172 , p_side => 'NA'
27173 );
27174
27175 xla_ae_lines_pkg.set_ccid(
27176 p_code_combination_id => l_ccid
27177 , p_value_type_code => l_adr_value_type_code
27178 , p_transaction_coa_id => l_adr_transaction_coa_id
27179 , p_accounting_coa_id => l_adr_accounting_coa_id
27180 , p_adr_code => 'DIST_CCID'
27181 , p_adr_type_code => 'S'
27182 , p_component_type => l_component_type
27183 , p_component_code => l_component_code
27184 , p_component_type_code => l_component_type_code
27185 , p_component_appl_id => l_component_appl_id
27186 , p_amb_context_code => l_amb_context_code
27187 , p_side => 'NA'
27188 );
27189
27190
27191 l_segment := AcctDerRule_17(
27192 p_application_id => p_application_id
27193 , p_ae_header_id => l_ae_header_id
27194 , p_source_12 => p_source_12
27195 , p_source_13 => p_source_13
27196 , p_source_14 => p_source_14
27197 , p_source_15 => p_source_15
27198 , x_transaction_coa_id => l_adr_transaction_coa_id
27199 , x_accounting_coa_id => l_adr_accounting_coa_id
27200 , x_flexfield_segment_code => l_adr_flexfield_segment_code
27201 , x_flex_value_set_id => l_adr_flex_value_set_id
27202 , x_value_type_code => l_adr_value_type_code
27203 , x_value_combination_id => l_adr_value_combination_id
27204 , x_value_segment_code => l_adr_value_segment_code
27205 , p_side => 'NA'
27206 , p_override_seg_flag => 'Y'
27207 );
27208
27209 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
27210
27211 xla_ae_lines_pkg.set_segment(
27212 p_to_segment_code => 'GL_ACCOUNT'
27213 , p_segment_value => l_segment
27214 , p_from_segment_code => l_adr_value_segment_code
27215 , p_from_combination_id => l_adr_value_combination_id
27216 , p_value_type_code => l_adr_value_type_code
27217 , p_transaction_coa_id => l_adr_transaction_coa_id
27218 , p_accounting_coa_id => l_adr_accounting_coa_id
27219 , p_flexfield_segment_code => l_adr_flexfield_segment_code
27220 , p_flex_value_set_id => l_adr_flex_value_set_id
27221 , p_adr_code => 'FV_AR_46X002_MISC_RCT_CR'
27222 , p_adr_type_code => 'S'
27223 , p_component_type => l_component_type
27224 , p_component_code => l_component_code
27225 , p_component_type_code => l_component_type_code
27226 , p_component_appl_id => l_component_appl_id
27227 , p_amb_context_code => l_amb_context_code
27228 , p_entity_code => 'RECEIPTS'
27229 , p_event_class_code => 'MISC_RECEIPT'
27230 , p_side => 'NA'
27231 );
27232
27233 END IF;
27234
27235 --
27236 --
27237 END IF;
27238
27239 --
27240 -- Update the line information that should be overwritten
27241 --
27242 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
27243 p_header_num => 1);
27244 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
27245
27249 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
27246 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
27247
27248 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
27250 END IF;
27251
27252 --
27253 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
27254 --
27255 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
27256 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
27257 ELSE
27258 ---------------------------------------------------------------------------------------------------
27259 -- 4262811a Switch Sign
27260 ---------------------------------------------------------------------------------------------------
27261 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
27262 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27263 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27264 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27265 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27266 -- 5132302
27267 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
27268 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27269
27270 END IF;
27271
27272 -- 4955764
27273 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27274 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
27275
27276
27277 XLA_AE_LINES_PKG.ValidateCurrentLine;
27278 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27279
27280 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27281 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
27282 ,p_balance_type_code => l_balance_type_code);
27283
27284 END IF;
27285
27286 -----------------------------------------------------------------------------------------
27287 -- 4262811 Multiperiod Accounting
27288 -----------------------------------------------------------------------------------------
27289 -- No MPA option is assigned.
27290
27291
27292 END IF;
27293 END IF;
27294 --
27295
27296 --
27297 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27298 trace
27299 (p_msg => 'END of AcctLineType_68'
27300 ,p_level => C_LEVEL_PROCEDURE
27301 ,p_module => l_log_module);
27302 END IF;
27303 --
27304 EXCEPTION
27305 WHEN xla_exceptions_pkg.application_exception THEN
27306 RAISE;
27307 WHEN OTHERS THEN
27308 xla_exceptions_pkg.raise_message
27309 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_68');
27310 END AcctLineType_68;
27311 --
27312
27313 ---------------------------------------
27314 --
27315 -- PRIVATE FUNCTION
27316 -- AcctLineType_69
27317 --
27318 ---------------------------------------
27319 PROCEDURE AcctLineType_69 (
27320 p_application_id IN NUMBER
27321 ,p_event_id IN NUMBER
27322 ,p_calculate_acctd_flag IN VARCHAR2
27323 ,p_calculate_g_l_flag IN VARCHAR2
27324 ,p_actual_flag IN OUT VARCHAR2
27325 ,p_balance_type_code OUT VARCHAR2
27326 ,p_gain_or_loss_ref OUT VARCHAR2
27327
27328 --Distribution GL Account
27329 , p_source_5 IN NUMBER
27330 --Federal Fund Expired Status
27331 , p_source_12 IN VARCHAR2
27332 --Federal Prior Year Flag
27333 , p_source_13 IN VARCHAR2
27334 --Federal Fund Time Frame
27335 , p_source_14 IN VARCHAR2
27336 --Federal Apportionment Category
27337 , p_source_15 IN VARCHAR2
27338 --Distribution Source Type
27339 , p_source_20 IN VARCHAR2
27340 --Distribution Line Identifier
27341 , p_source_22 IN NUMBER
27342 --Distribution Type
27343 , p_source_23 IN VARCHAR2
27344 --Entered Amount
27345 , p_source_24 IN NUMBER
27346 --Currency Code
27347 , p_source_25 IN VARCHAR2
27348 --Exchange Rate
27349 , p_source_27 IN NUMBER
27350 --Exchange Rate Type
27351 , p_source_28 IN VARCHAR2
27352 --Applied To Document Accounting Amount
27353 , p_source_29 IN NUMBER
27354 --Federal Account Valid Flag
27355 , p_source_56 IN VARCHAR2
27356 --Applied To Document Exchange Date
27357 , p_source_57 IN DATE
27358 )
27359 IS
27360
27361 l_component_type VARCHAR2(80);
27362 l_component_code VARCHAR2(30);
27363 l_component_type_code VARCHAR2(1);
27364 l_component_appl_id INTEGER;
27365 l_amb_context_code VARCHAR2(30);
27366 l_entity_code VARCHAR2(30);
27367 l_event_class_code VARCHAR2(30);
27368 l_ae_header_id NUMBER;
27369 l_event_type_code VARCHAR2(30);
27370 l_line_definition_code VARCHAR2(30);
27371 l_line_definition_owner_code VARCHAR2(1);
27372 --
27373 -- adr variables
27374 l_segment VARCHAR2(30);
27375 l_ccid NUMBER;
27376 l_adr_transaction_coa_id NUMBER;
27377 l_adr_accounting_coa_id NUMBER;
27378 l_adr_flexfield_segment_code VARCHAR2(30);
27379 l_adr_flex_value_set_id NUMBER;
27380 l_adr_value_type_code VARCHAR2(30);
27381 l_adr_value_combination_id NUMBER;
27382 l_adr_value_segment_code VARCHAR2(30);
27383
27384 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
27385 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
27386 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
27387 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
27388
27389 -- 4262811 Variables ------------------------------------------------------------------------------------------
27390 l_entered_amt_idx NUMBER;
27391 l_accted_amt_idx NUMBER;
27392 l_acc_rev_flag VARCHAR2(1);
27393 l_accrual_line_num NUMBER;
27394 l_tmp_amt NUMBER;
27395 l_acc_rev_natural_side_code VARCHAR2(1);
27396
27397 l_num_entries NUMBER;
27398 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
27399 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
27400 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
27401 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
27402 l_recog_line_1 NUMBER;
27403 l_recog_line_2 NUMBER;
27404
27405 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
27406 l_bflow_applied_to_amt NUMBER; -- 5132302
27407 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
27408
27409 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
27410
27411 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
27412 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
27413
27414 ---------------------------------------------------------------------------------------------------------------
27415
27416
27417 --
27418 -- bulk performance
27419 --
27420 l_balance_type_code VARCHAR2(1);
27421 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
27422 l_log_module VARCHAR2(240);
27423
27424 --
27425 -- Upgrade strategy
27426 --
27427 l_actual_upg_option VARCHAR2(1);
27428 l_enc_upg_option VARCHAR2(1);
27429
27430 --
27431 BEGIN
27432 --
27433 IF g_log_enabled THEN
27434 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_69';
27435 END IF;
27436 --
27437 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27438
27439 trace
27440 (p_msg => 'BEGIN of AcctLineType_69'
27441 ,p_level => C_LEVEL_PROCEDURE
27442 ,p_module => l_log_module);
27443
27444 END IF;
27445 --
27446 l_component_type := 'AMB_JLT';
27447 l_component_code := 'FV_MISC_RCT_REF_OUFC_DR';
27448 l_component_type_code := 'S';
27449 l_component_appl_id := 222;
27450 l_amb_context_code := 'DEFAULT';
27451 l_entity_code := 'RECEIPTS';
27452 l_event_class_code := 'MISC_RECEIPT';
27453 l_event_type_code := 'MISC_RECEIPT_ALL';
27454 l_line_definition_owner_code := 'S';
27455 l_line_definition_code := 'FEDERAL_AR_MISC_RECEIPTS';
27456 --
27457 l_balance_type_code := 'A';
27458 l_segment := NULL;
27459 l_ccid := NULL;
27460 l_adr_transaction_coa_id := NULL;
27461 l_adr_accounting_coa_id := NULL;
27462 l_adr_flexfield_segment_code := NULL;
27463 l_adr_flex_value_set_id := NULL;
27464 l_adr_value_type_code := NULL;
27468 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
27465 l_adr_value_combination_id := NULL;
27466 l_adr_value_segment_code := NULL;
27467
27469 l_bflow_class_code := ''; -- 4219869 Business Flow
27470 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
27471 l_budgetary_control_flag := 'N';
27472
27473 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27474 l_bflow_applied_to_amt := NULL; -- 5132302
27475 l_entered_amt_idx := NULL; -- 4262811
27476 l_accted_amt_idx := NULL; -- 4262811
27477 l_acc_rev_flag := NULL; -- 4262811
27478 l_accrual_line_num := NULL; -- 4262811
27479 l_tmp_amt := NULL; -- 4262811
27480 --
27481
27482 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
27483 l_balance_type_code <> 'B' THEN
27484 IF NVL(p_source_20,'
27485 ') = 'MISCCASH' AND
27486 NVL(p_source_12,'
27487 ') = 'Unexpired' AND
27488 NVL(p_source_13,'
27489 ') = 'N' AND
27490 (NVL(p_source_15,'
27491 ') = 'A' OR
27492 NVL(p_source_15,'
27493 ') = 'B' OR
27494 NVL(p_source_15,'
27495 ') = 'C') AND
27496 (NVL(p_source_14,'
27497 ') = 'SINGLE' OR
27498 NVL(p_source_14,'
27499 ') = 'MULTIPLE' OR
27500 NVL(p_source_14,'
27501 ') = 'NO_YEAR') AND
27502 NVL(p_source_56,'
27503 ') = 'Y'
27504 THEN
27505
27506 --
27507 XLA_AE_LINES_PKG.SetNewLine;
27508
27509 p_balance_type_code := l_balance_type_code;
27510 -- set the flag so later we will know whether the gain loss line needs to be created
27511
27512 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
27513 p_actual_flag :='A';
27514 END IF;
27515
27516 --
27517 -- bulk performance
27518 --
27519 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
27520 p_header_num => 0); -- 4262811
27521 --
27522 -- set accounting line options
27523 --
27524 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
27525 p_natural_side_code => 'D'
27526 , p_gain_or_loss_flag => 'N'
27527 , p_gl_transfer_mode_code => 'S'
27528 , p_acct_entry_type_code => 'A'
27529 , p_switch_side_flag => 'Y'
27530 , p_merge_duplicate_code => 'A'
27531 );
27532 --
27533 l_acc_rev_natural_side_code := 'C'; -- 4262811
27534 --
27535 --
27536 -- set accounting line type info
27537 --
27538 xla_ae_lines_pkg.SetAcctLineType
27539 (p_component_type => l_component_type
27540 ,p_event_type_code => l_event_type_code
27541 ,p_line_definition_owner_code => l_line_definition_owner_code
27542 ,p_line_definition_code => l_line_definition_code
27543 ,p_accounting_line_code => l_component_code
27544 ,p_accounting_line_type_code => l_component_type_code
27545 ,p_accounting_line_appl_id => l_component_appl_id
27546 ,p_amb_context_code => l_amb_context_code
27547 ,p_entity_code => l_entity_code
27548 ,p_event_class_code => l_event_class_code);
27549 --
27550 -- set accounting class
27551 --
27552 xla_ae_lines_pkg.SetAcctClass(
27553 p_accounting_class_code => 'FV_MISCCASH_DR'
27554 , p_ae_header_id => l_ae_header_id
27555 );
27556
27557 --
27558 -- set rounding class
27559 --
27560 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
27561 'RECEIVABLE';
27562
27563 --
27564 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
27565 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
27566 --
27567 -- bulk performance
27568 --
27569 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
27570
27571 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
27572 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
27573
27574 -- 4955764
27575 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27576 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
27577
27578 -- 4458381 Public Sector Enh
27579
27580 --
27581 -- set accounting attributes for the line type
27582 --
27583 l_entered_amt_idx := 3;
27584 l_accted_amt_idx := 8;
27585 l_bflow_applied_to_amt_idx := NULL; -- 5132302
27586 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
27587 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
27588 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
27589 l_rec_acct_attrs.array_char_value(2) := p_source_23;
27590 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
27591 l_rec_acct_attrs.array_num_value(3) := p_source_24;
27592 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
27593 l_rec_acct_attrs.array_char_value(4) := p_source_25;
27594 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
27595 l_rec_acct_attrs.array_date_value(5) := p_source_57;
27596 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
27597 l_rec_acct_attrs.array_num_value(6) := p_source_27;
27601 l_rec_acct_attrs.array_num_value(8) := p_source_29;
27598 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
27599 l_rec_acct_attrs.array_char_value(7) := p_source_28;
27600 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
27602
27603 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
27604 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
27605
27606 ---------------------------------------------------------------------------------------------------------------
27607 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
27608 ---------------------------------------------------------------------------------------------------------------
27609 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
27610
27611 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27612 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
27613
27614 IF xla_accounting_cache_pkg.GetValueChar
27615 (p_source_code => 'LEDGER_CATEGORY_CODE'
27616 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
27617 AND l_bflow_method_code = 'PRIOR_ENTRY'
27618 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
27619 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
27620 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
27621 )
27622 THEN
27623 xla_ae_lines_pkg.BflowUpgEntry
27624 (p_business_method_code => l_bflow_method_code
27625 ,p_business_class_code => l_bflow_class_code
27626 ,p_balance_type => l_balance_type_code);
27627 ELSE
27628 NULL;
27629 -- No business flow processing for business flow method of NONE.
27630 END IF;
27631
27632 --
27633 -- call analytical criteria
27634 --
27635
27636 --
27637 -- call description
27638 --
27639 -- No description or it is inherited.
27640 --
27641 -- call ADRs
27642 -- Bug 4922099
27643 --
27644 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27645 (NVL(l_actual_upg_option, 'N') = 'O') OR
27646 (NVL(l_enc_upg_option, 'N') = 'O')
27647 )
27648 THEN
27649 NULL;
27650 --
27651 --
27652
27653 l_ccid := AcctDerRule_4(
27654 p_application_id => p_application_id
27655 , p_ae_header_id => l_ae_header_id
27656 , p_source_5 => p_source_5
27657 , x_transaction_coa_id => l_adr_transaction_coa_id
27658 , x_accounting_coa_id => l_adr_accounting_coa_id
27659 , x_value_type_code => l_adr_value_type_code
27660 , p_side => 'NA'
27661 );
27662
27663 xla_ae_lines_pkg.set_ccid(
27664 p_code_combination_id => l_ccid
27665 , p_value_type_code => l_adr_value_type_code
27666 , p_transaction_coa_id => l_adr_transaction_coa_id
27667 , p_accounting_coa_id => l_adr_accounting_coa_id
27668 , p_adr_code => 'DIST_CCID'
27669 , p_adr_type_code => 'S'
27670 , p_component_type => l_component_type
27671 , p_component_code => l_component_code
27672 , p_component_type_code => l_component_type_code
27673 , p_component_appl_id => l_component_appl_id
27674 , p_amb_context_code => l_amb_context_code
27675 , p_side => 'NA'
27676 );
27677
27678
27679 l_segment := AcctDerRule_19(
27680 p_application_id => p_application_id
27681 , p_ae_header_id => l_ae_header_id
27682 , p_source_12 => p_source_12
27683 , p_source_13 => p_source_13
27684 , p_source_14 => p_source_14
27685 , p_source_15 => p_source_15
27686 , x_transaction_coa_id => l_adr_transaction_coa_id
27687 , x_accounting_coa_id => l_adr_accounting_coa_id
27688 , x_flexfield_segment_code => l_adr_flexfield_segment_code
27689 , x_flex_value_set_id => l_adr_flex_value_set_id
27690 , x_value_type_code => l_adr_value_type_code
27691 , x_value_combination_id => l_adr_value_combination_id
27692 , x_value_segment_code => l_adr_value_segment_code
27693 , p_side => 'NA'
27694 , p_override_seg_flag => 'Y'
27695 );
27696
27697 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
27698
27699 xla_ae_lines_pkg.set_segment(
27700 p_to_segment_code => 'GL_ACCOUNT'
27701 , p_segment_value => l_segment
27702 , p_from_segment_code => l_adr_value_segment_code
27703 , p_from_combination_id => l_adr_value_combination_id
27704 , p_value_type_code => l_adr_value_type_code
27705 , p_transaction_coa_id => l_adr_transaction_coa_id
27706 , p_accounting_coa_id => l_adr_accounting_coa_id
27707 , p_flexfield_segment_code => l_adr_flexfield_segment_code
27708 , p_flex_value_set_id => l_adr_flex_value_set_id
27709 , p_adr_code => 'FV_AR_490201_MISC_RCT_DR'
27710 , p_adr_type_code => 'S'
27711 , p_component_type => l_component_type
27712 , p_component_code => l_component_code
27713 , p_component_type_code => l_component_type_code
27714 , p_component_appl_id => l_component_appl_id
27718 , p_side => 'NA'
27715 , p_amb_context_code => l_amb_context_code
27716 , p_entity_code => 'RECEIPTS'
27717 , p_event_class_code => 'MISC_RECEIPT'
27719 );
27720
27721 END IF;
27722
27723 --
27724 --
27725 END IF;
27726 --
27727 -- Bug 4922099
27728 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
27729 (NVL(l_enc_upg_option, 'N') = 'O')
27730 ) AND
27731 (l_bflow_method_code = 'PRIOR_ENTRY')
27732 )
27733 THEN
27734 IF
27735 --
27736 1 = 2
27737 --
27738 THEN
27739 xla_accounting_err_pkg.build_message
27740 (p_appli_s_name => 'XLA'
27741 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27742 ,p_token_1 => 'LINE_NUMBER'
27743 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
27744 ,p_token_2 => 'LINE_TYPE_NAME'
27745 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
27746 l_component_type
27747 ,l_component_code
27748 ,l_component_type_code
27749 ,l_component_appl_id
27750 ,l_amb_context_code
27751 ,l_entity_code
27752 ,l_event_class_code
27753 )
27754 ,p_token_3 => 'OWNER'
27755 ,p_value_3 => xla_lookups_pkg.get_meaning(
27756 p_lookup_type => 'XLA_OWNER_TYPE'
27757 ,p_lookup_code => l_component_type_code
27758 )
27759 ,p_token_4 => 'PRODUCT_NAME'
27760 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
27761 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
27762 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
27763 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
27764 ,p_ae_header_id => NULL
27765 );
27766
27767 IF (C_LEVEL_ERROR>= g_log_level) THEN
27768 trace
27769 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
27770 ,p_level => C_LEVEL_ERROR
27771 ,p_module => l_log_module);
27772 END IF;
27773 END IF;
27774 END IF;
27775 --
27776 --
27777 ------------------------------------------------------------------------------------------------
27778 -- 4219869 Business Flow
27779 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
27780 -- Prior Entry. Currently, the following code is always generated.
27781 ------------------------------------------------------------------------------------------------
27782 XLA_AE_LINES_PKG.ValidateCurrentLine;
27783
27784 ------------------------------------------------------------------------------------
27785 -- 4219869 Business Flow
27786 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
27787 ------------------------------------------------------------------------------------
27788 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27789
27790 ----------------------------------------------------------------------------------
27791 -- 4219869 Business Flow
27792 -- Update journal entry status -- Need to generate this within IF <condition>
27793 ----------------------------------------------------------------------------------
27794 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27795 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
27796 ,p_balance_type_code => l_balance_type_code
27797 );
27798
27799 -------------------------------------------------------------------------------------------
27800 -- 4262811 - Generate the Accrual Reversal lines
27801 -------------------------------------------------------------------------------------------
27802 BEGIN
27803 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
27804 (g_array_event(p_event_id).array_value_num('header_index'));
27805 IF l_acc_rev_flag IS NULL THEN
27806 l_acc_rev_flag := 'N';
27807 END IF;
27808 EXCEPTION
27809 WHEN OTHERS THEN
27810 l_acc_rev_flag := 'N';
27811 END;
27812 --
27813 IF (l_acc_rev_flag = 'Y') THEN
27814
27815 -- 4645092 ------------------------------------------------------------------------------
27816 -- To allow MPA report to determine if it should generate report process
27820 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
27817 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
27818 ------------------------------------------------------------------------------------------
27819
27821 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
27822 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
27823 -- call ADRs
27824 -- Bug 4922099
27825 --
27826 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
27827 (NVL(l_actual_upg_option, 'N') = 'O') OR
27828 (NVL(l_enc_upg_option, 'N') = 'O')
27829 )
27830 THEN
27831 NULL;
27832 --
27833 --
27834
27835 l_ccid := AcctDerRule_4(
27836 p_application_id => p_application_id
27837 , p_ae_header_id => l_ae_header_id
27838 , p_source_5 => p_source_5
27839 , x_transaction_coa_id => l_adr_transaction_coa_id
27840 , x_accounting_coa_id => l_adr_accounting_coa_id
27841 , x_value_type_code => l_adr_value_type_code
27842 , p_side => 'NA'
27843 );
27844
27845 xla_ae_lines_pkg.set_ccid(
27846 p_code_combination_id => l_ccid
27847 , p_value_type_code => l_adr_value_type_code
27848 , p_transaction_coa_id => l_adr_transaction_coa_id
27849 , p_accounting_coa_id => l_adr_accounting_coa_id
27850 , p_adr_code => 'DIST_CCID'
27851 , p_adr_type_code => 'S'
27852 , p_component_type => l_component_type
27853 , p_component_code => l_component_code
27854 , p_component_type_code => l_component_type_code
27855 , p_component_appl_id => l_component_appl_id
27856 , p_amb_context_code => l_amb_context_code
27857 , p_side => 'NA'
27858 );
27859
27860
27861 l_segment := AcctDerRule_19(
27862 p_application_id => p_application_id
27863 , p_ae_header_id => l_ae_header_id
27864 , p_source_12 => p_source_12
27865 , p_source_13 => p_source_13
27866 , p_source_14 => p_source_14
27867 , p_source_15 => p_source_15
27868 , x_transaction_coa_id => l_adr_transaction_coa_id
27869 , x_accounting_coa_id => l_adr_accounting_coa_id
27870 , x_flexfield_segment_code => l_adr_flexfield_segment_code
27871 , x_flex_value_set_id => l_adr_flex_value_set_id
27872 , x_value_type_code => l_adr_value_type_code
27873 , x_value_combination_id => l_adr_value_combination_id
27874 , x_value_segment_code => l_adr_value_segment_code
27875 , p_side => 'NA'
27876 , p_override_seg_flag => 'Y'
27877 );
27878
27879 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
27880
27881 xla_ae_lines_pkg.set_segment(
27882 p_to_segment_code => 'GL_ACCOUNT'
27883 , p_segment_value => l_segment
27884 , p_from_segment_code => l_adr_value_segment_code
27885 , p_from_combination_id => l_adr_value_combination_id
27886 , p_value_type_code => l_adr_value_type_code
27887 , p_transaction_coa_id => l_adr_transaction_coa_id
27888 , p_accounting_coa_id => l_adr_accounting_coa_id
27889 , p_flexfield_segment_code => l_adr_flexfield_segment_code
27890 , p_flex_value_set_id => l_adr_flex_value_set_id
27891 , p_adr_code => 'FV_AR_490201_MISC_RCT_DR'
27892 , p_adr_type_code => 'S'
27893 , p_component_type => l_component_type
27894 , p_component_code => l_component_code
27895 , p_component_type_code => l_component_type_code
27896 , p_component_appl_id => l_component_appl_id
27897 , p_amb_context_code => l_amb_context_code
27898 , p_entity_code => 'RECEIPTS'
27899 , p_event_class_code => 'MISC_RECEIPT'
27900 , p_side => 'NA'
27901 );
27902
27903 END IF;
27904
27905 --
27906 --
27907 END IF;
27908
27909 --
27910 -- Update the line information that should be overwritten
27911 --
27912 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
27913 p_header_num => 1);
27914 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
27915
27916 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
27917
27918 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
27919 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
27920 END IF;
27921
27922 --
27923 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
27924 --
27925 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
27926 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
27927 ELSE
27928 ---------------------------------------------------------------------------------------------------
27929 -- 4262811a Switch Sign
27930 ---------------------------------------------------------------------------------------------------
27931 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
27932 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27933 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27934 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
27935 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27936 -- 5132302
27937 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
27938 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
27939
27940 END IF;
27941
27942 -- 4955764
27943 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
27944 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
27945
27946
27947 XLA_AE_LINES_PKG.ValidateCurrentLine;
27948 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
27949
27950 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
27951 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
27952 ,p_balance_type_code => l_balance_type_code);
27953
27954 END IF;
27955
27956 -----------------------------------------------------------------------------------------
27957 -- 4262811 Multiperiod Accounting
27958 -----------------------------------------------------------------------------------------
27959 -- No MPA option is assigned.
27960
27961
27962 END IF;
27963 END IF;
27964 --
27965
27966 --
27967 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
27968 trace
27969 (p_msg => 'END of AcctLineType_69'
27970 ,p_level => C_LEVEL_PROCEDURE
27971 ,p_module => l_log_module);
27972 END IF;
27973 --
27974 EXCEPTION
27975 WHEN xla_exceptions_pkg.application_exception THEN
27976 RAISE;
27977 WHEN OTHERS THEN
27978 xla_exceptions_pkg.raise_message
27979 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_69');
27980 END AcctLineType_69;
27981 --
27982
27983 ---------------------------------------
27984 --
27985 -- PRIVATE FUNCTION
27986 -- AcctLineType_70
27987 --
27988 ---------------------------------------
27989 PROCEDURE AcctLineType_70 (
27990 p_application_id IN NUMBER
27991 ,p_event_id IN NUMBER
27992 ,p_calculate_acctd_flag IN VARCHAR2
27993 ,p_calculate_g_l_flag IN VARCHAR2
27994 ,p_actual_flag IN OUT VARCHAR2
27995 ,p_balance_type_code OUT VARCHAR2
27996 ,p_gain_or_loss_ref OUT VARCHAR2
27997
27998 --Distribution GL Account
27999 , p_source_5 IN NUMBER
28000 --Federal Fund Expired Status
28001 , p_source_12 IN VARCHAR2
28002 --Federal Prior Year Flag
28003 , p_source_13 IN VARCHAR2
28004 --Federal Fund Time Frame
28005 , p_source_14 IN VARCHAR2
28006 --Distribution Source Type
28007 , p_source_20 IN VARCHAR2
28008 --Distribution Line Identifier
28009 , p_source_22 IN NUMBER
28010 --Distribution Type
28011 , p_source_23 IN VARCHAR2
28012 --Entered Amount
28013 , p_source_24 IN NUMBER
28014 --Currency Code
28015 , p_source_25 IN VARCHAR2
28016 --Exchange Rate
28017 , p_source_27 IN NUMBER
28018 --Exchange Rate Type
28019 , p_source_28 IN VARCHAR2
28020 --Applied To Document Accounting Amount
28021 , p_source_29 IN NUMBER
28022 --Federal Account Valid Flag
28023 , p_source_56 IN VARCHAR2
28024 --Applied To Document Exchange Date
28025 , p_source_57 IN DATE
28026 )
28027 IS
28028
28029 l_component_type VARCHAR2(80);
28030 l_component_code VARCHAR2(30);
28031 l_component_type_code VARCHAR2(1);
28032 l_component_appl_id INTEGER;
28033 l_amb_context_code VARCHAR2(30);
28034 l_entity_code VARCHAR2(30);
28035 l_event_class_code VARCHAR2(30);
28036 l_ae_header_id NUMBER;
28037 l_event_type_code VARCHAR2(30);
28038 l_line_definition_code VARCHAR2(30);
28039 l_line_definition_owner_code VARCHAR2(1);
28040 --
28041 -- adr variables
28042 l_segment VARCHAR2(30);
28043 l_ccid NUMBER;
28044 l_adr_transaction_coa_id NUMBER;
28045 l_adr_accounting_coa_id NUMBER;
28046 l_adr_flexfield_segment_code VARCHAR2(30);
28047 l_adr_flex_value_set_id NUMBER;
28048 l_adr_value_type_code VARCHAR2(30);
28049 l_adr_value_combination_id NUMBER;
28050 l_adr_value_segment_code VARCHAR2(30);
28051
28052 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
28053 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
28054 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
28055 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
28056
28057 -- 4262811 Variables ------------------------------------------------------------------------------------------
28058 l_entered_amt_idx NUMBER;
28059 l_accted_amt_idx NUMBER;
28060 l_acc_rev_flag VARCHAR2(1);
28061 l_accrual_line_num NUMBER;
28062 l_tmp_amt NUMBER;
28063 l_acc_rev_natural_side_code VARCHAR2(1);
28064
28065 l_num_entries NUMBER;
28066 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
28067 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
28068 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
28069 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
28070 l_recog_line_1 NUMBER;
28071 l_recog_line_2 NUMBER;
28072
28073 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
28074 l_bflow_applied_to_amt NUMBER; -- 5132302
28075 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
28076
28077 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
28078
28079 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
28080 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
28081
28082 ---------------------------------------------------------------------------------------------------------------
28083
28084
28085 --
28086 -- bulk performance
28087 --
28088 l_balance_type_code VARCHAR2(1);
28089 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
28090 l_log_module VARCHAR2(240);
28091
28092 --
28093 -- Upgrade strategy
28094 --
28095 l_actual_upg_option VARCHAR2(1);
28096 l_enc_upg_option VARCHAR2(1);
28097
28098 --
28099 BEGIN
28100 --
28101 IF g_log_enabled THEN
28102 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_70';
28103 END IF;
28104 --
28105 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28106
28107 trace
28108 (p_msg => 'BEGIN of AcctLineType_70'
28109 ,p_level => C_LEVEL_PROCEDURE
28110 ,p_module => l_log_module);
28111
28112 END IF;
28113 --
28114 l_component_type := 'AMB_JLT';
28115 l_component_code := 'FV_MISC_RCT_REF_OUFP_CR';
28116 l_component_type_code := 'S';
28117 l_component_appl_id := 222;
28118 l_amb_context_code := 'DEFAULT';
28119 l_entity_code := 'RECEIPTS';
28120 l_event_class_code := 'MISC_RECEIPT';
28121 l_event_type_code := 'MISC_RECEIPT_ALL';
28122 l_line_definition_owner_code := 'S';
28123 l_line_definition_code := 'FEDERAL_AR_MISC_RECEIPTS';
28124 --
28125 l_balance_type_code := 'A';
28126 l_segment := NULL;
28127 l_ccid := NULL;
28128 l_adr_transaction_coa_id := NULL;
28129 l_adr_accounting_coa_id := NULL;
28130 l_adr_flexfield_segment_code := NULL;
28131 l_adr_flex_value_set_id := NULL;
28132 l_adr_value_type_code := NULL;
28133 l_adr_value_combination_id := NULL;
28134 l_adr_value_segment_code := NULL;
28135
28136 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
28137 l_bflow_class_code := ''; -- 4219869 Business Flow
28138 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
28139 l_budgetary_control_flag := 'N';
28140
28141 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28142 l_bflow_applied_to_amt := NULL; -- 5132302
28143 l_entered_amt_idx := NULL; -- 4262811
28144 l_accted_amt_idx := NULL; -- 4262811
28145 l_acc_rev_flag := NULL; -- 4262811
28146 l_accrual_line_num := NULL; -- 4262811
28147 l_tmp_amt := NULL; -- 4262811
28148 --
28149
28150 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
28151 l_balance_type_code <> 'B' THEN
28152 IF NVL(p_source_20,'
28153 ') = 'MISCCASH' AND
28154 NVL(p_source_12,'
28155 ') = 'Unexpired' AND
28156 NVL(p_source_13,'
28157 ') = 'Y' AND
28158 (NVL(p_source_14,'
28159 ') = 'MULTIPLE' OR
28160 NVL(p_source_14,'
28161 ') = 'NO_YEAR') AND
28162 NVL(p_source_56,'
28163 ') = 'Y'
28164 THEN
28165
28166 --
28167 XLA_AE_LINES_PKG.SetNewLine;
28168
28169 p_balance_type_code := l_balance_type_code;
28170 -- set the flag so later we will know whether the gain loss line needs to be created
28171
28172 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
28173 p_actual_flag :='A';
28174 END IF;
28175
28176 --
28177 -- bulk performance
28178 --
28179 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
28180 p_header_num => 0); -- 4262811
28181 --
28182 -- set accounting line options
28183 --
28184 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
28185 p_natural_side_code => 'C'
28186 , p_gain_or_loss_flag => 'N'
28187 , p_gl_transfer_mode_code => 'S'
28188 , p_acct_entry_type_code => 'A'
28189 , p_switch_side_flag => 'Y'
28190 , p_merge_duplicate_code => 'A'
28191 );
28192 --
28193 l_acc_rev_natural_side_code := 'D'; -- 4262811
28194 --
28195 --
28196 -- set accounting line type info
28197 --
28198 xla_ae_lines_pkg.SetAcctLineType
28199 (p_component_type => l_component_type
28200 ,p_event_type_code => l_event_type_code
28201 ,p_line_definition_owner_code => l_line_definition_owner_code
28202 ,p_line_definition_code => l_line_definition_code
28203 ,p_accounting_line_code => l_component_code
28204 ,p_accounting_line_type_code => l_component_type_code
28205 ,p_accounting_line_appl_id => l_component_appl_id
28206 ,p_amb_context_code => l_amb_context_code
28207 ,p_entity_code => l_entity_code
28208 ,p_event_class_code => l_event_class_code);
28209 --
28210 -- set accounting class
28211 --
28212 xla_ae_lines_pkg.SetAcctClass(
28213 p_accounting_class_code => 'FV_MISCCASH_CR'
28214 , p_ae_header_id => l_ae_header_id
28215 );
28216
28217 --
28218 -- set rounding class
28219 --
28220 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
28221 'RECEIVABLE';
28222
28223 --
28224 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
28225 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
28226 --
28227 -- bulk performance
28228 --
28229 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
28230
28231 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
28232 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
28233
28234 -- 4955764
28235 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28236 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
28237
28238 -- 4458381 Public Sector Enh
28239
28240 --
28241 -- set accounting attributes for the line type
28242 --
28243 l_entered_amt_idx := 3;
28244 l_accted_amt_idx := 8;
28245 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28246 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
28247 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
28248 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
28249 l_rec_acct_attrs.array_char_value(2) := p_source_23;
28250 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
28251 l_rec_acct_attrs.array_num_value(3) := p_source_24;
28252 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
28253 l_rec_acct_attrs.array_char_value(4) := p_source_25;
28254 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
28255 l_rec_acct_attrs.array_date_value(5) := p_source_57;
28256 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
28257 l_rec_acct_attrs.array_num_value(6) := p_source_27;
28258 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
28262
28259 l_rec_acct_attrs.array_char_value(7) := p_source_28;
28260 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
28261 l_rec_acct_attrs.array_num_value(8) := p_source_29;
28263 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
28264 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
28265
28266 ---------------------------------------------------------------------------------------------------------------
28267 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
28268 ---------------------------------------------------------------------------------------------------------------
28269 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
28270
28271 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28272 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28273
28274 IF xla_accounting_cache_pkg.GetValueChar
28275 (p_source_code => 'LEDGER_CATEGORY_CODE'
28276 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
28277 AND l_bflow_method_code = 'PRIOR_ENTRY'
28278 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
28279 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
28280 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
28281 )
28282 THEN
28283 xla_ae_lines_pkg.BflowUpgEntry
28284 (p_business_method_code => l_bflow_method_code
28285 ,p_business_class_code => l_bflow_class_code
28286 ,p_balance_type => l_balance_type_code);
28287 ELSE
28288 NULL;
28289 -- No business flow processing for business flow method of NONE.
28290 END IF;
28291
28292 --
28293 -- call analytical criteria
28294 --
28295
28296 --
28297 -- call description
28298 --
28299 -- No description or it is inherited.
28300 --
28301 -- call ADRs
28302 -- Bug 4922099
28303 --
28304 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28305 (NVL(l_actual_upg_option, 'N') = 'O') OR
28306 (NVL(l_enc_upg_option, 'N') = 'O')
28307 )
28308 THEN
28309 NULL;
28310 --
28311 --
28312
28313 l_ccid := AcctDerRule_4(
28314 p_application_id => p_application_id
28315 , p_ae_header_id => l_ae_header_id
28316 , p_source_5 => p_source_5
28317 , x_transaction_coa_id => l_adr_transaction_coa_id
28318 , x_accounting_coa_id => l_adr_accounting_coa_id
28319 , x_value_type_code => l_adr_value_type_code
28320 , p_side => 'NA'
28321 );
28322
28323 xla_ae_lines_pkg.set_ccid(
28324 p_code_combination_id => l_ccid
28325 , p_value_type_code => l_adr_value_type_code
28326 , p_transaction_coa_id => l_adr_transaction_coa_id
28327 , p_accounting_coa_id => l_adr_accounting_coa_id
28328 , p_adr_code => 'DIST_CCID'
28329 , p_adr_type_code => 'S'
28330 , p_component_type => l_component_type
28331 , p_component_code => l_component_code
28332 , p_component_type_code => l_component_type_code
28333 , p_component_appl_id => l_component_appl_id
28334 , p_amb_context_code => l_amb_context_code
28335 , p_side => 'NA'
28336 );
28337
28338
28339 l_segment := AcctDerRule_13(
28340 p_application_id => p_application_id
28341 , p_ae_header_id => l_ae_header_id
28342 , p_source_12 => p_source_12
28343 , p_source_13 => p_source_13
28344 , p_source_14 => p_source_14
28345 , x_transaction_coa_id => l_adr_transaction_coa_id
28346 , x_accounting_coa_id => l_adr_accounting_coa_id
28347 , x_flexfield_segment_code => l_adr_flexfield_segment_code
28348 , x_flex_value_set_id => l_adr_flex_value_set_id
28349 , x_value_type_code => l_adr_value_type_code
28350 , x_value_combination_id => l_adr_value_combination_id
28351 , x_value_segment_code => l_adr_value_segment_code
28352 , p_side => 'NA'
28353 , p_override_seg_flag => 'Y'
28354 );
28355
28356 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
28357
28358 xla_ae_lines_pkg.set_segment(
28359 p_to_segment_code => 'GL_ACCOUNT'
28360 , p_segment_value => l_segment
28361 , p_from_segment_code => l_adr_value_segment_code
28362 , p_from_combination_id => l_adr_value_combination_id
28363 , p_value_type_code => l_adr_value_type_code
28364 , p_transaction_coa_id => l_adr_transaction_coa_id
28365 , p_accounting_coa_id => l_adr_accounting_coa_id
28366 , p_flexfield_segment_code => l_adr_flexfield_segment_code
28367 , p_flex_value_set_id => l_adr_flex_value_set_id
28368 , p_adr_code => 'FV_AR_445001_MISC_RCT_CR'
28369 , p_adr_type_code => 'S'
28370 , p_component_type => l_component_type
28371 , p_component_code => l_component_code
28372 , p_component_type_code => l_component_type_code
28373 , p_component_appl_id => l_component_appl_id
28374 , p_amb_context_code => l_amb_context_code
28375 , p_entity_code => 'RECEIPTS'
28376 , p_event_class_code => 'MISC_RECEIPT'
28377 , p_side => 'NA'
28378 );
28379
28380 END IF;
28381
28382 --
28383 --
28384 END IF;
28385 --
28386 -- Bug 4922099
28387 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
28388 (NVL(l_enc_upg_option, 'N') = 'O')
28389 ) AND
28390 (l_bflow_method_code = 'PRIOR_ENTRY')
28391 )
28392 THEN
28393 IF
28394 --
28395 1 = 2
28396 --
28397 THEN
28398 xla_accounting_err_pkg.build_message
28399 (p_appli_s_name => 'XLA'
28400 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28401 ,p_token_1 => 'LINE_NUMBER'
28402 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
28403 ,p_token_2 => 'LINE_TYPE_NAME'
28404 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
28405 l_component_type
28406 ,l_component_code
28407 ,l_component_type_code
28408 ,l_component_appl_id
28409 ,l_amb_context_code
28410 ,l_entity_code
28411 ,l_event_class_code
28412 )
28413 ,p_token_3 => 'OWNER'
28414 ,p_value_3 => xla_lookups_pkg.get_meaning(
28415 p_lookup_type => 'XLA_OWNER_TYPE'
28416 ,p_lookup_code => l_component_type_code
28417 )
28418 ,p_token_4 => 'PRODUCT_NAME'
28419 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
28420 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
28421 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
28422 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
28423 ,p_ae_header_id => NULL
28424 );
28425
28426 IF (C_LEVEL_ERROR>= g_log_level) THEN
28427 trace
28428 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
28429 ,p_level => C_LEVEL_ERROR
28430 ,p_module => l_log_module);
28431 END IF;
28432 END IF;
28433 END IF;
28434 --
28435 --
28436 ------------------------------------------------------------------------------------------------
28437 -- 4219869 Business Flow
28438 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
28439 -- Prior Entry. Currently, the following code is always generated.
28440 ------------------------------------------------------------------------------------------------
28441 XLA_AE_LINES_PKG.ValidateCurrentLine;
28442
28443 ------------------------------------------------------------------------------------
28444 -- 4219869 Business Flow
28445 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
28446 ------------------------------------------------------------------------------------
28447 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28448
28449 ----------------------------------------------------------------------------------
28450 -- 4219869 Business Flow
28451 -- Update journal entry status -- Need to generate this within IF <condition>
28452 ----------------------------------------------------------------------------------
28453 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28454 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
28455 ,p_balance_type_code => l_balance_type_code
28456 );
28457
28458 -------------------------------------------------------------------------------------------
28459 -- 4262811 - Generate the Accrual Reversal lines
28460 -------------------------------------------------------------------------------------------
28461 BEGIN
28462 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
28463 (g_array_event(p_event_id).array_value_num('header_index'));
28464 IF l_acc_rev_flag IS NULL THEN
28465 l_acc_rev_flag := 'N';
28466 END IF;
28467 EXCEPTION
28468 WHEN OTHERS THEN
28469 l_acc_rev_flag := 'N';
28470 END;
28471 --
28472 IF (l_acc_rev_flag = 'Y') THEN
28473
28474 -- 4645092 ------------------------------------------------------------------------------
28475 -- To allow MPA report to determine if it should generate report process
28476 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
28477 ------------------------------------------------------------------------------------------
28478
28479 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
28480 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
28481 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
28482 -- call ADRs
28483 -- Bug 4922099
28484 --
28485 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28486 (NVL(l_actual_upg_option, 'N') = 'O') OR
28487 (NVL(l_enc_upg_option, 'N') = 'O')
28488 )
28489 THEN
28490 NULL;
28491 --
28492 --
28493
28494 l_ccid := AcctDerRule_4(
28495 p_application_id => p_application_id
28496 , p_ae_header_id => l_ae_header_id
28497 , p_source_5 => p_source_5
28498 , x_transaction_coa_id => l_adr_transaction_coa_id
28499 , x_accounting_coa_id => l_adr_accounting_coa_id
28500 , x_value_type_code => l_adr_value_type_code
28501 , p_side => 'NA'
28502 );
28503
28504 xla_ae_lines_pkg.set_ccid(
28505 p_code_combination_id => l_ccid
28506 , p_value_type_code => l_adr_value_type_code
28507 , p_transaction_coa_id => l_adr_transaction_coa_id
28508 , p_accounting_coa_id => l_adr_accounting_coa_id
28509 , p_adr_code => 'DIST_CCID'
28510 , p_adr_type_code => 'S'
28511 , p_component_type => l_component_type
28512 , p_component_code => l_component_code
28513 , p_component_type_code => l_component_type_code
28514 , p_component_appl_id => l_component_appl_id
28515 , p_amb_context_code => l_amb_context_code
28516 , p_side => 'NA'
28517 );
28518
28519
28520 l_segment := AcctDerRule_13(
28521 p_application_id => p_application_id
28522 , p_ae_header_id => l_ae_header_id
28523 , p_source_12 => p_source_12
28524 , p_source_13 => p_source_13
28525 , p_source_14 => p_source_14
28526 , x_transaction_coa_id => l_adr_transaction_coa_id
28527 , x_accounting_coa_id => l_adr_accounting_coa_id
28528 , x_flexfield_segment_code => l_adr_flexfield_segment_code
28529 , x_flex_value_set_id => l_adr_flex_value_set_id
28530 , x_value_type_code => l_adr_value_type_code
28531 , x_value_combination_id => l_adr_value_combination_id
28532 , x_value_segment_code => l_adr_value_segment_code
28533 , p_side => 'NA'
28534 , p_override_seg_flag => 'Y'
28535 );
28536
28537 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
28538
28539 xla_ae_lines_pkg.set_segment(
28540 p_to_segment_code => 'GL_ACCOUNT'
28541 , p_segment_value => l_segment
28542 , p_from_segment_code => l_adr_value_segment_code
28543 , p_from_combination_id => l_adr_value_combination_id
28544 , p_value_type_code => l_adr_value_type_code
28545 , p_transaction_coa_id => l_adr_transaction_coa_id
28546 , p_accounting_coa_id => l_adr_accounting_coa_id
28547 , p_flexfield_segment_code => l_adr_flexfield_segment_code
28548 , p_flex_value_set_id => l_adr_flex_value_set_id
28549 , p_adr_code => 'FV_AR_445001_MISC_RCT_CR'
28550 , p_adr_type_code => 'S'
28551 , p_component_type => l_component_type
28552 , p_component_code => l_component_code
28553 , p_component_type_code => l_component_type_code
28554 , p_component_appl_id => l_component_appl_id
28555 , p_amb_context_code => l_amb_context_code
28556 , p_entity_code => 'RECEIPTS'
28557 , p_event_class_code => 'MISC_RECEIPT'
28558 , p_side => 'NA'
28559 );
28560
28561 END IF;
28562
28563 --
28564 --
28565 END IF;
28566
28567 --
28568 -- Update the line information that should be overwritten
28569 --
28570 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
28571 p_header_num => 1);
28572 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
28573
28574 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
28575
28576 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
28577 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
28578 END IF;
28579
28580 --
28581 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
28582 --
28583 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
28584 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
28585 ELSE
28586 ---------------------------------------------------------------------------------------------------
28587 -- 4262811a Switch Sign
28588 ---------------------------------------------------------------------------------------------------
28589 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
28590 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28591 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28592 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
28593 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28594 -- 5132302
28595 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
28596 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
28597
28598 END IF;
28599
28600 -- 4955764
28601 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28602 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
28603
28604
28605 XLA_AE_LINES_PKG.ValidateCurrentLine;
28606 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
28607
28608 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
28609 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
28610 ,p_balance_type_code => l_balance_type_code);
28611
28612 END IF;
28613
28614 -----------------------------------------------------------------------------------------
28615 -- 4262811 Multiperiod Accounting
28616 -----------------------------------------------------------------------------------------
28617 -- No MPA option is assigned.
28618
28619
28620 END IF;
28621 END IF;
28622 --
28623
28624 --
28625 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28626 trace
28627 (p_msg => 'END of AcctLineType_70'
28628 ,p_level => C_LEVEL_PROCEDURE
28629 ,p_module => l_log_module);
28630 END IF;
28631 --
28632 EXCEPTION
28633 WHEN xla_exceptions_pkg.application_exception THEN
28634 RAISE;
28635 WHEN OTHERS THEN
28636 xla_exceptions_pkg.raise_message
28637 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_70');
28638 END AcctLineType_70;
28639 --
28640
28641 ---------------------------------------
28642 --
28643 -- PRIVATE FUNCTION
28644 -- AcctLineType_71
28645 --
28646 ---------------------------------------
28647 PROCEDURE AcctLineType_71 (
28648 p_application_id IN NUMBER
28649 ,p_event_id IN NUMBER
28650 ,p_calculate_acctd_flag IN VARCHAR2
28651 ,p_calculate_g_l_flag IN VARCHAR2
28652 ,p_actual_flag IN OUT VARCHAR2
28653 ,p_balance_type_code OUT VARCHAR2
28654 ,p_gain_or_loss_ref OUT VARCHAR2
28655
28656 --Distribution GL Account
28657 , p_source_5 IN NUMBER
28658 --Federal Fund Expired Status
28659 , p_source_12 IN VARCHAR2
28660 --Federal Prior Year Flag
28661 , p_source_13 IN VARCHAR2
28662 --Federal Fund Time Frame
28663 , p_source_14 IN VARCHAR2
28664 --Distribution Source Type
28665 , p_source_20 IN VARCHAR2
28666 --Distribution Line Identifier
28667 , p_source_22 IN NUMBER
28668 --Distribution Type
28669 , p_source_23 IN VARCHAR2
28670 --Entered Amount
28671 , p_source_24 IN NUMBER
28672 --Currency Code
28673 , p_source_25 IN VARCHAR2
28674 --Exchange Rate
28675 , p_source_27 IN NUMBER
28676 --Exchange Rate Type
28677 , p_source_28 IN VARCHAR2
28678 --Applied To Document Accounting Amount
28679 , p_source_29 IN NUMBER
28680 --Federal Account Valid Flag
28681 , p_source_56 IN VARCHAR2
28682 --Applied To Document Exchange Date
28683 , p_source_57 IN DATE
28684 )
28685 IS
28686
28687 l_component_type VARCHAR2(80);
28688 l_component_code VARCHAR2(30);
28689 l_component_type_code VARCHAR2(1);
28690 l_component_appl_id INTEGER;
28691 l_amb_context_code VARCHAR2(30);
28692 l_entity_code VARCHAR2(30);
28693 l_event_class_code VARCHAR2(30);
28694 l_ae_header_id NUMBER;
28695 l_event_type_code VARCHAR2(30);
28696 l_line_definition_code VARCHAR2(30);
28697 l_line_definition_owner_code VARCHAR2(1);
28698 --
28699 -- adr variables
28700 l_segment VARCHAR2(30);
28701 l_ccid NUMBER;
28702 l_adr_transaction_coa_id NUMBER;
28703 l_adr_accounting_coa_id NUMBER;
28704 l_adr_flexfield_segment_code VARCHAR2(30);
28705 l_adr_flex_value_set_id NUMBER;
28706 l_adr_value_type_code VARCHAR2(30);
28707 l_adr_value_combination_id NUMBER;
28708 l_adr_value_segment_code VARCHAR2(30);
28709
28710 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
28711 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
28712 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
28713 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
28714
28715 -- 4262811 Variables ------------------------------------------------------------------------------------------
28716 l_entered_amt_idx NUMBER;
28717 l_accted_amt_idx NUMBER;
28718 l_acc_rev_flag VARCHAR2(1);
28719 l_accrual_line_num NUMBER;
28720 l_tmp_amt NUMBER;
28721 l_acc_rev_natural_side_code VARCHAR2(1);
28722
28723 l_num_entries NUMBER;
28724 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
28725 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
28726 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
28727 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
28728 l_recog_line_1 NUMBER;
28729 l_recog_line_2 NUMBER;
28730
28731 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
28732 l_bflow_applied_to_amt NUMBER; -- 5132302
28733 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
28734
28735 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
28736
28737 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
28738 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
28739
28740 ---------------------------------------------------------------------------------------------------------------
28741
28742
28743 --
28744 -- bulk performance
28745 --
28746 l_balance_type_code VARCHAR2(1);
28747 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
28748 l_log_module VARCHAR2(240);
28749
28750 --
28751 -- Upgrade strategy
28752 --
28753 l_actual_upg_option VARCHAR2(1);
28754 l_enc_upg_option VARCHAR2(1);
28755
28756 --
28757 BEGIN
28758 --
28759 IF g_log_enabled THEN
28760 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_71';
28761 END IF;
28762 --
28763 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
28764
28765 trace
28766 (p_msg => 'BEGIN of AcctLineType_71'
28767 ,p_level => C_LEVEL_PROCEDURE
28768 ,p_module => l_log_module);
28769
28770 END IF;
28771 --
28772 l_component_type := 'AMB_JLT';
28773 l_component_code := 'FV_MISC_RCT_REF_OUFP_DR';
28774 l_component_type_code := 'S';
28775 l_component_appl_id := 222;
28776 l_amb_context_code := 'DEFAULT';
28777 l_entity_code := 'RECEIPTS';
28778 l_event_class_code := 'MISC_RECEIPT';
28779 l_event_type_code := 'MISC_RECEIPT_ALL';
28780 l_line_definition_owner_code := 'S';
28781 l_line_definition_code := 'FEDERAL_AR_MISC_RECEIPTS';
28782 --
28783 l_balance_type_code := 'A';
28784 l_segment := NULL;
28785 l_ccid := NULL;
28786 l_adr_transaction_coa_id := NULL;
28787 l_adr_accounting_coa_id := NULL;
28788 l_adr_flexfield_segment_code := NULL;
28789 l_adr_flex_value_set_id := NULL;
28790 l_adr_value_type_code := NULL;
28791 l_adr_value_combination_id := NULL;
28792 l_adr_value_segment_code := NULL;
28793
28794 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
28795 l_bflow_class_code := ''; -- 4219869 Business Flow
28796 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
28797 l_budgetary_control_flag := 'N';
28798
28799 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28800 l_bflow_applied_to_amt := NULL; -- 5132302
28801 l_entered_amt_idx := NULL; -- 4262811
28802 l_accted_amt_idx := NULL; -- 4262811
28803 l_acc_rev_flag := NULL; -- 4262811
28804 l_accrual_line_num := NULL; -- 4262811
28805 l_tmp_amt := NULL; -- 4262811
28806 --
28807
28808 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
28809 l_balance_type_code <> 'B' THEN
28810 IF NVL(p_source_20,'
28811 ') = 'MISCCASH' AND
28812 NVL(p_source_12,'
28813 ') = 'Unexpired' AND
28814 NVL(p_source_13,'
28815 ') = 'Y' AND
28816 (NVL(p_source_14,'
28817 ') = 'MULTIPLE' OR
28818 NVL(p_source_14,'
28819 ') = 'NO_YEAR') AND
28820 NVL(p_source_56,'
28821 ') = 'Y'
28822 THEN
28823
28824 --
28825 XLA_AE_LINES_PKG.SetNewLine;
28826
28827 p_balance_type_code := l_balance_type_code;
28828 -- set the flag so later we will know whether the gain loss line needs to be created
28829
28830 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
28831 p_actual_flag :='A';
28832 END IF;
28833
28834 --
28835 -- bulk performance
28836 --
28837 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
28838 p_header_num => 0); -- 4262811
28839 --
28840 -- set accounting line options
28841 --
28842 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
28843 p_natural_side_code => 'D'
28844 , p_gain_or_loss_flag => 'N'
28845 , p_gl_transfer_mode_code => 'S'
28846 , p_acct_entry_type_code => 'A'
28847 , p_switch_side_flag => 'Y'
28848 , p_merge_duplicate_code => 'A'
28849 );
28850 --
28851 l_acc_rev_natural_side_code := 'C'; -- 4262811
28852 --
28853 --
28854 -- set accounting line type info
28855 --
28856 xla_ae_lines_pkg.SetAcctLineType
28857 (p_component_type => l_component_type
28858 ,p_event_type_code => l_event_type_code
28859 ,p_line_definition_owner_code => l_line_definition_owner_code
28860 ,p_line_definition_code => l_line_definition_code
28861 ,p_accounting_line_code => l_component_code
28862 ,p_accounting_line_type_code => l_component_type_code
28863 ,p_accounting_line_appl_id => l_component_appl_id
28864 ,p_amb_context_code => l_amb_context_code
28865 ,p_entity_code => l_entity_code
28866 ,p_event_class_code => l_event_class_code);
28867 --
28868 -- set accounting class
28869 --
28870 xla_ae_lines_pkg.SetAcctClass(
28871 p_accounting_class_code => 'FV_MISCCASH_DR'
28872 , p_ae_header_id => l_ae_header_id
28873 );
28874
28875 --
28876 -- set rounding class
28877 --
28878 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
28879 'RECEIVABLE';
28880
28881 --
28882 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
28883 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
28884 --
28885 -- bulk performance
28886 --
28887 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
28888
28889 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
28890 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
28891
28892 -- 4955764
28893 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
28894 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
28895
28896 -- 4458381 Public Sector Enh
28897
28898 --
28899 -- set accounting attributes for the line type
28900 --
28901 l_entered_amt_idx := 3;
28902 l_accted_amt_idx := 8;
28903 l_bflow_applied_to_amt_idx := NULL; -- 5132302
28904 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
28905 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
28906 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
28907 l_rec_acct_attrs.array_char_value(2) := p_source_23;
28908 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
28909 l_rec_acct_attrs.array_num_value(3) := p_source_24;
28910 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
28911 l_rec_acct_attrs.array_char_value(4) := p_source_25;
28912 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
28913 l_rec_acct_attrs.array_date_value(5) := p_source_57;
28914 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
28915 l_rec_acct_attrs.array_num_value(6) := p_source_27;
28916 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
28917 l_rec_acct_attrs.array_char_value(7) := p_source_28;
28918 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
28919 l_rec_acct_attrs.array_num_value(8) := p_source_29;
28920
28921 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
28922 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
28923
28924 ---------------------------------------------------------------------------------------------------------------
28925 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
28926 ---------------------------------------------------------------------------------------------------------------
28927 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
28928
28929 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28930 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
28931
28932 IF xla_accounting_cache_pkg.GetValueChar
28933 (p_source_code => 'LEDGER_CATEGORY_CODE'
28934 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
28935 AND l_bflow_method_code = 'PRIOR_ENTRY'
28936 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
28937 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
28938 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
28939 )
28940 THEN
28941 xla_ae_lines_pkg.BflowUpgEntry
28942 (p_business_method_code => l_bflow_method_code
28943 ,p_business_class_code => l_bflow_class_code
28944 ,p_balance_type => l_balance_type_code);
28945 ELSE
28946 NULL;
28947 -- No business flow processing for business flow method of NONE.
28948 END IF;
28949
28950 --
28951 -- call analytical criteria
28952 --
28953
28954 --
28955 -- call description
28956 --
28957 -- No description or it is inherited.
28958 --
28959 -- call ADRs
28960 -- Bug 4922099
28961 --
28962 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
28963 (NVL(l_actual_upg_option, 'N') = 'O') OR
28964 (NVL(l_enc_upg_option, 'N') = 'O')
28965 )
28966 THEN
28967 NULL;
28968 --
28969 --
28970
28971 l_ccid := AcctDerRule_4(
28972 p_application_id => p_application_id
28973 , p_ae_header_id => l_ae_header_id
28974 , p_source_5 => p_source_5
28975 , x_transaction_coa_id => l_adr_transaction_coa_id
28976 , x_accounting_coa_id => l_adr_accounting_coa_id
28977 , x_value_type_code => l_adr_value_type_code
28978 , p_side => 'NA'
28979 );
28980
28981 xla_ae_lines_pkg.set_ccid(
28982 p_code_combination_id => l_ccid
28983 , p_value_type_code => l_adr_value_type_code
28984 , p_transaction_coa_id => l_adr_transaction_coa_id
28985 , p_accounting_coa_id => l_adr_accounting_coa_id
28986 , p_adr_code => 'DIST_CCID'
28987 , p_adr_type_code => 'S'
28988 , p_component_type => l_component_type
28989 , p_component_code => l_component_code
28990 , p_component_type_code => l_component_type_code
28991 , p_component_appl_id => l_component_appl_id
28992 , p_amb_context_code => l_amb_context_code
28993 , p_side => 'NA'
28994 );
28995
28996
28997 l_segment := AcctDerRule_20(
28998 p_application_id => p_application_id
28999 , p_ae_header_id => l_ae_header_id
29000 , p_source_12 => p_source_12
29001 , p_source_13 => p_source_13
29002 , p_source_14 => p_source_14
29003 , x_transaction_coa_id => l_adr_transaction_coa_id
29004 , x_accounting_coa_id => l_adr_accounting_coa_id
29005 , x_flexfield_segment_code => l_adr_flexfield_segment_code
29006 , x_flex_value_set_id => l_adr_flex_value_set_id
29007 , x_value_type_code => l_adr_value_type_code
29008 , x_value_combination_id => l_adr_value_combination_id
29009 , x_value_segment_code => l_adr_value_segment_code
29010 , p_side => 'NA'
29011 , p_override_seg_flag => 'Y'
29012 );
29013
29014 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
29015
29016 xla_ae_lines_pkg.set_segment(
29017 p_to_segment_code => 'GL_ACCOUNT'
29018 , p_segment_value => l_segment
29019 , p_from_segment_code => l_adr_value_segment_code
29020 , p_from_combination_id => l_adr_value_combination_id
29021 , p_value_type_code => l_adr_value_type_code
29022 , p_transaction_coa_id => l_adr_transaction_coa_id
29023 , p_accounting_coa_id => l_adr_accounting_coa_id
29024 , p_flexfield_segment_code => l_adr_flexfield_segment_code
29025 , p_flex_value_set_id => l_adr_flex_value_set_id
29026 , p_adr_code => 'FV_AR_497201_MISC_RCT_DR'
29027 , p_adr_type_code => 'S'
29028 , p_component_type => l_component_type
29029 , p_component_code => l_component_code
29030 , p_component_type_code => l_component_type_code
29031 , p_component_appl_id => l_component_appl_id
29032 , p_amb_context_code => l_amb_context_code
29033 , p_entity_code => 'RECEIPTS'
29034 , p_event_class_code => 'MISC_RECEIPT'
29035 , p_side => 'NA'
29036 );
29037
29038 END IF;
29039
29040 --
29041 --
29042 END IF;
29043 --
29044 -- Bug 4922099
29045 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
29046 (NVL(l_enc_upg_option, 'N') = 'O')
29047 ) AND
29048 (l_bflow_method_code = 'PRIOR_ENTRY')
29049 )
29050 THEN
29051 IF
29052 --
29053 1 = 2
29054 --
29055 THEN
29056 xla_accounting_err_pkg.build_message
29057 (p_appli_s_name => 'XLA'
29058 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29059 ,p_token_1 => 'LINE_NUMBER'
29060 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
29061 ,p_token_2 => 'LINE_TYPE_NAME'
29062 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
29063 l_component_type
29064 ,l_component_code
29065 ,l_component_type_code
29066 ,l_component_appl_id
29067 ,l_amb_context_code
29068 ,l_entity_code
29069 ,l_event_class_code
29070 )
29071 ,p_token_3 => 'OWNER'
29072 ,p_value_3 => xla_lookups_pkg.get_meaning(
29073 p_lookup_type => 'XLA_OWNER_TYPE'
29074 ,p_lookup_code => l_component_type_code
29075 )
29076 ,p_token_4 => 'PRODUCT_NAME'
29077 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
29078 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
29079 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
29080 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
29081 ,p_ae_header_id => NULL
29082 );
29083
29084 IF (C_LEVEL_ERROR>= g_log_level) THEN
29085 trace
29086 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29087 ,p_level => C_LEVEL_ERROR
29088 ,p_module => l_log_module);
29089 END IF;
29090 END IF;
29091 END IF;
29092 --
29093 --
29094 ------------------------------------------------------------------------------------------------
29095 -- 4219869 Business Flow
29096 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
29097 -- Prior Entry. Currently, the following code is always generated.
29098 ------------------------------------------------------------------------------------------------
29099 XLA_AE_LINES_PKG.ValidateCurrentLine;
29100
29101 ------------------------------------------------------------------------------------
29102 -- 4219869 Business Flow
29103 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
29104 ------------------------------------------------------------------------------------
29105 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29106
29107 ----------------------------------------------------------------------------------
29108 -- 4219869 Business Flow
29109 -- Update journal entry status -- Need to generate this within IF <condition>
29110 ----------------------------------------------------------------------------------
29111 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29112 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
29113 ,p_balance_type_code => l_balance_type_code
29114 );
29115
29116 -------------------------------------------------------------------------------------------
29117 -- 4262811 - Generate the Accrual Reversal lines
29118 -------------------------------------------------------------------------------------------
29119 BEGIN
29120 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
29121 (g_array_event(p_event_id).array_value_num('header_index'));
29122 IF l_acc_rev_flag IS NULL THEN
29123 l_acc_rev_flag := 'N';
29124 END IF;
29125 EXCEPTION
29126 WHEN OTHERS THEN
29127 l_acc_rev_flag := 'N';
29128 END;
29129 --
29130 IF (l_acc_rev_flag = 'Y') THEN
29131
29132 -- 4645092 ------------------------------------------------------------------------------
29133 -- To allow MPA report to determine if it should generate report process
29134 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
29135 ------------------------------------------------------------------------------------------
29136
29137 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
29138 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
29139 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
29140 -- call ADRs
29141 -- Bug 4922099
29142 --
29143 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29144 (NVL(l_actual_upg_option, 'N') = 'O') OR
29145 (NVL(l_enc_upg_option, 'N') = 'O')
29146 )
29147 THEN
29148 NULL;
29149 --
29150 --
29151
29152 l_ccid := AcctDerRule_4(
29153 p_application_id => p_application_id
29154 , p_ae_header_id => l_ae_header_id
29155 , p_source_5 => p_source_5
29156 , x_transaction_coa_id => l_adr_transaction_coa_id
29157 , x_accounting_coa_id => l_adr_accounting_coa_id
29158 , x_value_type_code => l_adr_value_type_code
29159 , p_side => 'NA'
29160 );
29161
29162 xla_ae_lines_pkg.set_ccid(
29163 p_code_combination_id => l_ccid
29164 , p_value_type_code => l_adr_value_type_code
29165 , p_transaction_coa_id => l_adr_transaction_coa_id
29166 , p_accounting_coa_id => l_adr_accounting_coa_id
29167 , p_adr_code => 'DIST_CCID'
29168 , p_adr_type_code => 'S'
29169 , p_component_type => l_component_type
29170 , p_component_code => l_component_code
29171 , p_component_type_code => l_component_type_code
29172 , p_component_appl_id => l_component_appl_id
29173 , p_amb_context_code => l_amb_context_code
29174 , p_side => 'NA'
29175 );
29176
29177
29178 l_segment := AcctDerRule_20(
29179 p_application_id => p_application_id
29180 , p_ae_header_id => l_ae_header_id
29181 , p_source_12 => p_source_12
29182 , p_source_13 => p_source_13
29183 , p_source_14 => p_source_14
29184 , x_transaction_coa_id => l_adr_transaction_coa_id
29185 , x_accounting_coa_id => l_adr_accounting_coa_id
29186 , x_flexfield_segment_code => l_adr_flexfield_segment_code
29187 , x_flex_value_set_id => l_adr_flex_value_set_id
29188 , x_value_type_code => l_adr_value_type_code
29189 , x_value_combination_id => l_adr_value_combination_id
29190 , x_value_segment_code => l_adr_value_segment_code
29191 , p_side => 'NA'
29192 , p_override_seg_flag => 'Y'
29193 );
29194
29195 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
29196
29197 xla_ae_lines_pkg.set_segment(
29198 p_to_segment_code => 'GL_ACCOUNT'
29199 , p_segment_value => l_segment
29200 , p_from_segment_code => l_adr_value_segment_code
29201 , p_from_combination_id => l_adr_value_combination_id
29202 , p_value_type_code => l_adr_value_type_code
29203 , p_transaction_coa_id => l_adr_transaction_coa_id
29204 , p_accounting_coa_id => l_adr_accounting_coa_id
29205 , p_flexfield_segment_code => l_adr_flexfield_segment_code
29206 , p_flex_value_set_id => l_adr_flex_value_set_id
29207 , p_adr_code => 'FV_AR_497201_MISC_RCT_DR'
29208 , p_adr_type_code => 'S'
29209 , p_component_type => l_component_type
29210 , p_component_code => l_component_code
29211 , p_component_type_code => l_component_type_code
29212 , p_component_appl_id => l_component_appl_id
29213 , p_amb_context_code => l_amb_context_code
29214 , p_entity_code => 'RECEIPTS'
29215 , p_event_class_code => 'MISC_RECEIPT'
29216 , p_side => 'NA'
29217 );
29218
29219 END IF;
29220
29221 --
29222 --
29223 END IF;
29224
29225 --
29226 -- Update the line information that should be overwritten
29227 --
29228 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
29229 p_header_num => 1);
29230 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
29231
29232 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
29233
29234 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
29235 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
29236 END IF;
29237
29238 --
29239 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
29240 --
29241 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
29242 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
29243 ELSE
29244 ---------------------------------------------------------------------------------------------------
29245 -- 4262811a Switch Sign
29246 ---------------------------------------------------------------------------------------------------
29247 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
29248 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29249 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29250 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29251 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29252 -- 5132302
29253 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
29254 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29255
29256 END IF;
29257
29258 -- 4955764
29259 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29260 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
29261
29262
29263 XLA_AE_LINES_PKG.ValidateCurrentLine;
29264 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29265
29266 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29267 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
29268 ,p_balance_type_code => l_balance_type_code);
29269
29270 END IF;
29271
29272 -----------------------------------------------------------------------------------------
29273 -- 4262811 Multiperiod Accounting
29274 -----------------------------------------------------------------------------------------
29275 -- No MPA option is assigned.
29276
29277
29278 END IF;
29279 END IF;
29280 --
29281
29282 --
29283 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29284 trace
29285 (p_msg => 'END of AcctLineType_71'
29286 ,p_level => C_LEVEL_PROCEDURE
29287 ,p_module => l_log_module);
29288 END IF;
29289 --
29290 EXCEPTION
29291 WHEN xla_exceptions_pkg.application_exception THEN
29292 RAISE;
29293 WHEN OTHERS THEN
29294 xla_exceptions_pkg.raise_message
29295 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_71');
29296 END AcctLineType_71;
29297 --
29298
29299 ---------------------------------------
29300 --
29301 -- PRIVATE FUNCTION
29302 -- AcctLineType_72
29303 --
29304 ---------------------------------------
29305 PROCEDURE AcctLineType_72 (
29306 p_application_id IN NUMBER
29307 ,p_event_id IN NUMBER
29308 ,p_calculate_acctd_flag IN VARCHAR2
29309 ,p_calculate_g_l_flag IN VARCHAR2
29310 ,p_actual_flag IN OUT VARCHAR2
29311 ,p_balance_type_code OUT VARCHAR2
29312 ,p_gain_or_loss_ref OUT VARCHAR2
29313
29314 --Distribution GL Account
29315 , p_source_5 IN NUMBER
29316 --Federal Fund Category
29317 , p_source_9 IN VARCHAR2
29318 --Distribution Source Type
29319 , p_source_20 IN VARCHAR2
29320 --Distribution Line Identifier
29321 , p_source_22 IN NUMBER
29322 --Distribution Type
29323 , p_source_23 IN VARCHAR2
29324 --Entered Amount
29325 , p_source_24 IN NUMBER
29326 --Currency Code
29327 , p_source_25 IN VARCHAR2
29328 --Exchange Rate
29329 , p_source_27 IN NUMBER
29330 --Exchange Rate Type
29331 , p_source_28 IN VARCHAR2
29332 --Applied To Document Accounting Amount
29333 , p_source_29 IN NUMBER
29334 --Federal Account Valid Flag
29335 , p_source_56 IN VARCHAR2
29336 --Applied To Document Exchange Date
29337 , p_source_57 IN DATE
29338 )
29339 IS
29340
29341 l_component_type VARCHAR2(80);
29342 l_component_code VARCHAR2(30);
29343 l_component_type_code VARCHAR2(1);
29344 l_component_appl_id INTEGER;
29345 l_amb_context_code VARCHAR2(30);
29346 l_entity_code VARCHAR2(30);
29347 l_event_class_code VARCHAR2(30);
29348 l_ae_header_id NUMBER;
29349 l_event_type_code VARCHAR2(30);
29350 l_line_definition_code VARCHAR2(30);
29351 l_line_definition_owner_code VARCHAR2(1);
29352 --
29353 -- adr variables
29354 l_segment VARCHAR2(30);
29355 l_ccid NUMBER;
29356 l_adr_transaction_coa_id NUMBER;
29357 l_adr_accounting_coa_id NUMBER;
29358 l_adr_flexfield_segment_code VARCHAR2(30);
29359 l_adr_flex_value_set_id NUMBER;
29360 l_adr_value_type_code VARCHAR2(30);
29361 l_adr_value_combination_id NUMBER;
29362 l_adr_value_segment_code VARCHAR2(30);
29363
29364 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
29365 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
29366 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
29367 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
29368
29369 -- 4262811 Variables ------------------------------------------------------------------------------------------
29370 l_entered_amt_idx NUMBER;
29371 l_accted_amt_idx NUMBER;
29372 l_acc_rev_flag VARCHAR2(1);
29373 l_accrual_line_num NUMBER;
29374 l_tmp_amt NUMBER;
29375 l_acc_rev_natural_side_code VARCHAR2(1);
29376
29377 l_num_entries NUMBER;
29378 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
29379 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
29380 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
29381 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
29382 l_recog_line_1 NUMBER;
29383 l_recog_line_2 NUMBER;
29384
29385 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
29386 l_bflow_applied_to_amt NUMBER; -- 5132302
29387 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
29388
29389 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
29390
29391 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
29392 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
29393
29394 ---------------------------------------------------------------------------------------------------------------
29395
29396
29397 --
29398 -- bulk performance
29399 --
29400 l_balance_type_code VARCHAR2(1);
29401 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
29402 l_log_module VARCHAR2(240);
29403
29404 --
29405 -- Upgrade strategy
29406 --
29407 l_actual_upg_option VARCHAR2(1);
29408 l_enc_upg_option VARCHAR2(1);
29409
29410 --
29411 BEGIN
29412 --
29413 IF g_log_enabled THEN
29414 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_72';
29415 END IF;
29416 --
29417 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29418
29419 trace
29420 (p_msg => 'BEGIN of AcctLineType_72'
29421 ,p_level => C_LEVEL_PROCEDURE
29422 ,p_module => l_log_module);
29423
29424 END IF;
29425 --
29426 l_component_type := 'AMB_JLT';
29427 l_component_code := 'FV_MISC_RCT_REIM_WO_ADV_CR';
29428 l_component_type_code := 'S';
29429 l_component_appl_id := 222;
29430 l_amb_context_code := 'DEFAULT';
29431 l_entity_code := 'RECEIPTS';
29432 l_event_class_code := 'MISC_RECEIPT';
29433 l_event_type_code := 'MISC_RECEIPT_ALL';
29434 l_line_definition_owner_code := 'S';
29435 l_line_definition_code := 'FEDERAL_AR_MISC_RECEIPTS';
29436 --
29437 l_balance_type_code := 'A';
29438 l_segment := NULL;
29439 l_ccid := NULL;
29440 l_adr_transaction_coa_id := NULL;
29441 l_adr_accounting_coa_id := NULL;
29442 l_adr_flexfield_segment_code := NULL;
29443 l_adr_flex_value_set_id := NULL;
29444 l_adr_value_type_code := NULL;
29445 l_adr_value_combination_id := NULL;
29446 l_adr_value_segment_code := NULL;
29447
29448 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
29449 l_bflow_class_code := ''; -- 4219869 Business Flow
29450 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
29451 l_budgetary_control_flag := 'N';
29452
29453 l_bflow_applied_to_amt_idx := NULL; -- 5132302
29454 l_bflow_applied_to_amt := NULL; -- 5132302
29455 l_entered_amt_idx := NULL; -- 4262811
29456 l_accted_amt_idx := NULL; -- 4262811
29457 l_acc_rev_flag := NULL; -- 4262811
29458 l_accrual_line_num := NULL; -- 4262811
29459 l_tmp_amt := NULL; -- 4262811
29460 --
29461
29462 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
29463 l_balance_type_code <> 'B' THEN
29464 IF NVL(p_source_20,'
29465 ') = 'MISCCASH' AND
29466 NVL(p_source_9,'
29467 ') = 'Reimbursable' AND
29468 NVL(p_source_56,'
29469 ') = 'Y'
29470 THEN
29471
29472 --
29473 XLA_AE_LINES_PKG.SetNewLine;
29474
29475 p_balance_type_code := l_balance_type_code;
29476 -- set the flag so later we will know whether the gain loss line needs to be created
29477
29478 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
29479 p_actual_flag :='A';
29480 END IF;
29481
29482 --
29483 -- bulk performance
29484 --
29485 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
29486 p_header_num => 0); -- 4262811
29487 --
29488 -- set accounting line options
29489 --
29490 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
29491 p_natural_side_code => 'C'
29492 , p_gain_or_loss_flag => 'N'
29493 , p_gl_transfer_mode_code => 'S'
29494 , p_acct_entry_type_code => 'A'
29495 , p_switch_side_flag => 'Y'
29496 , p_merge_duplicate_code => 'A'
29497 );
29498 --
29499 l_acc_rev_natural_side_code := 'D'; -- 4262811
29500 --
29501 --
29502 -- set accounting line type info
29503 --
29504 xla_ae_lines_pkg.SetAcctLineType
29505 (p_component_type => l_component_type
29506 ,p_event_type_code => l_event_type_code
29507 ,p_line_definition_owner_code => l_line_definition_owner_code
29508 ,p_line_definition_code => l_line_definition_code
29509 ,p_accounting_line_code => l_component_code
29510 ,p_accounting_line_type_code => l_component_type_code
29511 ,p_accounting_line_appl_id => l_component_appl_id
29512 ,p_amb_context_code => l_amb_context_code
29513 ,p_entity_code => l_entity_code
29514 ,p_event_class_code => l_event_class_code);
29515 --
29516 -- set accounting class
29517 --
29518 xla_ae_lines_pkg.SetAcctClass(
29519 p_accounting_class_code => 'FV_MISCCASH_CR'
29520 , p_ae_header_id => l_ae_header_id
29521 );
29522
29523 --
29524 -- set rounding class
29525 --
29526 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
29527 'RECEIVABLE';
29528
29529 --
29530 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
29531 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
29532 --
29533 -- bulk performance
29534 --
29535 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
29536
29537 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
29538 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
29539
29540 -- 4955764
29541 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29542 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
29543
29544 -- 4458381 Public Sector Enh
29545
29546 --
29547 -- set accounting attributes for the line type
29548 --
29549 l_entered_amt_idx := 3;
29550 l_accted_amt_idx := 8;
29551 l_bflow_applied_to_amt_idx := NULL; -- 5132302
29552 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
29553 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
29554 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
29555 l_rec_acct_attrs.array_char_value(2) := p_source_23;
29556 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
29557 l_rec_acct_attrs.array_num_value(3) := p_source_24;
29558 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
29559 l_rec_acct_attrs.array_char_value(4) := p_source_25;
29560 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
29561 l_rec_acct_attrs.array_date_value(5) := p_source_57;
29562 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
29563 l_rec_acct_attrs.array_num_value(6) := p_source_27;
29564 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
29565 l_rec_acct_attrs.array_char_value(7) := p_source_28;
29566 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
29567 l_rec_acct_attrs.array_num_value(8) := p_source_29;
29568
29569 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
29570 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
29571
29572 ---------------------------------------------------------------------------------------------------------------
29573 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
29574 ---------------------------------------------------------------------------------------------------------------
29575 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
29576
29577 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
29578 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
29579
29580 IF xla_accounting_cache_pkg.GetValueChar
29581 (p_source_code => 'LEDGER_CATEGORY_CODE'
29582 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
29583 AND l_bflow_method_code = 'PRIOR_ENTRY'
29584 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
29585 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
29586 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
29587 )
29588 THEN
29589 xla_ae_lines_pkg.BflowUpgEntry
29590 (p_business_method_code => l_bflow_method_code
29591 ,p_business_class_code => l_bflow_class_code
29592 ,p_balance_type => l_balance_type_code);
29593 ELSE
29594 NULL;
29595 -- No business flow processing for business flow method of NONE.
29596 END IF;
29597
29598 --
29599 -- call analytical criteria
29600 --
29601
29602 --
29603 -- call description
29604 --
29605 -- No description or it is inherited.
29606 --
29607 -- call ADRs
29608 -- Bug 4922099
29609 --
29610 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29611 (NVL(l_actual_upg_option, 'N') = 'O') OR
29612 (NVL(l_enc_upg_option, 'N') = 'O')
29613 )
29614 THEN
29615 NULL;
29616 --
29617 --
29618
29619 l_ccid := AcctDerRule_4(
29620 p_application_id => p_application_id
29621 , p_ae_header_id => l_ae_header_id
29622 , p_source_5 => p_source_5
29623 , x_transaction_coa_id => l_adr_transaction_coa_id
29624 , x_accounting_coa_id => l_adr_accounting_coa_id
29625 , x_value_type_code => l_adr_value_type_code
29626 , p_side => 'NA'
29627 );
29628
29629 xla_ae_lines_pkg.set_ccid(
29630 p_code_combination_id => l_ccid
29631 , p_value_type_code => l_adr_value_type_code
29632 , p_transaction_coa_id => l_adr_transaction_coa_id
29633 , p_accounting_coa_id => l_adr_accounting_coa_id
29634 , p_adr_code => 'DIST_CCID'
29635 , p_adr_type_code => 'S'
29636 , p_component_type => l_component_type
29637 , p_component_code => l_component_code
29638 , p_component_type_code => l_component_type_code
29639 , p_component_appl_id => l_component_appl_id
29640 , p_amb_context_code => l_amb_context_code
29641 , p_side => 'NA'
29642 );
29643
29644
29645 l_segment := AcctDerRule_7(
29646 p_application_id => p_application_id
29647 , p_ae_header_id => l_ae_header_id
29648 , p_source_9 => p_source_9
29649 , x_transaction_coa_id => l_adr_transaction_coa_id
29650 , x_accounting_coa_id => l_adr_accounting_coa_id
29651 , x_flexfield_segment_code => l_adr_flexfield_segment_code
29652 , x_flex_value_set_id => l_adr_flex_value_set_id
29653 , x_value_type_code => l_adr_value_type_code
29654 , x_value_combination_id => l_adr_value_combination_id
29655 , x_value_segment_code => l_adr_value_segment_code
29656 , p_side => 'NA'
29657 , p_override_seg_flag => 'Y'
29658 );
29659
29660 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
29661
29662 xla_ae_lines_pkg.set_segment(
29663 p_to_segment_code => 'GL_ACCOUNT'
29664 , p_segment_value => l_segment
29665 , p_from_segment_code => l_adr_value_segment_code
29666 , p_from_combination_id => l_adr_value_combination_id
29667 , p_value_type_code => l_adr_value_type_code
29668 , p_transaction_coa_id => l_adr_transaction_coa_id
29669 , p_accounting_coa_id => l_adr_accounting_coa_id
29670 , p_flexfield_segment_code => l_adr_flexfield_segment_code
29671 , p_flex_value_set_id => l_adr_flex_value_set_id
29672 , p_adr_code => 'FV_AR_422101_MISC_RCT_CR'
29673 , p_adr_type_code => 'S'
29674 , p_component_type => l_component_type
29675 , p_component_code => l_component_code
29676 , p_component_type_code => l_component_type_code
29677 , p_component_appl_id => l_component_appl_id
29678 , p_amb_context_code => l_amb_context_code
29679 , p_entity_code => 'RECEIPTS'
29680 , p_event_class_code => 'MISC_RECEIPT'
29681 , p_side => 'NA'
29682 );
29683
29684 END IF;
29685
29686 --
29687 --
29688 END IF;
29689 --
29690 -- Bug 4922099
29691 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
29692 (NVL(l_enc_upg_option, 'N') = 'O')
29693 ) AND
29694 (l_bflow_method_code = 'PRIOR_ENTRY')
29695 )
29696 THEN
29697 IF
29698 --
29699 1 = 2
29700 --
29701 THEN
29702 xla_accounting_err_pkg.build_message
29703 (p_appli_s_name => 'XLA'
29704 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29705 ,p_token_1 => 'LINE_NUMBER'
29706 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
29707 ,p_token_2 => 'LINE_TYPE_NAME'
29708 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
29709 l_component_type
29710 ,l_component_code
29711 ,l_component_type_code
29712 ,l_component_appl_id
29713 ,l_amb_context_code
29714 ,l_entity_code
29715 ,l_event_class_code
29716 )
29717 ,p_token_3 => 'OWNER'
29718 ,p_value_3 => xla_lookups_pkg.get_meaning(
29719 p_lookup_type => 'XLA_OWNER_TYPE'
29720 ,p_lookup_code => l_component_type_code
29721 )
29722 ,p_token_4 => 'PRODUCT_NAME'
29723 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
29724 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
29725 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
29726 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
29727 ,p_ae_header_id => NULL
29728 );
29729
29730 IF (C_LEVEL_ERROR>= g_log_level) THEN
29731 trace
29732 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
29733 ,p_level => C_LEVEL_ERROR
29734 ,p_module => l_log_module);
29735 END IF;
29736 END IF;
29737 END IF;
29738 --
29739 --
29740 ------------------------------------------------------------------------------------------------
29741 -- 4219869 Business Flow
29742 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
29743 -- Prior Entry. Currently, the following code is always generated.
29744 ------------------------------------------------------------------------------------------------
29745 XLA_AE_LINES_PKG.ValidateCurrentLine;
29746
29747 ------------------------------------------------------------------------------------
29748 -- 4219869 Business Flow
29749 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
29750 ------------------------------------------------------------------------------------
29751 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29752
29753 ----------------------------------------------------------------------------------
29754 -- 4219869 Business Flow
29755 -- Update journal entry status -- Need to generate this within IF <condition>
29756 ----------------------------------------------------------------------------------
29757 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29758 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
29759 ,p_balance_type_code => l_balance_type_code
29760 );
29761
29762 -------------------------------------------------------------------------------------------
29763 -- 4262811 - Generate the Accrual Reversal lines
29764 -------------------------------------------------------------------------------------------
29765 BEGIN
29766 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
29767 (g_array_event(p_event_id).array_value_num('header_index'));
29768 IF l_acc_rev_flag IS NULL THEN
29769 l_acc_rev_flag := 'N';
29770 END IF;
29771 EXCEPTION
29772 WHEN OTHERS THEN
29773 l_acc_rev_flag := 'N';
29774 END;
29775 --
29776 IF (l_acc_rev_flag = 'Y') THEN
29777
29778 -- 4645092 ------------------------------------------------------------------------------
29779 -- To allow MPA report to determine if it should generate report process
29780 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
29781 ------------------------------------------------------------------------------------------
29782
29783 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
29784 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
29785 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
29786 -- call ADRs
29787 -- Bug 4922099
29788 --
29789 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
29790 (NVL(l_actual_upg_option, 'N') = 'O') OR
29791 (NVL(l_enc_upg_option, 'N') = 'O')
29792 )
29793 THEN
29794 NULL;
29795 --
29796 --
29797
29798 l_ccid := AcctDerRule_4(
29799 p_application_id => p_application_id
29800 , p_ae_header_id => l_ae_header_id
29801 , p_source_5 => p_source_5
29802 , x_transaction_coa_id => l_adr_transaction_coa_id
29803 , x_accounting_coa_id => l_adr_accounting_coa_id
29804 , x_value_type_code => l_adr_value_type_code
29805 , p_side => 'NA'
29806 );
29807
29808 xla_ae_lines_pkg.set_ccid(
29809 p_code_combination_id => l_ccid
29810 , p_value_type_code => l_adr_value_type_code
29811 , p_transaction_coa_id => l_adr_transaction_coa_id
29812 , p_accounting_coa_id => l_adr_accounting_coa_id
29813 , p_adr_code => 'DIST_CCID'
29814 , p_adr_type_code => 'S'
29815 , p_component_type => l_component_type
29816 , p_component_code => l_component_code
29817 , p_component_type_code => l_component_type_code
29818 , p_component_appl_id => l_component_appl_id
29819 , p_amb_context_code => l_amb_context_code
29820 , p_side => 'NA'
29821 );
29822
29823
29824 l_segment := AcctDerRule_7(
29825 p_application_id => p_application_id
29826 , p_ae_header_id => l_ae_header_id
29827 , p_source_9 => p_source_9
29828 , x_transaction_coa_id => l_adr_transaction_coa_id
29829 , x_accounting_coa_id => l_adr_accounting_coa_id
29830 , x_flexfield_segment_code => l_adr_flexfield_segment_code
29831 , x_flex_value_set_id => l_adr_flex_value_set_id
29832 , x_value_type_code => l_adr_value_type_code
29833 , x_value_combination_id => l_adr_value_combination_id
29834 , x_value_segment_code => l_adr_value_segment_code
29835 , p_side => 'NA'
29836 , p_override_seg_flag => 'Y'
29837 );
29838
29839 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
29840
29841 xla_ae_lines_pkg.set_segment(
29842 p_to_segment_code => 'GL_ACCOUNT'
29843 , p_segment_value => l_segment
29844 , p_from_segment_code => l_adr_value_segment_code
29845 , p_from_combination_id => l_adr_value_combination_id
29846 , p_value_type_code => l_adr_value_type_code
29847 , p_transaction_coa_id => l_adr_transaction_coa_id
29848 , p_accounting_coa_id => l_adr_accounting_coa_id
29849 , p_flexfield_segment_code => l_adr_flexfield_segment_code
29850 , p_flex_value_set_id => l_adr_flex_value_set_id
29851 , p_adr_code => 'FV_AR_422101_MISC_RCT_CR'
29852 , p_adr_type_code => 'S'
29853 , p_component_type => l_component_type
29854 , p_component_code => l_component_code
29855 , p_component_type_code => l_component_type_code
29856 , p_component_appl_id => l_component_appl_id
29857 , p_amb_context_code => l_amb_context_code
29858 , p_entity_code => 'RECEIPTS'
29859 , p_event_class_code => 'MISC_RECEIPT'
29860 , p_side => 'NA'
29861 );
29862
29863 END IF;
29864
29865 --
29866 --
29867 END IF;
29868
29869 --
29870 -- Update the line information that should be overwritten
29871 --
29872 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
29873 p_header_num => 1);
29874 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
29875
29876 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
29877
29878 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
29879 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
29880 END IF;
29881
29882 --
29883 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
29884 --
29885 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
29886 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
29887 ELSE
29888 ---------------------------------------------------------------------------------------------------
29889 -- 4262811a Switch Sign
29890 ---------------------------------------------------------------------------------------------------
29891 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
29892 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29893 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29894 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
29895 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29896 -- 5132302
29897 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
29898 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
29899
29900 END IF;
29901
29902 -- 4955764
29903 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
29904 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
29905
29906
29907 XLA_AE_LINES_PKG.ValidateCurrentLine;
29908 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
29909
29910 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
29911 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
29912 ,p_balance_type_code => l_balance_type_code);
29913
29914 END IF;
29915
29916 -----------------------------------------------------------------------------------------
29917 -- 4262811 Multiperiod Accounting
29918 -----------------------------------------------------------------------------------------
29919 -- No MPA option is assigned.
29920
29921
29922 END IF;
29923 END IF;
29924 --
29925
29926 --
29927 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
29928 trace
29929 (p_msg => 'END of AcctLineType_72'
29930 ,p_level => C_LEVEL_PROCEDURE
29931 ,p_module => l_log_module);
29932 END IF;
29933 --
29934 EXCEPTION
29935 WHEN xla_exceptions_pkg.application_exception THEN
29936 RAISE;
29937 WHEN OTHERS THEN
29938 xla_exceptions_pkg.raise_message
29939 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_72');
29940 END AcctLineType_72;
29941 --
29942
29943 ---------------------------------------
29944 --
29945 -- PRIVATE FUNCTION
29946 -- AcctLineType_73
29947 --
29948 ---------------------------------------
29949 PROCEDURE AcctLineType_73 (
29950 p_application_id IN NUMBER
29951 ,p_event_id IN NUMBER
29952 ,p_calculate_acctd_flag IN VARCHAR2
29953 ,p_calculate_g_l_flag IN VARCHAR2
29954 ,p_actual_flag IN OUT VARCHAR2
29955 ,p_balance_type_code OUT VARCHAR2
29956 ,p_gain_or_loss_ref OUT VARCHAR2
29957
29958 --Distribution GL Account
29959 , p_source_5 IN NUMBER
29960 --Federal Fund Category
29961 , p_source_9 IN VARCHAR2
29962 --Distribution Source Type
29963 , p_source_20 IN VARCHAR2
29964 --Distribution Line Identifier
29965 , p_source_22 IN NUMBER
29966 --Distribution Type
29967 , p_source_23 IN VARCHAR2
29968 --Entered Amount
29969 , p_source_24 IN NUMBER
29970 --Currency Code
29971 , p_source_25 IN VARCHAR2
29972 --Exchange Rate
29973 , p_source_27 IN NUMBER
29974 --Exchange Rate Type
29975 , p_source_28 IN VARCHAR2
29976 --Applied To Document Accounting Amount
29977 , p_source_29 IN NUMBER
29978 --Federal Account Valid Flag
29979 , p_source_56 IN VARCHAR2
29980 --Applied To Document Exchange Date
29981 , p_source_57 IN DATE
29982 )
29983 IS
29984
29985 l_component_type VARCHAR2(80);
29986 l_component_code VARCHAR2(30);
29987 l_component_type_code VARCHAR2(1);
29988 l_component_appl_id INTEGER;
29989 l_amb_context_code VARCHAR2(30);
29990 l_entity_code VARCHAR2(30);
29991 l_event_class_code VARCHAR2(30);
29992 l_ae_header_id NUMBER;
29993 l_event_type_code VARCHAR2(30);
29994 l_line_definition_code VARCHAR2(30);
29995 l_line_definition_owner_code VARCHAR2(1);
29996 --
29997 -- adr variables
29998 l_segment VARCHAR2(30);
29999 l_ccid NUMBER;
30000 l_adr_transaction_coa_id NUMBER;
30001 l_adr_accounting_coa_id NUMBER;
30002 l_adr_flexfield_segment_code VARCHAR2(30);
30003 l_adr_flex_value_set_id NUMBER;
30004 l_adr_value_type_code VARCHAR2(30);
30005 l_adr_value_combination_id NUMBER;
30006 l_adr_value_segment_code VARCHAR2(30);
30007
30008 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
30009 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
30010 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
30011 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
30012
30013 -- 4262811 Variables ------------------------------------------------------------------------------------------
30014 l_entered_amt_idx NUMBER;
30015 l_accted_amt_idx NUMBER;
30016 l_acc_rev_flag VARCHAR2(1);
30017 l_accrual_line_num NUMBER;
30018 l_tmp_amt NUMBER;
30019 l_acc_rev_natural_side_code VARCHAR2(1);
30020
30021 l_num_entries NUMBER;
30022 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
30023 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
30024 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
30025 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
30026 l_recog_line_1 NUMBER;
30027 l_recog_line_2 NUMBER;
30028
30029 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
30030 l_bflow_applied_to_amt NUMBER; -- 5132302
30031 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
30032
30033 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
30034
30035 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
30036 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
30037
30038 ---------------------------------------------------------------------------------------------------------------
30039
30040
30041 --
30042 -- bulk performance
30043 --
30044 l_balance_type_code VARCHAR2(1);
30045 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
30046 l_log_module VARCHAR2(240);
30047
30048 --
30049 -- Upgrade strategy
30050 --
30051 l_actual_upg_option VARCHAR2(1);
30052 l_enc_upg_option VARCHAR2(1);
30053
30054 --
30055 BEGIN
30056 --
30057 IF g_log_enabled THEN
30058 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_73';
30059 END IF;
30060 --
30061 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30062
30063 trace
30064 (p_msg => 'BEGIN of AcctLineType_73'
30065 ,p_level => C_LEVEL_PROCEDURE
30066 ,p_module => l_log_module);
30067
30068 END IF;
30069 --
30070 l_component_type := 'AMB_JLT';
30071 l_component_code := 'FV_MISC_RCT_REIM_WO_ADV_DR';
30072 l_component_type_code := 'S';
30073 l_component_appl_id := 222;
30074 l_amb_context_code := 'DEFAULT';
30075 l_entity_code := 'RECEIPTS';
30076 l_event_class_code := 'MISC_RECEIPT';
30077 l_event_type_code := 'MISC_RECEIPT_ALL';
30078 l_line_definition_owner_code := 'S';
30079 l_line_definition_code := 'FEDERAL_AR_MISC_RECEIPTS';
30080 --
30081 l_balance_type_code := 'A';
30082 l_segment := NULL;
30083 l_ccid := NULL;
30084 l_adr_transaction_coa_id := NULL;
30085 l_adr_accounting_coa_id := NULL;
30086 l_adr_flexfield_segment_code := NULL;
30087 l_adr_flex_value_set_id := NULL;
30088 l_adr_value_type_code := NULL;
30089 l_adr_value_combination_id := NULL;
30090 l_adr_value_segment_code := NULL;
30091
30092 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
30093 l_bflow_class_code := ''; -- 4219869 Business Flow
30094 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
30095 l_budgetary_control_flag := 'N';
30096
30097 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30098 l_bflow_applied_to_amt := NULL; -- 5132302
30099 l_entered_amt_idx := NULL; -- 4262811
30100 l_accted_amt_idx := NULL; -- 4262811
30101 l_acc_rev_flag := NULL; -- 4262811
30102 l_accrual_line_num := NULL; -- 4262811
30103 l_tmp_amt := NULL; -- 4262811
30104 --
30105
30106 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
30107 l_balance_type_code <> 'B' THEN
30108 IF NVL(p_source_20,'
30109 ') = 'MISCCASH' AND
30110 NVL(p_source_9,'
30111 ') = 'Reimbursable' AND
30112 NVL(p_source_56,'
30113 ') = 'Y'
30114 THEN
30115
30116 --
30117 XLA_AE_LINES_PKG.SetNewLine;
30118
30119 p_balance_type_code := l_balance_type_code;
30120 -- set the flag so later we will know whether the gain loss line needs to be created
30121
30122 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
30123 p_actual_flag :='A';
30124 END IF;
30125
30126 --
30127 -- bulk performance
30128 --
30129 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
30130 p_header_num => 0); -- 4262811
30131 --
30132 -- set accounting line options
30133 --
30134 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
30135 p_natural_side_code => 'D'
30136 , p_gain_or_loss_flag => 'N'
30137 , p_gl_transfer_mode_code => 'S'
30138 , p_acct_entry_type_code => 'A'
30139 , p_switch_side_flag => 'Y'
30140 , p_merge_duplicate_code => 'A'
30141 );
30142 --
30143 l_acc_rev_natural_side_code := 'C'; -- 4262811
30144 --
30145 --
30146 -- set accounting line type info
30147 --
30148 xla_ae_lines_pkg.SetAcctLineType
30149 (p_component_type => l_component_type
30150 ,p_event_type_code => l_event_type_code
30151 ,p_line_definition_owner_code => l_line_definition_owner_code
30152 ,p_line_definition_code => l_line_definition_code
30153 ,p_accounting_line_code => l_component_code
30154 ,p_accounting_line_type_code => l_component_type_code
30155 ,p_accounting_line_appl_id => l_component_appl_id
30156 ,p_amb_context_code => l_amb_context_code
30157 ,p_entity_code => l_entity_code
30158 ,p_event_class_code => l_event_class_code);
30159 --
30160 -- set accounting class
30161 --
30162 xla_ae_lines_pkg.SetAcctClass(
30163 p_accounting_class_code => 'FV_MISCCASH_DR'
30164 , p_ae_header_id => l_ae_header_id
30165 );
30166
30167 --
30168 -- set rounding class
30169 --
30170 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
30171 'RECEIVABLE';
30172
30173 --
30174 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
30175 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
30176 --
30177 -- bulk performance
30178 --
30179 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
30180
30181 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
30182 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
30183
30184 -- 4955764
30185 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30186 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
30187
30188 -- 4458381 Public Sector Enh
30189
30190 --
30191 -- set accounting attributes for the line type
30192 --
30193 l_entered_amt_idx := 3;
30194 l_accted_amt_idx := 8;
30195 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30196 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
30197 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
30198 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
30199 l_rec_acct_attrs.array_char_value(2) := p_source_23;
30200 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
30201 l_rec_acct_attrs.array_num_value(3) := p_source_24;
30202 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
30203 l_rec_acct_attrs.array_char_value(4) := p_source_25;
30204 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
30205 l_rec_acct_attrs.array_date_value(5) := p_source_57;
30206 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
30207 l_rec_acct_attrs.array_num_value(6) := p_source_27;
30208 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
30209 l_rec_acct_attrs.array_char_value(7) := p_source_28;
30210 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
30211 l_rec_acct_attrs.array_num_value(8) := p_source_29;
30212
30213 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
30214 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
30215
30216 ---------------------------------------------------------------------------------------------------------------
30217 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
30218 ---------------------------------------------------------------------------------------------------------------
30219 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
30220
30221 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30222 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30223
30224 IF xla_accounting_cache_pkg.GetValueChar
30225 (p_source_code => 'LEDGER_CATEGORY_CODE'
30226 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
30227 AND l_bflow_method_code = 'PRIOR_ENTRY'
30228 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
30229 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
30230 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
30231 )
30232 THEN
30233 xla_ae_lines_pkg.BflowUpgEntry
30234 (p_business_method_code => l_bflow_method_code
30235 ,p_business_class_code => l_bflow_class_code
30236 ,p_balance_type => l_balance_type_code);
30237 ELSE
30238 NULL;
30239 -- No business flow processing for business flow method of NONE.
30240 END IF;
30241
30242 --
30243 -- call analytical criteria
30244 --
30245
30246 --
30247 -- call description
30248 --
30249 -- No description or it is inherited.
30250 --
30251 -- call ADRs
30252 -- Bug 4922099
30253 --
30254 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30255 (NVL(l_actual_upg_option, 'N') = 'O') OR
30256 (NVL(l_enc_upg_option, 'N') = 'O')
30257 )
30258 THEN
30259 NULL;
30260 --
30261 --
30262
30263 l_ccid := AcctDerRule_4(
30264 p_application_id => p_application_id
30265 , p_ae_header_id => l_ae_header_id
30266 , p_source_5 => p_source_5
30267 , x_transaction_coa_id => l_adr_transaction_coa_id
30268 , x_accounting_coa_id => l_adr_accounting_coa_id
30269 , x_value_type_code => l_adr_value_type_code
30270 , p_side => 'NA'
30271 );
30272
30273 xla_ae_lines_pkg.set_ccid(
30274 p_code_combination_id => l_ccid
30275 , p_value_type_code => l_adr_value_type_code
30276 , p_transaction_coa_id => l_adr_transaction_coa_id
30277 , p_accounting_coa_id => l_adr_accounting_coa_id
30278 , p_adr_code => 'DIST_CCID'
30279 , p_adr_type_code => 'S'
30280 , p_component_type => l_component_type
30281 , p_component_code => l_component_code
30282 , p_component_type_code => l_component_type_code
30283 , p_component_appl_id => l_component_appl_id
30284 , p_amb_context_code => l_amb_context_code
30285 , p_side => 'NA'
30286 );
30287
30288
30289 l_segment := AcctDerRule_10(
30290 p_application_id => p_application_id
30291 , p_ae_header_id => l_ae_header_id
30292 , p_source_9 => p_source_9
30293 , x_transaction_coa_id => l_adr_transaction_coa_id
30294 , x_accounting_coa_id => l_adr_accounting_coa_id
30295 , x_flexfield_segment_code => l_adr_flexfield_segment_code
30296 , x_flex_value_set_id => l_adr_flex_value_set_id
30297 , x_value_type_code => l_adr_value_type_code
30298 , x_value_combination_id => l_adr_value_combination_id
30299 , x_value_segment_code => l_adr_value_segment_code
30300 , p_side => 'NA'
30301 , p_override_seg_flag => 'Y'
30302 );
30303
30304 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
30305
30306 xla_ae_lines_pkg.set_segment(
30307 p_to_segment_code => 'GL_ACCOUNT'
30308 , p_segment_value => l_segment
30309 , p_from_segment_code => l_adr_value_segment_code
30310 , p_from_combination_id => l_adr_value_combination_id
30311 , p_value_type_code => l_adr_value_type_code
30312 , p_transaction_coa_id => l_adr_transaction_coa_id
30313 , p_accounting_coa_id => l_adr_accounting_coa_id
30314 , p_flexfield_segment_code => l_adr_flexfield_segment_code
30315 , p_flex_value_set_id => l_adr_flex_value_set_id
30316 , p_adr_code => 'FV_AR_425201_MISC_RCT_DR'
30317 , p_adr_type_code => 'S'
30318 , p_component_type => l_component_type
30319 , p_component_code => l_component_code
30320 , p_component_type_code => l_component_type_code
30321 , p_component_appl_id => l_component_appl_id
30322 , p_amb_context_code => l_amb_context_code
30323 , p_entity_code => 'RECEIPTS'
30324 , p_event_class_code => 'MISC_RECEIPT'
30325 , p_side => 'NA'
30326 );
30327
30328 END IF;
30329
30330 --
30331 --
30332 END IF;
30333 --
30334 -- Bug 4922099
30335 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
30336 (NVL(l_enc_upg_option, 'N') = 'O')
30337 ) AND
30338 (l_bflow_method_code = 'PRIOR_ENTRY')
30339 )
30340 THEN
30341 IF
30342 --
30343 1 = 2
30344 --
30345 THEN
30346 xla_accounting_err_pkg.build_message
30347 (p_appli_s_name => 'XLA'
30348 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30349 ,p_token_1 => 'LINE_NUMBER'
30350 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
30351 ,p_token_2 => 'LINE_TYPE_NAME'
30352 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
30353 l_component_type
30354 ,l_component_code
30355 ,l_component_type_code
30356 ,l_component_appl_id
30357 ,l_amb_context_code
30358 ,l_entity_code
30359 ,l_event_class_code
30360 )
30361 ,p_token_3 => 'OWNER'
30362 ,p_value_3 => xla_lookups_pkg.get_meaning(
30363 p_lookup_type => 'XLA_OWNER_TYPE'
30364 ,p_lookup_code => l_component_type_code
30365 )
30366 ,p_token_4 => 'PRODUCT_NAME'
30367 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
30368 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
30369 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
30370 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
30371 ,p_ae_header_id => NULL
30372 );
30373
30374 IF (C_LEVEL_ERROR>= g_log_level) THEN
30375 trace
30376 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
30377 ,p_level => C_LEVEL_ERROR
30378 ,p_module => l_log_module);
30379 END IF;
30380 END IF;
30381 END IF;
30382 --
30383 --
30384 ------------------------------------------------------------------------------------------------
30385 -- 4219869 Business Flow
30386 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
30387 -- Prior Entry. Currently, the following code is always generated.
30388 ------------------------------------------------------------------------------------------------
30389 XLA_AE_LINES_PKG.ValidateCurrentLine;
30390
30391 ------------------------------------------------------------------------------------
30392 -- 4219869 Business Flow
30393 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
30394 ------------------------------------------------------------------------------------
30395 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
30396
30397 ----------------------------------------------------------------------------------
30398 -- 4219869 Business Flow
30399 -- Update journal entry status -- Need to generate this within IF <condition>
30400 ----------------------------------------------------------------------------------
30401 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
30402 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
30403 ,p_balance_type_code => l_balance_type_code
30404 );
30405
30406 -------------------------------------------------------------------------------------------
30407 -- 4262811 - Generate the Accrual Reversal lines
30408 -------------------------------------------------------------------------------------------
30409 BEGIN
30410 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
30411 (g_array_event(p_event_id).array_value_num('header_index'));
30412 IF l_acc_rev_flag IS NULL THEN
30413 l_acc_rev_flag := 'N';
30414 END IF;
30415 EXCEPTION
30416 WHEN OTHERS THEN
30417 l_acc_rev_flag := 'N';
30418 END;
30419 --
30420 IF (l_acc_rev_flag = 'Y') THEN
30421
30422 -- 4645092 ------------------------------------------------------------------------------
30423 -- To allow MPA report to determine if it should generate report process
30424 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
30425 ------------------------------------------------------------------------------------------
30426
30427 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
30428 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
30429 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
30430 -- call ADRs
30431 -- Bug 4922099
30432 --
30433 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30434 (NVL(l_actual_upg_option, 'N') = 'O') OR
30435 (NVL(l_enc_upg_option, 'N') = 'O')
30436 )
30437 THEN
30438 NULL;
30439 --
30440 --
30441
30442 l_ccid := AcctDerRule_4(
30443 p_application_id => p_application_id
30444 , p_ae_header_id => l_ae_header_id
30445 , p_source_5 => p_source_5
30446 , x_transaction_coa_id => l_adr_transaction_coa_id
30447 , x_accounting_coa_id => l_adr_accounting_coa_id
30448 , x_value_type_code => l_adr_value_type_code
30449 , p_side => 'NA'
30450 );
30451
30452 xla_ae_lines_pkg.set_ccid(
30453 p_code_combination_id => l_ccid
30454 , p_value_type_code => l_adr_value_type_code
30455 , p_transaction_coa_id => l_adr_transaction_coa_id
30456 , p_accounting_coa_id => l_adr_accounting_coa_id
30457 , p_adr_code => 'DIST_CCID'
30458 , p_adr_type_code => 'S'
30459 , p_component_type => l_component_type
30460 , p_component_code => l_component_code
30461 , p_component_type_code => l_component_type_code
30462 , p_component_appl_id => l_component_appl_id
30463 , p_amb_context_code => l_amb_context_code
30464 , p_side => 'NA'
30465 );
30466
30467
30468 l_segment := AcctDerRule_10(
30469 p_application_id => p_application_id
30470 , p_ae_header_id => l_ae_header_id
30471 , p_source_9 => p_source_9
30472 , x_transaction_coa_id => l_adr_transaction_coa_id
30473 , x_accounting_coa_id => l_adr_accounting_coa_id
30474 , x_flexfield_segment_code => l_adr_flexfield_segment_code
30475 , x_flex_value_set_id => l_adr_flex_value_set_id
30476 , x_value_type_code => l_adr_value_type_code
30477 , x_value_combination_id => l_adr_value_combination_id
30478 , x_value_segment_code => l_adr_value_segment_code
30479 , p_side => 'NA'
30480 , p_override_seg_flag => 'Y'
30481 );
30482
30483 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
30484
30485 xla_ae_lines_pkg.set_segment(
30486 p_to_segment_code => 'GL_ACCOUNT'
30487 , p_segment_value => l_segment
30488 , p_from_segment_code => l_adr_value_segment_code
30489 , p_from_combination_id => l_adr_value_combination_id
30490 , p_value_type_code => l_adr_value_type_code
30491 , p_transaction_coa_id => l_adr_transaction_coa_id
30492 , p_accounting_coa_id => l_adr_accounting_coa_id
30493 , p_flexfield_segment_code => l_adr_flexfield_segment_code
30494 , p_flex_value_set_id => l_adr_flex_value_set_id
30495 , p_adr_code => 'FV_AR_425201_MISC_RCT_DR'
30496 , p_adr_type_code => 'S'
30497 , p_component_type => l_component_type
30498 , p_component_code => l_component_code
30499 , p_component_type_code => l_component_type_code
30500 , p_component_appl_id => l_component_appl_id
30501 , p_amb_context_code => l_amb_context_code
30502 , p_entity_code => 'RECEIPTS'
30503 , p_event_class_code => 'MISC_RECEIPT'
30504 , p_side => 'NA'
30505 );
30506
30507 END IF;
30508
30509 --
30510 --
30511 END IF;
30512
30513 --
30514 -- Update the line information that should be overwritten
30515 --
30516 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
30517 p_header_num => 1);
30518 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
30519
30520 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
30521
30522 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
30523 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
30524 END IF;
30525
30526 --
30527 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
30528 --
30529 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
30530 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
30531 ELSE
30532 ---------------------------------------------------------------------------------------------------
30533 -- 4262811a Switch Sign
30534 ---------------------------------------------------------------------------------------------------
30538 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30535 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
30536 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
30537 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30539 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30540 -- 5132302
30541 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
30542 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
30543
30544 END IF;
30545
30546 -- 4955764
30547 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30548 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
30549
30550
30551 XLA_AE_LINES_PKG.ValidateCurrentLine;
30552 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
30553
30554 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
30555 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
30556 ,p_balance_type_code => l_balance_type_code);
30557
30558 END IF;
30559
30560 -----------------------------------------------------------------------------------------
30561 -- 4262811 Multiperiod Accounting
30562 -----------------------------------------------------------------------------------------
30563 -- No MPA option is assigned.
30564
30565
30566 END IF;
30567 END IF;
30568 --
30569
30570 --
30571 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30572 trace
30573 (p_msg => 'END of AcctLineType_73'
30574 ,p_level => C_LEVEL_PROCEDURE
30575 ,p_module => l_log_module);
30576 END IF;
30577 --
30578 EXCEPTION
30579 WHEN xla_exceptions_pkg.application_exception THEN
30580 RAISE;
30581 WHEN OTHERS THEN
30582 xla_exceptions_pkg.raise_message
30583 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_73');
30584 END AcctLineType_73;
30585 --
30586
30587 ---------------------------------------
30588 --
30589 -- PRIVATE FUNCTION
30590 -- AcctLineType_74
30591 --
30592 ---------------------------------------
30593 PROCEDURE AcctLineType_74 (
30594 p_application_id IN NUMBER
30595 ,p_event_id IN NUMBER
30596 ,p_calculate_acctd_flag IN VARCHAR2
30597 ,p_calculate_g_l_flag IN VARCHAR2
30598 ,p_actual_flag IN OUT VARCHAR2
30599 ,p_balance_type_code OUT VARCHAR2
30600 ,p_gain_or_loss_ref OUT VARCHAR2
30601
30602 --Distribution GL Account
30603 , p_source_5 IN NUMBER
30604 --Federal Account Rule
30605 , p_source_11 IN VARCHAR2
30606 --Federal Fund Expired Status
30607 , p_source_12 IN VARCHAR2
30608 --Federal Prior Year Flag
30609 , p_source_13 IN VARCHAR2
30610 --Federal Fund Time Frame
30611 , p_source_14 IN VARCHAR2
30612 --Distribution Source Type
30613 , p_source_20 IN VARCHAR2
30614 --Distribution Line Identifier
30615 , p_source_22 IN NUMBER
30616 --Distribution Type
30617 , p_source_23 IN VARCHAR2
30618 --Entered Amount
30619 , p_source_24 IN NUMBER
30620 --Exchange Rate Type
30621 , p_source_28 IN VARCHAR2
30622 --Applied To Document Accounting Amount
30623 , p_source_29 IN NUMBER
30624 --Transaction Distribution Account Class
30625 , p_source_33 IN VARCHAR2
30626 --Transaction Distribution Identifier
30627 , p_source_34 IN NUMBER
30628 --Transaction Distribution Type
30629 , p_source_35 IN VARCHAR2
30630 --Federal Account Valid Flag
30631 , p_source_56 IN VARCHAR2
30632 --Applied To Document Exchange Date
30633 , p_source_57 IN DATE
30634 --Receipt Applied To Application Identifier
30635 , p_source_58 IN NUMBER
30636 --Transaction Entity Code
30637 , p_source_59 IN VARCHAR2
30638 --Transaction Identifier
30639 , p_source_60 IN NUMBER
30640 --Applying Document Currency Code
30641 , p_source_61 IN VARCHAR2
30642 --Applied To Document Exchange Rate
30643 , p_source_62 IN NUMBER
30644 --Distribution Party Identifier
30645 , p_source_63 IN NUMBER
30646 --Distribution Party Site Id
30647 , p_source_64 IN NUMBER
30648 --Distribution Party Type
30649 , p_source_65 IN VARCHAR2
30650 )
30651 IS
30652
30653 l_component_type VARCHAR2(80);
30654 l_component_code VARCHAR2(30);
30655 l_component_type_code VARCHAR2(1);
30656 l_component_appl_id INTEGER;
30657 l_amb_context_code VARCHAR2(30);
30658 l_entity_code VARCHAR2(30);
30659 l_event_class_code VARCHAR2(30);
30660 l_ae_header_id NUMBER;
30661 l_event_type_code VARCHAR2(30);
30662 l_line_definition_code VARCHAR2(30);
30663 l_line_definition_owner_code VARCHAR2(1);
30664 --
30665 -- adr variables
30666 l_segment VARCHAR2(30);
30667 l_ccid NUMBER;
30668 l_adr_transaction_coa_id NUMBER;
30672 l_adr_value_type_code VARCHAR2(30);
30669 l_adr_accounting_coa_id NUMBER;
30670 l_adr_flexfield_segment_code VARCHAR2(30);
30671 l_adr_flex_value_set_id NUMBER;
30673 l_adr_value_combination_id NUMBER;
30674 l_adr_value_segment_code VARCHAR2(30);
30675
30676 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
30677 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
30678 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
30679 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
30680
30681 -- 4262811 Variables ------------------------------------------------------------------------------------------
30682 l_entered_amt_idx NUMBER;
30683 l_accted_amt_idx NUMBER;
30684 l_acc_rev_flag VARCHAR2(1);
30685 l_accrual_line_num NUMBER;
30686 l_tmp_amt NUMBER;
30687 l_acc_rev_natural_side_code VARCHAR2(1);
30688
30689 l_num_entries NUMBER;
30690 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
30691 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
30692 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
30693 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
30694 l_recog_line_1 NUMBER;
30695 l_recog_line_2 NUMBER;
30696
30697 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
30698 l_bflow_applied_to_amt NUMBER; -- 5132302
30699 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
30700
30701 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
30702
30703 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
30704 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
30705
30706 ---------------------------------------------------------------------------------------------------------------
30707
30708
30709 --
30710 -- bulk performance
30711 --
30712 l_balance_type_code VARCHAR2(1);
30713 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
30714 l_log_module VARCHAR2(240);
30715
30716 --
30717 -- Upgrade strategy
30718 --
30719 l_actual_upg_option VARCHAR2(1);
30720 l_enc_upg_option VARCHAR2(1);
30721
30722 --
30723 BEGIN
30724 --
30725 IF g_log_enabled THEN
30726 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_74';
30727 END IF;
30728 --
30729 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
30730
30731 trace
30732 (p_msg => 'BEGIN of AcctLineType_74'
30733 ,p_level => C_LEVEL_PROCEDURE
30734 ,p_module => l_log_module);
30735
30736 END IF;
30737 --
30738 l_component_type := 'AMB_JLT';
30739 l_component_code := 'FV_RCT_REF_OAP_EF_CR';
30740 l_component_type_code := 'S';
30741 l_component_appl_id := 222;
30742 l_amb_context_code := 'DEFAULT';
30743 l_entity_code := 'RECEIPTS';
30744 l_event_class_code := 'RECEIPT';
30745 l_event_type_code := 'RECEIPT_ALL';
30746 l_line_definition_owner_code := 'S';
30747 l_line_definition_code := 'FEDERAL_AR_RCT_DEFAULT_ACCRUAL';
30748 --
30749 l_balance_type_code := 'A';
30750 l_segment := NULL;
30751 l_ccid := NULL;
30752 l_adr_transaction_coa_id := NULL;
30753 l_adr_accounting_coa_id := NULL;
30754 l_adr_flexfield_segment_code := NULL;
30755 l_adr_flex_value_set_id := NULL;
30756 l_adr_value_type_code := NULL;
30757 l_adr_value_combination_id := NULL;
30758 l_adr_value_segment_code := NULL;
30759
30760 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
30761 l_bflow_class_code := ''; -- 4219869 Business Flow
30762 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
30763 l_budgetary_control_flag := 'N';
30764
30765 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30766 l_bflow_applied_to_amt := NULL; -- 5132302
30767 l_entered_amt_idx := NULL; -- 4262811
30768 l_accted_amt_idx := NULL; -- 4262811
30769 l_acc_rev_flag := NULL; -- 4262811
30770 l_accrual_line_num := NULL; -- 4262811
30771 l_tmp_amt := NULL; -- 4262811
30772 --
30773
30774 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
30775 l_balance_type_code <> 'B' THEN
30776 IF NVL(p_source_20,'
30777 ') = 'REC' AND
30778 NVL(p_source_33,'
30779 ') = 'REV' AND
30780 NVL(p_source_12,'
30781 ') = 'Expired' AND
30782 NVL(p_source_13,'
30783 ') = 'Y' AND
30784 (NVL(p_source_14,'
30785 ') = 'SINGLE' OR
30786 NVL(p_source_14,'
30787 ') = 'MULTIPLE' OR
30788 NVL(p_source_14,'
30789 ') = 'NO_YEAR') AND
30790 (NVL(p_source_11,'
30791 ') = 'Overpayment Refund' OR
30792 NVL(p_source_11,'
30793 ') = 'Advance Refund') AND
30794 NVL(p_source_56,'
30795 ') = 'Y'
30796 THEN
30797
30798 --
30799 XLA_AE_LINES_PKG.SetNewLine;
30800
30801 p_balance_type_code := l_balance_type_code;
30802 -- set the flag so later we will know whether the gain loss line needs to be created
30803
30804 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
30805 p_actual_flag :='A';
30806 END IF;
30807
30808 --
30812 p_header_num => 0); -- 4262811
30809 -- bulk performance
30810 --
30811 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
30813 --
30814 -- set accounting line options
30815 --
30816 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
30817 p_natural_side_code => 'C'
30818 , p_gain_or_loss_flag => 'N'
30819 , p_gl_transfer_mode_code => 'S'
30820 , p_acct_entry_type_code => 'A'
30821 , p_switch_side_flag => 'Y'
30822 , p_merge_duplicate_code => 'A'
30823 );
30824 --
30825 l_acc_rev_natural_side_code := 'D'; -- 4262811
30826 --
30827 --
30828 -- set accounting line type info
30829 --
30830 xla_ae_lines_pkg.SetAcctLineType
30831 (p_component_type => l_component_type
30832 ,p_event_type_code => l_event_type_code
30833 ,p_line_definition_owner_code => l_line_definition_owner_code
30834 ,p_line_definition_code => l_line_definition_code
30835 ,p_accounting_line_code => l_component_code
30836 ,p_accounting_line_type_code => l_component_type_code
30837 ,p_accounting_line_appl_id => l_component_appl_id
30838 ,p_amb_context_code => l_amb_context_code
30839 ,p_entity_code => l_entity_code
30840 ,p_event_class_code => l_event_class_code);
30841 --
30842 -- set accounting class
30843 --
30844 xla_ae_lines_pkg.SetAcctClass(
30845 p_accounting_class_code => 'FV_CASH_CR'
30846 , p_ae_header_id => l_ae_header_id
30847 );
30848
30849 --
30850 -- set rounding class
30851 --
30852 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
30853 'RECEIVABLE';
30854
30855 --
30856 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
30857 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
30858 --
30859 -- bulk performance
30860 --
30861 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
30862
30863 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
30864 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
30865
30866 -- 4955764
30867 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
30868 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
30869
30870 -- 4458381 Public Sector Enh
30871
30872 --
30873 -- set accounting attributes for the line type
30874 --
30875 l_entered_amt_idx := 8;
30876 l_accted_amt_idx := 13;
30877 l_bflow_applied_to_amt_idx := NULL; -- 5132302
30878 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
30879 l_rec_acct_attrs.array_num_value(1) := p_source_58;
30880 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
30881 l_rec_acct_attrs.array_char_value(2) := p_source_35;
30882 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
30883 l_rec_acct_attrs.array_char_value(3) := p_source_59;
30884 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
30885 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
30886 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
30887 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
30888 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
30889 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
30890 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
30891 l_rec_acct_attrs.array_char_value(7) := p_source_23;
30892 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
30893 l_rec_acct_attrs.array_num_value(8) := p_source_24;
30894 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
30895 l_rec_acct_attrs.array_char_value(9) := p_source_61;
30896 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
30897 l_rec_acct_attrs.array_date_value(10) := p_source_57;
30898 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
30899 l_rec_acct_attrs.array_num_value(11) := p_source_62;
30900 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
30901 l_rec_acct_attrs.array_char_value(12) := p_source_28;
30902 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
30903 l_rec_acct_attrs.array_num_value(13) := p_source_29;
30904 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
30905 l_rec_acct_attrs.array_num_value(14) := p_source_63;
30906 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
30907 l_rec_acct_attrs.array_num_value(15) := p_source_64;
30908 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
30909 l_rec_acct_attrs.array_char_value(16) := p_source_65;
30910
30911 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
30912 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
30913
30914 ---------------------------------------------------------------------------------------------------------------
30915 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
30916 ---------------------------------------------------------------------------------------------------------------
30917 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
30918
30919 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30920 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
30921
30922 IF xla_accounting_cache_pkg.GetValueChar
30923 (p_source_code => 'LEDGER_CATEGORY_CODE'
30924 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
30925 AND l_bflow_method_code = 'PRIOR_ENTRY'
30926 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
30927 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
30928 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
30929 )
30930 THEN
30931 xla_ae_lines_pkg.BflowUpgEntry
30932 (p_business_method_code => l_bflow_method_code
30933 ,p_business_class_code => l_bflow_class_code
30934 ,p_balance_type => l_balance_type_code);
30935 ELSE
30936 NULL;
30937 -- No business flow processing for business flow method of NONE.
30938 END IF;
30939
30940 --
30941 -- call analytical criteria
30942 --
30943
30944 --
30945 -- call description
30946 --
30947 -- No description or it is inherited.
30948 --
30949 -- call ADRs
30950 -- Bug 4922099
30951 --
30952 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
30953 (NVL(l_actual_upg_option, 'N') = 'O') OR
30954 (NVL(l_enc_upg_option, 'N') = 'O')
30955 )
30956 THEN
30957 NULL;
30958 --
30959 --
30960
30961 l_ccid := AcctDerRule_4(
30962 p_application_id => p_application_id
30963 , p_ae_header_id => l_ae_header_id
30964 , p_source_5 => p_source_5
30965 , x_transaction_coa_id => l_adr_transaction_coa_id
30966 , x_accounting_coa_id => l_adr_accounting_coa_id
30967 , x_value_type_code => l_adr_value_type_code
30968 , p_side => 'NA'
30969 );
30970
30971 xla_ae_lines_pkg.set_ccid(
30972 p_code_combination_id => l_ccid
30973 , p_value_type_code => l_adr_value_type_code
30974 , p_transaction_coa_id => l_adr_transaction_coa_id
30975 , p_accounting_coa_id => l_adr_accounting_coa_id
30976 , p_adr_code => 'DIST_CCID'
30977 , p_adr_type_code => 'S'
30978 , p_component_type => l_component_type
30979 , p_component_code => l_component_code
30980 , p_component_type_code => l_component_type_code
30981 , p_component_appl_id => l_component_appl_id
30982 , p_amb_context_code => l_amb_context_code
30983 , p_side => 'NA'
30984 );
30985
30986
30987 l_segment := AcctDerRule_16(
30988 p_application_id => p_application_id
30989 , p_ae_header_id => l_ae_header_id
30990 , p_source_12 => p_source_12
30991 , p_source_13 => p_source_13
30992 , p_source_14 => p_source_14
30993 , x_transaction_coa_id => l_adr_transaction_coa_id
30994 , x_accounting_coa_id => l_adr_accounting_coa_id
30995 , x_flexfield_segment_code => l_adr_flexfield_segment_code
30996 , x_flex_value_set_id => l_adr_flex_value_set_id
30997 , x_value_type_code => l_adr_value_type_code
30998 , x_value_combination_id => l_adr_value_combination_id
30999 , x_value_segment_code => l_adr_value_segment_code
31000 , p_side => 'NA'
31001 , p_override_seg_flag => 'Y'
31002 );
31003
31004 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
31005
31006 xla_ae_lines_pkg.set_segment(
31007 p_to_segment_code => 'GL_ACCOUNT'
31008 , p_segment_value => l_segment
31009 , p_from_segment_code => l_adr_value_segment_code
31010 , p_from_combination_id => l_adr_value_combination_id
31011 , p_value_type_code => l_adr_value_type_code
31012 , p_transaction_coa_id => l_adr_transaction_coa_id
31013 , p_accounting_coa_id => l_adr_accounting_coa_id
31014 , p_flexfield_segment_code => l_adr_flexfield_segment_code
31015 , p_flex_value_set_id => l_adr_flex_value_set_id
31016 , p_adr_code => 'FV_AR_465002_RCT_CR'
31017 , p_adr_type_code => 'S'
31018 , p_component_type => l_component_type
31019 , p_component_code => l_component_code
31020 , p_component_type_code => l_component_type_code
31021 , p_component_appl_id => l_component_appl_id
31022 , p_amb_context_code => l_amb_context_code
31023 , p_entity_code => 'RECEIPTS'
31024 , p_event_class_code => 'RECEIPT'
31025 , p_side => 'NA'
31026 );
31027
31028 END IF;
31029
31030 --
31031 --
31032 END IF;
31033 --
31034 -- Bug 4922099
31035 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
31036 (NVL(l_enc_upg_option, 'N') = 'O')
31037 ) AND
31038 (l_bflow_method_code = 'PRIOR_ENTRY')
31039 )
31040 THEN
31041 IF
31042 --
31043 1 = 2
31044 --
31045 THEN
31046 xla_accounting_err_pkg.build_message
31047 (p_appli_s_name => 'XLA'
31048 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31049 ,p_token_1 => 'LINE_NUMBER'
31050 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
31051 ,p_token_2 => 'LINE_TYPE_NAME'
31052 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
31053 l_component_type
31054 ,l_component_code
31055 ,l_component_type_code
31056 ,l_component_appl_id
31057 ,l_amb_context_code
31058 ,l_entity_code
31059 ,l_event_class_code
31060 )
31061 ,p_token_3 => 'OWNER'
31062 ,p_value_3 => xla_lookups_pkg.get_meaning(
31063 p_lookup_type => 'XLA_OWNER_TYPE'
31064 ,p_lookup_code => l_component_type_code
31065 )
31066 ,p_token_4 => 'PRODUCT_NAME'
31067 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
31068 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
31069 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
31070 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
31071 ,p_ae_header_id => NULL
31072 );
31073
31074 IF (C_LEVEL_ERROR>= g_log_level) THEN
31075 trace
31076 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31077 ,p_level => C_LEVEL_ERROR
31078 ,p_module => l_log_module);
31079 END IF;
31080 END IF;
31081 END IF;
31082 --
31083 --
31084 ------------------------------------------------------------------------------------------------
31085 -- 4219869 Business Flow
31086 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
31087 -- Prior Entry. Currently, the following code is always generated.
31088 ------------------------------------------------------------------------------------------------
31089 XLA_AE_LINES_PKG.ValidateCurrentLine;
31090
31091 ------------------------------------------------------------------------------------
31092 -- 4219869 Business Flow
31093 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
31094 ------------------------------------------------------------------------------------
31095 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31096
31100 ----------------------------------------------------------------------------------
31097 ----------------------------------------------------------------------------------
31098 -- 4219869 Business Flow
31099 -- Update journal entry status -- Need to generate this within IF <condition>
31101 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31102 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
31103 ,p_balance_type_code => l_balance_type_code
31104 );
31105
31106 -------------------------------------------------------------------------------------------
31107 -- 4262811 - Generate the Accrual Reversal lines
31108 -------------------------------------------------------------------------------------------
31109 BEGIN
31110 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
31111 (g_array_event(p_event_id).array_value_num('header_index'));
31112 IF l_acc_rev_flag IS NULL THEN
31113 l_acc_rev_flag := 'N';
31114 END IF;
31115 EXCEPTION
31116 WHEN OTHERS THEN
31117 l_acc_rev_flag := 'N';
31118 END;
31119 --
31120 IF (l_acc_rev_flag = 'Y') THEN
31121
31122 -- 4645092 ------------------------------------------------------------------------------
31123 -- To allow MPA report to determine if it should generate report process
31124 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
31125 ------------------------------------------------------------------------------------------
31126
31127 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
31128 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
31129 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
31130 -- call ADRs
31131 -- Bug 4922099
31132 --
31133 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31134 (NVL(l_actual_upg_option, 'N') = 'O') OR
31135 (NVL(l_enc_upg_option, 'N') = 'O')
31136 )
31137 THEN
31138 NULL;
31139 --
31140 --
31141
31142 l_ccid := AcctDerRule_4(
31143 p_application_id => p_application_id
31144 , p_ae_header_id => l_ae_header_id
31145 , p_source_5 => p_source_5
31146 , x_transaction_coa_id => l_adr_transaction_coa_id
31147 , x_accounting_coa_id => l_adr_accounting_coa_id
31148 , x_value_type_code => l_adr_value_type_code
31149 , p_side => 'NA'
31150 );
31151
31152 xla_ae_lines_pkg.set_ccid(
31153 p_code_combination_id => l_ccid
31154 , p_value_type_code => l_adr_value_type_code
31155 , p_transaction_coa_id => l_adr_transaction_coa_id
31156 , p_accounting_coa_id => l_adr_accounting_coa_id
31157 , p_adr_code => 'DIST_CCID'
31158 , p_adr_type_code => 'S'
31159 , p_component_type => l_component_type
31160 , p_component_code => l_component_code
31161 , p_component_type_code => l_component_type_code
31162 , p_component_appl_id => l_component_appl_id
31163 , p_amb_context_code => l_amb_context_code
31164 , p_side => 'NA'
31165 );
31166
31167
31168 l_segment := AcctDerRule_16(
31169 p_application_id => p_application_id
31170 , p_ae_header_id => l_ae_header_id
31171 , p_source_12 => p_source_12
31172 , p_source_13 => p_source_13
31173 , p_source_14 => p_source_14
31174 , x_transaction_coa_id => l_adr_transaction_coa_id
31175 , x_accounting_coa_id => l_adr_accounting_coa_id
31176 , x_flexfield_segment_code => l_adr_flexfield_segment_code
31177 , x_flex_value_set_id => l_adr_flex_value_set_id
31178 , x_value_type_code => l_adr_value_type_code
31179 , x_value_combination_id => l_adr_value_combination_id
31180 , x_value_segment_code => l_adr_value_segment_code
31181 , p_side => 'NA'
31182 , p_override_seg_flag => 'Y'
31183 );
31184
31185 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
31186
31187 xla_ae_lines_pkg.set_segment(
31188 p_to_segment_code => 'GL_ACCOUNT'
31189 , p_segment_value => l_segment
31190 , p_from_segment_code => l_adr_value_segment_code
31191 , p_from_combination_id => l_adr_value_combination_id
31192 , p_value_type_code => l_adr_value_type_code
31193 , p_transaction_coa_id => l_adr_transaction_coa_id
31194 , p_accounting_coa_id => l_adr_accounting_coa_id
31195 , p_flexfield_segment_code => l_adr_flexfield_segment_code
31196 , p_flex_value_set_id => l_adr_flex_value_set_id
31197 , p_adr_code => 'FV_AR_465002_RCT_CR'
31198 , p_adr_type_code => 'S'
31199 , p_component_type => l_component_type
31200 , p_component_code => l_component_code
31201 , p_component_type_code => l_component_type_code
31202 , p_component_appl_id => l_component_appl_id
31203 , p_amb_context_code => l_amb_context_code
31204 , p_entity_code => 'RECEIPTS'
31205 , p_event_class_code => 'RECEIPT'
31206 , p_side => 'NA'
31207 );
31208
31209 END IF;
31210
31211 --
31212 --
31213 END IF;
31214
31215 --
31216 -- Update the line information that should be overwritten
31217 --
31218 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
31219 p_header_num => 1);
31220 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
31221
31222 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
31223
31224 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
31225 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
31226 END IF;
31227
31228 --
31229 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
31230 --
31231 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
31232 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
31233 ELSE
31234 ---------------------------------------------------------------------------------------------------
31235 -- 4262811a Switch Sign
31236 ---------------------------------------------------------------------------------------------------
31237 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
31238 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31239 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31240 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31241 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31242 -- 5132302
31246 END IF;
31243 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
31244 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31245
31247
31248 -- 4955764
31249 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31250 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
31251
31252
31253 XLA_AE_LINES_PKG.ValidateCurrentLine;
31254 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31255
31256 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31257 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
31258 ,p_balance_type_code => l_balance_type_code);
31259
31260 END IF;
31261
31262 -----------------------------------------------------------------------------------------
31263 -- 4262811 Multiperiod Accounting
31264 -----------------------------------------------------------------------------------------
31265 -- No MPA option is assigned.
31266
31267
31268 END IF;
31269 END IF;
31270 --
31271
31272 --
31273 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31274 trace
31275 (p_msg => 'END of AcctLineType_74'
31276 ,p_level => C_LEVEL_PROCEDURE
31277 ,p_module => l_log_module);
31278 END IF;
31279 --
31280 EXCEPTION
31281 WHEN xla_exceptions_pkg.application_exception THEN
31282 RAISE;
31283 WHEN OTHERS THEN
31284 xla_exceptions_pkg.raise_message
31285 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_74');
31286 END AcctLineType_74;
31287 --
31288
31289 ---------------------------------------
31290 --
31291 -- PRIVATE FUNCTION
31292 -- AcctLineType_75
31293 --
31294 ---------------------------------------
31295 PROCEDURE AcctLineType_75 (
31296 p_application_id IN NUMBER
31297 ,p_event_id IN NUMBER
31298 ,p_calculate_acctd_flag IN VARCHAR2
31299 ,p_calculate_g_l_flag IN VARCHAR2
31300 ,p_actual_flag IN OUT VARCHAR2
31301 ,p_balance_type_code OUT VARCHAR2
31302 ,p_gain_or_loss_ref OUT VARCHAR2
31303
31304 --Distribution GL Account
31305 , p_source_5 IN NUMBER
31306 --Federal Account Rule
31307 , p_source_11 IN VARCHAR2
31308 --Federal Fund Expired Status
31309 , p_source_12 IN VARCHAR2
31310 --Federal Prior Year Flag
31311 , p_source_13 IN VARCHAR2
31312 --Federal Fund Time Frame
31313 , p_source_14 IN VARCHAR2
31314 --Distribution Source Type
31315 , p_source_20 IN VARCHAR2
31316 --Distribution Line Identifier
31317 , p_source_22 IN NUMBER
31318 --Distribution Type
31319 , p_source_23 IN VARCHAR2
31320 --Entered Amount
31321 , p_source_24 IN NUMBER
31322 --Exchange Rate Type
31323 , p_source_28 IN VARCHAR2
31324 --Applied To Document Accounting Amount
31325 , p_source_29 IN NUMBER
31326 --Transaction Distribution Account Class
31327 , p_source_33 IN VARCHAR2
31328 --Transaction Distribution Identifier
31329 , p_source_34 IN NUMBER
31330 --Transaction Distribution Type
31331 , p_source_35 IN VARCHAR2
31332 --Federal Account Valid Flag
31333 , p_source_56 IN VARCHAR2
31334 --Applied To Document Exchange Date
31335 , p_source_57 IN DATE
31336 --Receipt Applied To Application Identifier
31337 , p_source_58 IN NUMBER
31338 --Transaction Entity Code
31339 , p_source_59 IN VARCHAR2
31340 --Transaction Identifier
31341 , p_source_60 IN NUMBER
31342 --Applying Document Currency Code
31343 , p_source_61 IN VARCHAR2
31344 --Applied To Document Exchange Rate
31345 , p_source_62 IN NUMBER
31346 --Distribution Party Identifier
31347 , p_source_63 IN NUMBER
31348 --Distribution Party Site Id
31349 , p_source_64 IN NUMBER
31350 --Distribution Party Type
31351 , p_source_65 IN VARCHAR2
31352 )
31353 IS
31354
31355 l_component_type VARCHAR2(80);
31356 l_component_code VARCHAR2(30);
31357 l_component_type_code VARCHAR2(1);
31358 l_component_appl_id INTEGER;
31359 l_amb_context_code VARCHAR2(30);
31360 l_entity_code VARCHAR2(30);
31361 l_event_class_code VARCHAR2(30);
31362 l_ae_header_id NUMBER;
31363 l_event_type_code VARCHAR2(30);
31364 l_line_definition_code VARCHAR2(30);
31365 l_line_definition_owner_code VARCHAR2(1);
31366 --
31367 -- adr variables
31368 l_segment VARCHAR2(30);
31369 l_ccid NUMBER;
31370 l_adr_transaction_coa_id NUMBER;
31371 l_adr_accounting_coa_id NUMBER;
31372 l_adr_flexfield_segment_code VARCHAR2(30);
31373 l_adr_flex_value_set_id NUMBER;
31374 l_adr_value_type_code VARCHAR2(30);
31375 l_adr_value_combination_id NUMBER;
31376 l_adr_value_segment_code VARCHAR2(30);
31377
31378 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
31379 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
31380 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
31381 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
31382
31383 -- 4262811 Variables ------------------------------------------------------------------------------------------
31384 l_entered_amt_idx NUMBER;
31385 l_accted_amt_idx NUMBER;
31386 l_acc_rev_flag VARCHAR2(1);
31387 l_accrual_line_num NUMBER;
31388 l_tmp_amt NUMBER;
31389 l_acc_rev_natural_side_code VARCHAR2(1);
31390
31391 l_num_entries NUMBER;
31392 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
31393 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
31394 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
31395 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
31396 l_recog_line_1 NUMBER;
31397 l_recog_line_2 NUMBER;
31398
31399 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
31400 l_bflow_applied_to_amt NUMBER; -- 5132302
31401 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
31402
31403 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
31404
31405 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
31406 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
31407
31408 ---------------------------------------------------------------------------------------------------------------
31409
31410
31411 --
31412 -- bulk performance
31413 --
31414 l_balance_type_code VARCHAR2(1);
31415 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
31416 l_log_module VARCHAR2(240);
31417
31418 --
31419 -- Upgrade strategy
31420 --
31421 l_actual_upg_option VARCHAR2(1);
31422 l_enc_upg_option VARCHAR2(1);
31423
31424 --
31425 BEGIN
31426 --
31427 IF g_log_enabled THEN
31428 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_75';
31429 END IF;
31430 --
31431 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31432
31433 trace
31434 (p_msg => 'BEGIN of AcctLineType_75'
31435 ,p_level => C_LEVEL_PROCEDURE
31436 ,p_module => l_log_module);
31437
31438 END IF;
31439 --
31440 l_component_type := 'AMB_JLT';
31441 l_component_code := 'FV_RCT_REF_OAP_EF_DR';
31442 l_component_type_code := 'S';
31443 l_component_appl_id := 222;
31444 l_amb_context_code := 'DEFAULT';
31445 l_entity_code := 'RECEIPTS';
31446 l_event_class_code := 'RECEIPT';
31447 l_event_type_code := 'RECEIPT_ALL';
31448 l_line_definition_owner_code := 'S';
31449 l_line_definition_code := 'FEDERAL_AR_RCT_DEFAULT_ACCRUAL';
31450 --
31451 l_balance_type_code := 'A';
31452 l_segment := NULL;
31453 l_ccid := NULL;
31454 l_adr_transaction_coa_id := NULL;
31455 l_adr_accounting_coa_id := NULL;
31456 l_adr_flexfield_segment_code := NULL;
31457 l_adr_flex_value_set_id := NULL;
31458 l_adr_value_type_code := NULL;
31459 l_adr_value_combination_id := NULL;
31460 l_adr_value_segment_code := NULL;
31461
31462 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
31463 l_bflow_class_code := ''; -- 4219869 Business Flow
31464 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
31465 l_budgetary_control_flag := 'N';
31466
31467 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31468 l_bflow_applied_to_amt := NULL; -- 5132302
31469 l_entered_amt_idx := NULL; -- 4262811
31470 l_accted_amt_idx := NULL; -- 4262811
31471 l_acc_rev_flag := NULL; -- 4262811
31472 l_accrual_line_num := NULL; -- 4262811
31473 l_tmp_amt := NULL; -- 4262811
31474 --
31475
31476 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
31477 l_balance_type_code <> 'B' THEN
31478 IF NVL(p_source_20,'
31479 ') = 'REC' AND
31480 NVL(p_source_33,'
31481 ') = 'REV' AND
31482 NVL(p_source_12,'
31483 ') = 'Expired' AND
31484 NVL(p_source_13,'
31485 ') = 'Y' AND
31486 (NVL(p_source_14,'
31487 ') = 'SINGLE' OR
31488 NVL(p_source_14,'
31489 ') = 'MULTIPLE' OR
31490 NVL(p_source_14,'
31491 ') = 'NO_YEAR') AND
31492 (NVL(p_source_11,'
31493 ') = 'Overpayment Refund' OR
31494 NVL(p_source_11,'
31495 ') = 'Advance Refund') AND
31496 NVL(p_source_56,'
31497 ') = 'Y'
31498 THEN
31499
31500 --
31501 XLA_AE_LINES_PKG.SetNewLine;
31502
31503 p_balance_type_code := l_balance_type_code;
31504 -- set the flag so later we will know whether the gain loss line needs to be created
31505
31506 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
31507 p_actual_flag :='A';
31508 END IF;
31509
31510 --
31511 -- bulk performance
31512 --
31513 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
31514 p_header_num => 0); -- 4262811
31515 --
31516 -- set accounting line options
31517 --
31518 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
31519 p_natural_side_code => 'D'
31520 , p_gain_or_loss_flag => 'N'
31521 , p_gl_transfer_mode_code => 'S'
31522 , p_acct_entry_type_code => 'A'
31523 , p_switch_side_flag => 'Y'
31524 , p_merge_duplicate_code => 'A'
31525 );
31526 --
31527 l_acc_rev_natural_side_code := 'C'; -- 4262811
31528 --
31529 --
31530 -- set accounting line type info
31531 --
31532 xla_ae_lines_pkg.SetAcctLineType
31533 (p_component_type => l_component_type
31534 ,p_event_type_code => l_event_type_code
31535 ,p_line_definition_owner_code => l_line_definition_owner_code
31536 ,p_line_definition_code => l_line_definition_code
31537 ,p_accounting_line_code => l_component_code
31538 ,p_accounting_line_type_code => l_component_type_code
31539 ,p_accounting_line_appl_id => l_component_appl_id
31540 ,p_amb_context_code => l_amb_context_code
31541 ,p_entity_code => l_entity_code
31542 ,p_event_class_code => l_event_class_code);
31543 --
31544 -- set accounting class
31545 --
31546 xla_ae_lines_pkg.SetAcctClass(
31547 p_accounting_class_code => 'FV_CASH_DR'
31548 , p_ae_header_id => l_ae_header_id
31549 );
31550
31551 --
31552 -- set rounding class
31553 --
31554 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
31555 'RECEIVABLE';
31556
31557 --
31558 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
31559 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
31560 --
31561 -- bulk performance
31562 --
31563 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
31564
31565 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
31566 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
31567
31568 -- 4955764
31569 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31570 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
31571
31572 -- 4458381 Public Sector Enh
31573
31574 --
31575 -- set accounting attributes for the line type
31576 --
31577 l_entered_amt_idx := 8;
31578 l_accted_amt_idx := 13;
31579 l_bflow_applied_to_amt_idx := NULL; -- 5132302
31580 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
31581 l_rec_acct_attrs.array_num_value(1) := p_source_58;
31582 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
31583 l_rec_acct_attrs.array_char_value(2) := p_source_35;
31584 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
31585 l_rec_acct_attrs.array_char_value(3) := p_source_59;
31586 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
31587 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
31588 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
31589 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
31590 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
31591 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
31592 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
31593 l_rec_acct_attrs.array_char_value(7) := p_source_23;
31594 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
31595 l_rec_acct_attrs.array_num_value(8) := p_source_24;
31596 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
31597 l_rec_acct_attrs.array_char_value(9) := p_source_61;
31598 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
31599 l_rec_acct_attrs.array_date_value(10) := p_source_57;
31603 l_rec_acct_attrs.array_char_value(12) := p_source_28;
31600 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
31601 l_rec_acct_attrs.array_num_value(11) := p_source_62;
31602 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
31604 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
31605 l_rec_acct_attrs.array_num_value(13) := p_source_29;
31606 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
31607 l_rec_acct_attrs.array_num_value(14) := p_source_63;
31608 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
31609 l_rec_acct_attrs.array_num_value(15) := p_source_64;
31610 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
31611 l_rec_acct_attrs.array_char_value(16) := p_source_65;
31612
31613 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
31614 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
31615
31616 ---------------------------------------------------------------------------------------------------------------
31617 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
31618 ---------------------------------------------------------------------------------------------------------------
31619 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
31620
31621 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
31622 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
31623
31624 IF xla_accounting_cache_pkg.GetValueChar
31625 (p_source_code => 'LEDGER_CATEGORY_CODE'
31626 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
31627 AND l_bflow_method_code = 'PRIOR_ENTRY'
31628 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
31629 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
31630 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
31631 )
31632 THEN
31633 xla_ae_lines_pkg.BflowUpgEntry
31634 (p_business_method_code => l_bflow_method_code
31635 ,p_business_class_code => l_bflow_class_code
31636 ,p_balance_type => l_balance_type_code);
31637 ELSE
31638 NULL;
31639 -- No business flow processing for business flow method of NONE.
31640 END IF;
31641
31642 --
31643 -- call analytical criteria
31644 --
31645
31646 --
31647 -- call description
31648 --
31649 -- No description or it is inherited.
31650 --
31651 -- call ADRs
31652 -- Bug 4922099
31653 --
31654 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31655 (NVL(l_actual_upg_option, 'N') = 'O') OR
31656 (NVL(l_enc_upg_option, 'N') = 'O')
31657 )
31658 THEN
31659 NULL;
31660 --
31661 --
31662
31663 l_ccid := AcctDerRule_4(
31664 p_application_id => p_application_id
31665 , p_ae_header_id => l_ae_header_id
31666 , p_source_5 => p_source_5
31667 , x_transaction_coa_id => l_adr_transaction_coa_id
31668 , x_accounting_coa_id => l_adr_accounting_coa_id
31669 , x_value_type_code => l_adr_value_type_code
31670 , p_side => 'NA'
31671 );
31672
31673 xla_ae_lines_pkg.set_ccid(
31674 p_code_combination_id => l_ccid
31675 , p_value_type_code => l_adr_value_type_code
31676 , p_transaction_coa_id => l_adr_transaction_coa_id
31677 , p_accounting_coa_id => l_adr_accounting_coa_id
31678 , p_adr_code => 'DIST_CCID'
31679 , p_adr_type_code => 'S'
31680 , p_component_type => l_component_type
31681 , p_component_code => l_component_code
31682 , p_component_type_code => l_component_type_code
31683 , p_component_appl_id => l_component_appl_id
31684 , p_amb_context_code => l_amb_context_code
31685 , p_side => 'NA'
31686 );
31687
31688
31689 l_segment := AcctDerRule_22(
31690 p_application_id => p_application_id
31691 , p_ae_header_id => l_ae_header_id
31692 , p_source_11 => p_source_11
31693 , p_source_12 => p_source_12
31694 , p_source_13 => p_source_13
31695 , p_source_14 => p_source_14
31696 , x_transaction_coa_id => l_adr_transaction_coa_id
31697 , x_accounting_coa_id => l_adr_accounting_coa_id
31698 , x_flexfield_segment_code => l_adr_flexfield_segment_code
31699 , x_flex_value_set_id => l_adr_flex_value_set_id
31700 , x_value_type_code => l_adr_value_type_code
31701 , x_value_combination_id => l_adr_value_combination_id
31702 , x_value_segment_code => l_adr_value_segment_code
31703 , p_side => 'NA'
31704 , p_override_seg_flag => 'Y'
31705 );
31706
31707 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
31708
31709 xla_ae_lines_pkg.set_segment(
31710 p_to_segment_code => 'GL_ACCOUNT'
31711 , p_segment_value => l_segment
31712 , p_from_segment_code => l_adr_value_segment_code
31713 , p_from_combination_id => l_adr_value_combination_id
31714 , p_value_type_code => l_adr_value_type_code
31715 , p_transaction_coa_id => l_adr_transaction_coa_id
31716 , p_accounting_coa_id => l_adr_accounting_coa_id
31717 , p_flexfield_segment_code => l_adr_flexfield_segment_code
31718 , p_flex_value_set_id => l_adr_flex_value_set_id
31719 , p_adr_code => 'FV_AR_4X7201_RCT_DR'
31720 , p_adr_type_code => 'S'
31721 , p_component_type => l_component_type
31722 , p_component_code => l_component_code
31723 , p_component_type_code => l_component_type_code
31724 , p_component_appl_id => l_component_appl_id
31725 , p_amb_context_code => l_amb_context_code
31726 , p_entity_code => 'RECEIPTS'
31727 , p_event_class_code => 'RECEIPT'
31728 , p_side => 'NA'
31729 );
31730
31731 END IF;
31732
31733 --
31734 --
31735 END IF;
31736 --
31737 -- Bug 4922099
31738 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
31739 (NVL(l_enc_upg_option, 'N') = 'O')
31740 ) AND
31741 (l_bflow_method_code = 'PRIOR_ENTRY')
31742 )
31743 THEN
31744 IF
31745 --
31746 1 = 2
31747 --
31748 THEN
31749 xla_accounting_err_pkg.build_message
31750 (p_appli_s_name => 'XLA'
31751 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31752 ,p_token_1 => 'LINE_NUMBER'
31753 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
31754 ,p_token_2 => 'LINE_TYPE_NAME'
31755 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
31756 l_component_type
31757 ,l_component_code
31758 ,l_component_type_code
31759 ,l_component_appl_id
31760 ,l_amb_context_code
31761 ,l_entity_code
31762 ,l_event_class_code
31763 )
31764 ,p_token_3 => 'OWNER'
31765 ,p_value_3 => xla_lookups_pkg.get_meaning(
31766 p_lookup_type => 'XLA_OWNER_TYPE'
31767 ,p_lookup_code => l_component_type_code
31768 )
31769 ,p_token_4 => 'PRODUCT_NAME'
31770 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
31771 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
31772 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
31773 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
31774 ,p_ae_header_id => NULL
31775 );
31776
31777 IF (C_LEVEL_ERROR>= g_log_level) THEN
31778 trace
31779 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
31780 ,p_level => C_LEVEL_ERROR
31781 ,p_module => l_log_module);
31782 END IF;
31783 END IF;
31784 END IF;
31785 --
31786 --
31787 ------------------------------------------------------------------------------------------------
31788 -- 4219869 Business Flow
31789 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
31790 -- Prior Entry. Currently, the following code is always generated.
31791 ------------------------------------------------------------------------------------------------
31792 XLA_AE_LINES_PKG.ValidateCurrentLine;
31793
31794 ------------------------------------------------------------------------------------
31795 -- 4219869 Business Flow
31796 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
31797 ------------------------------------------------------------------------------------
31798 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31799
31800 ----------------------------------------------------------------------------------
31801 -- 4219869 Business Flow
31802 -- Update journal entry status -- Need to generate this within IF <condition>
31803 ----------------------------------------------------------------------------------
31804 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31805 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
31806 ,p_balance_type_code => l_balance_type_code
31807 );
31808
31809 -------------------------------------------------------------------------------------------
31810 -- 4262811 - Generate the Accrual Reversal lines
31811 -------------------------------------------------------------------------------------------
31812 BEGIN
31813 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
31814 (g_array_event(p_event_id).array_value_num('header_index'));
31815 IF l_acc_rev_flag IS NULL THEN
31816 l_acc_rev_flag := 'N';
31817 END IF;
31818 EXCEPTION
31819 WHEN OTHERS THEN
31820 l_acc_rev_flag := 'N';
31821 END;
31822 --
31823 IF (l_acc_rev_flag = 'Y') THEN
31824
31825 -- 4645092 ------------------------------------------------------------------------------
31826 -- To allow MPA report to determine if it should generate report process
31827 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
31828 ------------------------------------------------------------------------------------------
31829
31830 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
31831 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
31832 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
31833 -- call ADRs
31834 -- Bug 4922099
31835 --
31836 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
31837 (NVL(l_actual_upg_option, 'N') = 'O') OR
31838 (NVL(l_enc_upg_option, 'N') = 'O')
31839 )
31840 THEN
31841 NULL;
31842 --
31843 --
31844
31845 l_ccid := AcctDerRule_4(
31846 p_application_id => p_application_id
31847 , p_ae_header_id => l_ae_header_id
31848 , p_source_5 => p_source_5
31849 , x_transaction_coa_id => l_adr_transaction_coa_id
31850 , x_accounting_coa_id => l_adr_accounting_coa_id
31851 , x_value_type_code => l_adr_value_type_code
31852 , p_side => 'NA'
31853 );
31854
31855 xla_ae_lines_pkg.set_ccid(
31856 p_code_combination_id => l_ccid
31857 , p_value_type_code => l_adr_value_type_code
31858 , p_transaction_coa_id => l_adr_transaction_coa_id
31859 , p_accounting_coa_id => l_adr_accounting_coa_id
31860 , p_adr_code => 'DIST_CCID'
31861 , p_adr_type_code => 'S'
31862 , p_component_type => l_component_type
31863 , p_component_code => l_component_code
31864 , p_component_type_code => l_component_type_code
31865 , p_component_appl_id => l_component_appl_id
31866 , p_amb_context_code => l_amb_context_code
31867 , p_side => 'NA'
31868 );
31869
31870
31871 l_segment := AcctDerRule_22(
31872 p_application_id => p_application_id
31873 , p_ae_header_id => l_ae_header_id
31874 , p_source_11 => p_source_11
31875 , p_source_12 => p_source_12
31876 , p_source_13 => p_source_13
31877 , p_source_14 => p_source_14
31878 , x_transaction_coa_id => l_adr_transaction_coa_id
31879 , x_accounting_coa_id => l_adr_accounting_coa_id
31880 , x_flexfield_segment_code => l_adr_flexfield_segment_code
31881 , x_flex_value_set_id => l_adr_flex_value_set_id
31882 , x_value_type_code => l_adr_value_type_code
31883 , x_value_combination_id => l_adr_value_combination_id
31884 , x_value_segment_code => l_adr_value_segment_code
31885 , p_side => 'NA'
31886 , p_override_seg_flag => 'Y'
31887 );
31888
31889 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
31890
31891 xla_ae_lines_pkg.set_segment(
31892 p_to_segment_code => 'GL_ACCOUNT'
31893 , p_segment_value => l_segment
31894 , p_from_segment_code => l_adr_value_segment_code
31895 , p_from_combination_id => l_adr_value_combination_id
31896 , p_value_type_code => l_adr_value_type_code
31897 , p_transaction_coa_id => l_adr_transaction_coa_id
31898 , p_accounting_coa_id => l_adr_accounting_coa_id
31899 , p_flexfield_segment_code => l_adr_flexfield_segment_code
31900 , p_flex_value_set_id => l_adr_flex_value_set_id
31901 , p_adr_code => 'FV_AR_4X7201_RCT_DR'
31902 , p_adr_type_code => 'S'
31903 , p_component_type => l_component_type
31904 , p_component_code => l_component_code
31905 , p_component_type_code => l_component_type_code
31906 , p_component_appl_id => l_component_appl_id
31907 , p_amb_context_code => l_amb_context_code
31908 , p_entity_code => 'RECEIPTS'
31909 , p_event_class_code => 'RECEIPT'
31910 , p_side => 'NA'
31911 );
31912
31913 END IF;
31914
31915 --
31916 --
31917 END IF;
31918
31919 --
31920 -- Update the line information that should be overwritten
31921 --
31922 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
31923 p_header_num => 1);
31924 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
31925
31926 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
31927
31928 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
31929 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
31930 END IF;
31931
31932 --
31933 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
31934 --
31935 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
31936 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
31937 ELSE
31938 ---------------------------------------------------------------------------------------------------
31939 -- 4262811a Switch Sign
31940 ---------------------------------------------------------------------------------------------------
31941 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
31942 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31943 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31944 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
31945 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31946 -- 5132302
31947 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
31948 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
31949
31950 END IF;
31951
31952 -- 4955764
31953 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
31954 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
31955
31956
31957 XLA_AE_LINES_PKG.ValidateCurrentLine;
31958 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
31959
31960 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
31961 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
31962 ,p_balance_type_code => l_balance_type_code);
31963
31964 END IF;
31965
31966 -----------------------------------------------------------------------------------------
31967 -- 4262811 Multiperiod Accounting
31968 -----------------------------------------------------------------------------------------
31969 -- No MPA option is assigned.
31970
31971
31972 END IF;
31973 END IF;
31974 --
31975
31976 --
31977 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
31978 trace
31979 (p_msg => 'END of AcctLineType_75'
31980 ,p_level => C_LEVEL_PROCEDURE
31981 ,p_module => l_log_module);
31982 END IF;
31983 --
31984 EXCEPTION
31985 WHEN xla_exceptions_pkg.application_exception THEN
31986 RAISE;
31987 WHEN OTHERS THEN
31988 xla_exceptions_pkg.raise_message
31989 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_75');
31990 END AcctLineType_75;
31991 --
31992
31993 ---------------------------------------
31994 --
31995 -- PRIVATE FUNCTION
31996 -- AcctLineType_76
31997 --
31998 ---------------------------------------
31999 PROCEDURE AcctLineType_76 (
32000 p_application_id IN NUMBER
32001 ,p_event_id IN NUMBER
32002 ,p_calculate_acctd_flag IN VARCHAR2
32003 ,p_calculate_g_l_flag IN VARCHAR2
32004 ,p_actual_flag IN OUT VARCHAR2
32005 ,p_balance_type_code OUT VARCHAR2
32006 ,p_gain_or_loss_ref OUT VARCHAR2
32007
32008 --Distribution GL Account
32009 , p_source_5 IN NUMBER
32010 --Federal Account Rule
32011 , p_source_11 IN VARCHAR2
32012 --Federal Fund Expired Status
32013 , p_source_12 IN VARCHAR2
32014 --Federal Prior Year Flag
32015 , p_source_13 IN VARCHAR2
32016 --Federal Fund Time Frame
32017 , p_source_14 IN VARCHAR2
32018 --Federal Apportionment Category
32019 , p_source_15 IN VARCHAR2
32020 --Distribution Source Type
32021 , p_source_20 IN VARCHAR2
32022 --Distribution Line Identifier
32023 , p_source_22 IN NUMBER
32024 --Distribution Type
32025 , p_source_23 IN VARCHAR2
32026 --Entered Amount
32027 , p_source_24 IN NUMBER
32028 --Exchange Rate Type
32029 , p_source_28 IN VARCHAR2
32030 --Applied To Document Accounting Amount
32031 , p_source_29 IN NUMBER
32032 --Transaction Distribution Account Class
32033 , p_source_33 IN VARCHAR2
32034 --Transaction Distribution Identifier
32035 , p_source_34 IN NUMBER
32036 --Transaction Distribution Type
32037 , p_source_35 IN VARCHAR2
32038 --Federal Account Valid Flag
32039 , p_source_56 IN VARCHAR2
32040 --Applied To Document Exchange Date
32041 , p_source_57 IN DATE
32042 --Receipt Applied To Application Identifier
32043 , p_source_58 IN NUMBER
32044 --Transaction Entity Code
32045 , p_source_59 IN VARCHAR2
32046 --Transaction Identifier
32047 , p_source_60 IN NUMBER
32048 --Applying Document Currency Code
32049 , p_source_61 IN VARCHAR2
32050 --Applied To Document Exchange Rate
32051 , p_source_62 IN NUMBER
32052 --Distribution Party Identifier
32053 , p_source_63 IN NUMBER
32054 --Distribution Party Site Id
32055 , p_source_64 IN NUMBER
32056 --Distribution Party Type
32057 , p_source_65 IN VARCHAR2
32058 )
32059 IS
32060
32061 l_component_type VARCHAR2(80);
32062 l_component_code VARCHAR2(30);
32063 l_component_type_code VARCHAR2(1);
32064 l_component_appl_id INTEGER;
32065 l_amb_context_code VARCHAR2(30);
32066 l_entity_code VARCHAR2(30);
32067 l_event_class_code VARCHAR2(30);
32068 l_ae_header_id NUMBER;
32069 l_event_type_code VARCHAR2(30);
32070 l_line_definition_code VARCHAR2(30);
32071 l_line_definition_owner_code VARCHAR2(1);
32072 --
32073 -- adr variables
32074 l_segment VARCHAR2(30);
32075 l_ccid NUMBER;
32076 l_adr_transaction_coa_id NUMBER;
32077 l_adr_accounting_coa_id NUMBER;
32078 l_adr_flexfield_segment_code VARCHAR2(30);
32079 l_adr_flex_value_set_id NUMBER;
32080 l_adr_value_type_code VARCHAR2(30);
32081 l_adr_value_combination_id NUMBER;
32082 l_adr_value_segment_code VARCHAR2(30);
32083
32084 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
32085 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
32086 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
32087 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
32088
32089 -- 4262811 Variables ------------------------------------------------------------------------------------------
32090 l_entered_amt_idx NUMBER;
32091 l_accted_amt_idx NUMBER;
32092 l_acc_rev_flag VARCHAR2(1);
32093 l_accrual_line_num NUMBER;
32094 l_tmp_amt NUMBER;
32095 l_acc_rev_natural_side_code VARCHAR2(1);
32096
32097 l_num_entries NUMBER;
32098 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
32099 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
32100 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
32101 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
32102 l_recog_line_1 NUMBER;
32103 l_recog_line_2 NUMBER;
32104
32105 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
32106 l_bflow_applied_to_amt NUMBER; -- 5132302
32107 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
32108
32109 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
32110
32111 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
32112 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
32113
32114 ---------------------------------------------------------------------------------------------------------------
32115
32116
32117 --
32118 -- bulk performance
32119 --
32120 l_balance_type_code VARCHAR2(1);
32121 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
32122 l_log_module VARCHAR2(240);
32123
32124 --
32125 -- Upgrade strategy
32126 --
32127 l_actual_upg_option VARCHAR2(1);
32128 l_enc_upg_option VARCHAR2(1);
32129
32130 --
32131 BEGIN
32132 --
32133 IF g_log_enabled THEN
32134 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_76';
32135 END IF;
32136 --
32137 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32138
32139 trace
32140 (p_msg => 'BEGIN of AcctLineType_76'
32141 ,p_level => C_LEVEL_PROCEDURE
32142 ,p_module => l_log_module);
32143
32144 END IF;
32145 --
32146 l_component_type := 'AMB_JLT';
32147 l_component_code := 'FV_RCT_REF_OAP_UFC_CR';
32148 l_component_type_code := 'S';
32149 l_component_appl_id := 222;
32150 l_amb_context_code := 'DEFAULT';
32151 l_entity_code := 'RECEIPTS';
32152 l_event_class_code := 'RECEIPT';
32153 l_event_type_code := 'RECEIPT_ALL';
32154 l_line_definition_owner_code := 'S';
32155 l_line_definition_code := 'FEDERAL_AR_RCT_DEFAULT_ACCRUAL';
32156 --
32157 l_balance_type_code := 'A';
32158 l_segment := NULL;
32159 l_ccid := NULL;
32160 l_adr_transaction_coa_id := NULL;
32161 l_adr_accounting_coa_id := NULL;
32162 l_adr_flexfield_segment_code := NULL;
32163 l_adr_flex_value_set_id := NULL;
32164 l_adr_value_type_code := NULL;
32165 l_adr_value_combination_id := NULL;
32166 l_adr_value_segment_code := NULL;
32167
32168 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
32169 l_bflow_class_code := ''; -- 4219869 Business Flow
32170 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
32171 l_budgetary_control_flag := 'N';
32172
32173 l_bflow_applied_to_amt_idx := NULL; -- 5132302
32174 l_bflow_applied_to_amt := NULL; -- 5132302
32175 l_entered_amt_idx := NULL; -- 4262811
32176 l_accted_amt_idx := NULL; -- 4262811
32177 l_acc_rev_flag := NULL; -- 4262811
32178 l_accrual_line_num := NULL; -- 4262811
32179 l_tmp_amt := NULL; -- 4262811
32180 --
32181
32182 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
32183 l_balance_type_code <> 'B' THEN
32184 IF NVL(p_source_20,'
32185 ') = 'REC' AND
32186 NVL(p_source_33,'
32187 ') = 'REV' AND
32188 NVL(p_source_12,'
32189 ') = 'Unexpired' AND
32190 NVL(p_source_13,'
32191 ') = 'N' AND
32192 (NVL(p_source_15,'
32193 ') = 'A' OR
32194 NVL(p_source_15,'
32195 ') = 'B' OR
32196 NVL(p_source_15,'
32197 ') = 'C') AND
32198 (NVL(p_source_14,'
32199 ') = 'SINGLE' OR
32200 NVL(p_source_14,'
32201 ') = 'MUTIPLE' OR
32202 NVL(p_source_14,'
32203 ') = 'NO_YEAR') AND
32204 (NVL(p_source_11,'
32205 ') = 'Overpayment Refund' OR
32206 NVL(p_source_11,'
32207 ') = 'Advance Refund') AND
32208 NVL(p_source_56,'
32209 ') = 'Y'
32210 THEN
32211
32212 --
32213 XLA_AE_LINES_PKG.SetNewLine;
32214
32215 p_balance_type_code := l_balance_type_code;
32216 -- set the flag so later we will know whether the gain loss line needs to be created
32217
32218 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
32219 p_actual_flag :='A';
32220 END IF;
32221
32222 --
32223 -- bulk performance
32224 --
32225 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
32226 p_header_num => 0); -- 4262811
32227 --
32228 -- set accounting line options
32229 --
32230 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
32231 p_natural_side_code => 'C'
32232 , p_gain_or_loss_flag => 'N'
32233 , p_gl_transfer_mode_code => 'S'
32234 , p_acct_entry_type_code => 'A'
32235 , p_switch_side_flag => 'Y'
32236 , p_merge_duplicate_code => 'A'
32237 );
32238 --
32239 l_acc_rev_natural_side_code := 'D'; -- 4262811
32240 --
32241 --
32242 -- set accounting line type info
32243 --
32244 xla_ae_lines_pkg.SetAcctLineType
32245 (p_component_type => l_component_type
32246 ,p_event_type_code => l_event_type_code
32247 ,p_line_definition_owner_code => l_line_definition_owner_code
32248 ,p_line_definition_code => l_line_definition_code
32249 ,p_accounting_line_code => l_component_code
32250 ,p_accounting_line_type_code => l_component_type_code
32251 ,p_accounting_line_appl_id => l_component_appl_id
32252 ,p_amb_context_code => l_amb_context_code
32253 ,p_entity_code => l_entity_code
32254 ,p_event_class_code => l_event_class_code);
32255 --
32256 -- set accounting class
32257 --
32258 xla_ae_lines_pkg.SetAcctClass(
32259 p_accounting_class_code => 'FV_CASH_CR'
32260 , p_ae_header_id => l_ae_header_id
32261 );
32262
32263 --
32264 -- set rounding class
32265 --
32266 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
32267 'RECEIVABLE';
32268
32269 --
32270 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
32271 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
32272 --
32273 -- bulk performance
32274 --
32275 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
32276
32277 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
32278 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
32279
32280 -- 4955764
32281 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32282 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
32283
32284 -- 4458381 Public Sector Enh
32285
32286 --
32287 -- set accounting attributes for the line type
32288 --
32289 l_entered_amt_idx := 8;
32290 l_accted_amt_idx := 13;
32291 l_bflow_applied_to_amt_idx := NULL; -- 5132302
32292 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
32293 l_rec_acct_attrs.array_num_value(1) := p_source_58;
32294 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
32295 l_rec_acct_attrs.array_char_value(2) := p_source_35;
32296 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
32300 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
32297 l_rec_acct_attrs.array_char_value(3) := p_source_59;
32298 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
32299 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
32301 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
32302 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
32303 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
32304 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
32305 l_rec_acct_attrs.array_char_value(7) := p_source_23;
32306 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
32307 l_rec_acct_attrs.array_num_value(8) := p_source_24;
32308 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
32309 l_rec_acct_attrs.array_char_value(9) := p_source_61;
32310 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
32311 l_rec_acct_attrs.array_date_value(10) := p_source_57;
32312 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
32313 l_rec_acct_attrs.array_num_value(11) := p_source_62;
32314 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
32315 l_rec_acct_attrs.array_char_value(12) := p_source_28;
32316 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
32317 l_rec_acct_attrs.array_num_value(13) := p_source_29;
32318 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
32319 l_rec_acct_attrs.array_num_value(14) := p_source_63;
32320 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
32321 l_rec_acct_attrs.array_num_value(15) := p_source_64;
32322 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
32323 l_rec_acct_attrs.array_char_value(16) := p_source_65;
32324
32325 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
32326 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
32327
32328 ---------------------------------------------------------------------------------------------------------------
32329 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
32330 ---------------------------------------------------------------------------------------------------------------
32331 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
32332
32333 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32334 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
32335
32336 IF xla_accounting_cache_pkg.GetValueChar
32337 (p_source_code => 'LEDGER_CATEGORY_CODE'
32338 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
32339 AND l_bflow_method_code = 'PRIOR_ENTRY'
32340 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
32341 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
32342 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
32343 )
32344 THEN
32345 xla_ae_lines_pkg.BflowUpgEntry
32346 (p_business_method_code => l_bflow_method_code
32347 ,p_business_class_code => l_bflow_class_code
32348 ,p_balance_type => l_balance_type_code);
32349 ELSE
32350 NULL;
32351 -- No business flow processing for business flow method of NONE.
32352 END IF;
32353
32354 --
32355 -- call analytical criteria
32356 --
32357
32358 --
32359 -- call description
32360 --
32361 -- No description or it is inherited.
32362 --
32363 -- call ADRs
32364 -- Bug 4922099
32365 --
32366 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32367 (NVL(l_actual_upg_option, 'N') = 'O') OR
32368 (NVL(l_enc_upg_option, 'N') = 'O')
32369 )
32370 THEN
32371 NULL;
32372 --
32373 --
32374
32375 l_ccid := AcctDerRule_4(
32376 p_application_id => p_application_id
32377 , p_ae_header_id => l_ae_header_id
32378 , p_source_5 => p_source_5
32379 , x_transaction_coa_id => l_adr_transaction_coa_id
32380 , x_accounting_coa_id => l_adr_accounting_coa_id
32381 , x_value_type_code => l_adr_value_type_code
32382 , p_side => 'NA'
32383 );
32384
32385 xla_ae_lines_pkg.set_ccid(
32386 p_code_combination_id => l_ccid
32387 , p_value_type_code => l_adr_value_type_code
32388 , p_transaction_coa_id => l_adr_transaction_coa_id
32389 , p_accounting_coa_id => l_adr_accounting_coa_id
32390 , p_adr_code => 'DIST_CCID'
32391 , p_adr_type_code => 'S'
32392 , p_component_type => l_component_type
32393 , p_component_code => l_component_code
32394 , p_component_type_code => l_component_type_code
32395 , p_component_appl_id => l_component_appl_id
32396 , p_amb_context_code => l_amb_context_code
32397 , p_side => 'NA'
32398 );
32399
32400
32401 l_segment := AcctDerRule_18(
32402 p_application_id => p_application_id
32403 , p_ae_header_id => l_ae_header_id
32404 , p_source_12 => p_source_12
32405 , p_source_13 => p_source_13
32406 , p_source_14 => p_source_14
32407 , p_source_15 => p_source_15
32408 , x_transaction_coa_id => l_adr_transaction_coa_id
32409 , x_accounting_coa_id => l_adr_accounting_coa_id
32410 , x_flexfield_segment_code => l_adr_flexfield_segment_code
32411 , x_flex_value_set_id => l_adr_flex_value_set_id
32412 , x_value_type_code => l_adr_value_type_code
32413 , x_value_combination_id => l_adr_value_combination_id
32414 , x_value_segment_code => l_adr_value_segment_code
32415 , p_side => 'NA'
32416 , p_override_seg_flag => 'Y'
32417 );
32418
32419 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
32420
32421 xla_ae_lines_pkg.set_segment(
32422 p_to_segment_code => 'GL_ACCOUNT'
32423 , p_segment_value => l_segment
32424 , p_from_segment_code => l_adr_value_segment_code
32425 , p_from_combination_id => l_adr_value_combination_id
32426 , p_value_type_code => l_adr_value_type_code
32427 , p_transaction_coa_id => l_adr_transaction_coa_id
32428 , p_accounting_coa_id => l_adr_accounting_coa_id
32429 , p_flexfield_segment_code => l_adr_flexfield_segment_code
32430 , p_flex_value_set_id => l_adr_flex_value_set_id
32431 , p_adr_code => 'FV_AR_46X002_RCT_CR'
32432 , p_adr_type_code => 'S'
32433 , p_component_type => l_component_type
32434 , p_component_code => l_component_code
32435 , p_component_type_code => l_component_type_code
32436 , p_component_appl_id => l_component_appl_id
32437 , p_amb_context_code => l_amb_context_code
32438 , p_entity_code => 'RECEIPTS'
32439 , p_event_class_code => 'RECEIPT'
32440 , p_side => 'NA'
32441 );
32442
32443 END IF;
32444
32445 --
32446 --
32447 END IF;
32448 --
32449 -- Bug 4922099
32450 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
32451 (NVL(l_enc_upg_option, 'N') = 'O')
32452 ) AND
32453 (l_bflow_method_code = 'PRIOR_ENTRY')
32454 )
32455 THEN
32456 IF
32457 --
32458 1 = 2
32459 --
32460 THEN
32461 xla_accounting_err_pkg.build_message
32462 (p_appli_s_name => 'XLA'
32463 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32464 ,p_token_1 => 'LINE_NUMBER'
32465 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
32466 ,p_token_2 => 'LINE_TYPE_NAME'
32467 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
32468 l_component_type
32469 ,l_component_code
32470 ,l_component_type_code
32471 ,l_component_appl_id
32472 ,l_amb_context_code
32473 ,l_entity_code
32474 ,l_event_class_code
32475 )
32476 ,p_token_3 => 'OWNER'
32477 ,p_value_3 => xla_lookups_pkg.get_meaning(
32478 p_lookup_type => 'XLA_OWNER_TYPE'
32479 ,p_lookup_code => l_component_type_code
32480 )
32481 ,p_token_4 => 'PRODUCT_NAME'
32482 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
32483 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
32484 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
32485 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
32486 ,p_ae_header_id => NULL
32487 );
32488
32489 IF (C_LEVEL_ERROR>= g_log_level) THEN
32490 trace
32491 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
32492 ,p_level => C_LEVEL_ERROR
32493 ,p_module => l_log_module);
32494 END IF;
32495 END IF;
32496 END IF;
32497 --
32498 --
32499 ------------------------------------------------------------------------------------------------
32500 -- 4219869 Business Flow
32501 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
32502 -- Prior Entry. Currently, the following code is always generated.
32503 ------------------------------------------------------------------------------------------------
32504 XLA_AE_LINES_PKG.ValidateCurrentLine;
32505
32506 ------------------------------------------------------------------------------------
32507 -- 4219869 Business Flow
32508 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
32509 ------------------------------------------------------------------------------------
32510 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32511
32512 ----------------------------------------------------------------------------------
32513 -- 4219869 Business Flow
32514 -- Update journal entry status -- Need to generate this within IF <condition>
32515 ----------------------------------------------------------------------------------
32516 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32517 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
32518 ,p_balance_type_code => l_balance_type_code
32519 );
32520
32521 -------------------------------------------------------------------------------------------
32522 -- 4262811 - Generate the Accrual Reversal lines
32523 -------------------------------------------------------------------------------------------
32524 BEGIN
32525 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
32526 (g_array_event(p_event_id).array_value_num('header_index'));
32527 IF l_acc_rev_flag IS NULL THEN
32528 l_acc_rev_flag := 'N';
32529 END IF;
32530 EXCEPTION
32531 WHEN OTHERS THEN
32532 l_acc_rev_flag := 'N';
32533 END;
32534 --
32535 IF (l_acc_rev_flag = 'Y') THEN
32536
32537 -- 4645092 ------------------------------------------------------------------------------
32538 -- To allow MPA report to determine if it should generate report process
32539 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
32540 ------------------------------------------------------------------------------------------
32541
32542 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
32543 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
32544 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
32545 -- call ADRs
32546 -- Bug 4922099
32547 --
32548 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
32549 (NVL(l_actual_upg_option, 'N') = 'O') OR
32550 (NVL(l_enc_upg_option, 'N') = 'O')
32551 )
32552 THEN
32553 NULL;
32554 --
32555 --
32556
32557 l_ccid := AcctDerRule_4(
32558 p_application_id => p_application_id
32559 , p_ae_header_id => l_ae_header_id
32560 , p_source_5 => p_source_5
32561 , x_transaction_coa_id => l_adr_transaction_coa_id
32562 , x_accounting_coa_id => l_adr_accounting_coa_id
32563 , x_value_type_code => l_adr_value_type_code
32564 , p_side => 'NA'
32565 );
32566
32567 xla_ae_lines_pkg.set_ccid(
32568 p_code_combination_id => l_ccid
32569 , p_value_type_code => l_adr_value_type_code
32570 , p_transaction_coa_id => l_adr_transaction_coa_id
32571 , p_accounting_coa_id => l_adr_accounting_coa_id
32572 , p_adr_code => 'DIST_CCID'
32573 , p_adr_type_code => 'S'
32574 , p_component_type => l_component_type
32575 , p_component_code => l_component_code
32576 , p_component_type_code => l_component_type_code
32577 , p_component_appl_id => l_component_appl_id
32578 , p_amb_context_code => l_amb_context_code
32579 , p_side => 'NA'
32580 );
32581
32582
32583 l_segment := AcctDerRule_18(
32584 p_application_id => p_application_id
32585 , p_ae_header_id => l_ae_header_id
32586 , p_source_12 => p_source_12
32587 , p_source_13 => p_source_13
32588 , p_source_14 => p_source_14
32589 , p_source_15 => p_source_15
32590 , x_transaction_coa_id => l_adr_transaction_coa_id
32591 , x_accounting_coa_id => l_adr_accounting_coa_id
32592 , x_flexfield_segment_code => l_adr_flexfield_segment_code
32593 , x_flex_value_set_id => l_adr_flex_value_set_id
32594 , x_value_type_code => l_adr_value_type_code
32595 , x_value_combination_id => l_adr_value_combination_id
32596 , x_value_segment_code => l_adr_value_segment_code
32597 , p_side => 'NA'
32598 , p_override_seg_flag => 'Y'
32599 );
32600
32601 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
32602
32603 xla_ae_lines_pkg.set_segment(
32604 p_to_segment_code => 'GL_ACCOUNT'
32605 , p_segment_value => l_segment
32606 , p_from_segment_code => l_adr_value_segment_code
32607 , p_from_combination_id => l_adr_value_combination_id
32608 , p_value_type_code => l_adr_value_type_code
32609 , p_transaction_coa_id => l_adr_transaction_coa_id
32610 , p_accounting_coa_id => l_adr_accounting_coa_id
32611 , p_flexfield_segment_code => l_adr_flexfield_segment_code
32612 , p_flex_value_set_id => l_adr_flex_value_set_id
32613 , p_adr_code => 'FV_AR_46X002_RCT_CR'
32614 , p_adr_type_code => 'S'
32615 , p_component_type => l_component_type
32616 , p_component_code => l_component_code
32617 , p_component_type_code => l_component_type_code
32618 , p_component_appl_id => l_component_appl_id
32619 , p_amb_context_code => l_amb_context_code
32620 , p_entity_code => 'RECEIPTS'
32621 , p_event_class_code => 'RECEIPT'
32622 , p_side => 'NA'
32623 );
32624
32625 END IF;
32626
32627 --
32628 --
32629 END IF;
32630
32631 --
32632 -- Update the line information that should be overwritten
32633 --
32634 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
32635 p_header_num => 1);
32636 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
32637
32638 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
32639
32640 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
32641 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
32642 END IF;
32643
32644 --
32645 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
32646 --
32647 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
32648 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
32649 ELSE
32650 ---------------------------------------------------------------------------------------------------
32651 -- 4262811a Switch Sign
32652 ---------------------------------------------------------------------------------------------------
32653 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
32654 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32655 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32656 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
32657 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32658 -- 5132302
32659 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
32660 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
32661
32662 END IF;
32663
32664 -- 4955764
32665 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32666 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
32667
32668
32669 XLA_AE_LINES_PKG.ValidateCurrentLine;
32670 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
32671
32672 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
32673 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
32674 ,p_balance_type_code => l_balance_type_code);
32675
32676 END IF;
32677
32678 -----------------------------------------------------------------------------------------
32679 -- 4262811 Multiperiod Accounting
32680 -----------------------------------------------------------------------------------------
32681 -- No MPA option is assigned.
32682
32683
32684 END IF;
32685 END IF;
32686 --
32687
32688 --
32689 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32690 trace
32691 (p_msg => 'END of AcctLineType_76'
32692 ,p_level => C_LEVEL_PROCEDURE
32693 ,p_module => l_log_module);
32694 END IF;
32695 --
32696 EXCEPTION
32697 WHEN xla_exceptions_pkg.application_exception THEN
32698 RAISE;
32699 WHEN OTHERS THEN
32700 xla_exceptions_pkg.raise_message
32701 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_76');
32702 END AcctLineType_76;
32703 --
32704
32705 ---------------------------------------
32706 --
32707 -- PRIVATE FUNCTION
32708 -- AcctLineType_77
32709 --
32710 ---------------------------------------
32711 PROCEDURE AcctLineType_77 (
32712 p_application_id IN NUMBER
32713 ,p_event_id IN NUMBER
32714 ,p_calculate_acctd_flag IN VARCHAR2
32715 ,p_calculate_g_l_flag IN VARCHAR2
32716 ,p_actual_flag IN OUT VARCHAR2
32717 ,p_balance_type_code OUT VARCHAR2
32718 ,p_gain_or_loss_ref OUT VARCHAR2
32719
32720 --Distribution GL Account
32721 , p_source_5 IN NUMBER
32722 --Federal Account Rule
32723 , p_source_11 IN VARCHAR2
32724 --Federal Fund Expired Status
32725 , p_source_12 IN VARCHAR2
32726 --Federal Prior Year Flag
32727 , p_source_13 IN VARCHAR2
32728 --Federal Fund Time Frame
32729 , p_source_14 IN VARCHAR2
32730 --Federal Apportionment Category
32731 , p_source_15 IN VARCHAR2
32732 --Distribution Source Type
32733 , p_source_20 IN VARCHAR2
32734 --Distribution Line Identifier
32735 , p_source_22 IN NUMBER
32736 --Distribution Type
32737 , p_source_23 IN VARCHAR2
32738 --Entered Amount
32739 , p_source_24 IN NUMBER
32740 --Exchange Rate Type
32741 , p_source_28 IN VARCHAR2
32742 --Applied To Document Accounting Amount
32743 , p_source_29 IN NUMBER
32744 --Transaction Distribution Account Class
32745 , p_source_33 IN VARCHAR2
32746 --Transaction Distribution Identifier
32747 , p_source_34 IN NUMBER
32748 --Transaction Distribution Type
32749 , p_source_35 IN VARCHAR2
32750 --Federal Account Valid Flag
32751 , p_source_56 IN VARCHAR2
32752 --Applied To Document Exchange Date
32753 , p_source_57 IN DATE
32754 --Receipt Applied To Application Identifier
32755 , p_source_58 IN NUMBER
32756 --Transaction Entity Code
32757 , p_source_59 IN VARCHAR2
32758 --Transaction Identifier
32759 , p_source_60 IN NUMBER
32760 --Applying Document Currency Code
32761 , p_source_61 IN VARCHAR2
32762 --Applied To Document Exchange Rate
32763 , p_source_62 IN NUMBER
32764 --Distribution Party Identifier
32765 , p_source_63 IN NUMBER
32766 --Distribution Party Site Id
32767 , p_source_64 IN NUMBER
32768 --Distribution Party Type
32769 , p_source_65 IN VARCHAR2
32770 )
32771 IS
32772
32773 l_component_type VARCHAR2(80);
32774 l_component_code VARCHAR2(30);
32775 l_component_type_code VARCHAR2(1);
32776 l_component_appl_id INTEGER;
32777 l_amb_context_code VARCHAR2(30);
32778 l_entity_code VARCHAR2(30);
32779 l_event_class_code VARCHAR2(30);
32780 l_ae_header_id NUMBER;
32781 l_event_type_code VARCHAR2(30);
32782 l_line_definition_code VARCHAR2(30);
32783 l_line_definition_owner_code VARCHAR2(1);
32784 --
32785 -- adr variables
32786 l_segment VARCHAR2(30);
32787 l_ccid NUMBER;
32788 l_adr_transaction_coa_id NUMBER;
32789 l_adr_accounting_coa_id NUMBER;
32790 l_adr_flexfield_segment_code VARCHAR2(30);
32791 l_adr_flex_value_set_id NUMBER;
32792 l_adr_value_type_code VARCHAR2(30);
32793 l_adr_value_combination_id NUMBER;
32794 l_adr_value_segment_code VARCHAR2(30);
32795
32796 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
32797 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
32798 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
32799 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
32800
32801 -- 4262811 Variables ------------------------------------------------------------------------------------------
32802 l_entered_amt_idx NUMBER;
32803 l_accted_amt_idx NUMBER;
32804 l_acc_rev_flag VARCHAR2(1);
32805 l_accrual_line_num NUMBER;
32806 l_tmp_amt NUMBER;
32807 l_acc_rev_natural_side_code VARCHAR2(1);
32808
32809 l_num_entries NUMBER;
32810 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
32811 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
32812 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
32813 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
32814 l_recog_line_1 NUMBER;
32815 l_recog_line_2 NUMBER;
32816
32817 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
32818 l_bflow_applied_to_amt NUMBER; -- 5132302
32819 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
32820
32821 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
32822
32823 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
32824 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
32825
32826 ---------------------------------------------------------------------------------------------------------------
32827
32828
32829 --
32830 -- bulk performance
32831 --
32832 l_balance_type_code VARCHAR2(1);
32833 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
32834 l_log_module VARCHAR2(240);
32835
32836 --
32837 -- Upgrade strategy
32838 --
32839 l_actual_upg_option VARCHAR2(1);
32840 l_enc_upg_option VARCHAR2(1);
32841
32842 --
32843 BEGIN
32844 --
32845 IF g_log_enabled THEN
32846 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_77';
32847 END IF;
32848 --
32849 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
32850
32851 trace
32852 (p_msg => 'BEGIN of AcctLineType_77'
32853 ,p_level => C_LEVEL_PROCEDURE
32854 ,p_module => l_log_module);
32855
32856 END IF;
32857 --
32858 l_component_type := 'AMB_JLT';
32859 l_component_code := 'FV_RCT_REF_OAP_UFC_DR';
32860 l_component_type_code := 'S';
32861 l_component_appl_id := 222;
32862 l_amb_context_code := 'DEFAULT';
32863 l_entity_code := 'RECEIPTS';
32864 l_event_class_code := 'RECEIPT';
32865 l_event_type_code := 'RECEIPT_ALL';
32866 l_line_definition_owner_code := 'S';
32867 l_line_definition_code := 'FEDERAL_AR_RCT_DEFAULT_ACCRUAL';
32868 --
32869 l_balance_type_code := 'A';
32870 l_segment := NULL;
32871 l_ccid := NULL;
32872 l_adr_transaction_coa_id := NULL;
32873 l_adr_accounting_coa_id := NULL;
32874 l_adr_flexfield_segment_code := NULL;
32875 l_adr_flex_value_set_id := NULL;
32876 l_adr_value_type_code := NULL;
32877 l_adr_value_combination_id := NULL;
32878 l_adr_value_segment_code := NULL;
32879
32880 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
32881 l_bflow_class_code := ''; -- 4219869 Business Flow
32882 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
32883 l_budgetary_control_flag := 'N';
32884
32885 l_bflow_applied_to_amt_idx := NULL; -- 5132302
32886 l_bflow_applied_to_amt := NULL; -- 5132302
32887 l_entered_amt_idx := NULL; -- 4262811
32888 l_accted_amt_idx := NULL; -- 4262811
32889 l_acc_rev_flag := NULL; -- 4262811
32890 l_accrual_line_num := NULL; -- 4262811
32891 l_tmp_amt := NULL; -- 4262811
32892 --
32893
32894 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
32895 l_balance_type_code <> 'B' THEN
32896 IF NVL(p_source_20,'
32897 ') = 'REC' AND
32898 NVL(p_source_33,'
32899 ') = 'REV' AND
32900 NVL(p_source_12,'
32901 ') = 'Unexpired' AND
32902 NVL(p_source_13,'
32903 ') = 'N' AND
32904 (NVL(p_source_15,'
32905 ') = 'A' OR
32906 NVL(p_source_15,'
32907 ') = 'B' OR
32908 NVL(p_source_15,'
32909 ') = 'C') AND
32910 (NVL(p_source_14,'
32911 ') = 'SINGLE' OR
32912 NVL(p_source_14,'
32913 ') = 'MUTIPLE' OR
32914 NVL(p_source_14,'
32915 ') = 'NO_YEAR') AND
32916 (NVL(p_source_11,'
32917 ') = 'Overpayment Refund' OR
32918 NVL(p_source_11,'
32919 ') = 'Advance Refund') AND
32920 NVL(p_source_56,'
32921 ') = 'Y'
32922 THEN
32923
32924 --
32925 XLA_AE_LINES_PKG.SetNewLine;
32926
32927 p_balance_type_code := l_balance_type_code;
32928 -- set the flag so later we will know whether the gain loss line needs to be created
32929
32930 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
32931 p_actual_flag :='A';
32932 END IF;
32933
32934 --
32935 -- bulk performance
32936 --
32937 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
32938 p_header_num => 0); -- 4262811
32939 --
32940 -- set accounting line options
32941 --
32942 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
32943 p_natural_side_code => 'D'
32944 , p_gain_or_loss_flag => 'N'
32945 , p_gl_transfer_mode_code => 'S'
32946 , p_acct_entry_type_code => 'A'
32947 , p_switch_side_flag => 'Y'
32948 , p_merge_duplicate_code => 'A'
32949 );
32950 --
32951 l_acc_rev_natural_side_code := 'C'; -- 4262811
32952 --
32953 --
32954 -- set accounting line type info
32955 --
32956 xla_ae_lines_pkg.SetAcctLineType
32957 (p_component_type => l_component_type
32958 ,p_event_type_code => l_event_type_code
32959 ,p_line_definition_owner_code => l_line_definition_owner_code
32960 ,p_line_definition_code => l_line_definition_code
32964 ,p_amb_context_code => l_amb_context_code
32961 ,p_accounting_line_code => l_component_code
32962 ,p_accounting_line_type_code => l_component_type_code
32963 ,p_accounting_line_appl_id => l_component_appl_id
32965 ,p_entity_code => l_entity_code
32966 ,p_event_class_code => l_event_class_code);
32967 --
32968 -- set accounting class
32969 --
32970 xla_ae_lines_pkg.SetAcctClass(
32971 p_accounting_class_code => 'FV_CASH_DR'
32972 , p_ae_header_id => l_ae_header_id
32973 );
32974
32975 --
32976 -- set rounding class
32977 --
32978 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
32979 'RECEIVABLE';
32980
32981 --
32982 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
32983 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
32984 --
32985 -- bulk performance
32986 --
32987 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
32988
32989 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
32990 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
32991
32992 -- 4955764
32993 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
32994 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
32995
32996 -- 4458381 Public Sector Enh
32997
32998 --
32999 -- set accounting attributes for the line type
33000 --
33001 l_entered_amt_idx := 8;
33002 l_accted_amt_idx := 13;
33003 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33004 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
33005 l_rec_acct_attrs.array_num_value(1) := p_source_58;
33006 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
33007 l_rec_acct_attrs.array_char_value(2) := p_source_35;
33008 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
33009 l_rec_acct_attrs.array_char_value(3) := p_source_59;
33010 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
33011 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
33012 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
33013 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
33014 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
33015 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
33016 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
33017 l_rec_acct_attrs.array_char_value(7) := p_source_23;
33018 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
33019 l_rec_acct_attrs.array_num_value(8) := p_source_24;
33020 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
33021 l_rec_acct_attrs.array_char_value(9) := p_source_61;
33022 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
33023 l_rec_acct_attrs.array_date_value(10) := p_source_57;
33024 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
33025 l_rec_acct_attrs.array_num_value(11) := p_source_62;
33026 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
33027 l_rec_acct_attrs.array_char_value(12) := p_source_28;
33028 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
33029 l_rec_acct_attrs.array_num_value(13) := p_source_29;
33030 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
33031 l_rec_acct_attrs.array_num_value(14) := p_source_63;
33032 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
33033 l_rec_acct_attrs.array_num_value(15) := p_source_64;
33034 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
33035 l_rec_acct_attrs.array_char_value(16) := p_source_65;
33036
33037 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
33038 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
33039
33040 ---------------------------------------------------------------------------------------------------------------
33041 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
33042 ---------------------------------------------------------------------------------------------------------------
33043 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
33044
33045 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33046 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33047
33048 IF xla_accounting_cache_pkg.GetValueChar
33049 (p_source_code => 'LEDGER_CATEGORY_CODE'
33050 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
33051 AND l_bflow_method_code = 'PRIOR_ENTRY'
33052 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
33053 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
33054 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
33055 )
33056 THEN
33057 xla_ae_lines_pkg.BflowUpgEntry
33058 (p_business_method_code => l_bflow_method_code
33059 ,p_business_class_code => l_bflow_class_code
33060 ,p_balance_type => l_balance_type_code);
33061 ELSE
33062 NULL;
33063 -- No business flow processing for business flow method of NONE.
33064 END IF;
33065
33066 --
33067 -- call analytical criteria
33068 --
33069
33070 --
33071 -- call description
33075 -- call ADRs
33072 --
33073 -- No description or it is inherited.
33074 --
33076 -- Bug 4922099
33077 --
33078 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33079 (NVL(l_actual_upg_option, 'N') = 'O') OR
33080 (NVL(l_enc_upg_option, 'N') = 'O')
33081 )
33082 THEN
33083 NULL;
33084 --
33085 --
33086
33087 l_ccid := AcctDerRule_4(
33088 p_application_id => p_application_id
33089 , p_ae_header_id => l_ae_header_id
33090 , p_source_5 => p_source_5
33091 , x_transaction_coa_id => l_adr_transaction_coa_id
33092 , x_accounting_coa_id => l_adr_accounting_coa_id
33093 , x_value_type_code => l_adr_value_type_code
33094 , p_side => 'NA'
33095 );
33096
33097 xla_ae_lines_pkg.set_ccid(
33098 p_code_combination_id => l_ccid
33099 , p_value_type_code => l_adr_value_type_code
33100 , p_transaction_coa_id => l_adr_transaction_coa_id
33101 , p_accounting_coa_id => l_adr_accounting_coa_id
33102 , p_adr_code => 'DIST_CCID'
33103 , p_adr_type_code => 'S'
33104 , p_component_type => l_component_type
33105 , p_component_code => l_component_code
33106 , p_component_type_code => l_component_type_code
33107 , p_component_appl_id => l_component_appl_id
33108 , p_amb_context_code => l_amb_context_code
33109 , p_side => 'NA'
33110 );
33111
33112
33113 l_segment := AcctDerRule_21(
33114 p_application_id => p_application_id
33115 , p_ae_header_id => l_ae_header_id
33116 , p_source_11 => p_source_11
33117 , p_source_12 => p_source_12
33118 , p_source_13 => p_source_13
33119 , p_source_14 => p_source_14
33120 , p_source_15 => p_source_15
33121 , x_transaction_coa_id => l_adr_transaction_coa_id
33122 , x_accounting_coa_id => l_adr_accounting_coa_id
33123 , x_flexfield_segment_code => l_adr_flexfield_segment_code
33124 , x_flex_value_set_id => l_adr_flex_value_set_id
33125 , x_value_type_code => l_adr_value_type_code
33126 , x_value_combination_id => l_adr_value_combination_id
33127 , x_value_segment_code => l_adr_value_segment_code
33128 , p_side => 'NA'
33129 , p_override_seg_flag => 'Y'
33130 );
33131
33132 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
33133
33134 xla_ae_lines_pkg.set_segment(
33135 p_to_segment_code => 'GL_ACCOUNT'
33136 , p_segment_value => l_segment
33137 , p_from_segment_code => l_adr_value_segment_code
33138 , p_from_combination_id => l_adr_value_combination_id
33139 , p_value_type_code => l_adr_value_type_code
33140 , p_transaction_coa_id => l_adr_transaction_coa_id
33141 , p_accounting_coa_id => l_adr_accounting_coa_id
33142 , p_flexfield_segment_code => l_adr_flexfield_segment_code
33143 , p_flex_value_set_id => l_adr_flex_value_set_id
33144 , p_adr_code => 'FV_AR_4X0201_RCT_DR'
33145 , p_adr_type_code => 'S'
33146 , p_component_type => l_component_type
33147 , p_component_code => l_component_code
33148 , p_component_type_code => l_component_type_code
33149 , p_component_appl_id => l_component_appl_id
33150 , p_amb_context_code => l_amb_context_code
33151 , p_entity_code => 'RECEIPTS'
33152 , p_event_class_code => 'RECEIPT'
33153 , p_side => 'NA'
33154 );
33155
33156 END IF;
33157
33158 --
33159 --
33160 END IF;
33161 --
33162 -- Bug 4922099
33163 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
33164 (NVL(l_enc_upg_option, 'N') = 'O')
33165 ) AND
33166 (l_bflow_method_code = 'PRIOR_ENTRY')
33167 )
33168 THEN
33169 IF
33170 --
33171 1 = 2
33172 --
33173 THEN
33174 xla_accounting_err_pkg.build_message
33175 (p_appli_s_name => 'XLA'
33176 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33177 ,p_token_1 => 'LINE_NUMBER'
33178 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
33179 ,p_token_2 => 'LINE_TYPE_NAME'
33180 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
33181 l_component_type
33182 ,l_component_code
33183 ,l_component_type_code
33184 ,l_component_appl_id
33185 ,l_amb_context_code
33186 ,l_entity_code
33187 ,l_event_class_code
33188 )
33189 ,p_token_3 => 'OWNER'
33190 ,p_value_3 => xla_lookups_pkg.get_meaning(
33194 ,p_token_4 => 'PRODUCT_NAME'
33191 p_lookup_type => 'XLA_OWNER_TYPE'
33192 ,p_lookup_code => l_component_type_code
33193 )
33195 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
33196 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
33197 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
33198 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
33199 ,p_ae_header_id => NULL
33200 );
33201
33202 IF (C_LEVEL_ERROR>= g_log_level) THEN
33203 trace
33204 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33205 ,p_level => C_LEVEL_ERROR
33206 ,p_module => l_log_module);
33207 END IF;
33208 END IF;
33209 END IF;
33210 --
33211 --
33212 ------------------------------------------------------------------------------------------------
33213 -- 4219869 Business Flow
33214 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
33215 -- Prior Entry. Currently, the following code is always generated.
33216 ------------------------------------------------------------------------------------------------
33217 XLA_AE_LINES_PKG.ValidateCurrentLine;
33218
33219 ------------------------------------------------------------------------------------
33220 -- 4219869 Business Flow
33221 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
33222 ------------------------------------------------------------------------------------
33223 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33224
33225 ----------------------------------------------------------------------------------
33226 -- 4219869 Business Flow
33227 -- Update journal entry status -- Need to generate this within IF <condition>
33228 ----------------------------------------------------------------------------------
33229 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33230 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
33231 ,p_balance_type_code => l_balance_type_code
33232 );
33233
33234 -------------------------------------------------------------------------------------------
33235 -- 4262811 - Generate the Accrual Reversal lines
33236 -------------------------------------------------------------------------------------------
33237 BEGIN
33238 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
33239 (g_array_event(p_event_id).array_value_num('header_index'));
33240 IF l_acc_rev_flag IS NULL THEN
33241 l_acc_rev_flag := 'N';
33242 END IF;
33243 EXCEPTION
33244 WHEN OTHERS THEN
33245 l_acc_rev_flag := 'N';
33246 END;
33247 --
33248 IF (l_acc_rev_flag = 'Y') THEN
33249
33250 -- 4645092 ------------------------------------------------------------------------------
33251 -- To allow MPA report to determine if it should generate report process
33252 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
33253 ------------------------------------------------------------------------------------------
33254
33255 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
33256 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
33257 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
33258 -- call ADRs
33259 -- Bug 4922099
33260 --
33261 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33262 (NVL(l_actual_upg_option, 'N') = 'O') OR
33263 (NVL(l_enc_upg_option, 'N') = 'O')
33264 )
33265 THEN
33266 NULL;
33267 --
33268 --
33269
33270 l_ccid := AcctDerRule_4(
33271 p_application_id => p_application_id
33272 , p_ae_header_id => l_ae_header_id
33273 , p_source_5 => p_source_5
33274 , x_transaction_coa_id => l_adr_transaction_coa_id
33275 , x_accounting_coa_id => l_adr_accounting_coa_id
33276 , x_value_type_code => l_adr_value_type_code
33277 , p_side => 'NA'
33278 );
33279
33280 xla_ae_lines_pkg.set_ccid(
33281 p_code_combination_id => l_ccid
33282 , p_value_type_code => l_adr_value_type_code
33283 , p_transaction_coa_id => l_adr_transaction_coa_id
33284 , p_accounting_coa_id => l_adr_accounting_coa_id
33285 , p_adr_code => 'DIST_CCID'
33286 , p_adr_type_code => 'S'
33287 , p_component_type => l_component_type
33288 , p_component_code => l_component_code
33289 , p_component_type_code => l_component_type_code
33290 , p_component_appl_id => l_component_appl_id
33291 , p_amb_context_code => l_amb_context_code
33292 , p_side => 'NA'
33293 );
33294
33295
33296 l_segment := AcctDerRule_21(
33297 p_application_id => p_application_id
33298 , p_ae_header_id => l_ae_header_id
33299 , p_source_11 => p_source_11
33300 , p_source_12 => p_source_12
33301 , p_source_13 => p_source_13
33302 , p_source_14 => p_source_14
33303 , p_source_15 => p_source_15
33304 , x_transaction_coa_id => l_adr_transaction_coa_id
33305 , x_accounting_coa_id => l_adr_accounting_coa_id
33306 , x_flexfield_segment_code => l_adr_flexfield_segment_code
33307 , x_flex_value_set_id => l_adr_flex_value_set_id
33308 , x_value_type_code => l_adr_value_type_code
33309 , x_value_combination_id => l_adr_value_combination_id
33310 , x_value_segment_code => l_adr_value_segment_code
33311 , p_side => 'NA'
33312 , p_override_seg_flag => 'Y'
33313 );
33314
33315 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
33316
33317 xla_ae_lines_pkg.set_segment(
33318 p_to_segment_code => 'GL_ACCOUNT'
33319 , p_segment_value => l_segment
33320 , p_from_segment_code => l_adr_value_segment_code
33321 , p_from_combination_id => l_adr_value_combination_id
33322 , p_value_type_code => l_adr_value_type_code
33323 , p_transaction_coa_id => l_adr_transaction_coa_id
33324 , p_accounting_coa_id => l_adr_accounting_coa_id
33325 , p_flexfield_segment_code => l_adr_flexfield_segment_code
33326 , p_flex_value_set_id => l_adr_flex_value_set_id
33327 , p_adr_code => 'FV_AR_4X0201_RCT_DR'
33328 , p_adr_type_code => 'S'
33329 , p_component_type => l_component_type
33330 , p_component_code => l_component_code
33331 , p_component_type_code => l_component_type_code
33332 , p_component_appl_id => l_component_appl_id
33333 , p_amb_context_code => l_amb_context_code
33334 , p_entity_code => 'RECEIPTS'
33335 , p_event_class_code => 'RECEIPT'
33336 , p_side => 'NA'
33337 );
33338
33339 END IF;
33340
33341 --
33342 --
33343 END IF;
33344
33345 --
33346 -- Update the line information that should be overwritten
33347 --
33348 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
33349 p_header_num => 1);
33350 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
33351
33352 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
33353
33354 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
33355 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
33356 END IF;
33357
33358 --
33359 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
33360 --
33361 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
33362 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
33363 ELSE
33364 ---------------------------------------------------------------------------------------------------
33365 -- 4262811a Switch Sign
33366 ---------------------------------------------------------------------------------------------------
33367 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
33368 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33369 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33370 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
33371 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33372 -- 5132302
33373 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
33374 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
33375
33376 END IF;
33377
33378 -- 4955764
33379 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33380 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
33381
33382
33383 XLA_AE_LINES_PKG.ValidateCurrentLine;
33384 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33385
33386 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33387 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
33391
33388 ,p_balance_type_code => l_balance_type_code);
33389
33390 END IF;
33392 -----------------------------------------------------------------------------------------
33393 -- 4262811 Multiperiod Accounting
33394 -----------------------------------------------------------------------------------------
33395 -- No MPA option is assigned.
33396
33397
33398 END IF;
33399 END IF;
33400 --
33401
33402 --
33403 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33404 trace
33405 (p_msg => 'END of AcctLineType_77'
33406 ,p_level => C_LEVEL_PROCEDURE
33407 ,p_module => l_log_module);
33408 END IF;
33409 --
33410 EXCEPTION
33411 WHEN xla_exceptions_pkg.application_exception THEN
33412 RAISE;
33413 WHEN OTHERS THEN
33414 xla_exceptions_pkg.raise_message
33415 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_77');
33416 END AcctLineType_77;
33417 --
33418
33419 ---------------------------------------
33420 --
33421 -- PRIVATE FUNCTION
33422 -- AcctLineType_78
33423 --
33424 ---------------------------------------
33425 PROCEDURE AcctLineType_78 (
33426 p_application_id IN NUMBER
33427 ,p_event_id IN NUMBER
33428 ,p_calculate_acctd_flag IN VARCHAR2
33429 ,p_calculate_g_l_flag IN VARCHAR2
33430 ,p_actual_flag IN OUT VARCHAR2
33431 ,p_balance_type_code OUT VARCHAR2
33432 ,p_gain_or_loss_ref OUT VARCHAR2
33433
33434 --Distribution GL Account
33435 , p_source_5 IN NUMBER
33436 --Federal Account Rule
33437 , p_source_11 IN VARCHAR2
33438 --Federal Fund Expired Status
33439 , p_source_12 IN VARCHAR2
33440 --Federal Prior Year Flag
33441 , p_source_13 IN VARCHAR2
33442 --Federal Fund Time Frame
33443 , p_source_14 IN VARCHAR2
33444 --Distribution Source Type
33445 , p_source_20 IN VARCHAR2
33446 --Distribution Line Identifier
33447 , p_source_22 IN NUMBER
33448 --Distribution Type
33449 , p_source_23 IN VARCHAR2
33450 --Entered Amount
33451 , p_source_24 IN NUMBER
33452 --Exchange Rate Type
33453 , p_source_28 IN VARCHAR2
33454 --Applied To Document Accounting Amount
33455 , p_source_29 IN NUMBER
33456 --Transaction Distribution Account Class
33457 , p_source_33 IN VARCHAR2
33458 --Transaction Distribution Identifier
33459 , p_source_34 IN NUMBER
33460 --Transaction Distribution Type
33461 , p_source_35 IN VARCHAR2
33462 --Federal Account Valid Flag
33463 , p_source_56 IN VARCHAR2
33464 --Applied To Document Exchange Date
33465 , p_source_57 IN DATE
33466 --Receipt Applied To Application Identifier
33467 , p_source_58 IN NUMBER
33468 --Transaction Entity Code
33469 , p_source_59 IN VARCHAR2
33470 --Transaction Identifier
33471 , p_source_60 IN NUMBER
33472 --Applying Document Currency Code
33473 , p_source_61 IN VARCHAR2
33474 --Applied To Document Exchange Rate
33475 , p_source_62 IN NUMBER
33476 --Distribution Party Identifier
33477 , p_source_63 IN NUMBER
33478 --Distribution Party Site Id
33479 , p_source_64 IN NUMBER
33480 --Distribution Party Type
33481 , p_source_65 IN VARCHAR2
33482 )
33483 IS
33484
33485 l_component_type VARCHAR2(80);
33486 l_component_code VARCHAR2(30);
33487 l_component_type_code VARCHAR2(1);
33488 l_component_appl_id INTEGER;
33489 l_amb_context_code VARCHAR2(30);
33490 l_entity_code VARCHAR2(30);
33491 l_event_class_code VARCHAR2(30);
33492 l_ae_header_id NUMBER;
33493 l_event_type_code VARCHAR2(30);
33494 l_line_definition_code VARCHAR2(30);
33495 l_line_definition_owner_code VARCHAR2(1);
33496 --
33497 -- adr variables
33498 l_segment VARCHAR2(30);
33499 l_ccid NUMBER;
33500 l_adr_transaction_coa_id NUMBER;
33501 l_adr_accounting_coa_id NUMBER;
33502 l_adr_flexfield_segment_code VARCHAR2(30);
33503 l_adr_flex_value_set_id NUMBER;
33504 l_adr_value_type_code VARCHAR2(30);
33505 l_adr_value_combination_id NUMBER;
33506 l_adr_value_segment_code VARCHAR2(30);
33507
33508 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
33509 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
33510 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
33511 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
33512
33513 -- 4262811 Variables ------------------------------------------------------------------------------------------
33514 l_entered_amt_idx NUMBER;
33515 l_accted_amt_idx NUMBER;
33516 l_acc_rev_flag VARCHAR2(1);
33517 l_accrual_line_num NUMBER;
33518 l_tmp_amt NUMBER;
33519 l_acc_rev_natural_side_code VARCHAR2(1);
33520
33521 l_num_entries NUMBER;
33522 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
33523 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
33524 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
33525 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
33526 l_recog_line_1 NUMBER;
33530 l_bflow_applied_to_amt NUMBER; -- 5132302
33527 l_recog_line_2 NUMBER;
33528
33529 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
33531 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
33532
33533 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
33534
33535 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
33536 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
33537
33538 ---------------------------------------------------------------------------------------------------------------
33539
33540
33541 --
33542 -- bulk performance
33543 --
33544 l_balance_type_code VARCHAR2(1);
33545 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
33546 l_log_module VARCHAR2(240);
33547
33548 --
33549 -- Upgrade strategy
33550 --
33551 l_actual_upg_option VARCHAR2(1);
33552 l_enc_upg_option VARCHAR2(1);
33553
33554 --
33555 BEGIN
33556 --
33557 IF g_log_enabled THEN
33558 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_78';
33559 END IF;
33560 --
33561 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
33562
33563 trace
33564 (p_msg => 'BEGIN of AcctLineType_78'
33565 ,p_level => C_LEVEL_PROCEDURE
33566 ,p_module => l_log_module);
33567
33568 END IF;
33569 --
33570 l_component_type := 'AMB_JLT';
33571 l_component_code := 'FV_RCT_REF_OAP_UFP_CR';
33572 l_component_type_code := 'S';
33573 l_component_appl_id := 222;
33574 l_amb_context_code := 'DEFAULT';
33575 l_entity_code := 'RECEIPTS';
33576 l_event_class_code := 'RECEIPT';
33577 l_event_type_code := 'RECEIPT_ALL';
33578 l_line_definition_owner_code := 'S';
33579 l_line_definition_code := 'FEDERAL_AR_RCT_DEFAULT_ACCRUAL';
33580 --
33581 l_balance_type_code := 'A';
33582 l_segment := NULL;
33583 l_ccid := NULL;
33584 l_adr_transaction_coa_id := NULL;
33585 l_adr_accounting_coa_id := NULL;
33586 l_adr_flexfield_segment_code := NULL;
33587 l_adr_flex_value_set_id := NULL;
33588 l_adr_value_type_code := NULL;
33589 l_adr_value_combination_id := NULL;
33590 l_adr_value_segment_code := NULL;
33591
33592 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
33593 l_bflow_class_code := ''; -- 4219869 Business Flow
33594 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
33595 l_budgetary_control_flag := 'N';
33596
33597 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33598 l_bflow_applied_to_amt := NULL; -- 5132302
33599 l_entered_amt_idx := NULL; -- 4262811
33600 l_accted_amt_idx := NULL; -- 4262811
33601 l_acc_rev_flag := NULL; -- 4262811
33602 l_accrual_line_num := NULL; -- 4262811
33603 l_tmp_amt := NULL; -- 4262811
33604 --
33605
33606 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
33607 l_balance_type_code <> 'B' THEN
33608 IF NVL(p_source_20,'
33609 ') = 'REC' AND
33610 NVL(p_source_33,'
33611 ') = 'REV' AND
33612 NVL(p_source_12,'
33613 ') = 'Unexpired' AND
33614 NVL(p_source_13,'
33615 ') = 'Y' AND
33616 (NVL(p_source_14,'
33617 ') = 'MUTIPLE' OR
33618 NVL(p_source_14,'
33619 ') = 'NO_YEAR') AND
33620 (NVL(p_source_11,'
33621 ') = 'Overpayment Refund' OR
33622 NVL(p_source_11,'
33623 ') = 'Advance Refund') AND
33624 NVL(p_source_56,'
33625 ') = 'Y'
33626 THEN
33627
33628 --
33629 XLA_AE_LINES_PKG.SetNewLine;
33630
33631 p_balance_type_code := l_balance_type_code;
33632 -- set the flag so later we will know whether the gain loss line needs to be created
33633
33634 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
33635 p_actual_flag :='A';
33636 END IF;
33637
33638 --
33639 -- bulk performance
33640 --
33641 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
33642 p_header_num => 0); -- 4262811
33643 --
33644 -- set accounting line options
33645 --
33646 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
33647 p_natural_side_code => 'C'
33648 , p_gain_or_loss_flag => 'N'
33649 , p_gl_transfer_mode_code => 'S'
33650 , p_acct_entry_type_code => 'A'
33651 , p_switch_side_flag => 'Y'
33652 , p_merge_duplicate_code => 'A'
33653 );
33654 --
33655 l_acc_rev_natural_side_code := 'D'; -- 4262811
33656 --
33657 --
33658 -- set accounting line type info
33659 --
33660 xla_ae_lines_pkg.SetAcctLineType
33661 (p_component_type => l_component_type
33662 ,p_event_type_code => l_event_type_code
33663 ,p_line_definition_owner_code => l_line_definition_owner_code
33664 ,p_line_definition_code => l_line_definition_code
33665 ,p_accounting_line_code => l_component_code
33666 ,p_accounting_line_type_code => l_component_type_code
33667 ,p_accounting_line_appl_id => l_component_appl_id
33668 ,p_amb_context_code => l_amb_context_code
33672 -- set accounting class
33669 ,p_entity_code => l_entity_code
33670 ,p_event_class_code => l_event_class_code);
33671 --
33673 --
33674 xla_ae_lines_pkg.SetAcctClass(
33675 p_accounting_class_code => 'FV_CASH_CR'
33676 , p_ae_header_id => l_ae_header_id
33677 );
33678
33679 --
33680 -- set rounding class
33681 --
33682 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
33683 'RECEIVABLE';
33684
33685 --
33686 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
33687 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
33688 --
33689 -- bulk performance
33690 --
33691 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
33692
33693 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
33694 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
33695
33696 -- 4955764
33697 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
33698 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
33699
33700 -- 4458381 Public Sector Enh
33701
33702 --
33703 -- set accounting attributes for the line type
33704 --
33705 l_entered_amt_idx := 8;
33706 l_accted_amt_idx := 13;
33707 l_bflow_applied_to_amt_idx := NULL; -- 5132302
33708 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
33709 l_rec_acct_attrs.array_num_value(1) := p_source_58;
33710 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
33711 l_rec_acct_attrs.array_char_value(2) := p_source_35;
33712 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
33713 l_rec_acct_attrs.array_char_value(3) := p_source_59;
33714 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
33715 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
33716 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
33717 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
33718 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
33719 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
33720 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
33721 l_rec_acct_attrs.array_char_value(7) := p_source_23;
33722 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
33723 l_rec_acct_attrs.array_num_value(8) := p_source_24;
33724 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
33725 l_rec_acct_attrs.array_char_value(9) := p_source_61;
33726 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
33727 l_rec_acct_attrs.array_date_value(10) := p_source_57;
33728 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
33729 l_rec_acct_attrs.array_num_value(11) := p_source_62;
33730 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
33731 l_rec_acct_attrs.array_char_value(12) := p_source_28;
33732 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
33733 l_rec_acct_attrs.array_num_value(13) := p_source_29;
33734 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
33735 l_rec_acct_attrs.array_num_value(14) := p_source_63;
33736 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
33737 l_rec_acct_attrs.array_num_value(15) := p_source_64;
33738 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
33739 l_rec_acct_attrs.array_char_value(16) := p_source_65;
33740
33741 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
33742 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
33743
33744 ---------------------------------------------------------------------------------------------------------------
33745 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
33746 ---------------------------------------------------------------------------------------------------------------
33747 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
33748
33749 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33750 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
33751
33752 IF xla_accounting_cache_pkg.GetValueChar
33753 (p_source_code => 'LEDGER_CATEGORY_CODE'
33754 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
33755 AND l_bflow_method_code = 'PRIOR_ENTRY'
33756 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
33757 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
33758 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
33759 )
33760 THEN
33761 xla_ae_lines_pkg.BflowUpgEntry
33762 (p_business_method_code => l_bflow_method_code
33763 ,p_business_class_code => l_bflow_class_code
33764 ,p_balance_type => l_balance_type_code);
33765 ELSE
33766 NULL;
33767 -- No business flow processing for business flow method of NONE.
33768 END IF;
33769
33770 --
33771 -- call analytical criteria
33772 --
33773
33774 --
33775 -- call description
33776 --
33780 -- Bug 4922099
33777 -- No description or it is inherited.
33778 --
33779 -- call ADRs
33781 --
33782 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33783 (NVL(l_actual_upg_option, 'N') = 'O') OR
33784 (NVL(l_enc_upg_option, 'N') = 'O')
33785 )
33786 THEN
33787 NULL;
33788 --
33789 --
33790
33791 l_ccid := AcctDerRule_4(
33792 p_application_id => p_application_id
33793 , p_ae_header_id => l_ae_header_id
33794 , p_source_5 => p_source_5
33795 , x_transaction_coa_id => l_adr_transaction_coa_id
33796 , x_accounting_coa_id => l_adr_accounting_coa_id
33797 , x_value_type_code => l_adr_value_type_code
33798 , p_side => 'NA'
33799 );
33800
33801 xla_ae_lines_pkg.set_ccid(
33802 p_code_combination_id => l_ccid
33803 , p_value_type_code => l_adr_value_type_code
33804 , p_transaction_coa_id => l_adr_transaction_coa_id
33805 , p_accounting_coa_id => l_adr_accounting_coa_id
33806 , p_adr_code => 'DIST_CCID'
33807 , p_adr_type_code => 'S'
33808 , p_component_type => l_component_type
33809 , p_component_code => l_component_code
33810 , p_component_type_code => l_component_type_code
33811 , p_component_appl_id => l_component_appl_id
33812 , p_amb_context_code => l_amb_context_code
33813 , p_side => 'NA'
33814 );
33815
33816
33817 l_segment := AcctDerRule_14(
33818 p_application_id => p_application_id
33819 , p_ae_header_id => l_ae_header_id
33820 , p_source_12 => p_source_12
33821 , p_source_13 => p_source_13
33822 , p_source_14 => p_source_14
33823 , x_transaction_coa_id => l_adr_transaction_coa_id
33824 , x_accounting_coa_id => l_adr_accounting_coa_id
33825 , x_flexfield_segment_code => l_adr_flexfield_segment_code
33826 , x_flex_value_set_id => l_adr_flex_value_set_id
33827 , x_value_type_code => l_adr_value_type_code
33828 , x_value_combination_id => l_adr_value_combination_id
33829 , x_value_segment_code => l_adr_value_segment_code
33830 , p_side => 'NA'
33831 , p_override_seg_flag => 'Y'
33832 );
33833
33834 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
33835
33836 xla_ae_lines_pkg.set_segment(
33837 p_to_segment_code => 'GL_ACCOUNT'
33838 , p_segment_value => l_segment
33839 , p_from_segment_code => l_adr_value_segment_code
33840 , p_from_combination_id => l_adr_value_combination_id
33841 , p_value_type_code => l_adr_value_type_code
33842 , p_transaction_coa_id => l_adr_transaction_coa_id
33843 , p_accounting_coa_id => l_adr_accounting_coa_id
33844 , p_flexfield_segment_code => l_adr_flexfield_segment_code
33845 , p_flex_value_set_id => l_adr_flex_value_set_id
33846 , p_adr_code => 'FV_AR_445001_RCT_CR'
33847 , p_adr_type_code => 'S'
33848 , p_component_type => l_component_type
33849 , p_component_code => l_component_code
33850 , p_component_type_code => l_component_type_code
33851 , p_component_appl_id => l_component_appl_id
33852 , p_amb_context_code => l_amb_context_code
33853 , p_entity_code => 'RECEIPTS'
33854 , p_event_class_code => 'RECEIPT'
33855 , p_side => 'NA'
33856 );
33857
33858 END IF;
33859
33860 --
33861 --
33862 END IF;
33863 --
33864 -- Bug 4922099
33865 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
33866 (NVL(l_enc_upg_option, 'N') = 'O')
33867 ) AND
33868 (l_bflow_method_code = 'PRIOR_ENTRY')
33869 )
33870 THEN
33871 IF
33872 --
33873 1 = 2
33874 --
33875 THEN
33876 xla_accounting_err_pkg.build_message
33877 (p_appli_s_name => 'XLA'
33878 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33879 ,p_token_1 => 'LINE_NUMBER'
33880 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
33881 ,p_token_2 => 'LINE_TYPE_NAME'
33882 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
33883 l_component_type
33884 ,l_component_code
33885 ,l_component_type_code
33886 ,l_component_appl_id
33887 ,l_amb_context_code
33888 ,l_entity_code
33889 ,l_event_class_code
33890 )
33891 ,p_token_3 => 'OWNER'
33892 ,p_value_3 => xla_lookups_pkg.get_meaning(
33893 p_lookup_type => 'XLA_OWNER_TYPE'
33894 ,p_lookup_code => l_component_type_code
33895 )
33896 ,p_token_4 => 'PRODUCT_NAME'
33897 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
33898 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
33899 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
33900 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
33901 ,p_ae_header_id => NULL
33902 );
33903
33904 IF (C_LEVEL_ERROR>= g_log_level) THEN
33905 trace
33906 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
33907 ,p_level => C_LEVEL_ERROR
33908 ,p_module => l_log_module);
33909 END IF;
33910 END IF;
33911 END IF;
33912 --
33913 --
33914 ------------------------------------------------------------------------------------------------
33915 -- 4219869 Business Flow
33916 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
33917 -- Prior Entry. Currently, the following code is always generated.
33918 ------------------------------------------------------------------------------------------------
33919 XLA_AE_LINES_PKG.ValidateCurrentLine;
33920
33921 ------------------------------------------------------------------------------------
33922 -- 4219869 Business Flow
33923 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
33924 ------------------------------------------------------------------------------------
33925 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
33926
33927 ----------------------------------------------------------------------------------
33928 -- 4219869 Business Flow
33929 -- Update journal entry status -- Need to generate this within IF <condition>
33930 ----------------------------------------------------------------------------------
33931 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
33932 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
33933 ,p_balance_type_code => l_balance_type_code
33934 );
33935
33936 -------------------------------------------------------------------------------------------
33937 -- 4262811 - Generate the Accrual Reversal lines
33938 -------------------------------------------------------------------------------------------
33939 BEGIN
33940 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
33941 (g_array_event(p_event_id).array_value_num('header_index'));
33942 IF l_acc_rev_flag IS NULL THEN
33943 l_acc_rev_flag := 'N';
33944 END IF;
33945 EXCEPTION
33946 WHEN OTHERS THEN
33947 l_acc_rev_flag := 'N';
33948 END;
33949 --
33950 IF (l_acc_rev_flag = 'Y') THEN
33951
33952 -- 4645092 ------------------------------------------------------------------------------
33953 -- To allow MPA report to determine if it should generate report process
33954 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
33955 ------------------------------------------------------------------------------------------
33956
33957 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
33958 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
33959 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
33960 -- call ADRs
33961 -- Bug 4922099
33962 --
33963 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
33964 (NVL(l_actual_upg_option, 'N') = 'O') OR
33965 (NVL(l_enc_upg_option, 'N') = 'O')
33966 )
33967 THEN
33968 NULL;
33969 --
33970 --
33971
33972 l_ccid := AcctDerRule_4(
33973 p_application_id => p_application_id
33974 , p_ae_header_id => l_ae_header_id
33975 , p_source_5 => p_source_5
33976 , x_transaction_coa_id => l_adr_transaction_coa_id
33977 , x_accounting_coa_id => l_adr_accounting_coa_id
33978 , x_value_type_code => l_adr_value_type_code
33979 , p_side => 'NA'
33980 );
33981
33982 xla_ae_lines_pkg.set_ccid(
33983 p_code_combination_id => l_ccid
33984 , p_value_type_code => l_adr_value_type_code
33985 , p_transaction_coa_id => l_adr_transaction_coa_id
33986 , p_accounting_coa_id => l_adr_accounting_coa_id
33987 , p_adr_code => 'DIST_CCID'
33988 , p_adr_type_code => 'S'
33989 , p_component_type => l_component_type
33990 , p_component_code => l_component_code
33991 , p_component_type_code => l_component_type_code
33992 , p_component_appl_id => l_component_appl_id
33993 , p_amb_context_code => l_amb_context_code
33994 , p_side => 'NA'
33995 );
33996
33997
33998 l_segment := AcctDerRule_14(
33999 p_application_id => p_application_id
34000 , p_ae_header_id => l_ae_header_id
34001 , p_source_12 => p_source_12
34002 , p_source_13 => p_source_13
34003 , p_source_14 => p_source_14
34004 , x_transaction_coa_id => l_adr_transaction_coa_id
34005 , x_accounting_coa_id => l_adr_accounting_coa_id
34006 , x_flexfield_segment_code => l_adr_flexfield_segment_code
34007 , x_flex_value_set_id => l_adr_flex_value_set_id
34008 , x_value_type_code => l_adr_value_type_code
34009 , x_value_combination_id => l_adr_value_combination_id
34010 , x_value_segment_code => l_adr_value_segment_code
34011 , p_side => 'NA'
34012 , p_override_seg_flag => 'Y'
34013 );
34014
34015 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
34016
34017 xla_ae_lines_pkg.set_segment(
34018 p_to_segment_code => 'GL_ACCOUNT'
34019 , p_segment_value => l_segment
34020 , p_from_segment_code => l_adr_value_segment_code
34021 , p_from_combination_id => l_adr_value_combination_id
34022 , p_value_type_code => l_adr_value_type_code
34023 , p_transaction_coa_id => l_adr_transaction_coa_id
34024 , p_accounting_coa_id => l_adr_accounting_coa_id
34025 , p_flexfield_segment_code => l_adr_flexfield_segment_code
34026 , p_flex_value_set_id => l_adr_flex_value_set_id
34027 , p_adr_code => 'FV_AR_445001_RCT_CR'
34028 , p_adr_type_code => 'S'
34029 , p_component_type => l_component_type
34030 , p_component_code => l_component_code
34031 , p_component_type_code => l_component_type_code
34032 , p_component_appl_id => l_component_appl_id
34033 , p_amb_context_code => l_amb_context_code
34034 , p_entity_code => 'RECEIPTS'
34035 , p_event_class_code => 'RECEIPT'
34036 , p_side => 'NA'
34037 );
34038
34039 END IF;
34040
34041 --
34042 --
34043 END IF;
34044
34045 --
34046 -- Update the line information that should be overwritten
34047 --
34048 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
34049 p_header_num => 1);
34050 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
34051
34052 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
34053
34054 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
34055 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
34056 END IF;
34057
34058 --
34059 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
34060 --
34061 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
34062 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
34063 ELSE
34064 ---------------------------------------------------------------------------------------------------
34065 -- 4262811a Switch Sign
34066 ---------------------------------------------------------------------------------------------------
34067 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
34068 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34069 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34070 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34071 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34072 -- 5132302
34073 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
34074 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34075
34076 END IF;
34077
34078 -- 4955764
34079 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34080 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
34081
34082
34083 XLA_AE_LINES_PKG.ValidateCurrentLine;
34084 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
34085
34086 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
34087 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
34088 ,p_balance_type_code => l_balance_type_code);
34089
34090 END IF;
34091
34092 -----------------------------------------------------------------------------------------
34093 -- 4262811 Multiperiod Accounting
34094 -----------------------------------------------------------------------------------------
34095 -- No MPA option is assigned.
34096
34097
34098 END IF;
34099 END IF;
34100 --
34101
34102 --
34103 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34104 trace
34105 (p_msg => 'END of AcctLineType_78'
34106 ,p_level => C_LEVEL_PROCEDURE
34107 ,p_module => l_log_module);
34108 END IF;
34109 --
34110 EXCEPTION
34111 WHEN xla_exceptions_pkg.application_exception THEN
34112 RAISE;
34113 WHEN OTHERS THEN
34114 xla_exceptions_pkg.raise_message
34115 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_78');
34116 END AcctLineType_78;
34117 --
34118
34119 ---------------------------------------
34120 --
34121 -- PRIVATE FUNCTION
34122 -- AcctLineType_79
34123 --
34124 ---------------------------------------
34125 PROCEDURE AcctLineType_79 (
34126 p_application_id IN NUMBER
34127 ,p_event_id IN NUMBER
34128 ,p_calculate_acctd_flag IN VARCHAR2
34129 ,p_calculate_g_l_flag IN VARCHAR2
34130 ,p_actual_flag IN OUT VARCHAR2
34131 ,p_balance_type_code OUT VARCHAR2
34132 ,p_gain_or_loss_ref OUT VARCHAR2
34133
34134 --Distribution GL Account
34135 , p_source_5 IN NUMBER
34136 --Federal Account Rule
34137 , p_source_11 IN VARCHAR2
34138 --Federal Fund Expired Status
34139 , p_source_12 IN VARCHAR2
34140 --Federal Prior Year Flag
34141 , p_source_13 IN VARCHAR2
34142 --Federal Fund Time Frame
34143 , p_source_14 IN VARCHAR2
34144 --Distribution Source Type
34145 , p_source_20 IN VARCHAR2
34146 --Distribution Line Identifier
34147 , p_source_22 IN NUMBER
34148 --Distribution Type
34149 , p_source_23 IN VARCHAR2
34150 --Entered Amount
34151 , p_source_24 IN NUMBER
34152 --Exchange Rate Type
34153 , p_source_28 IN VARCHAR2
34154 --Applied To Document Accounting Amount
34155 , p_source_29 IN NUMBER
34156 --Transaction Distribution Account Class
34157 , p_source_33 IN VARCHAR2
34158 --Transaction Distribution Identifier
34159 , p_source_34 IN NUMBER
34160 --Transaction Distribution Type
34161 , p_source_35 IN VARCHAR2
34162 --Federal Account Valid Flag
34163 , p_source_56 IN VARCHAR2
34164 --Applied To Document Exchange Date
34165 , p_source_57 IN DATE
34166 --Receipt Applied To Application Identifier
34167 , p_source_58 IN NUMBER
34168 --Transaction Entity Code
34169 , p_source_59 IN VARCHAR2
34170 --Transaction Identifier
34171 , p_source_60 IN NUMBER
34172 --Applying Document Currency Code
34173 , p_source_61 IN VARCHAR2
34174 --Applied To Document Exchange Rate
34175 , p_source_62 IN NUMBER
34176 --Distribution Party Identifier
34177 , p_source_63 IN NUMBER
34178 --Distribution Party Site Id
34179 , p_source_64 IN NUMBER
34180 --Distribution Party Type
34181 , p_source_65 IN VARCHAR2
34182 )
34183 IS
34184
34185 l_component_type VARCHAR2(80);
34186 l_component_code VARCHAR2(30);
34187 l_component_type_code VARCHAR2(1);
34188 l_component_appl_id INTEGER;
34189 l_amb_context_code VARCHAR2(30);
34190 l_entity_code VARCHAR2(30);
34191 l_event_class_code VARCHAR2(30);
34192 l_ae_header_id NUMBER;
34193 l_event_type_code VARCHAR2(30);
34194 l_line_definition_code VARCHAR2(30);
34195 l_line_definition_owner_code VARCHAR2(1);
34196 --
34197 -- adr variables
34198 l_segment VARCHAR2(30);
34199 l_ccid NUMBER;
34200 l_adr_transaction_coa_id NUMBER;
34201 l_adr_accounting_coa_id NUMBER;
34202 l_adr_flexfield_segment_code VARCHAR2(30);
34203 l_adr_flex_value_set_id NUMBER;
34204 l_adr_value_type_code VARCHAR2(30);
34205 l_adr_value_combination_id NUMBER;
34206 l_adr_value_segment_code VARCHAR2(30);
34207
34208 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
34209 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
34210 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
34211 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
34212
34213 -- 4262811 Variables ------------------------------------------------------------------------------------------
34214 l_entered_amt_idx NUMBER;
34215 l_accted_amt_idx NUMBER;
34216 l_acc_rev_flag VARCHAR2(1);
34217 l_accrual_line_num NUMBER;
34218 l_tmp_amt NUMBER;
34219 l_acc_rev_natural_side_code VARCHAR2(1);
34220
34221 l_num_entries NUMBER;
34222 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
34223 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
34224 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
34225 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
34226 l_recog_line_1 NUMBER;
34227 l_recog_line_2 NUMBER;
34228
34229 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
34230 l_bflow_applied_to_amt NUMBER; -- 5132302
34231 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
34232
34233 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
34234
34235 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
34236 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
34237
34238 ---------------------------------------------------------------------------------------------------------------
34239
34240
34241 --
34242 -- bulk performance
34243 --
34244 l_balance_type_code VARCHAR2(1);
34245 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
34246 l_log_module VARCHAR2(240);
34247
34248 --
34249 -- Upgrade strategy
34250 --
34251 l_actual_upg_option VARCHAR2(1);
34252 l_enc_upg_option VARCHAR2(1);
34253
34254 --
34255 BEGIN
34256 --
34257 IF g_log_enabled THEN
34258 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_79';
34259 END IF;
34260 --
34261 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34262
34263 trace
34264 (p_msg => 'BEGIN of AcctLineType_79'
34265 ,p_level => C_LEVEL_PROCEDURE
34266 ,p_module => l_log_module);
34267
34268 END IF;
34269 --
34270 l_component_type := 'AMB_JLT';
34271 l_component_code := 'FV_RCT_REF_OAP_UFP_DR';
34272 l_component_type_code := 'S';
34273 l_component_appl_id := 222;
34274 l_amb_context_code := 'DEFAULT';
34275 l_entity_code := 'RECEIPTS';
34276 l_event_class_code := 'RECEIPT';
34277 l_event_type_code := 'RECEIPT_ALL';
34278 l_line_definition_owner_code := 'S';
34279 l_line_definition_code := 'FEDERAL_AR_RCT_DEFAULT_ACCRUAL';
34280 --
34281 l_balance_type_code := 'A';
34282 l_segment := NULL;
34283 l_ccid := NULL;
34284 l_adr_transaction_coa_id := NULL;
34285 l_adr_accounting_coa_id := NULL;
34286 l_adr_flexfield_segment_code := NULL;
34287 l_adr_flex_value_set_id := NULL;
34288 l_adr_value_type_code := NULL;
34289 l_adr_value_combination_id := NULL;
34290 l_adr_value_segment_code := NULL;
34291
34292 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
34293 l_bflow_class_code := ''; -- 4219869 Business Flow
34294 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
34295 l_budgetary_control_flag := 'N';
34296
34297 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34298 l_bflow_applied_to_amt := NULL; -- 5132302
34299 l_entered_amt_idx := NULL; -- 4262811
34300 l_accted_amt_idx := NULL; -- 4262811
34301 l_acc_rev_flag := NULL; -- 4262811
34302 l_accrual_line_num := NULL; -- 4262811
34303 l_tmp_amt := NULL; -- 4262811
34304 --
34305
34306 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
34307 l_balance_type_code <> 'B' THEN
34308 IF NVL(p_source_20,'
34309 ') = 'REC' AND
34310 NVL(p_source_33,'
34311 ') = 'REV' AND
34312 NVL(p_source_12,'
34313 ') = 'Unexpired' AND
34314 NVL(p_source_13,'
34315 ') = 'Y' AND
34316 (NVL(p_source_14,'
34317 ') = 'MUTIPLE' OR
34318 NVL(p_source_14,'
34319 ') = 'NO_YEAR') AND
34320 (NVL(p_source_11,'
34321 ') = 'Overpayment Refund' OR
34322 NVL(p_source_11,'
34323 ') = 'Advance Refund') AND
34324 NVL(p_source_56,'
34325 ') = 'Y'
34326 THEN
34327
34328 --
34329 XLA_AE_LINES_PKG.SetNewLine;
34330
34331 p_balance_type_code := l_balance_type_code;
34332 -- set the flag so later we will know whether the gain loss line needs to be created
34333
34334 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
34335 p_actual_flag :='A';
34336 END IF;
34337
34338 --
34339 -- bulk performance
34340 --
34341 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
34342 p_header_num => 0); -- 4262811
34343 --
34344 -- set accounting line options
34345 --
34346 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
34347 p_natural_side_code => 'D'
34348 , p_gain_or_loss_flag => 'N'
34349 , p_gl_transfer_mode_code => 'S'
34350 , p_acct_entry_type_code => 'A'
34351 , p_switch_side_flag => 'Y'
34352 , p_merge_duplicate_code => 'A'
34353 );
34354 --
34355 l_acc_rev_natural_side_code := 'C'; -- 4262811
34356 --
34357 --
34358 -- set accounting line type info
34359 --
34360 xla_ae_lines_pkg.SetAcctLineType
34361 (p_component_type => l_component_type
34362 ,p_event_type_code => l_event_type_code
34363 ,p_line_definition_owner_code => l_line_definition_owner_code
34364 ,p_line_definition_code => l_line_definition_code
34365 ,p_accounting_line_code => l_component_code
34366 ,p_accounting_line_type_code => l_component_type_code
34367 ,p_accounting_line_appl_id => l_component_appl_id
34368 ,p_amb_context_code => l_amb_context_code
34369 ,p_entity_code => l_entity_code
34370 ,p_event_class_code => l_event_class_code);
34371 --
34372 -- set accounting class
34373 --
34374 xla_ae_lines_pkg.SetAcctClass(
34375 p_accounting_class_code => 'FV_CASH_DR'
34376 , p_ae_header_id => l_ae_header_id
34377 );
34378
34379 --
34380 -- set rounding class
34381 --
34382 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
34383 'RECEIVABLE';
34384
34385 --
34386 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
34387 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
34388 --
34389 -- bulk performance
34390 --
34391 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
34392
34393 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
34394 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
34395
34396 -- 4955764
34397 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34398 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
34399
34400 -- 4458381 Public Sector Enh
34401
34402 --
34403 -- set accounting attributes for the line type
34404 --
34405 l_entered_amt_idx := 8;
34406 l_accted_amt_idx := 13;
34407 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34408 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
34409 l_rec_acct_attrs.array_num_value(1) := p_source_58;
34410 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
34411 l_rec_acct_attrs.array_char_value(2) := p_source_35;
34412 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
34413 l_rec_acct_attrs.array_char_value(3) := p_source_59;
34414 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
34415 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
34416 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
34417 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
34418 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
34419 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
34420 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
34421 l_rec_acct_attrs.array_char_value(7) := p_source_23;
34422 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
34423 l_rec_acct_attrs.array_num_value(8) := p_source_24;
34424 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
34425 l_rec_acct_attrs.array_char_value(9) := p_source_61;
34426 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
34427 l_rec_acct_attrs.array_date_value(10) := p_source_57;
34428 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
34429 l_rec_acct_attrs.array_num_value(11) := p_source_62;
34430 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
34431 l_rec_acct_attrs.array_char_value(12) := p_source_28;
34432 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
34433 l_rec_acct_attrs.array_num_value(13) := p_source_29;
34434 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
34435 l_rec_acct_attrs.array_num_value(14) := p_source_63;
34436 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
34437 l_rec_acct_attrs.array_num_value(15) := p_source_64;
34438 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
34439 l_rec_acct_attrs.array_char_value(16) := p_source_65;
34440
34441 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
34442 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
34443
34444 ---------------------------------------------------------------------------------------------------------------
34445 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
34446 ---------------------------------------------------------------------------------------------------------------
34447 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
34448
34449 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34450 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
34451
34452 IF xla_accounting_cache_pkg.GetValueChar
34453 (p_source_code => 'LEDGER_CATEGORY_CODE'
34454 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
34455 AND l_bflow_method_code = 'PRIOR_ENTRY'
34456 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
34457 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
34458 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
34459 )
34460 THEN
34461 xla_ae_lines_pkg.BflowUpgEntry
34462 (p_business_method_code => l_bflow_method_code
34463 ,p_business_class_code => l_bflow_class_code
34464 ,p_balance_type => l_balance_type_code);
34465 ELSE
34466 NULL;
34467 -- No business flow processing for business flow method of NONE.
34468 END IF;
34469
34470 --
34471 -- call analytical criteria
34472 --
34473
34474 --
34475 -- call description
34476 --
34477 -- No description or it is inherited.
34478 --
34479 -- call ADRs
34480 -- Bug 4922099
34481 --
34482 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
34483 (NVL(l_actual_upg_option, 'N') = 'O') OR
34484 (NVL(l_enc_upg_option, 'N') = 'O')
34485 )
34486 THEN
34487 NULL;
34488 --
34489 --
34490
34491 l_ccid := AcctDerRule_4(
34492 p_application_id => p_application_id
34493 , p_ae_header_id => l_ae_header_id
34494 , p_source_5 => p_source_5
34495 , x_transaction_coa_id => l_adr_transaction_coa_id
34496 , x_accounting_coa_id => l_adr_accounting_coa_id
34497 , x_value_type_code => l_adr_value_type_code
34498 , p_side => 'NA'
34499 );
34500
34501 xla_ae_lines_pkg.set_ccid(
34502 p_code_combination_id => l_ccid
34503 , p_value_type_code => l_adr_value_type_code
34504 , p_transaction_coa_id => l_adr_transaction_coa_id
34505 , p_accounting_coa_id => l_adr_accounting_coa_id
34506 , p_adr_code => 'DIST_CCID'
34507 , p_adr_type_code => 'S'
34508 , p_component_type => l_component_type
34509 , p_component_code => l_component_code
34510 , p_component_type_code => l_component_type_code
34511 , p_component_appl_id => l_component_appl_id
34512 , p_amb_context_code => l_amb_context_code
34513 , p_side => 'NA'
34514 );
34515
34516
34517 l_segment := AcctDerRule_22(
34518 p_application_id => p_application_id
34519 , p_ae_header_id => l_ae_header_id
34520 , p_source_11 => p_source_11
34521 , p_source_12 => p_source_12
34522 , p_source_13 => p_source_13
34523 , p_source_14 => p_source_14
34527 , x_flex_value_set_id => l_adr_flex_value_set_id
34524 , x_transaction_coa_id => l_adr_transaction_coa_id
34525 , x_accounting_coa_id => l_adr_accounting_coa_id
34526 , x_flexfield_segment_code => l_adr_flexfield_segment_code
34528 , x_value_type_code => l_adr_value_type_code
34529 , x_value_combination_id => l_adr_value_combination_id
34530 , x_value_segment_code => l_adr_value_segment_code
34531 , p_side => 'NA'
34532 , p_override_seg_flag => 'Y'
34533 );
34534
34535 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
34536
34537 xla_ae_lines_pkg.set_segment(
34538 p_to_segment_code => 'GL_ACCOUNT'
34539 , p_segment_value => l_segment
34540 , p_from_segment_code => l_adr_value_segment_code
34541 , p_from_combination_id => l_adr_value_combination_id
34542 , p_value_type_code => l_adr_value_type_code
34543 , p_transaction_coa_id => l_adr_transaction_coa_id
34544 , p_accounting_coa_id => l_adr_accounting_coa_id
34545 , p_flexfield_segment_code => l_adr_flexfield_segment_code
34546 , p_flex_value_set_id => l_adr_flex_value_set_id
34547 , p_adr_code => 'FV_AR_4X7201_RCT_DR'
34548 , p_adr_type_code => 'S'
34549 , p_component_type => l_component_type
34550 , p_component_code => l_component_code
34551 , p_component_type_code => l_component_type_code
34552 , p_component_appl_id => l_component_appl_id
34553 , p_amb_context_code => l_amb_context_code
34554 , p_entity_code => 'RECEIPTS'
34555 , p_event_class_code => 'RECEIPT'
34556 , p_side => 'NA'
34557 );
34558
34559 END IF;
34560
34561 --
34562 --
34563 END IF;
34564 --
34565 -- Bug 4922099
34566 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
34567 (NVL(l_enc_upg_option, 'N') = 'O')
34568 ) AND
34569 (l_bflow_method_code = 'PRIOR_ENTRY')
34570 )
34571 THEN
34572 IF
34573 --
34574 1 = 2
34575 --
34576 THEN
34577 xla_accounting_err_pkg.build_message
34578 (p_appli_s_name => 'XLA'
34579 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
34580 ,p_token_1 => 'LINE_NUMBER'
34581 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
34582 ,p_token_2 => 'LINE_TYPE_NAME'
34583 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
34584 l_component_type
34585 ,l_component_code
34586 ,l_component_type_code
34587 ,l_component_appl_id
34588 ,l_amb_context_code
34589 ,l_entity_code
34590 ,l_event_class_code
34591 )
34592 ,p_token_3 => 'OWNER'
34593 ,p_value_3 => xla_lookups_pkg.get_meaning(
34594 p_lookup_type => 'XLA_OWNER_TYPE'
34595 ,p_lookup_code => l_component_type_code
34596 )
34597 ,p_token_4 => 'PRODUCT_NAME'
34598 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
34599 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
34600 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
34601 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
34602 ,p_ae_header_id => NULL
34603 );
34604
34605 IF (C_LEVEL_ERROR>= g_log_level) THEN
34606 trace
34607 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
34608 ,p_level => C_LEVEL_ERROR
34609 ,p_module => l_log_module);
34610 END IF;
34611 END IF;
34612 END IF;
34613 --
34614 --
34615 ------------------------------------------------------------------------------------------------
34616 -- 4219869 Business Flow
34617 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
34618 -- Prior Entry. Currently, the following code is always generated.
34619 ------------------------------------------------------------------------------------------------
34620 XLA_AE_LINES_PKG.ValidateCurrentLine;
34621
34622 ------------------------------------------------------------------------------------
34623 -- 4219869 Business Flow
34624 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
34628 ----------------------------------------------------------------------------------
34625 ------------------------------------------------------------------------------------
34626 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
34627
34629 -- 4219869 Business Flow
34630 -- Update journal entry status -- Need to generate this within IF <condition>
34631 ----------------------------------------------------------------------------------
34632 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
34633 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
34634 ,p_balance_type_code => l_balance_type_code
34635 );
34636
34637 -------------------------------------------------------------------------------------------
34638 -- 4262811 - Generate the Accrual Reversal lines
34639 -------------------------------------------------------------------------------------------
34640 BEGIN
34641 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
34642 (g_array_event(p_event_id).array_value_num('header_index'));
34643 IF l_acc_rev_flag IS NULL THEN
34644 l_acc_rev_flag := 'N';
34645 END IF;
34646 EXCEPTION
34647 WHEN OTHERS THEN
34648 l_acc_rev_flag := 'N';
34649 END;
34650 --
34651 IF (l_acc_rev_flag = 'Y') THEN
34652
34653 -- 4645092 ------------------------------------------------------------------------------
34654 -- To allow MPA report to determine if it should generate report process
34655 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
34656 ------------------------------------------------------------------------------------------
34657
34658 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
34659 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
34660 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
34661 -- call ADRs
34662 -- Bug 4922099
34663 --
34664 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
34665 (NVL(l_actual_upg_option, 'N') = 'O') OR
34666 (NVL(l_enc_upg_option, 'N') = 'O')
34667 )
34668 THEN
34669 NULL;
34670 --
34671 --
34672
34673 l_ccid := AcctDerRule_4(
34674 p_application_id => p_application_id
34675 , p_ae_header_id => l_ae_header_id
34676 , p_source_5 => p_source_5
34677 , x_transaction_coa_id => l_adr_transaction_coa_id
34678 , x_accounting_coa_id => l_adr_accounting_coa_id
34679 , x_value_type_code => l_adr_value_type_code
34680 , p_side => 'NA'
34681 );
34682
34683 xla_ae_lines_pkg.set_ccid(
34684 p_code_combination_id => l_ccid
34685 , p_value_type_code => l_adr_value_type_code
34686 , p_transaction_coa_id => l_adr_transaction_coa_id
34687 , p_accounting_coa_id => l_adr_accounting_coa_id
34688 , p_adr_code => 'DIST_CCID'
34689 , p_adr_type_code => 'S'
34690 , p_component_type => l_component_type
34691 , p_component_code => l_component_code
34692 , p_component_type_code => l_component_type_code
34693 , p_component_appl_id => l_component_appl_id
34694 , p_amb_context_code => l_amb_context_code
34695 , p_side => 'NA'
34696 );
34697
34698
34699 l_segment := AcctDerRule_22(
34700 p_application_id => p_application_id
34701 , p_ae_header_id => l_ae_header_id
34702 , p_source_11 => p_source_11
34703 , p_source_12 => p_source_12
34704 , p_source_13 => p_source_13
34705 , p_source_14 => p_source_14
34706 , x_transaction_coa_id => l_adr_transaction_coa_id
34707 , x_accounting_coa_id => l_adr_accounting_coa_id
34708 , x_flexfield_segment_code => l_adr_flexfield_segment_code
34709 , x_flex_value_set_id => l_adr_flex_value_set_id
34710 , x_value_type_code => l_adr_value_type_code
34711 , x_value_combination_id => l_adr_value_combination_id
34712 , x_value_segment_code => l_adr_value_segment_code
34713 , p_side => 'NA'
34714 , p_override_seg_flag => 'Y'
34715 );
34716
34717 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
34718
34719 xla_ae_lines_pkg.set_segment(
34720 p_to_segment_code => 'GL_ACCOUNT'
34721 , p_segment_value => l_segment
34722 , p_from_segment_code => l_adr_value_segment_code
34723 , p_from_combination_id => l_adr_value_combination_id
34724 , p_value_type_code => l_adr_value_type_code
34725 , p_transaction_coa_id => l_adr_transaction_coa_id
34726 , p_accounting_coa_id => l_adr_accounting_coa_id
34727 , p_flexfield_segment_code => l_adr_flexfield_segment_code
34728 , p_flex_value_set_id => l_adr_flex_value_set_id
34729 , p_adr_code => 'FV_AR_4X7201_RCT_DR'
34730 , p_adr_type_code => 'S'
34731 , p_component_type => l_component_type
34732 , p_component_code => l_component_code
34733 , p_component_type_code => l_component_type_code
34734 , p_component_appl_id => l_component_appl_id
34735 , p_amb_context_code => l_amb_context_code
34736 , p_entity_code => 'RECEIPTS'
34737 , p_event_class_code => 'RECEIPT'
34738 , p_side => 'NA'
34739 );
34740
34741 END IF;
34742
34743 --
34747 --
34744 --
34745 END IF;
34746
34748 -- Update the line information that should be overwritten
34749 --
34750 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
34751 p_header_num => 1);
34752 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
34753
34754 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
34755
34756 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
34757 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
34758 END IF;
34759
34760 --
34761 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
34762 --
34763 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
34764 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
34765 ELSE
34766 ---------------------------------------------------------------------------------------------------
34767 -- 4262811a Switch Sign
34768 ---------------------------------------------------------------------------------------------------
34769 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
34770 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34771 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34772 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
34773 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34774 -- 5132302
34775 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
34776 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
34777
34778 END IF;
34779
34780 -- 4955764
34781 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
34782 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
34783
34784
34785 XLA_AE_LINES_PKG.ValidateCurrentLine;
34786 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
34787
34788 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
34789 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
34790 ,p_balance_type_code => l_balance_type_code);
34791
34792 END IF;
34793
34794 -----------------------------------------------------------------------------------------
34795 -- 4262811 Multiperiod Accounting
34796 -----------------------------------------------------------------------------------------
34797 -- No MPA option is assigned.
34798
34799
34800 END IF;
34801 END IF;
34802 --
34803
34804 --
34805 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34806 trace
34807 (p_msg => 'END of AcctLineType_79'
34808 ,p_level => C_LEVEL_PROCEDURE
34809 ,p_module => l_log_module);
34810 END IF;
34811 --
34812 EXCEPTION
34813 WHEN xla_exceptions_pkg.application_exception THEN
34814 RAISE;
34815 WHEN OTHERS THEN
34816 xla_exceptions_pkg.raise_message
34817 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_79');
34818 END AcctLineType_79;
34819 --
34820
34821 ---------------------------------------
34822 --
34823 -- PRIVATE FUNCTION
34824 -- AcctLineType_80
34825 --
34826 ---------------------------------------
34827 PROCEDURE AcctLineType_80 (
34828 p_application_id IN NUMBER
34829 ,p_event_id IN NUMBER
34830 ,p_calculate_acctd_flag IN VARCHAR2
34831 ,p_calculate_g_l_flag IN VARCHAR2
34832 ,p_actual_flag IN OUT VARCHAR2
34833 ,p_balance_type_code OUT VARCHAR2
34834 ,p_gain_or_loss_ref OUT VARCHAR2
34835
34836 --Distribution GL Account
34837 , p_source_5 IN NUMBER
34838 --Bill To Customer Classification
34839 , p_source_10 IN VARCHAR2
34840 --Federal Account Rule
34841 , p_source_11 IN VARCHAR2
34842 --Distribution Source Type
34843 , p_source_20 IN VARCHAR2
34844 --Distribution Line Identifier
34845 , p_source_22 IN NUMBER
34846 --Distribution Type
34847 , p_source_23 IN VARCHAR2
34848 --Entered Amount
34849 , p_source_24 IN NUMBER
34850 --Exchange Date
34851 , p_source_26 IN DATE
34852 --Exchange Rate
34853 , p_source_27 IN NUMBER
34854 --Exchange Rate Type
34855 , p_source_28 IN VARCHAR2
34856 --Applied To Document Accounting Amount
34857 , p_source_29 IN NUMBER
34858 --Transaction Distribution Account Class
34859 , p_source_33 IN VARCHAR2
34860 --Transaction Distribution Identifier
34861 , p_source_34 IN NUMBER
34862 --Transaction Distribution Type
34863 , p_source_35 IN VARCHAR2
34864 --Federal Account Valid Flag
34865 , p_source_56 IN VARCHAR2
34866 --Receipt Applied To Application Identifier
34867 , p_source_58 IN NUMBER
34868 --Transaction Entity Code
34869 , p_source_59 IN VARCHAR2
34870 --Transaction Identifier
34871 , p_source_60 IN NUMBER
34872 --Applying Document Currency Code
34873 , p_source_61 IN VARCHAR2
34874 --Distribution Party Identifier
34875 , p_source_63 IN NUMBER
34876 --Distribution Party Site Id
34877 , p_source_64 IN NUMBER
34878 --Distribution Party Type
34879 , p_source_65 IN VARCHAR2
34880 )
34881 IS
34882
34883 l_component_type VARCHAR2(80);
34884 l_component_code VARCHAR2(30);
34885 l_component_type_code VARCHAR2(1);
34886 l_component_appl_id INTEGER;
34887 l_amb_context_code VARCHAR2(30);
34888 l_entity_code VARCHAR2(30);
34889 l_event_class_code VARCHAR2(30);
34890 l_ae_header_id NUMBER;
34891 l_event_type_code VARCHAR2(30);
34892 l_line_definition_code VARCHAR2(30);
34893 l_line_definition_owner_code VARCHAR2(1);
34894 --
34895 -- adr variables
34896 l_segment VARCHAR2(30);
34897 l_ccid NUMBER;
34898 l_adr_transaction_coa_id NUMBER;
34899 l_adr_accounting_coa_id NUMBER;
34900 l_adr_flexfield_segment_code VARCHAR2(30);
34901 l_adr_flex_value_set_id NUMBER;
34902 l_adr_value_type_code VARCHAR2(30);
34903 l_adr_value_combination_id NUMBER;
34904 l_adr_value_segment_code VARCHAR2(30);
34905
34906 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
34907 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
34908 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
34909 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
34910
34911 -- 4262811 Variables ------------------------------------------------------------------------------------------
34912 l_entered_amt_idx NUMBER;
34913 l_accted_amt_idx NUMBER;
34914 l_acc_rev_flag VARCHAR2(1);
34915 l_accrual_line_num NUMBER;
34916 l_tmp_amt NUMBER;
34917 l_acc_rev_natural_side_code VARCHAR2(1);
34918
34919 l_num_entries NUMBER;
34920 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
34921 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
34922 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
34923 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
34924 l_recog_line_1 NUMBER;
34925 l_recog_line_2 NUMBER;
34926
34927 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
34928 l_bflow_applied_to_amt NUMBER; -- 5132302
34929 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
34930
34931 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
34932
34933 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
34934 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
34935
34936 ---------------------------------------------------------------------------------------------------------------
34937
34938
34939 --
34940 -- bulk performance
34941 --
34942 l_balance_type_code VARCHAR2(1);
34943 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
34944 l_log_module VARCHAR2(240);
34945
34946 --
34947 -- Upgrade strategy
34948 --
34949 l_actual_upg_option VARCHAR2(1);
34950 l_enc_upg_option VARCHAR2(1);
34951
34952 --
34953 BEGIN
34954 --
34955 IF g_log_enabled THEN
34956 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_80';
34957 END IF;
34958 --
34959 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
34960
34961 trace
34962 (p_msg => 'BEGIN of AcctLineType_80'
34963 ,p_level => C_LEVEL_PROCEDURE
34964 ,p_module => l_log_module);
34965
34966 END IF;
34967 --
34968 l_component_type := 'AMB_JLT';
34969 l_component_code := 'FV_RCT_REIM_WO_ADV_CR';
34970 l_component_type_code := 'S';
34971 l_component_appl_id := 222;
34972 l_amb_context_code := 'DEFAULT';
34973 l_entity_code := 'RECEIPTS';
34974 l_event_class_code := 'RECEIPT';
34975 l_event_type_code := 'RECEIPT_ALL';
34976 l_line_definition_owner_code := 'S';
34977 l_line_definition_code := 'FEDERAL_AR_RCT_DEFAULT_ACCRUAL';
34978 --
34979 l_balance_type_code := 'A';
34980 l_segment := NULL;
34981 l_ccid := NULL;
34982 l_adr_transaction_coa_id := NULL;
34983 l_adr_accounting_coa_id := NULL;
34984 l_adr_flexfield_segment_code := NULL;
34985 l_adr_flex_value_set_id := NULL;
34986 l_adr_value_type_code := NULL;
34987 l_adr_value_combination_id := NULL;
34988 l_adr_value_segment_code := NULL;
34989
34990 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
34991 l_bflow_class_code := ''; -- 4219869 Business Flow
34992 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
34993 l_budgetary_control_flag := 'N';
34994
34995 l_bflow_applied_to_amt_idx := NULL; -- 5132302
34996 l_bflow_applied_to_amt := NULL; -- 5132302
34997 l_entered_amt_idx := NULL; -- 4262811
34998 l_accted_amt_idx := NULL; -- 4262811
34999 l_acc_rev_flag := NULL; -- 4262811
35000 l_accrual_line_num := NULL; -- 4262811
35001 l_tmp_amt := NULL; -- 4262811
35002 --
35003
35004 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
35005 l_balance_type_code <> 'B' THEN
35006 IF NVL(p_source_20,'
35007 ') = 'REC' AND
35008 NVL(p_source_33,'
35009 ') = 'REV' AND
35010 NVL(p_source_10,'
35011 ') = 'FEDERAL' AND
35012 NVL(p_source_11,'
35013 ') = 'Order No Advance' AND
35014 NVL(p_source_56,'
35015 ') = 'Y'
35016 THEN
35017
35018 --
35019 XLA_AE_LINES_PKG.SetNewLine;
35020
35021 p_balance_type_code := l_balance_type_code;
35022 -- set the flag so later we will know whether the gain loss line needs to be created
35023
35024 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
35025 p_actual_flag :='A';
35026 END IF;
35027
35028 --
35029 -- bulk performance
35030 --
35031 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
35032 p_header_num => 0); -- 4262811
35033 --
35034 -- set accounting line options
35035 --
35036 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
35037 p_natural_side_code => 'C'
35038 , p_gain_or_loss_flag => 'N'
35039 , p_gl_transfer_mode_code => 'S'
35040 , p_acct_entry_type_code => 'A'
35041 , p_switch_side_flag => 'Y'
35042 , p_merge_duplicate_code => 'A'
35043 );
35044 --
35045 l_acc_rev_natural_side_code := 'D'; -- 4262811
35046 --
35047 --
35048 -- set accounting line type info
35049 --
35050 xla_ae_lines_pkg.SetAcctLineType
35051 (p_component_type => l_component_type
35052 ,p_event_type_code => l_event_type_code
35053 ,p_line_definition_owner_code => l_line_definition_owner_code
35054 ,p_line_definition_code => l_line_definition_code
35055 ,p_accounting_line_code => l_component_code
35056 ,p_accounting_line_type_code => l_component_type_code
35057 ,p_accounting_line_appl_id => l_component_appl_id
35058 ,p_amb_context_code => l_amb_context_code
35059 ,p_entity_code => l_entity_code
35060 ,p_event_class_code => l_event_class_code);
35061 --
35062 -- set accounting class
35063 --
35064 xla_ae_lines_pkg.SetAcctClass(
35065 p_accounting_class_code => 'FV_CASH_CR'
35066 , p_ae_header_id => l_ae_header_id
35067 );
35068
35069 --
35070 -- set rounding class
35071 --
35072 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
35073 'RECEIVABLE';
35074
35075 --
35076 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
35077 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
35078 --
35079 -- bulk performance
35080 --
35081 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
35082
35083 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
35084 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
35085
35086 -- 4955764
35087 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35088 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
35089
35090 -- 4458381 Public Sector Enh
35091
35092 --
35093 -- set accounting attributes for the line type
35094 --
35095 l_entered_amt_idx := 8;
35096 l_accted_amt_idx := 13;
35097 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35098 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
35099 l_rec_acct_attrs.array_num_value(1) := p_source_58;
35100 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
35101 l_rec_acct_attrs.array_char_value(2) := p_source_35;
35102 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
35103 l_rec_acct_attrs.array_char_value(3) := p_source_59;
35104 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
35105 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
35106 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
35107 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
35108 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
35109 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
35110 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
35111 l_rec_acct_attrs.array_char_value(7) := p_source_23;
35112 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
35113 l_rec_acct_attrs.array_num_value(8) := p_source_24;
35114 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
35115 l_rec_acct_attrs.array_char_value(9) := p_source_61;
35116 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
35117 l_rec_acct_attrs.array_date_value(10) := p_source_26;
35118 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
35119 l_rec_acct_attrs.array_num_value(11) := p_source_27;
35120 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
35121 l_rec_acct_attrs.array_char_value(12) := p_source_28;
35122 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
35123 l_rec_acct_attrs.array_num_value(13) := p_source_29;
35124 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
35125 l_rec_acct_attrs.array_num_value(14) := p_source_63;
35126 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
35127 l_rec_acct_attrs.array_num_value(15) := p_source_64;
35128 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
35129 l_rec_acct_attrs.array_char_value(16) := p_source_65;
35130
35131 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
35132 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
35133
35134 ---------------------------------------------------------------------------------------------------------------
35135 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
35136 ---------------------------------------------------------------------------------------------------------------
35137 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
35138
35139 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
35140 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
35141
35142 IF xla_accounting_cache_pkg.GetValueChar
35143 (p_source_code => 'LEDGER_CATEGORY_CODE'
35144 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
35145 AND l_bflow_method_code = 'PRIOR_ENTRY'
35146 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
35147 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
35148 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
35149 )
35150 THEN
35151 xla_ae_lines_pkg.BflowUpgEntry
35152 (p_business_method_code => l_bflow_method_code
35153 ,p_business_class_code => l_bflow_class_code
35154 ,p_balance_type => l_balance_type_code);
35155 ELSE
35156 NULL;
35157 -- No business flow processing for business flow method of NONE.
35158 END IF;
35159
35160 --
35161 -- call analytical criteria
35162 --
35163
35164 --
35165 -- call description
35166 --
35167 -- No description or it is inherited.
35168 --
35169 -- call ADRs
35170 -- Bug 4922099
35171 --
35172 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35173 (NVL(l_actual_upg_option, 'N') = 'O') OR
35174 (NVL(l_enc_upg_option, 'N') = 'O')
35175 )
35176 THEN
35177 NULL;
35178 --
35179 --
35180
35181 l_ccid := AcctDerRule_4(
35182 p_application_id => p_application_id
35183 , p_ae_header_id => l_ae_header_id
35184 , p_source_5 => p_source_5
35185 , x_transaction_coa_id => l_adr_transaction_coa_id
35186 , x_accounting_coa_id => l_adr_accounting_coa_id
35187 , x_value_type_code => l_adr_value_type_code
35188 , p_side => 'NA'
35189 );
35190
35191 xla_ae_lines_pkg.set_ccid(
35192 p_code_combination_id => l_ccid
35193 , p_value_type_code => l_adr_value_type_code
35194 , p_transaction_coa_id => l_adr_transaction_coa_id
35195 , p_accounting_coa_id => l_adr_accounting_coa_id
35196 , p_adr_code => 'DIST_CCID'
35197 , p_adr_type_code => 'S'
35198 , p_component_type => l_component_type
35199 , p_component_code => l_component_code
35200 , p_component_type_code => l_component_type_code
35201 , p_component_appl_id => l_component_appl_id
35202 , p_amb_context_code => l_amb_context_code
35203 , p_side => 'NA'
35204 );
35205
35206
35207 l_segment := AcctDerRule_9(
35208 p_application_id => p_application_id
35209 , p_ae_header_id => l_ae_header_id
35210 , p_source_11 => p_source_11
35211 , x_transaction_coa_id => l_adr_transaction_coa_id
35212 , x_accounting_coa_id => l_adr_accounting_coa_id
35213 , x_flexfield_segment_code => l_adr_flexfield_segment_code
35214 , x_flex_value_set_id => l_adr_flex_value_set_id
35215 , x_value_type_code => l_adr_value_type_code
35216 , x_value_combination_id => l_adr_value_combination_id
35217 , x_value_segment_code => l_adr_value_segment_code
35218 , p_side => 'NA'
35219 , p_override_seg_flag => 'Y'
35220 );
35221
35222 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
35223
35224 xla_ae_lines_pkg.set_segment(
35225 p_to_segment_code => 'GL_ACCOUNT'
35226 , p_segment_value => l_segment
35227 , p_from_segment_code => l_adr_value_segment_code
35228 , p_from_combination_id => l_adr_value_combination_id
35229 , p_value_type_code => l_adr_value_type_code
35230 , p_transaction_coa_id => l_adr_transaction_coa_id
35231 , p_accounting_coa_id => l_adr_accounting_coa_id
35232 , p_flexfield_segment_code => l_adr_flexfield_segment_code
35233 , p_flex_value_set_id => l_adr_flex_value_set_id
35234 , p_adr_code => 'FV_AR_425101_RCT_CR'
35235 , p_adr_type_code => 'S'
35236 , p_component_type => l_component_type
35237 , p_component_code => l_component_code
35238 , p_component_type_code => l_component_type_code
35239 , p_component_appl_id => l_component_appl_id
35240 , p_amb_context_code => l_amb_context_code
35241 , p_entity_code => 'RECEIPTS'
35242 , p_event_class_code => 'RECEIPT'
35243 , p_side => 'NA'
35244 );
35245
35246 END IF;
35247
35248 --
35249 --
35250 END IF;
35251 --
35252 -- Bug 4922099
35253 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
35254 (NVL(l_enc_upg_option, 'N') = 'O')
35255 ) AND
35256 (l_bflow_method_code = 'PRIOR_ENTRY')
35257 )
35258 THEN
35259 IF
35260 --
35261 1 = 2
35262 --
35263 THEN
35264 xla_accounting_err_pkg.build_message
35265 (p_appli_s_name => 'XLA'
35266 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35267 ,p_token_1 => 'LINE_NUMBER'
35268 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
35269 ,p_token_2 => 'LINE_TYPE_NAME'
35270 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
35271 l_component_type
35272 ,l_component_code
35273 ,l_component_type_code
35274 ,l_component_appl_id
35275 ,l_amb_context_code
35276 ,l_entity_code
35277 ,l_event_class_code
35278 )
35279 ,p_token_3 => 'OWNER'
35280 ,p_value_3 => xla_lookups_pkg.get_meaning(
35281 p_lookup_type => 'XLA_OWNER_TYPE'
35282 ,p_lookup_code => l_component_type_code
35283 )
35284 ,p_token_4 => 'PRODUCT_NAME'
35285 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
35286 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
35287 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
35288 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
35289 ,p_ae_header_id => NULL
35290 );
35291
35292 IF (C_LEVEL_ERROR>= g_log_level) THEN
35293 trace
35294 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35295 ,p_level => C_LEVEL_ERROR
35296 ,p_module => l_log_module);
35297 END IF;
35298 END IF;
35299 END IF;
35300 --
35301 --
35302 ------------------------------------------------------------------------------------------------
35303 -- 4219869 Business Flow
35304 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
35305 -- Prior Entry. Currently, the following code is always generated.
35306 ------------------------------------------------------------------------------------------------
35307 XLA_AE_LINES_PKG.ValidateCurrentLine;
35308
35309 ------------------------------------------------------------------------------------
35310 -- 4219869 Business Flow
35311 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
35312 ------------------------------------------------------------------------------------
35313 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35314
35315 ----------------------------------------------------------------------------------
35316 -- 4219869 Business Flow
35317 -- Update journal entry status -- Need to generate this within IF <condition>
35318 ----------------------------------------------------------------------------------
35319 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35320 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
35321 ,p_balance_type_code => l_balance_type_code
35322 );
35323
35324 -------------------------------------------------------------------------------------------
35325 -- 4262811 - Generate the Accrual Reversal lines
35326 -------------------------------------------------------------------------------------------
35327 BEGIN
35328 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
35329 (g_array_event(p_event_id).array_value_num('header_index'));
35330 IF l_acc_rev_flag IS NULL THEN
35331 l_acc_rev_flag := 'N';
35332 END IF;
35333 EXCEPTION
35334 WHEN OTHERS THEN
35335 l_acc_rev_flag := 'N';
35336 END;
35337 --
35338 IF (l_acc_rev_flag = 'Y') THEN
35339
35340 -- 4645092 ------------------------------------------------------------------------------
35341 -- To allow MPA report to determine if it should generate report process
35342 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
35343 ------------------------------------------------------------------------------------------
35344
35345 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
35346 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
35347 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
35348 -- call ADRs
35349 -- Bug 4922099
35350 --
35351 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35352 (NVL(l_actual_upg_option, 'N') = 'O') OR
35353 (NVL(l_enc_upg_option, 'N') = 'O')
35354 )
35355 THEN
35356 NULL;
35357 --
35358 --
35359
35360 l_ccid := AcctDerRule_4(
35361 p_application_id => p_application_id
35362 , p_ae_header_id => l_ae_header_id
35363 , p_source_5 => p_source_5
35364 , x_transaction_coa_id => l_adr_transaction_coa_id
35365 , x_accounting_coa_id => l_adr_accounting_coa_id
35366 , x_value_type_code => l_adr_value_type_code
35367 , p_side => 'NA'
35368 );
35369
35370 xla_ae_lines_pkg.set_ccid(
35371 p_code_combination_id => l_ccid
35372 , p_value_type_code => l_adr_value_type_code
35373 , p_transaction_coa_id => l_adr_transaction_coa_id
35374 , p_accounting_coa_id => l_adr_accounting_coa_id
35375 , p_adr_code => 'DIST_CCID'
35376 , p_adr_type_code => 'S'
35377 , p_component_type => l_component_type
35378 , p_component_code => l_component_code
35379 , p_component_type_code => l_component_type_code
35380 , p_component_appl_id => l_component_appl_id
35381 , p_amb_context_code => l_amb_context_code
35382 , p_side => 'NA'
35383 );
35384
35385
35386 l_segment := AcctDerRule_9(
35387 p_application_id => p_application_id
35388 , p_ae_header_id => l_ae_header_id
35389 , p_source_11 => p_source_11
35390 , x_transaction_coa_id => l_adr_transaction_coa_id
35391 , x_accounting_coa_id => l_adr_accounting_coa_id
35392 , x_flexfield_segment_code => l_adr_flexfield_segment_code
35393 , x_flex_value_set_id => l_adr_flex_value_set_id
35394 , x_value_type_code => l_adr_value_type_code
35395 , x_value_combination_id => l_adr_value_combination_id
35396 , x_value_segment_code => l_adr_value_segment_code
35397 , p_side => 'NA'
35398 , p_override_seg_flag => 'Y'
35399 );
35400
35401 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
35402
35403 xla_ae_lines_pkg.set_segment(
35404 p_to_segment_code => 'GL_ACCOUNT'
35405 , p_segment_value => l_segment
35406 , p_from_segment_code => l_adr_value_segment_code
35407 , p_from_combination_id => l_adr_value_combination_id
35408 , p_value_type_code => l_adr_value_type_code
35409 , p_transaction_coa_id => l_adr_transaction_coa_id
35410 , p_accounting_coa_id => l_adr_accounting_coa_id
35411 , p_flexfield_segment_code => l_adr_flexfield_segment_code
35412 , p_flex_value_set_id => l_adr_flex_value_set_id
35413 , p_adr_code => 'FV_AR_425101_RCT_CR'
35414 , p_adr_type_code => 'S'
35415 , p_component_type => l_component_type
35416 , p_component_code => l_component_code
35417 , p_component_type_code => l_component_type_code
35418 , p_component_appl_id => l_component_appl_id
35419 , p_amb_context_code => l_amb_context_code
35420 , p_entity_code => 'RECEIPTS'
35421 , p_event_class_code => 'RECEIPT'
35422 , p_side => 'NA'
35423 );
35424
35425 END IF;
35426
35427 --
35428 --
35429 END IF;
35430
35431 --
35432 -- Update the line information that should be overwritten
35433 --
35434 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
35435 p_header_num => 1);
35436 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
35437
35438 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
35439
35440 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
35441 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
35442 END IF;
35443
35444 --
35445 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
35446 --
35447 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
35448 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
35449 ELSE
35450 ---------------------------------------------------------------------------------------------------
35451 -- 4262811a Switch Sign
35452 ---------------------------------------------------------------------------------------------------
35453 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
35454 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35455 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35456 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
35457 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35458 -- 5132302
35459 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
35460 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
35461
35462 END IF;
35463
35464 -- 4955764
35465 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35466 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
35467
35468
35469 XLA_AE_LINES_PKG.ValidateCurrentLine;
35470 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35471
35472 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
35473 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
35474 ,p_balance_type_code => l_balance_type_code);
35475
35476 END IF;
35477
35478 -----------------------------------------------------------------------------------------
35479 -- 4262811 Multiperiod Accounting
35480 -----------------------------------------------------------------------------------------
35481 -- No MPA option is assigned.
35482
35483
35484 END IF;
35485 END IF;
35486 --
35487
35488 --
35489 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35490 trace
35491 (p_msg => 'END of AcctLineType_80'
35492 ,p_level => C_LEVEL_PROCEDURE
35493 ,p_module => l_log_module);
35494 END IF;
35495 --
35496 EXCEPTION
35497 WHEN xla_exceptions_pkg.application_exception THEN
35498 RAISE;
35499 WHEN OTHERS THEN
35500 xla_exceptions_pkg.raise_message
35501 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_80');
35502 END AcctLineType_80;
35503 --
35504
35505 ---------------------------------------
35506 --
35507 -- PRIVATE FUNCTION
35508 -- AcctLineType_81
35509 --
35510 ---------------------------------------
35511 PROCEDURE AcctLineType_81 (
35512 p_application_id IN NUMBER
35513 ,p_event_id IN NUMBER
35514 ,p_calculate_acctd_flag IN VARCHAR2
35515 ,p_calculate_g_l_flag IN VARCHAR2
35516 ,p_actual_flag IN OUT VARCHAR2
35517 ,p_balance_type_code OUT VARCHAR2
35518 ,p_gain_or_loss_ref OUT VARCHAR2
35519
35520 --Distribution GL Account
35521 , p_source_5 IN NUMBER
35522 --Bill To Customer Classification
35523 , p_source_10 IN VARCHAR2
35524 --Federal Account Rule
35525 , p_source_11 IN VARCHAR2
35526 --Distribution Source Type
35527 , p_source_20 IN VARCHAR2
35528 --Distribution Line Identifier
35529 , p_source_22 IN NUMBER
35530 --Distribution Type
35531 , p_source_23 IN VARCHAR2
35532 --Entered Amount
35533 , p_source_24 IN NUMBER
35534 --Exchange Rate Type
35535 , p_source_28 IN VARCHAR2
35536 --Applied To Document Accounting Amount
35537 , p_source_29 IN NUMBER
35538 --Transaction Distribution Account Class
35539 , p_source_33 IN VARCHAR2
35540 --Transaction Distribution Identifier
35541 , p_source_34 IN NUMBER
35542 --Transaction Distribution Type
35543 , p_source_35 IN VARCHAR2
35544 --Federal Account Valid Flag
35545 , p_source_56 IN VARCHAR2
35546 --Applied To Document Exchange Date
35547 , p_source_57 IN DATE
35548 --Receipt Applied To Application Identifier
35549 , p_source_58 IN NUMBER
35550 --Transaction Entity Code
35551 , p_source_59 IN VARCHAR2
35552 --Transaction Identifier
35553 , p_source_60 IN NUMBER
35554 --Applying Document Currency Code
35555 , p_source_61 IN VARCHAR2
35556 --Applied To Document Exchange Rate
35557 , p_source_62 IN NUMBER
35558 --Distribution Party Identifier
35559 , p_source_63 IN NUMBER
35560 --Distribution Party Site Id
35561 , p_source_64 IN NUMBER
35562 --Distribution Party Type
35563 , p_source_65 IN VARCHAR2
35564 )
35565 IS
35566
35567 l_component_type VARCHAR2(80);
35568 l_component_code VARCHAR2(30);
35569 l_component_type_code VARCHAR2(1);
35570 l_component_appl_id INTEGER;
35571 l_amb_context_code VARCHAR2(30);
35572 l_entity_code VARCHAR2(30);
35573 l_event_class_code VARCHAR2(30);
35574 l_ae_header_id NUMBER;
35575 l_event_type_code VARCHAR2(30);
35576 l_line_definition_code VARCHAR2(30);
35577 l_line_definition_owner_code VARCHAR2(1);
35578 --
35579 -- adr variables
35580 l_segment VARCHAR2(30);
35581 l_ccid NUMBER;
35582 l_adr_transaction_coa_id NUMBER;
35583 l_adr_accounting_coa_id NUMBER;
35584 l_adr_flexfield_segment_code VARCHAR2(30);
35585 l_adr_flex_value_set_id NUMBER;
35586 l_adr_value_type_code VARCHAR2(30);
35587 l_adr_value_combination_id NUMBER;
35588 l_adr_value_segment_code VARCHAR2(30);
35589
35590 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
35591 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
35592 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
35593 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
35594
35595 -- 4262811 Variables ------------------------------------------------------------------------------------------
35596 l_entered_amt_idx NUMBER;
35597 l_accted_amt_idx NUMBER;
35598 l_acc_rev_flag VARCHAR2(1);
35599 l_accrual_line_num NUMBER;
35600 l_tmp_amt NUMBER;
35601 l_acc_rev_natural_side_code VARCHAR2(1);
35602
35603 l_num_entries NUMBER;
35604 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
35605 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
35606 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
35607 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
35608 l_recog_line_1 NUMBER;
35609 l_recog_line_2 NUMBER;
35610
35611 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
35612 l_bflow_applied_to_amt NUMBER; -- 5132302
35613 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
35614
35615 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
35616
35617 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
35618 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
35619
35620 ---------------------------------------------------------------------------------------------------------------
35621
35622
35623 --
35624 -- bulk performance
35625 --
35626 l_balance_type_code VARCHAR2(1);
35627 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
35628 l_log_module VARCHAR2(240);
35629
35630 --
35631 -- Upgrade strategy
35632 --
35633 l_actual_upg_option VARCHAR2(1);
35634 l_enc_upg_option VARCHAR2(1);
35635
35636 --
35637 BEGIN
35638 --
35639 IF g_log_enabled THEN
35640 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_81';
35641 END IF;
35642 --
35643 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
35644
35645 trace
35646 (p_msg => 'BEGIN of AcctLineType_81'
35647 ,p_level => C_LEVEL_PROCEDURE
35648 ,p_module => l_log_module);
35649
35650 END IF;
35651 --
35652 l_component_type := 'AMB_JLT';
35653 l_component_code := 'FV_RCT_REIM_WO_ADV_DR';
35654 l_component_type_code := 'S';
35655 l_component_appl_id := 222;
35656 l_amb_context_code := 'DEFAULT';
35657 l_entity_code := 'RECEIPTS';
35658 l_event_class_code := 'RECEIPT';
35659 l_event_type_code := 'RECEIPT_ALL';
35660 l_line_definition_owner_code := 'S';
35661 l_line_definition_code := 'FEDERAL_AR_RCT_DEFAULT_ACCRUAL';
35662 --
35663 l_balance_type_code := 'A';
35664 l_segment := NULL;
35665 l_ccid := NULL;
35666 l_adr_transaction_coa_id := NULL;
35667 l_adr_accounting_coa_id := NULL;
35668 l_adr_flexfield_segment_code := NULL;
35669 l_adr_flex_value_set_id := NULL;
35670 l_adr_value_type_code := NULL;
35671 l_adr_value_combination_id := NULL;
35672 l_adr_value_segment_code := NULL;
35673
35674 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
35675 l_bflow_class_code := ''; -- 4219869 Business Flow
35676 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
35677 l_budgetary_control_flag := 'N';
35678
35679 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35680 l_bflow_applied_to_amt := NULL; -- 5132302
35681 l_entered_amt_idx := NULL; -- 4262811
35682 l_accted_amt_idx := NULL; -- 4262811
35683 l_acc_rev_flag := NULL; -- 4262811
35684 l_accrual_line_num := NULL; -- 4262811
35685 l_tmp_amt := NULL; -- 4262811
35686 --
35687
35688 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
35689 l_balance_type_code <> 'B' THEN
35690 IF NVL(p_source_20,'
35691 ') = 'REC' AND
35692 NVL(p_source_33,'
35693 ') = 'REV' AND
35694 NVL(p_source_10,'
35695 ') = 'FEDERAL' AND
35696 NVL(p_source_11,'
35697 ') = 'Order No Advance' AND
35698 NVL(p_source_56,'
35699 ') = 'Y'
35700 THEN
35701
35702 --
35703 XLA_AE_LINES_PKG.SetNewLine;
35704
35705 p_balance_type_code := l_balance_type_code;
35706 -- set the flag so later we will know whether the gain loss line needs to be created
35707
35708 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
35709 p_actual_flag :='A';
35710 END IF;
35711
35712 --
35713 -- bulk performance
35714 --
35715 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
35716 p_header_num => 0); -- 4262811
35717 --
35718 -- set accounting line options
35719 --
35720 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
35721 p_natural_side_code => 'D'
35722 , p_gain_or_loss_flag => 'N'
35723 , p_gl_transfer_mode_code => 'S'
35724 , p_acct_entry_type_code => 'A'
35725 , p_switch_side_flag => 'Y'
35726 , p_merge_duplicate_code => 'A'
35727 );
35728 --
35729 l_acc_rev_natural_side_code := 'C'; -- 4262811
35730 --
35731 --
35732 -- set accounting line type info
35733 --
35734 xla_ae_lines_pkg.SetAcctLineType
35735 (p_component_type => l_component_type
35736 ,p_event_type_code => l_event_type_code
35737 ,p_line_definition_owner_code => l_line_definition_owner_code
35738 ,p_line_definition_code => l_line_definition_code
35739 ,p_accounting_line_code => l_component_code
35740 ,p_accounting_line_type_code => l_component_type_code
35741 ,p_accounting_line_appl_id => l_component_appl_id
35742 ,p_amb_context_code => l_amb_context_code
35743 ,p_entity_code => l_entity_code
35744 ,p_event_class_code => l_event_class_code);
35745 --
35746 -- set accounting class
35747 --
35748 xla_ae_lines_pkg.SetAcctClass(
35749 p_accounting_class_code => 'FV_CASH_DR'
35750 , p_ae_header_id => l_ae_header_id
35751 );
35752
35753 --
35754 -- set rounding class
35755 --
35756 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
35757 'RECEIVABLE';
35758
35759 --
35760 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
35761 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
35762 --
35763 -- bulk performance
35764 --
35765 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
35766
35767 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
35768 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
35769
35770 -- 4955764
35771 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
35772 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
35773
35774 -- 4458381 Public Sector Enh
35775
35776 --
35777 -- set accounting attributes for the line type
35778 --
35779 l_entered_amt_idx := 8;
35780 l_accted_amt_idx := 13;
35781 l_bflow_applied_to_amt_idx := NULL; -- 5132302
35782 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
35783 l_rec_acct_attrs.array_num_value(1) := p_source_58;
35784 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
35785 l_rec_acct_attrs.array_char_value(2) := p_source_35;
35786 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
35787 l_rec_acct_attrs.array_char_value(3) := p_source_59;
35788 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
35789 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
35790 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
35791 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
35792 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
35793 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
35794 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
35795 l_rec_acct_attrs.array_char_value(7) := p_source_23;
35796 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
35797 l_rec_acct_attrs.array_num_value(8) := p_source_24;
35798 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
35799 l_rec_acct_attrs.array_char_value(9) := p_source_61;
35800 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
35801 l_rec_acct_attrs.array_date_value(10) := p_source_57;
35802 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
35803 l_rec_acct_attrs.array_num_value(11) := p_source_62;
35804 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
35805 l_rec_acct_attrs.array_char_value(12) := p_source_28;
35806 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
35807 l_rec_acct_attrs.array_num_value(13) := p_source_29;
35808 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
35809 l_rec_acct_attrs.array_num_value(14) := p_source_63;
35810 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
35811 l_rec_acct_attrs.array_num_value(15) := p_source_64;
35812 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
35813 l_rec_acct_attrs.array_char_value(16) := p_source_65;
35814
35815 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
35816 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
35817
35818 ---------------------------------------------------------------------------------------------------------------
35819 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
35820 ---------------------------------------------------------------------------------------------------------------
35821 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
35822
35823 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
35824 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
35825
35826 IF xla_accounting_cache_pkg.GetValueChar
35827 (p_source_code => 'LEDGER_CATEGORY_CODE'
35828 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
35829 AND l_bflow_method_code = 'PRIOR_ENTRY'
35830 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
35831 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
35832 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
35833 )
35834 THEN
35835 xla_ae_lines_pkg.BflowUpgEntry
35836 (p_business_method_code => l_bflow_method_code
35840 NULL;
35837 ,p_business_class_code => l_bflow_class_code
35838 ,p_balance_type => l_balance_type_code);
35839 ELSE
35841 -- No business flow processing for business flow method of NONE.
35842 END IF;
35843
35844 --
35845 -- call analytical criteria
35846 --
35847
35848 --
35849 -- call description
35850 --
35851 -- No description or it is inherited.
35852 --
35853 -- call ADRs
35854 -- Bug 4922099
35855 --
35856 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
35857 (NVL(l_actual_upg_option, 'N') = 'O') OR
35858 (NVL(l_enc_upg_option, 'N') = 'O')
35859 )
35860 THEN
35861 NULL;
35862 --
35863 --
35864
35865 l_ccid := AcctDerRule_4(
35866 p_application_id => p_application_id
35867 , p_ae_header_id => l_ae_header_id
35868 , p_source_5 => p_source_5
35869 , x_transaction_coa_id => l_adr_transaction_coa_id
35870 , x_accounting_coa_id => l_adr_accounting_coa_id
35871 , x_value_type_code => l_adr_value_type_code
35872 , p_side => 'NA'
35873 );
35874
35875 xla_ae_lines_pkg.set_ccid(
35876 p_code_combination_id => l_ccid
35877 , p_value_type_code => l_adr_value_type_code
35878 , p_transaction_coa_id => l_adr_transaction_coa_id
35879 , p_accounting_coa_id => l_adr_accounting_coa_id
35880 , p_adr_code => 'DIST_CCID'
35881 , p_adr_type_code => 'S'
35882 , p_component_type => l_component_type
35883 , p_component_code => l_component_code
35884 , p_component_type_code => l_component_type_code
35885 , p_component_appl_id => l_component_appl_id
35886 , p_amb_context_code => l_amb_context_code
35887 , p_side => 'NA'
35888 );
35889
35890
35891 l_segment := AcctDerRule_11(
35892 p_application_id => p_application_id
35893 , p_ae_header_id => l_ae_header_id
35894 , p_source_11 => p_source_11
35895 , x_transaction_coa_id => l_adr_transaction_coa_id
35896 , x_accounting_coa_id => l_adr_accounting_coa_id
35897 , x_flexfield_segment_code => l_adr_flexfield_segment_code
35898 , x_flex_value_set_id => l_adr_flex_value_set_id
35899 , x_value_type_code => l_adr_value_type_code
35900 , x_value_combination_id => l_adr_value_combination_id
35901 , x_value_segment_code => l_adr_value_segment_code
35902 , p_side => 'NA'
35903 , p_override_seg_flag => 'Y'
35904 );
35905
35906 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
35907
35908 xla_ae_lines_pkg.set_segment(
35909 p_to_segment_code => 'GL_ACCOUNT'
35910 , p_segment_value => l_segment
35911 , p_from_segment_code => l_adr_value_segment_code
35912 , p_from_combination_id => l_adr_value_combination_id
35913 , p_value_type_code => l_adr_value_type_code
35914 , p_transaction_coa_id => l_adr_transaction_coa_id
35915 , p_accounting_coa_id => l_adr_accounting_coa_id
35916 , p_flexfield_segment_code => l_adr_flexfield_segment_code
35917 , p_flex_value_set_id => l_adr_flex_value_set_id
35918 , p_adr_code => 'FV_AR_425201_RCT_DR'
35919 , p_adr_type_code => 'S'
35920 , p_component_type => l_component_type
35921 , p_component_code => l_component_code
35922 , p_component_type_code => l_component_type_code
35923 , p_component_appl_id => l_component_appl_id
35924 , p_amb_context_code => l_amb_context_code
35925 , p_entity_code => 'RECEIPTS'
35926 , p_event_class_code => 'RECEIPT'
35927 , p_side => 'NA'
35928 );
35929
35930 END IF;
35931
35932 --
35933 --
35934 END IF;
35935 --
35936 -- Bug 4922099
35937 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
35938 (NVL(l_enc_upg_option, 'N') = 'O')
35939 ) AND
35940 (l_bflow_method_code = 'PRIOR_ENTRY')
35941 )
35942 THEN
35943 IF
35944 --
35945 1 = 2
35946 --
35947 THEN
35948 xla_accounting_err_pkg.build_message
35949 (p_appli_s_name => 'XLA'
35950 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35951 ,p_token_1 => 'LINE_NUMBER'
35952 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
35953 ,p_token_2 => 'LINE_TYPE_NAME'
35954 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
35955 l_component_type
35956 ,l_component_code
35957 ,l_component_type_code
35958 ,l_component_appl_id
35959 ,l_amb_context_code
35960 ,l_entity_code
35961 ,l_event_class_code
35962 )
35963 ,p_token_3 => 'OWNER'
35964 ,p_value_3 => xla_lookups_pkg.get_meaning(
35965 p_lookup_type => 'XLA_OWNER_TYPE'
35966 ,p_lookup_code => l_component_type_code
35967 )
35968 ,p_token_4 => 'PRODUCT_NAME'
35969 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
35970 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
35971 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
35975
35972 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
35973 ,p_ae_header_id => NULL
35974 );
35976 IF (C_LEVEL_ERROR>= g_log_level) THEN
35977 trace
35978 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
35979 ,p_level => C_LEVEL_ERROR
35980 ,p_module => l_log_module);
35981 END IF;
35982 END IF;
35983 END IF;
35984 --
35985 --
35986 ------------------------------------------------------------------------------------------------
35987 -- 4219869 Business Flow
35988 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
35989 -- Prior Entry. Currently, the following code is always generated.
35990 ------------------------------------------------------------------------------------------------
35991 XLA_AE_LINES_PKG.ValidateCurrentLine;
35992
35993 ------------------------------------------------------------------------------------
35994 -- 4219869 Business Flow
35995 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
35996 ------------------------------------------------------------------------------------
35997 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
35998
35999 ----------------------------------------------------------------------------------
36000 -- 4219869 Business Flow
36001 -- Update journal entry status -- Need to generate this within IF <condition>
36002 ----------------------------------------------------------------------------------
36003 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36004 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
36005 ,p_balance_type_code => l_balance_type_code
36006 );
36007
36008 -------------------------------------------------------------------------------------------
36009 -- 4262811 - Generate the Accrual Reversal lines
36010 -------------------------------------------------------------------------------------------
36011 BEGIN
36012 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
36013 (g_array_event(p_event_id).array_value_num('header_index'));
36014 IF l_acc_rev_flag IS NULL THEN
36015 l_acc_rev_flag := 'N';
36016 END IF;
36017 EXCEPTION
36018 WHEN OTHERS THEN
36019 l_acc_rev_flag := 'N';
36020 END;
36021 --
36022 IF (l_acc_rev_flag = 'Y') THEN
36023
36024 -- 4645092 ------------------------------------------------------------------------------
36025 -- To allow MPA report to determine if it should generate report process
36026 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
36027 ------------------------------------------------------------------------------------------
36028
36029 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
36030 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
36031 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
36032 -- call ADRs
36033 -- Bug 4922099
36034 --
36035 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36036 (NVL(l_actual_upg_option, 'N') = 'O') OR
36037 (NVL(l_enc_upg_option, 'N') = 'O')
36038 )
36039 THEN
36040 NULL;
36041 --
36042 --
36043
36044 l_ccid := AcctDerRule_4(
36045 p_application_id => p_application_id
36046 , p_ae_header_id => l_ae_header_id
36047 , p_source_5 => p_source_5
36048 , x_transaction_coa_id => l_adr_transaction_coa_id
36049 , x_accounting_coa_id => l_adr_accounting_coa_id
36050 , x_value_type_code => l_adr_value_type_code
36051 , p_side => 'NA'
36052 );
36053
36054 xla_ae_lines_pkg.set_ccid(
36055 p_code_combination_id => l_ccid
36056 , p_value_type_code => l_adr_value_type_code
36057 , p_transaction_coa_id => l_adr_transaction_coa_id
36058 , p_accounting_coa_id => l_adr_accounting_coa_id
36059 , p_adr_code => 'DIST_CCID'
36060 , p_adr_type_code => 'S'
36061 , p_component_type => l_component_type
36062 , p_component_code => l_component_code
36063 , p_component_type_code => l_component_type_code
36064 , p_component_appl_id => l_component_appl_id
36065 , p_amb_context_code => l_amb_context_code
36066 , p_side => 'NA'
36067 );
36068
36069
36070 l_segment := AcctDerRule_11(
36071 p_application_id => p_application_id
36072 , p_ae_header_id => l_ae_header_id
36073 , p_source_11 => p_source_11
36074 , x_transaction_coa_id => l_adr_transaction_coa_id
36075 , x_accounting_coa_id => l_adr_accounting_coa_id
36076 , x_flexfield_segment_code => l_adr_flexfield_segment_code
36077 , x_flex_value_set_id => l_adr_flex_value_set_id
36078 , x_value_type_code => l_adr_value_type_code
36079 , x_value_combination_id => l_adr_value_combination_id
36080 , x_value_segment_code => l_adr_value_segment_code
36081 , p_side => 'NA'
36082 , p_override_seg_flag => 'Y'
36083 );
36084
36085 IF NVL(l_segment,'NULL') <> '#$NO_OVERRIDE#$' THEN -- 4465612
36086
36087 xla_ae_lines_pkg.set_segment(
36088 p_to_segment_code => 'GL_ACCOUNT'
36089 , p_segment_value => l_segment
36090 , p_from_segment_code => l_adr_value_segment_code
36091 , p_from_combination_id => l_adr_value_combination_id
36092 , p_value_type_code => l_adr_value_type_code
36093 , p_transaction_coa_id => l_adr_transaction_coa_id
36094 , p_accounting_coa_id => l_adr_accounting_coa_id
36095 , p_flexfield_segment_code => l_adr_flexfield_segment_code
36096 , p_flex_value_set_id => l_adr_flex_value_set_id
36097 , p_adr_code => 'FV_AR_425201_RCT_DR'
36098 , p_adr_type_code => 'S'
36099 , p_component_type => l_component_type
36100 , p_component_code => l_component_code
36101 , p_component_type_code => l_component_type_code
36102 , p_component_appl_id => l_component_appl_id
36103 , p_amb_context_code => l_amb_context_code
36104 , p_entity_code => 'RECEIPTS'
36108
36105 , p_event_class_code => 'RECEIPT'
36106 , p_side => 'NA'
36107 );
36109 END IF;
36110
36111 --
36112 --
36113 END IF;
36114
36115 --
36116 -- Update the line information that should be overwritten
36117 --
36118 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
36119 p_header_num => 1);
36120 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
36121
36122 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
36123
36124 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
36125 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
36126 END IF;
36127
36128 --
36129 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
36130 --
36131 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
36132 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
36133 ELSE
36134 ---------------------------------------------------------------------------------------------------
36135 -- 4262811a Switch Sign
36136 ---------------------------------------------------------------------------------------------------
36137 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
36138 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36139 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36140 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36141 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36142 -- 5132302
36143 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
36144 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36145
36146 END IF;
36147
36148 -- 4955764
36149 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36150 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
36151
36152
36153 XLA_AE_LINES_PKG.ValidateCurrentLine;
36154 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36155
36156 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36157 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
36158 ,p_balance_type_code => l_balance_type_code);
36159
36160 END IF;
36161
36162 -----------------------------------------------------------------------------------------
36163 -- 4262811 Multiperiod Accounting
36164 -----------------------------------------------------------------------------------------
36165 -- No MPA option is assigned.
36166
36167
36168 END IF;
36169 END IF;
36170 --
36171
36172 --
36173 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36174 trace
36175 (p_msg => 'END of AcctLineType_81'
36176 ,p_level => C_LEVEL_PROCEDURE
36177 ,p_module => l_log_module);
36178 END IF;
36179 --
36180 EXCEPTION
36181 WHEN xla_exceptions_pkg.application_exception THEN
36182 RAISE;
36183 WHEN OTHERS THEN
36184 xla_exceptions_pkg.raise_message
36188
36185 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_81');
36186 END AcctLineType_81;
36187 --
36189 ---------------------------------------
36190 --
36191 -- PRIVATE FUNCTION
36192 -- AcctLineType_82
36193 --
36194 ---------------------------------------
36195 PROCEDURE AcctLineType_82 (
36196 p_application_id IN NUMBER
36197 ,p_event_id IN NUMBER
36198 ,p_calculate_acctd_flag IN VARCHAR2
36199 ,p_calculate_g_l_flag IN VARCHAR2
36200 ,p_actual_flag IN OUT VARCHAR2
36201 ,p_balance_type_code OUT VARCHAR2
36202 ,p_gain_or_loss_ref OUT VARCHAR2
36203
36204 --Transaction Distribution GL Account
36205 , p_source_19 IN NUMBER
36206 --Bill To Customer Account Identifier
36207 , p_source_30 IN NUMBER
36208 --Bill To Customer Site Use Identifier
36209 , p_source_31 IN NUMBER
36210 --SLA Party Type
36211 , p_source_32 IN VARCHAR2
36212 --Transaction Distribution Account Class
36213 , p_source_33 IN VARCHAR2
36214 --Transaction Distribution Identifier
36215 , p_source_34 IN NUMBER
36216 --Transaction Distribution Type
36217 , p_source_35 IN VARCHAR2
36218 --Transaction Distribution Entered Amount
36219 , p_source_36 IN NUMBER
36220 --Transaction Currency Code
36221 , p_source_37 IN VARCHAR2
36222 --Transaction Exchange Date
36223 , p_source_38 IN DATE
36224 --Transaction Exchange Rate
36225 , p_source_39 IN NUMBER
36226 --Transaction Exchange Rate Type
36227 , p_source_40 IN VARCHAR2
36228 --Transaction Accounting Amount
36229 , p_source_41 IN NUMBER
36230 )
36231 IS
36232
36233 l_component_type VARCHAR2(80);
36234 l_component_code VARCHAR2(30);
36235 l_component_type_code VARCHAR2(1);
36236 l_component_appl_id INTEGER;
36237 l_amb_context_code VARCHAR2(30);
36238 l_entity_code VARCHAR2(30);
36239 l_event_class_code VARCHAR2(30);
36240 l_ae_header_id NUMBER;
36241 l_event_type_code VARCHAR2(30);
36242 l_line_definition_code VARCHAR2(30);
36243 l_line_definition_owner_code VARCHAR2(1);
36244 --
36245 -- adr variables
36246 l_segment VARCHAR2(30);
36247 l_ccid NUMBER;
36248 l_adr_transaction_coa_id NUMBER;
36249 l_adr_accounting_coa_id NUMBER;
36250 l_adr_flexfield_segment_code VARCHAR2(30);
36251 l_adr_flex_value_set_id NUMBER;
36252 l_adr_value_type_code VARCHAR2(30);
36253 l_adr_value_combination_id NUMBER;
36254 l_adr_value_segment_code VARCHAR2(30);
36255
36256 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
36257 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
36258 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
36259 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
36260
36261 -- 4262811 Variables ------------------------------------------------------------------------------------------
36262 l_entered_amt_idx NUMBER;
36263 l_accted_amt_idx NUMBER;
36264 l_acc_rev_flag VARCHAR2(1);
36265 l_accrual_line_num NUMBER;
36266 l_tmp_amt NUMBER;
36270 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
36267 l_acc_rev_natural_side_code VARCHAR2(1);
36268
36269 l_num_entries NUMBER;
36271 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
36272 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
36273 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
36274 l_recog_line_1 NUMBER;
36275 l_recog_line_2 NUMBER;
36276
36277 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
36278 l_bflow_applied_to_amt NUMBER; -- 5132302
36279 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
36280
36281 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
36282
36283 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
36284 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
36285
36286 ---------------------------------------------------------------------------------------------------------------
36287
36288
36289 --
36290 -- bulk performance
36291 --
36292 l_balance_type_code VARCHAR2(1);
36293 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
36294 l_log_module VARCHAR2(240);
36295
36296 --
36297 -- Upgrade strategy
36298 --
36299 l_actual_upg_option VARCHAR2(1);
36300 l_enc_upg_option VARCHAR2(1);
36301
36302 --
36303 BEGIN
36304 --
36305 IF g_log_enabled THEN
36306 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_82';
36307 END IF;
36308 --
36309 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36310
36311 trace
36312 (p_msg => 'BEGIN of AcctLineType_82'
36313 ,p_level => C_LEVEL_PROCEDURE
36314 ,p_module => l_log_module);
36315
36316 END IF;
36317 --
36318 l_component_type := 'AMB_JLT';
36319 l_component_code := 'GUAR_DEFAULT_REC';
36320 l_component_type_code := 'S';
36321 l_component_appl_id := 222;
36322 l_amb_context_code := 'DEFAULT';
36323 l_entity_code := 'TRANSACTIONS';
36324 l_event_class_code := 'GUARANTEE';
36325 l_event_type_code := 'GUARANTEE_ALL';
36326 l_line_definition_owner_code := 'S';
36327 l_line_definition_code := 'AR_GUAR_DEFAULT_ACCRUAL';
36328 --
36329 l_balance_type_code := 'A';
36330 l_segment := NULL;
36331 l_ccid := NULL;
36332 l_adr_transaction_coa_id := NULL;
36333 l_adr_accounting_coa_id := NULL;
36334 l_adr_flexfield_segment_code := NULL;
36335 l_adr_flex_value_set_id := NULL;
36336 l_adr_value_type_code := NULL;
36337 l_adr_value_combination_id := NULL;
36338 l_adr_value_segment_code := NULL;
36339
36340 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
36341 l_bflow_class_code := ''; -- 4219869 Business Flow
36342 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
36343 l_budgetary_control_flag := 'N';
36344
36345 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36346 l_bflow_applied_to_amt := NULL; -- 5132302
36347 l_entered_amt_idx := NULL; -- 4262811
36348 l_accted_amt_idx := NULL; -- 4262811
36349 l_acc_rev_flag := NULL; -- 4262811
36350 l_accrual_line_num := NULL; -- 4262811
36351 l_tmp_amt := NULL; -- 4262811
36352 --
36353
36354 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
36355 l_balance_type_code <> 'B' THEN
36356 IF NVL(p_source_33,'
36357 ') = 'REC'
36358 THEN
36359
36360 --
36361 XLA_AE_LINES_PKG.SetNewLine;
36362
36363 p_balance_type_code := l_balance_type_code;
36364 -- set the flag so later we will know whether the gain loss line needs to be created
36365
36366 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
36367 p_actual_flag :='A';
36368 END IF;
36369
36370 --
36371 -- bulk performance
36372 --
36373 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
36374 p_header_num => 0); -- 4262811
36375 --
36376 -- set accounting line options
36377 --
36378 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
36379 p_natural_side_code => 'D'
36380 , p_gain_or_loss_flag => 'N'
36381 , p_gl_transfer_mode_code => 'S'
36382 , p_acct_entry_type_code => 'A'
36383 , p_switch_side_flag => 'Y'
36384 , p_merge_duplicate_code => 'A'
36385 );
36386 --
36387 l_acc_rev_natural_side_code := 'C'; -- 4262811
36388 --
36389 --
36390 -- set accounting line type info
36391 --
36392 xla_ae_lines_pkg.SetAcctLineType
36393 (p_component_type => l_component_type
36394 ,p_event_type_code => l_event_type_code
36395 ,p_line_definition_owner_code => l_line_definition_owner_code
36396 ,p_line_definition_code => l_line_definition_code
36397 ,p_accounting_line_code => l_component_code
36398 ,p_accounting_line_type_code => l_component_type_code
36399 ,p_accounting_line_appl_id => l_component_appl_id
36400 ,p_amb_context_code => l_amb_context_code
36401 ,p_entity_code => l_entity_code
36402 ,p_event_class_code => l_event_class_code);
36403 --
36404 -- set accounting class
36405 --
36406 xla_ae_lines_pkg.SetAcctClass(
36407 p_accounting_class_code => 'RECEIVABLE'
36408 , p_ae_header_id => l_ae_header_id
36409 );
36410
36411 --
36412 -- set rounding class
36413 --
36414 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
36415 'RECEIVABLE';
36416
36417 --
36418 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
36419 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
36420 --
36421 -- bulk performance
36422 --
36423 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
36424
36425 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
36426 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
36427
36428 -- 4955764
36429 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36430 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
36431
36432 -- 4458381 Public Sector Enh
36433
36434 --
36435 -- set accounting attributes for the line type
36436 --
36437 l_entered_amt_idx := 3;
36438 l_accted_amt_idx := 8;
36439 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36440 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
36441 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
36442 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
36443 l_rec_acct_attrs.array_char_value(2) := p_source_35;
36444 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
36445 l_rec_acct_attrs.array_num_value(3) := p_source_36;
36446 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
36447 l_rec_acct_attrs.array_char_value(4) := p_source_37;
36448 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
36449 l_rec_acct_attrs.array_date_value(5) := p_source_38;
36450 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
36451 l_rec_acct_attrs.array_num_value(6) := p_source_39;
36452 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
36453 l_rec_acct_attrs.array_char_value(7) := p_source_40;
36454 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
36455 l_rec_acct_attrs.array_num_value(8) := p_source_41;
36456 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
36457 l_rec_acct_attrs.array_num_value(9) := p_source_30;
36458 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
36459 l_rec_acct_attrs.array_num_value(10) := p_source_31;
36460 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
36461 l_rec_acct_attrs.array_char_value(11) := p_source_32;
36462
36463 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
36464 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
36465
36466 ---------------------------------------------------------------------------------------------------------------
36467 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
36468 ---------------------------------------------------------------------------------------------------------------
36472 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36469 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
36470
36471 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
36473
36474 IF xla_accounting_cache_pkg.GetValueChar
36475 (p_source_code => 'LEDGER_CATEGORY_CODE'
36476 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
36477 AND l_bflow_method_code = 'PRIOR_ENTRY'
36478 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
36479 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
36480 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
36481 )
36482 THEN
36483 xla_ae_lines_pkg.BflowUpgEntry
36484 (p_business_method_code => l_bflow_method_code
36485 ,p_business_class_code => l_bflow_class_code
36486 ,p_balance_type => l_balance_type_code);
36487 ELSE
36488 NULL;
36489 -- No business flow processing for business flow method of NONE.
36490 END IF;
36491
36492 --
36493 -- call analytical criteria
36494 --
36495
36496 --
36497 -- call description
36498 --
36499 -- No description or it is inherited.
36500 --
36501 -- call ADRs
36502 -- Bug 4922099
36503 --
36504 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36505 (NVL(l_actual_upg_option, 'N') = 'O') OR
36506 (NVL(l_enc_upg_option, 'N') = 'O')
36507 )
36508 THEN
36509 NULL;
36510 --
36511 --
36512
36513 l_ccid := AcctDerRule_28(
36514 p_application_id => p_application_id
36515 , p_ae_header_id => l_ae_header_id
36516 , p_source_19 => p_source_19
36517 , x_transaction_coa_id => l_adr_transaction_coa_id
36518 , x_accounting_coa_id => l_adr_accounting_coa_id
36519 , x_value_type_code => l_adr_value_type_code
36520 , p_side => 'NA'
36521 );
36522
36523 xla_ae_lines_pkg.set_ccid(
36524 p_code_combination_id => l_ccid
36525 , p_value_type_code => l_adr_value_type_code
36526 , p_transaction_coa_id => l_adr_transaction_coa_id
36527 , p_accounting_coa_id => l_adr_accounting_coa_id
36528 , p_adr_code => 'TRX_DIST_CCID'
36529 , p_adr_type_code => 'S'
36530 , p_component_type => l_component_type
36531 , p_component_code => l_component_code
36532 , p_component_type_code => l_component_type_code
36533 , p_component_appl_id => l_component_appl_id
36534 , p_amb_context_code => l_amb_context_code
36535 , p_side => 'NA'
36536 );
36537
36538
36539 --
36540 --
36541 END IF;
36542 --
36543 -- Bug 4922099
36544 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
36545 (NVL(l_enc_upg_option, 'N') = 'O')
36546 ) AND
36547 (l_bflow_method_code = 'PRIOR_ENTRY')
36548 )
36549 THEN
36550 IF
36551 --
36552 1 = 2
36553 --
36554 THEN
36555 xla_accounting_err_pkg.build_message
36556 (p_appli_s_name => 'XLA'
36557 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36558 ,p_token_1 => 'LINE_NUMBER'
36562 l_component_type
36559 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
36560 ,p_token_2 => 'LINE_TYPE_NAME'
36561 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
36563 ,l_component_code
36564 ,l_component_type_code
36565 ,l_component_appl_id
36566 ,l_amb_context_code
36567 ,l_entity_code
36568 ,l_event_class_code
36569 )
36570 ,p_token_3 => 'OWNER'
36571 ,p_value_3 => xla_lookups_pkg.get_meaning(
36572 p_lookup_type => 'XLA_OWNER_TYPE'
36573 ,p_lookup_code => l_component_type_code
36574 )
36575 ,p_token_4 => 'PRODUCT_NAME'
36576 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
36577 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
36578 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
36579 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
36580 ,p_ae_header_id => NULL
36581 );
36582
36583 IF (C_LEVEL_ERROR>= g_log_level) THEN
36584 trace
36585 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
36586 ,p_level => C_LEVEL_ERROR
36587 ,p_module => l_log_module);
36588 END IF;
36589 END IF;
36590 END IF;
36591 --
36592 --
36593 ------------------------------------------------------------------------------------------------
36594 -- 4219869 Business Flow
36595 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
36596 -- Prior Entry. Currently, the following code is always generated.
36597 ------------------------------------------------------------------------------------------------
36598 XLA_AE_LINES_PKG.ValidateCurrentLine;
36599
36600 ------------------------------------------------------------------------------------
36601 -- 4219869 Business Flow
36602 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
36603 ------------------------------------------------------------------------------------
36604 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36605
36606 ----------------------------------------------------------------------------------
36607 -- 4219869 Business Flow
36608 -- Update journal entry status -- Need to generate this within IF <condition>
36609 ----------------------------------------------------------------------------------
36610 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36611 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
36612 ,p_balance_type_code => l_balance_type_code
36613 );
36614
36615 -------------------------------------------------------------------------------------------
36616 -- 4262811 - Generate the Accrual Reversal lines
36617 -------------------------------------------------------------------------------------------
36618 BEGIN
36619 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
36620 (g_array_event(p_event_id).array_value_num('header_index'));
36621 IF l_acc_rev_flag IS NULL THEN
36622 l_acc_rev_flag := 'N';
36623 END IF;
36624 EXCEPTION
36625 WHEN OTHERS THEN
36626 l_acc_rev_flag := 'N';
36627 END;
36628 --
36629 IF (l_acc_rev_flag = 'Y') THEN
36630
36631 -- 4645092 ------------------------------------------------------------------------------
36632 -- To allow MPA report to determine if it should generate report process
36633 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
36634 ------------------------------------------------------------------------------------------
36635
36636 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
36637 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
36638 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
36639 -- call ADRs
36640 -- Bug 4922099
36641 --
36642 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
36643 (NVL(l_actual_upg_option, 'N') = 'O') OR
36644 (NVL(l_enc_upg_option, 'N') = 'O')
36645 )
36646 THEN
36647 NULL;
36648 --
36649 --
36650
36651 l_ccid := AcctDerRule_28(
36652 p_application_id => p_application_id
36653 , p_ae_header_id => l_ae_header_id
36654 , p_source_19 => p_source_19
36655 , x_transaction_coa_id => l_adr_transaction_coa_id
36656 , x_accounting_coa_id => l_adr_accounting_coa_id
36657 , x_value_type_code => l_adr_value_type_code
36658 , p_side => 'NA'
36659 );
36660
36661 xla_ae_lines_pkg.set_ccid(
36662 p_code_combination_id => l_ccid
36663 , p_value_type_code => l_adr_value_type_code
36664 , p_transaction_coa_id => l_adr_transaction_coa_id
36665 , p_accounting_coa_id => l_adr_accounting_coa_id
36666 , p_adr_code => 'TRX_DIST_CCID'
36667 , p_adr_type_code => 'S'
36668 , p_component_type => l_component_type
36669 , p_component_code => l_component_code
36670 , p_component_type_code => l_component_type_code
36671 , p_component_appl_id => l_component_appl_id
36672 , p_amb_context_code => l_amb_context_code
36673 , p_side => 'NA'
36674 );
36675
36676
36677 --
36678 --
36679 END IF;
36680
36681 --
36682 -- Update the line information that should be overwritten
36683 --
36684 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
36685 p_header_num => 1);
36686 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
36687
36688 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
36689
36690 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
36691 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
36692 END IF;
36693
36694 --
36695 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
36696 --
36697 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
36698 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
36699 ELSE
36700 ---------------------------------------------------------------------------------------------------
36701 -- 4262811a Switch Sign
36702 ---------------------------------------------------------------------------------------------------
36703 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
36704 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36705 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36706 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
36707 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36708 -- 5132302
36709 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
36710 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
36711
36712 END IF;
36713
36714 -- 4955764
36715 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36716 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
36717
36718
36719 XLA_AE_LINES_PKG.ValidateCurrentLine;
36720 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
36721
36722 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
36723 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
36724 ,p_balance_type_code => l_balance_type_code);
36725
36726 END IF;
36727
36728 -----------------------------------------------------------------------------------------
36729 -- 4262811 Multiperiod Accounting
36730 -----------------------------------------------------------------------------------------
36731 -- No MPA option is assigned.
36732
36733
36734 END IF;
36735 END IF;
36736 --
36737
36738 --
36739 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36740 trace
36741 (p_msg => 'END of AcctLineType_82'
36742 ,p_level => C_LEVEL_PROCEDURE
36743 ,p_module => l_log_module);
36744 END IF;
36745 --
36746 EXCEPTION
36747 WHEN xla_exceptions_pkg.application_exception THEN
36748 RAISE;
36749 WHEN OTHERS THEN
36750 xla_exceptions_pkg.raise_message
36751 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_82');
36752 END AcctLineType_82;
36753 --
36754
36755 ---------------------------------------
36756 --
36757 -- PRIVATE FUNCTION
36758 -- AcctLineType_83
36759 --
36760 ---------------------------------------
36761 PROCEDURE AcctLineType_83 (
36762 p_application_id IN NUMBER
36763 ,p_event_id IN NUMBER
36764 ,p_calculate_acctd_flag IN VARCHAR2
36765 ,p_calculate_g_l_flag IN VARCHAR2
36766 ,p_actual_flag IN OUT VARCHAR2
36767 ,p_balance_type_code OUT VARCHAR2
36768 ,p_gain_or_loss_ref OUT VARCHAR2
36769
36770 --Transaction Distribution GL Account
36771 , p_source_19 IN NUMBER
36772 --Bill To Customer Account Identifier
36773 , p_source_30 IN NUMBER
36774 --Bill To Customer Site Use Identifier
36775 , p_source_31 IN NUMBER
36776 --SLA Party Type
36777 , p_source_32 IN VARCHAR2
36778 --Transaction Distribution Account Class
36779 , p_source_33 IN VARCHAR2
36780 --Transaction Distribution Identifier
36781 , p_source_34 IN NUMBER
36782 --Transaction Distribution Type
36783 , p_source_35 IN VARCHAR2
36784 --Transaction Distribution Entered Amount
36785 , p_source_36 IN NUMBER
36786 --Transaction Currency Code
36787 , p_source_37 IN VARCHAR2
36788 --Transaction Exchange Date
36789 , p_source_38 IN DATE
36790 --Transaction Exchange Rate
36791 , p_source_39 IN NUMBER
36792 --Transaction Exchange Rate Type
36793 , p_source_40 IN VARCHAR2
36794 --Transaction Accounting Amount
36795 , p_source_41 IN NUMBER
36796 )
36797 IS
36798
36799 l_component_type VARCHAR2(80);
36800 l_component_code VARCHAR2(30);
36801 l_component_type_code VARCHAR2(1);
36802 l_component_appl_id INTEGER;
36803 l_amb_context_code VARCHAR2(30);
36804 l_entity_code VARCHAR2(30);
36805 l_event_class_code VARCHAR2(30);
36806 l_ae_header_id NUMBER;
36807 l_event_type_code VARCHAR2(30);
36808 l_line_definition_code VARCHAR2(30);
36809 l_line_definition_owner_code VARCHAR2(1);
36810 --
36811 -- adr variables
36812 l_segment VARCHAR2(30);
36813 l_ccid NUMBER;
36814 l_adr_transaction_coa_id NUMBER;
36815 l_adr_accounting_coa_id NUMBER;
36816 l_adr_flexfield_segment_code VARCHAR2(30);
36817 l_adr_flex_value_set_id NUMBER;
36818 l_adr_value_type_code VARCHAR2(30);
36819 l_adr_value_combination_id NUMBER;
36820 l_adr_value_segment_code VARCHAR2(30);
36821
36822 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
36823 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
36824 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
36825 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
36826
36827 -- 4262811 Variables ------------------------------------------------------------------------------------------
36828 l_entered_amt_idx NUMBER;
36829 l_accted_amt_idx NUMBER;
36833 l_acc_rev_natural_side_code VARCHAR2(1);
36830 l_acc_rev_flag VARCHAR2(1);
36831 l_accrual_line_num NUMBER;
36832 l_tmp_amt NUMBER;
36834
36835 l_num_entries NUMBER;
36836 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
36837 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
36838 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
36839 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
36840 l_recog_line_1 NUMBER;
36841 l_recog_line_2 NUMBER;
36842
36843 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
36844 l_bflow_applied_to_amt NUMBER; -- 5132302
36845 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
36846
36847 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
36848
36849 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
36850 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
36851
36852 ---------------------------------------------------------------------------------------------------------------
36853
36854
36855 --
36856 -- bulk performance
36857 --
36858 l_balance_type_code VARCHAR2(1);
36859 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
36860 l_log_module VARCHAR2(240);
36861
36862 --
36863 -- Upgrade strategy
36864 --
36865 l_actual_upg_option VARCHAR2(1);
36866 l_enc_upg_option VARCHAR2(1);
36867
36868 --
36869 BEGIN
36870 --
36871 IF g_log_enabled THEN
36872 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_83';
36873 END IF;
36874 --
36875 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
36876
36877 trace
36878 (p_msg => 'BEGIN of AcctLineType_83'
36879 ,p_level => C_LEVEL_PROCEDURE
36880 ,p_module => l_log_module);
36881
36882 END IF;
36883 --
36884 l_component_type := 'AMB_JLT';
36885 l_component_code := 'GUAR_REV';
36886 l_component_type_code := 'S';
36887 l_component_appl_id := 222;
36888 l_amb_context_code := 'DEFAULT';
36889 l_entity_code := 'TRANSACTIONS';
36890 l_event_class_code := 'GUARANTEE';
36891 l_event_type_code := 'GUARANTEE_ALL';
36892 l_line_definition_owner_code := 'S';
36893 l_line_definition_code := 'AR_GUAR_DEFAULT_ACCRUAL';
36894 --
36895 l_balance_type_code := 'A';
36896 l_segment := NULL;
36897 l_ccid := NULL;
36898 l_adr_transaction_coa_id := NULL;
36899 l_adr_accounting_coa_id := NULL;
36900 l_adr_flexfield_segment_code := NULL;
36901 l_adr_flex_value_set_id := NULL;
36902 l_adr_value_type_code := NULL;
36903 l_adr_value_combination_id := NULL;
36904 l_adr_value_segment_code := NULL;
36905
36906 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
36907 l_bflow_class_code := ''; -- 4219869 Business Flow
36908 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
36909 l_budgetary_control_flag := 'N';
36910
36911 l_bflow_applied_to_amt_idx := NULL; -- 5132302
36912 l_bflow_applied_to_amt := NULL; -- 5132302
36913 l_entered_amt_idx := NULL; -- 4262811
36914 l_accted_amt_idx := NULL; -- 4262811
36915 l_acc_rev_flag := NULL; -- 4262811
36916 l_accrual_line_num := NULL; -- 4262811
36917 l_tmp_amt := NULL; -- 4262811
36918 --
36919
36920 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
36921 l_balance_type_code <> 'B' THEN
36922 IF NVL(p_source_33,'
36923 ') = 'REV'
36924 THEN
36925
36926 --
36927 XLA_AE_LINES_PKG.SetNewLine;
36928
36929 p_balance_type_code := l_balance_type_code;
36930 -- set the flag so later we will know whether the gain loss line needs to be created
36931
36932 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
36933 p_actual_flag :='A';
36934 END IF;
36935
36936 --
36937 -- bulk performance
36938 --
36939 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
36940 p_header_num => 0); -- 4262811
36941 --
36942 -- set accounting line options
36943 --
36944 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
36945 p_natural_side_code => 'C'
36946 , p_gain_or_loss_flag => 'N'
36947 , p_gl_transfer_mode_code => 'S'
36948 , p_acct_entry_type_code => 'A'
36949 , p_switch_side_flag => 'Y'
36950 , p_merge_duplicate_code => 'A'
36951 );
36952 --
36953 l_acc_rev_natural_side_code := 'D'; -- 4262811
36954 --
36955 --
36956 -- set accounting line type info
36957 --
36958 xla_ae_lines_pkg.SetAcctLineType
36959 (p_component_type => l_component_type
36960 ,p_event_type_code => l_event_type_code
36961 ,p_line_definition_owner_code => l_line_definition_owner_code
36962 ,p_line_definition_code => l_line_definition_code
36963 ,p_accounting_line_code => l_component_code
36964 ,p_accounting_line_type_code => l_component_type_code
36965 ,p_accounting_line_appl_id => l_component_appl_id
36966 ,p_amb_context_code => l_amb_context_code
36967 ,p_entity_code => l_entity_code
36968 ,p_event_class_code => l_event_class_code);
36969 --
36970 -- set accounting class
36971 --
36972 xla_ae_lines_pkg.SetAcctClass(
36973 p_accounting_class_code => 'REVENUE'
36974 , p_ae_header_id => l_ae_header_id
36975 );
36976
36977 --
36978 -- set rounding class
36979 --
36980 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
36981 'RECEIVABLE';
36982
36983 --
36984 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
36985 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
36986 --
36987 -- bulk performance
36988 --
36989 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
36990
36994 -- 4955764
36991 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
36992 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
36993
36995 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
36996 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
36997
36998 -- 4458381 Public Sector Enh
36999
37000 --
37001 -- set accounting attributes for the line type
37002 --
37003 l_entered_amt_idx := 3;
37004 l_accted_amt_idx := 8;
37005 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37006 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
37007 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
37008 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
37009 l_rec_acct_attrs.array_char_value(2) := p_source_35;
37010 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
37011 l_rec_acct_attrs.array_num_value(3) := p_source_36;
37012 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
37013 l_rec_acct_attrs.array_char_value(4) := p_source_37;
37014 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
37015 l_rec_acct_attrs.array_date_value(5) := p_source_38;
37016 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
37017 l_rec_acct_attrs.array_num_value(6) := p_source_39;
37018 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
37019 l_rec_acct_attrs.array_char_value(7) := p_source_40;
37020 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
37021 l_rec_acct_attrs.array_num_value(8) := p_source_41;
37022 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
37023 l_rec_acct_attrs.array_num_value(9) := p_source_30;
37024 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
37025 l_rec_acct_attrs.array_num_value(10) := p_source_31;
37026 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
37027 l_rec_acct_attrs.array_char_value(11) := p_source_32;
37028
37029 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
37030 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
37031
37032 ---------------------------------------------------------------------------------------------------------------
37033 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
37034 ---------------------------------------------------------------------------------------------------------------
37035 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
37036
37037 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37038 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37039
37040 IF xla_accounting_cache_pkg.GetValueChar
37041 (p_source_code => 'LEDGER_CATEGORY_CODE'
37042 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
37043 AND l_bflow_method_code = 'PRIOR_ENTRY'
37044 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
37045 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
37046 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
37047 )
37048 THEN
37049 xla_ae_lines_pkg.BflowUpgEntry
37050 (p_business_method_code => l_bflow_method_code
37051 ,p_business_class_code => l_bflow_class_code
37052 ,p_balance_type => l_balance_type_code);
37053 ELSE
37054 NULL;
37055 -- No business flow processing for business flow method of NONE.
37056 END IF;
37057
37058 --
37059 -- call analytical criteria
37060 --
37061
37062 --
37063 -- call description
37064 --
37065 -- No description or it is inherited.
37066 --
37067 -- call ADRs
37068 -- Bug 4922099
37069 --
37070 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37071 (NVL(l_actual_upg_option, 'N') = 'O') OR
37072 (NVL(l_enc_upg_option, 'N') = 'O')
37073 )
37074 THEN
37075 NULL;
37076 --
37077 --
37078
37079 l_ccid := AcctDerRule_28(
37080 p_application_id => p_application_id
37081 , p_ae_header_id => l_ae_header_id
37082 , p_source_19 => p_source_19
37083 , x_transaction_coa_id => l_adr_transaction_coa_id
37084 , x_accounting_coa_id => l_adr_accounting_coa_id
37085 , x_value_type_code => l_adr_value_type_code
37086 , p_side => 'NA'
37087 );
37088
37089 xla_ae_lines_pkg.set_ccid(
37090 p_code_combination_id => l_ccid
37091 , p_value_type_code => l_adr_value_type_code
37092 , p_transaction_coa_id => l_adr_transaction_coa_id
37093 , p_accounting_coa_id => l_adr_accounting_coa_id
37094 , p_adr_code => 'TRX_DIST_CCID'
37095 , p_adr_type_code => 'S'
37096 , p_component_type => l_component_type
37097 , p_component_code => l_component_code
37098 , p_component_type_code => l_component_type_code
37099 , p_component_appl_id => l_component_appl_id
37100 , p_amb_context_code => l_amb_context_code
37101 , p_side => 'NA'
37102 );
37103
37104
37105 --
37106 --
37107 END IF;
37108 --
37109 -- Bug 4922099
37110 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
37111 (NVL(l_enc_upg_option, 'N') = 'O')
37112 ) AND
37113 (l_bflow_method_code = 'PRIOR_ENTRY')
37114 )
37115 THEN
37116 IF
37117 --
37118 1 = 2
37119 --
37120 THEN
37121 xla_accounting_err_pkg.build_message
37122 (p_appli_s_name => 'XLA'
37123 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37124 ,p_token_1 => 'LINE_NUMBER'
37125 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
37126 ,p_token_2 => 'LINE_TYPE_NAME'
37127 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
37128 l_component_type
37129 ,l_component_code
37130 ,l_component_type_code
37131 ,l_component_appl_id
37132 ,l_amb_context_code
37133 ,l_entity_code
37134 ,l_event_class_code
37135 )
37136 ,p_token_3 => 'OWNER'
37137 ,p_value_3 => xla_lookups_pkg.get_meaning(
37138 p_lookup_type => 'XLA_OWNER_TYPE'
37139 ,p_lookup_code => l_component_type_code
37140 )
37141 ,p_token_4 => 'PRODUCT_NAME'
37142 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
37143 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
37144 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
37145 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
37146 ,p_ae_header_id => NULL
37147 );
37148
37149 IF (C_LEVEL_ERROR>= g_log_level) THEN
37150 trace
37151 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37152 ,p_level => C_LEVEL_ERROR
37153 ,p_module => l_log_module);
37154 END IF;
37155 END IF;
37156 END IF;
37157 --
37158 --
37159 ------------------------------------------------------------------------------------------------
37160 -- 4219869 Business Flow
37161 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
37162 -- Prior Entry. Currently, the following code is always generated.
37163 ------------------------------------------------------------------------------------------------
37164 XLA_AE_LINES_PKG.ValidateCurrentLine;
37165
37166 ------------------------------------------------------------------------------------
37167 -- 4219869 Business Flow
37168 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
37169 ------------------------------------------------------------------------------------
37170 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37171
37172 ----------------------------------------------------------------------------------
37173 -- 4219869 Business Flow
37174 -- Update journal entry status -- Need to generate this within IF <condition>
37175 ----------------------------------------------------------------------------------
37176 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37177 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
37178 ,p_balance_type_code => l_balance_type_code
37179 );
37180
37181 -------------------------------------------------------------------------------------------
37182 -- 4262811 - Generate the Accrual Reversal lines
37183 -------------------------------------------------------------------------------------------
37184 BEGIN
37185 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
37186 (g_array_event(p_event_id).array_value_num('header_index'));
37187 IF l_acc_rev_flag IS NULL THEN
37188 l_acc_rev_flag := 'N';
37192 l_acc_rev_flag := 'N';
37189 END IF;
37190 EXCEPTION
37191 WHEN OTHERS THEN
37193 END;
37194 --
37195 IF (l_acc_rev_flag = 'Y') THEN
37196
37197 -- 4645092 ------------------------------------------------------------------------------
37198 -- To allow MPA report to determine if it should generate report process
37199 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
37200 ------------------------------------------------------------------------------------------
37201
37202 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
37203 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
37204 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
37205 -- call ADRs
37206 -- Bug 4922099
37207 --
37208 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37209 (NVL(l_actual_upg_option, 'N') = 'O') OR
37210 (NVL(l_enc_upg_option, 'N') = 'O')
37211 )
37212 THEN
37213 NULL;
37214 --
37215 --
37216
37217 l_ccid := AcctDerRule_28(
37218 p_application_id => p_application_id
37219 , p_ae_header_id => l_ae_header_id
37220 , p_source_19 => p_source_19
37221 , x_transaction_coa_id => l_adr_transaction_coa_id
37222 , x_accounting_coa_id => l_adr_accounting_coa_id
37223 , x_value_type_code => l_adr_value_type_code
37224 , p_side => 'NA'
37225 );
37226
37227 xla_ae_lines_pkg.set_ccid(
37228 p_code_combination_id => l_ccid
37229 , p_value_type_code => l_adr_value_type_code
37230 , p_transaction_coa_id => l_adr_transaction_coa_id
37231 , p_accounting_coa_id => l_adr_accounting_coa_id
37232 , p_adr_code => 'TRX_DIST_CCID'
37233 , p_adr_type_code => 'S'
37234 , p_component_type => l_component_type
37235 , p_component_code => l_component_code
37236 , p_component_type_code => l_component_type_code
37237 , p_component_appl_id => l_component_appl_id
37238 , p_amb_context_code => l_amb_context_code
37239 , p_side => 'NA'
37240 );
37241
37242
37243 --
37244 --
37245 END IF;
37246
37247 --
37248 -- Update the line information that should be overwritten
37249 --
37250 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
37251 p_header_num => 1);
37252 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
37253
37254 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
37255
37256 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
37260 --
37257 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
37258 END IF;
37259
37261 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
37262 --
37263 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
37264 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
37265 ELSE
37266 ---------------------------------------------------------------------------------------------------
37267 -- 4262811a Switch Sign
37268 ---------------------------------------------------------------------------------------------------
37269 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
37270 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37271 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37272 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37273 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37274 -- 5132302
37275 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
37276 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37277
37278 END IF;
37279
37280 -- 4955764
37281 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37282 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
37283
37284
37285 XLA_AE_LINES_PKG.ValidateCurrentLine;
37286 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37287
37288 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37289 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
37290 ,p_balance_type_code => l_balance_type_code);
37291
37292 END IF;
37293
37294 -----------------------------------------------------------------------------------------
37295 -- 4262811 Multiperiod Accounting
37296 -----------------------------------------------------------------------------------------
37297 -- No MPA option is assigned.
37298
37299
37300 END IF;
37301 END IF;
37302 --
37303
37304 --
37305 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37306 trace
37307 (p_msg => 'END of AcctLineType_83'
37308 ,p_level => C_LEVEL_PROCEDURE
37309 ,p_module => l_log_module);
37310 END IF;
37311 --
37312 EXCEPTION
37313 WHEN xla_exceptions_pkg.application_exception THEN
37314 RAISE;
37315 WHEN OTHERS THEN
37316 xla_exceptions_pkg.raise_message
37317 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_83');
37318 END AcctLineType_83;
37319 --
37320
37321 ---------------------------------------
37322 --
37323 -- PRIVATE FUNCTION
37324 -- AcctLineType_84
37325 --
37326 ---------------------------------------
37327 PROCEDURE AcctLineType_84 (
37328 p_application_id IN NUMBER
37329 ,p_event_id IN NUMBER
37330 ,p_calculate_acctd_flag IN VARCHAR2
37331 ,p_calculate_g_l_flag IN VARCHAR2
37332 ,p_actual_flag IN OUT VARCHAR2
37333 ,p_balance_type_code OUT VARCHAR2
37334 ,p_gain_or_loss_ref OUT VARCHAR2
37335
37336 --Transaction Distribution GL Account
37337 , p_source_19 IN NUMBER
37338 --Bill To Customer Account Identifier
37339 , p_source_30 IN NUMBER
37340 --Bill To Customer Site Use Identifier
37341 , p_source_31 IN NUMBER
37342 --SLA Party Type
37343 , p_source_32 IN VARCHAR2
37344 --Transaction Distribution Account Class
37345 , p_source_33 IN VARCHAR2
37346 --Transaction Distribution Identifier
37347 , p_source_34 IN NUMBER
37348 --Transaction Distribution Type
37349 , p_source_35 IN VARCHAR2
37350 --Transaction Distribution Entered Amount
37351 , p_source_36 IN NUMBER
37352 --Transaction Currency Code
37353 , p_source_37 IN VARCHAR2
37354 --Transaction Exchange Date
37355 , p_source_38 IN DATE
37356 --Transaction Exchange Rate
37357 , p_source_39 IN NUMBER
37358 --Transaction Exchange Rate Type
37359 , p_source_40 IN VARCHAR2
37360 --Transaction Accounting Amount
37361 , p_source_41 IN NUMBER
37362 --Transaction Tax Line Identifier
37363 , p_source_55 IN NUMBER
37364 )
37365 IS
37366
37367 l_component_type VARCHAR2(80);
37368 l_component_code VARCHAR2(30);
37369 l_component_type_code VARCHAR2(1);
37370 l_component_appl_id INTEGER;
37371 l_amb_context_code VARCHAR2(30);
37372 l_entity_code VARCHAR2(30);
37373 l_event_class_code VARCHAR2(30);
37374 l_ae_header_id NUMBER;
37375 l_event_type_code VARCHAR2(30);
37376 l_line_definition_code VARCHAR2(30);
37377 l_line_definition_owner_code VARCHAR2(1);
37378 --
37379 -- adr variables
37380 l_segment VARCHAR2(30);
37381 l_ccid NUMBER;
37382 l_adr_transaction_coa_id NUMBER;
37383 l_adr_accounting_coa_id NUMBER;
37384 l_adr_flexfield_segment_code VARCHAR2(30);
37385 l_adr_flex_value_set_id NUMBER;
37386 l_adr_value_type_code VARCHAR2(30);
37387 l_adr_value_combination_id NUMBER;
37388 l_adr_value_segment_code VARCHAR2(30);
37389
37390 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
37391 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
37392 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
37393 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
37394
37395 -- 4262811 Variables ------------------------------------------------------------------------------------------
37396 l_entered_amt_idx NUMBER;
37397 l_accted_amt_idx NUMBER;
37398 l_acc_rev_flag VARCHAR2(1);
37399 l_accrual_line_num NUMBER;
37400 l_tmp_amt NUMBER;
37401 l_acc_rev_natural_side_code VARCHAR2(1);
37402
37403 l_num_entries NUMBER;
37404 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
37405 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
37409 l_recog_line_2 NUMBER;
37406 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
37407 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
37408 l_recog_line_1 NUMBER;
37410
37411 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
37412 l_bflow_applied_to_amt NUMBER; -- 5132302
37413 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
37414
37415 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
37416
37417 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
37418 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
37419
37420 ---------------------------------------------------------------------------------------------------------------
37421
37422
37423 --
37424 -- bulk performance
37425 --
37426 l_balance_type_code VARCHAR2(1);
37427 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
37428 l_log_module VARCHAR2(240);
37429
37430 --
37431 -- Upgrade strategy
37432 --
37433 l_actual_upg_option VARCHAR2(1);
37434 l_enc_upg_option VARCHAR2(1);
37435
37436 --
37437 BEGIN
37438 --
37439 IF g_log_enabled THEN
37440 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_84';
37441 END IF;
37442 --
37443 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37444
37445 trace
37446 (p_msg => 'BEGIN of AcctLineType_84'
37447 ,p_level => C_LEVEL_PROCEDURE
37448 ,p_module => l_log_module);
37449
37450 END IF;
37451 --
37452 l_component_type := 'AMB_JLT';
37453 l_component_code := 'INV_CHARGES';
37454 l_component_type_code := 'S';
37455 l_component_appl_id := 222;
37456 l_amb_context_code := 'DEFAULT';
37457 l_entity_code := 'TRANSACTIONS';
37458 l_event_class_code := 'INVOICE';
37459 l_event_type_code := 'INVOICE_ALL';
37460 l_line_definition_owner_code := 'S';
37461 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
37462 --
37463 l_balance_type_code := 'A';
37464 l_segment := NULL;
37465 l_ccid := NULL;
37466 l_adr_transaction_coa_id := NULL;
37467 l_adr_accounting_coa_id := NULL;
37468 l_adr_flexfield_segment_code := NULL;
37469 l_adr_flex_value_set_id := NULL;
37470 l_adr_value_type_code := NULL;
37471 l_adr_value_combination_id := NULL;
37472 l_adr_value_segment_code := NULL;
37473
37474 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
37475 l_bflow_class_code := ''; -- 4219869 Business Flow
37476 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
37477 l_budgetary_control_flag := 'N';
37478
37479 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37480 l_bflow_applied_to_amt := NULL; -- 5132302
37481 l_entered_amt_idx := NULL; -- 4262811
37482 l_accted_amt_idx := NULL; -- 4262811
37483 l_acc_rev_flag := NULL; -- 4262811
37484 l_accrual_line_num := NULL; -- 4262811
37485 l_tmp_amt := NULL; -- 4262811
37486 --
37487
37488 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
37489 l_balance_type_code <> 'B' THEN
37490 IF NVL(p_source_33,'
37491 ') = 'CHARGES'
37492 THEN
37493
37494 --
37495 XLA_AE_LINES_PKG.SetNewLine;
37496
37497 p_balance_type_code := l_balance_type_code;
37498 -- set the flag so later we will know whether the gain loss line needs to be created
37499
37500 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
37501 p_actual_flag :='A';
37502 END IF;
37503
37504 --
37505 -- bulk performance
37506 --
37507 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
37508 p_header_num => 0); -- 4262811
37509 --
37510 -- set accounting line options
37511 --
37512 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
37513 p_natural_side_code => 'C'
37514 , p_gain_or_loss_flag => 'N'
37515 , p_gl_transfer_mode_code => 'S'
37516 , p_acct_entry_type_code => 'A'
37517 , p_switch_side_flag => 'Y'
37518 , p_merge_duplicate_code => 'A'
37519 );
37520 --
37521 l_acc_rev_natural_side_code := 'D'; -- 4262811
37522 --
37523 --
37524 -- set accounting line type info
37525 --
37526 xla_ae_lines_pkg.SetAcctLineType
37527 (p_component_type => l_component_type
37528 ,p_event_type_code => l_event_type_code
37529 ,p_line_definition_owner_code => l_line_definition_owner_code
37530 ,p_line_definition_code => l_line_definition_code
37531 ,p_accounting_line_code => l_component_code
37532 ,p_accounting_line_type_code => l_component_type_code
37533 ,p_accounting_line_appl_id => l_component_appl_id
37534 ,p_amb_context_code => l_amb_context_code
37535 ,p_entity_code => l_entity_code
37536 ,p_event_class_code => l_event_class_code);
37537 --
37538 -- set accounting class
37539 --
37540 xla_ae_lines_pkg.SetAcctClass(
37541 p_accounting_class_code => 'CHARGES'
37542 , p_ae_header_id => l_ae_header_id
37543 );
37544
37545 --
37546 -- set rounding class
37547 --
37548 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
37549 'RECEIVABLE';
37550
37551 --
37552 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
37553 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
37554 --
37555 -- bulk performance
37556 --
37557 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
37558
37559 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
37560 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
37561
37562 -- 4955764
37563 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37564 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
37565
37566 -- 4458381 Public Sector Enh
37567
37568 --
37569 -- set accounting attributes for the line type
37570 --
37571 l_entered_amt_idx := 3;
37572 l_accted_amt_idx := 8;
37573 l_bflow_applied_to_amt_idx := NULL; -- 5132302
37574 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
37575 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
37576 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
37577 l_rec_acct_attrs.array_char_value(2) := p_source_35;
37578 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
37579 l_rec_acct_attrs.array_num_value(3) := p_source_36;
37580 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
37581 l_rec_acct_attrs.array_char_value(4) := p_source_37;
37582 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
37583 l_rec_acct_attrs.array_date_value(5) := p_source_38;
37584 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
37585 l_rec_acct_attrs.array_num_value(6) := p_source_39;
37586 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
37587 l_rec_acct_attrs.array_char_value(7) := p_source_40;
37588 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
37589 l_rec_acct_attrs.array_num_value(8) := p_source_41;
37590 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
37591 l_rec_acct_attrs.array_num_value(9) := p_source_30;
37592 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
37593 l_rec_acct_attrs.array_num_value(10) := p_source_31;
37594 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
37595 l_rec_acct_attrs.array_char_value(11) := p_source_32;
37596 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
37597 l_rec_acct_attrs.array_num_value(12) := p_source_55;
37598
37599 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
37600 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
37601
37602 ---------------------------------------------------------------------------------------------------------------
37603 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
37604 ---------------------------------------------------------------------------------------------------------------
37605 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
37606
37607 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37608 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
37609
37610 IF xla_accounting_cache_pkg.GetValueChar
37611 (p_source_code => 'LEDGER_CATEGORY_CODE'
37612 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
37613 AND l_bflow_method_code = 'PRIOR_ENTRY'
37614 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
37618 THEN
37615 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
37616 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
37617 )
37619 xla_ae_lines_pkg.BflowUpgEntry
37620 (p_business_method_code => l_bflow_method_code
37621 ,p_business_class_code => l_bflow_class_code
37622 ,p_balance_type => l_balance_type_code);
37623 ELSE
37624 NULL;
37625 -- No business flow processing for business flow method of NONE.
37626 END IF;
37627
37628 --
37629 -- call analytical criteria
37630 --
37631
37632 --
37633 -- call description
37634 --
37635 -- No description or it is inherited.
37636 --
37637 -- call ADRs
37638 -- Bug 4922099
37639 --
37640 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37641 (NVL(l_actual_upg_option, 'N') = 'O') OR
37642 (NVL(l_enc_upg_option, 'N') = 'O')
37643 )
37644 THEN
37645 NULL;
37646 --
37647 --
37648
37649 l_ccid := AcctDerRule_28(
37650 p_application_id => p_application_id
37651 , p_ae_header_id => l_ae_header_id
37652 , p_source_19 => p_source_19
37653 , x_transaction_coa_id => l_adr_transaction_coa_id
37654 , x_accounting_coa_id => l_adr_accounting_coa_id
37655 , x_value_type_code => l_adr_value_type_code
37656 , p_side => 'NA'
37657 );
37658
37659 xla_ae_lines_pkg.set_ccid(
37660 p_code_combination_id => l_ccid
37661 , p_value_type_code => l_adr_value_type_code
37662 , p_transaction_coa_id => l_adr_transaction_coa_id
37663 , p_accounting_coa_id => l_adr_accounting_coa_id
37664 , p_adr_code => 'TRX_DIST_CCID'
37665 , p_adr_type_code => 'S'
37666 , p_component_type => l_component_type
37667 , p_component_code => l_component_code
37668 , p_component_type_code => l_component_type_code
37669 , p_component_appl_id => l_component_appl_id
37670 , p_amb_context_code => l_amb_context_code
37671 , p_side => 'NA'
37672 );
37673
37674
37675 --
37676 --
37677 END IF;
37678 --
37679 -- Bug 4922099
37680 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
37681 (NVL(l_enc_upg_option, 'N') = 'O')
37682 ) AND
37683 (l_bflow_method_code = 'PRIOR_ENTRY')
37684 )
37685 THEN
37686 IF
37687 --
37688 1 = 2
37689 --
37690 THEN
37691 xla_accounting_err_pkg.build_message
37692 (p_appli_s_name => 'XLA'
37693 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37694 ,p_token_1 => 'LINE_NUMBER'
37695 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
37696 ,p_token_2 => 'LINE_TYPE_NAME'
37697 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
37698 l_component_type
37699 ,l_component_code
37700 ,l_component_type_code
37701 ,l_component_appl_id
37702 ,l_amb_context_code
37703 ,l_entity_code
37704 ,l_event_class_code
37705 )
37706 ,p_token_3 => 'OWNER'
37707 ,p_value_3 => xla_lookups_pkg.get_meaning(
37708 p_lookup_type => 'XLA_OWNER_TYPE'
37709 ,p_lookup_code => l_component_type_code
37710 )
37711 ,p_token_4 => 'PRODUCT_NAME'
37712 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
37713 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
37714 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
37715 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
37716 ,p_ae_header_id => NULL
37717 );
37718
37719 IF (C_LEVEL_ERROR>= g_log_level) THEN
37720 trace
37721 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
37722 ,p_level => C_LEVEL_ERROR
37723 ,p_module => l_log_module);
37724 END IF;
37725 END IF;
37726 END IF;
37727 --
37728 --
37729 ------------------------------------------------------------------------------------------------
37730 -- 4219869 Business Flow
37731 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
37732 -- Prior Entry. Currently, the following code is always generated.
37733 ------------------------------------------------------------------------------------------------
37734 XLA_AE_LINES_PKG.ValidateCurrentLine;
37735
37736 ------------------------------------------------------------------------------------
37737 -- 4219869 Business Flow
37738 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
37739 ------------------------------------------------------------------------------------
37740 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37741
37742 ----------------------------------------------------------------------------------
37743 -- 4219869 Business Flow
37744 -- Update journal entry status -- Need to generate this within IF <condition>
37745 ----------------------------------------------------------------------------------
37746 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37747 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
37748 ,p_balance_type_code => l_balance_type_code
37749 );
37750
37751 -------------------------------------------------------------------------------------------
37752 -- 4262811 - Generate the Accrual Reversal lines
37753 -------------------------------------------------------------------------------------------
37754 BEGIN
37755 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
37756 (g_array_event(p_event_id).array_value_num('header_index'));
37757 IF l_acc_rev_flag IS NULL THEN
37758 l_acc_rev_flag := 'N';
37759 END IF;
37760 EXCEPTION
37761 WHEN OTHERS THEN
37762 l_acc_rev_flag := 'N';
37763 END;
37764 --
37765 IF (l_acc_rev_flag = 'Y') THEN
37766
37767 -- 4645092 ------------------------------------------------------------------------------
37768 -- To allow MPA report to determine if it should generate report process
37769 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
37770 ------------------------------------------------------------------------------------------
37771
37772 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
37773 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
37774 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
37775 -- call ADRs
37776 -- Bug 4922099
37777 --
37778 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
37779 (NVL(l_actual_upg_option, 'N') = 'O') OR
37780 (NVL(l_enc_upg_option, 'N') = 'O')
37781 )
37782 THEN
37783 NULL;
37784 --
37785 --
37786
37787 l_ccid := AcctDerRule_28(
37788 p_application_id => p_application_id
37789 , p_ae_header_id => l_ae_header_id
37790 , p_source_19 => p_source_19
37791 , x_transaction_coa_id => l_adr_transaction_coa_id
37792 , x_accounting_coa_id => l_adr_accounting_coa_id
37793 , x_value_type_code => l_adr_value_type_code
37794 , p_side => 'NA'
37795 );
37796
37797 xla_ae_lines_pkg.set_ccid(
37798 p_code_combination_id => l_ccid
37799 , p_value_type_code => l_adr_value_type_code
37800 , p_transaction_coa_id => l_adr_transaction_coa_id
37801 , p_accounting_coa_id => l_adr_accounting_coa_id
37802 , p_adr_code => 'TRX_DIST_CCID'
37803 , p_adr_type_code => 'S'
37804 , p_component_type => l_component_type
37805 , p_component_code => l_component_code
37806 , p_component_type_code => l_component_type_code
37807 , p_component_appl_id => l_component_appl_id
37808 , p_amb_context_code => l_amb_context_code
37809 , p_side => 'NA'
37810 );
37811
37812
37813 --
37814 --
37815 END IF;
37816
37817 --
37818 -- Update the line information that should be overwritten
37819 --
37820 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
37821 p_header_num => 1);
37822 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
37823
37824 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
37825
37826 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
37827 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
37828 END IF;
37829
37830 --
37834 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
37831 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
37832 --
37833 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
37835 ELSE
37836 ---------------------------------------------------------------------------------------------------
37837 -- 4262811a Switch Sign
37838 ---------------------------------------------------------------------------------------------------
37839 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
37840 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37841 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37842 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
37843 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37844 -- 5132302
37845 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
37846 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
37847
37848 END IF;
37849
37850 -- 4955764
37851 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
37852 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
37853
37854
37855 XLA_AE_LINES_PKG.ValidateCurrentLine;
37856 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
37857
37858 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
37859 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
37860 ,p_balance_type_code => l_balance_type_code);
37861
37862 END IF;
37863
37864 -----------------------------------------------------------------------------------------
37865 -- 4262811 Multiperiod Accounting
37866 -----------------------------------------------------------------------------------------
37867 -- No MPA option is assigned.
37868
37869
37870 END IF;
37871 END IF;
37872 --
37873
37874 --
37875 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
37876 trace
37877 (p_msg => 'END of AcctLineType_84'
37878 ,p_level => C_LEVEL_PROCEDURE
37879 ,p_module => l_log_module);
37880 END IF;
37881 --
37882 EXCEPTION
37883 WHEN xla_exceptions_pkg.application_exception THEN
37884 RAISE;
37885 WHEN OTHERS THEN
37886 xla_exceptions_pkg.raise_message
37887 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_84');
37888 END AcctLineType_84;
37889 --
37890
37891 ---------------------------------------
37892 --
37893 -- PRIVATE FUNCTION
37894 -- AcctLineType_85
37895 --
37896 ---------------------------------------
37897 PROCEDURE AcctLineType_85 (
37898 p_application_id IN NUMBER
37899 ,p_event_id IN NUMBER
37900 ,p_calculate_acctd_flag IN VARCHAR2
37901 ,p_calculate_g_l_flag IN VARCHAR2
37902 ,p_actual_flag IN OUT VARCHAR2
37903 ,p_balance_type_code OUT VARCHAR2
37904 ,p_gain_or_loss_ref OUT VARCHAR2
37905
37906 --Transaction Distribution GL Account
37907 , p_source_19 IN NUMBER
37908 --Bill To Customer Account Identifier
37909 , p_source_30 IN NUMBER
37910 --Bill To Customer Site Use Identifier
37911 , p_source_31 IN NUMBER
37912 --SLA Party Type
37913 , p_source_32 IN VARCHAR2
37914 --Transaction Distribution Account Class
37915 , p_source_33 IN VARCHAR2
37916 --Transaction Distribution Identifier
37917 , p_source_34 IN NUMBER
37918 --Transaction Distribution Type
37919 , p_source_35 IN VARCHAR2
37920 --Transaction Distribution Entered Amount
37921 , p_source_36 IN NUMBER
37922 --Transaction Currency Code
37923 , p_source_37 IN VARCHAR2
37924 --Transaction Exchange Date
37925 , p_source_38 IN DATE
37926 --Transaction Exchange Rate
37927 , p_source_39 IN NUMBER
37928 --Transaction Exchange Rate Type
37929 , p_source_40 IN VARCHAR2
37930 --Transaction Accounting Amount
37931 , p_source_41 IN NUMBER
37932 --Transaction Tax Line Identifier
37933 , p_source_55 IN NUMBER
37934 )
37935 IS
37936
37937 l_component_type VARCHAR2(80);
37938 l_component_code VARCHAR2(30);
37939 l_component_type_code VARCHAR2(1);
37940 l_component_appl_id INTEGER;
37941 l_amb_context_code VARCHAR2(30);
37942 l_entity_code VARCHAR2(30);
37943 l_event_class_code VARCHAR2(30);
37944 l_ae_header_id NUMBER;
37945 l_event_type_code VARCHAR2(30);
37946 l_line_definition_code VARCHAR2(30);
37947 l_line_definition_owner_code VARCHAR2(1);
37948 --
37949 -- adr variables
37950 l_segment VARCHAR2(30);
37951 l_ccid NUMBER;
37952 l_adr_transaction_coa_id NUMBER;
37953 l_adr_accounting_coa_id NUMBER;
37954 l_adr_flexfield_segment_code VARCHAR2(30);
37955 l_adr_flex_value_set_id NUMBER;
37959
37956 l_adr_value_type_code VARCHAR2(30);
37957 l_adr_value_combination_id NUMBER;
37958 l_adr_value_segment_code VARCHAR2(30);
37960 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
37961 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
37962 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
37963 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
37964
37965 -- 4262811 Variables ------------------------------------------------------------------------------------------
37966 l_entered_amt_idx NUMBER;
37967 l_accted_amt_idx NUMBER;
37968 l_acc_rev_flag VARCHAR2(1);
37969 l_accrual_line_num NUMBER;
37970 l_tmp_amt NUMBER;
37971 l_acc_rev_natural_side_code VARCHAR2(1);
37972
37973 l_num_entries NUMBER;
37974 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
37975 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
37976 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
37977 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
37978 l_recog_line_1 NUMBER;
37982 l_bflow_applied_to_amt NUMBER; -- 5132302
37979 l_recog_line_2 NUMBER;
37980
37981 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
37983 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
37984
37985 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
37986
37987 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
37988 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
37989
37990 ---------------------------------------------------------------------------------------------------------------
37991
37992
37993 --
37994 -- bulk performance
37995 --
37996 l_balance_type_code VARCHAR2(1);
37997 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
37998 l_log_module VARCHAR2(240);
37999
38000 --
38001 -- Upgrade strategy
38002 --
38003 l_actual_upg_option VARCHAR2(1);
38004 l_enc_upg_option VARCHAR2(1);
38005
38006 --
38007 BEGIN
38008 --
38009 IF g_log_enabled THEN
38010 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_85';
38011 END IF;
38012 --
38013 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38014
38015 trace
38016 (p_msg => 'BEGIN of AcctLineType_85'
38017 ,p_level => C_LEVEL_PROCEDURE
38018 ,p_module => l_log_module);
38019
38020 END IF;
38021 --
38022 l_component_type := 'AMB_JLT';
38023 l_component_code := 'INV_DEFAULT_REC';
38024 l_component_type_code := 'S';
38025 l_component_appl_id := 222;
38026 l_amb_context_code := 'DEFAULT';
38027 l_entity_code := 'TRANSACTIONS';
38028 l_event_class_code := 'INVOICE';
38029 l_event_type_code := 'INVOICE_ALL';
38030 l_line_definition_owner_code := 'S';
38031 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
38032 --
38033 l_balance_type_code := 'A';
38034 l_segment := NULL;
38035 l_ccid := NULL;
38036 l_adr_transaction_coa_id := NULL;
38037 l_adr_accounting_coa_id := NULL;
38038 l_adr_flexfield_segment_code := NULL;
38039 l_adr_flex_value_set_id := NULL;
38040 l_adr_value_type_code := NULL;
38041 l_adr_value_combination_id := NULL;
38042 l_adr_value_segment_code := NULL;
38043
38044 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
38045 l_bflow_class_code := 'RECEIVABLE'; -- 4219869 Business Flow
38046 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
38047 l_budgetary_control_flag := 'N';
38048
38049 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38050 l_bflow_applied_to_amt := NULL; -- 5132302
38051 l_entered_amt_idx := NULL; -- 4262811
38052 l_accted_amt_idx := NULL; -- 4262811
38053 l_acc_rev_flag := NULL; -- 4262811
38054 l_accrual_line_num := NULL; -- 4262811
38055 l_tmp_amt := NULL; -- 4262811
38056 --
38057
38058 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
38059 l_balance_type_code <> 'B' THEN
38060 IF NVL(p_source_33,'
38061 ') = 'REC'
38062 THEN
38063
38064 --
38065 XLA_AE_LINES_PKG.SetNewLine;
38066
38067 p_balance_type_code := l_balance_type_code;
38068 -- set the flag so later we will know whether the gain loss line needs to be created
38069
38070 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
38071 p_actual_flag :='A';
38072 END IF;
38073
38074 --
38075 -- bulk performance
38076 --
38077 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
38078 p_header_num => 0); -- 4262811
38079 --
38080 -- set accounting line options
38081 --
38082 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
38083 p_natural_side_code => 'D'
38084 , p_gain_or_loss_flag => 'N'
38085 , p_gl_transfer_mode_code => 'S'
38086 , p_acct_entry_type_code => 'A'
38087 , p_switch_side_flag => 'Y'
38088 , p_merge_duplicate_code => 'A'
38089 );
38090 --
38091 l_acc_rev_natural_side_code := 'C'; -- 4262811
38092 --
38093 --
38094 -- set accounting line type info
38095 --
38096 xla_ae_lines_pkg.SetAcctLineType
38097 (p_component_type => l_component_type
38098 ,p_event_type_code => l_event_type_code
38099 ,p_line_definition_owner_code => l_line_definition_owner_code
38100 ,p_line_definition_code => l_line_definition_code
38101 ,p_accounting_line_code => l_component_code
38102 ,p_accounting_line_type_code => l_component_type_code
38103 ,p_accounting_line_appl_id => l_component_appl_id
38104 ,p_amb_context_code => l_amb_context_code
38105 ,p_entity_code => l_entity_code
38106 ,p_event_class_code => l_event_class_code);
38107 --
38108 -- set accounting class
38109 --
38110 xla_ae_lines_pkg.SetAcctClass(
38111 p_accounting_class_code => 'RECEIVABLE'
38112 , p_ae_header_id => l_ae_header_id
38113 );
38114
38115 --
38116 -- set rounding class
38117 --
38118 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
38119 'RECEIVABLE';
38120
38121 --
38122 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
38123 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
38124 --
38125 -- bulk performance
38126 --
38127 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
38128
38129 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
38130 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
38131
38132 -- 4955764
38133 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38134 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
38135
38136 -- 4458381 Public Sector Enh
38137
38138 --
38139 -- set accounting attributes for the line type
38140 --
38141 l_entered_amt_idx := 3;
38142 l_accted_amt_idx := 8;
38143 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38144 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
38145 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
38146 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
38147 l_rec_acct_attrs.array_char_value(2) := p_source_35;
38148 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
38149 l_rec_acct_attrs.array_num_value(3) := p_source_36;
38150 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
38151 l_rec_acct_attrs.array_char_value(4) := p_source_37;
38152 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
38153 l_rec_acct_attrs.array_date_value(5) := p_source_38;
38154 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
38155 l_rec_acct_attrs.array_num_value(6) := p_source_39;
38156 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
38157 l_rec_acct_attrs.array_char_value(7) := p_source_40;
38158 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
38159 l_rec_acct_attrs.array_num_value(8) := p_source_41;
38160 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
38161 l_rec_acct_attrs.array_num_value(9) := p_source_30;
38162 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
38163 l_rec_acct_attrs.array_num_value(10) := p_source_31;
38164 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
38165 l_rec_acct_attrs.array_char_value(11) := p_source_32;
38166 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
38167 l_rec_acct_attrs.array_num_value(12) := p_source_55;
38168
38169 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
38170 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
38171
38172 ---------------------------------------------------------------------------------------------------------------
38173 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
38174 ---------------------------------------------------------------------------------------------------------------
38175 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
38176
38177 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38178 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38179
38180 IF xla_accounting_cache_pkg.GetValueChar
38181 (p_source_code => 'LEDGER_CATEGORY_CODE'
38182 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
38183 AND l_bflow_method_code = 'PRIOR_ENTRY'
38184 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
38185 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
38186 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
38187 )
38188 THEN
38189 xla_ae_lines_pkg.BflowUpgEntry
38190 (p_business_method_code => l_bflow_method_code
38191 ,p_business_class_code => l_bflow_class_code
38192 ,p_balance_type => l_balance_type_code);
38193 ELSE
38194 NULL;
38195 -- No business flow processing for business flow method of NONE.
38196 END IF;
38197
38198 --
38199 -- call analytical criteria
38200 --
38201
38202 --
38203 -- call description
38204 --
38205 -- No description or it is inherited.
38206 --
38207 -- call ADRs
38208 -- Bug 4922099
38209 --
38210 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38211 (NVL(l_actual_upg_option, 'N') = 'O') OR
38212 (NVL(l_enc_upg_option, 'N') = 'O')
38213 )
38214 THEN
38215 NULL;
38216 --
38217 --
38218
38219 l_ccid := AcctDerRule_28(
38220 p_application_id => p_application_id
38221 , p_ae_header_id => l_ae_header_id
38222 , p_source_19 => p_source_19
38223 , x_transaction_coa_id => l_adr_transaction_coa_id
38224 , x_accounting_coa_id => l_adr_accounting_coa_id
38225 , x_value_type_code => l_adr_value_type_code
38226 , p_side => 'NA'
38227 );
38228
38229 xla_ae_lines_pkg.set_ccid(
38230 p_code_combination_id => l_ccid
38231 , p_value_type_code => l_adr_value_type_code
38232 , p_transaction_coa_id => l_adr_transaction_coa_id
38233 , p_accounting_coa_id => l_adr_accounting_coa_id
38234 , p_adr_code => 'TRX_DIST_CCID'
38235 , p_adr_type_code => 'S'
38236 , p_component_type => l_component_type
38237 , p_component_code => l_component_code
38238 , p_component_type_code => l_component_type_code
38239 , p_component_appl_id => l_component_appl_id
38240 , p_amb_context_code => l_amb_context_code
38241 , p_side => 'NA'
38242 );
38243
38244
38245 --
38246 --
38247 END IF;
38248 --
38249 -- Bug 4922099
38250 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
38251 (NVL(l_enc_upg_option, 'N') = 'O')
38252 ) AND
38253 (l_bflow_method_code = 'PRIOR_ENTRY')
38254 )
38255 THEN
38256 IF
38257 --
38258 1 = 2
38259 --
38260 THEN
38261 xla_accounting_err_pkg.build_message
38262 (p_appli_s_name => 'XLA'
38263 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38264 ,p_token_1 => 'LINE_NUMBER'
38265 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
38266 ,p_token_2 => 'LINE_TYPE_NAME'
38267 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
38268 l_component_type
38269 ,l_component_code
38270 ,l_component_type_code
38271 ,l_component_appl_id
38272 ,l_amb_context_code
38273 ,l_entity_code
38277 ,p_value_3 => xla_lookups_pkg.get_meaning(
38274 ,l_event_class_code
38275 )
38276 ,p_token_3 => 'OWNER'
38278 p_lookup_type => 'XLA_OWNER_TYPE'
38279 ,p_lookup_code => l_component_type_code
38280 )
38281 ,p_token_4 => 'PRODUCT_NAME'
38282 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
38283 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
38284 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
38285 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
38286 ,p_ae_header_id => NULL
38287 );
38288
38289 IF (C_LEVEL_ERROR>= g_log_level) THEN
38290 trace
38291 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38292 ,p_level => C_LEVEL_ERROR
38293 ,p_module => l_log_module);
38294 END IF;
38295 END IF;
38296 END IF;
38297 --
38298 --
38299 ------------------------------------------------------------------------------------------------
38300 -- 4219869 Business Flow
38301 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
38302 -- Prior Entry. Currently, the following code is always generated.
38303 ------------------------------------------------------------------------------------------------
38304 XLA_AE_LINES_PKG.ValidateCurrentLine;
38305
38306 ------------------------------------------------------------------------------------
38307 -- 4219869 Business Flow
38308 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
38309 ------------------------------------------------------------------------------------
38310 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38311
38312 ----------------------------------------------------------------------------------
38313 -- 4219869 Business Flow
38314 -- Update journal entry status -- Need to generate this within IF <condition>
38315 ----------------------------------------------------------------------------------
38316 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38317 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
38318 ,p_balance_type_code => l_balance_type_code
38319 );
38320
38321 -------------------------------------------------------------------------------------------
38322 -- 4262811 - Generate the Accrual Reversal lines
38323 -------------------------------------------------------------------------------------------
38324 BEGIN
38325 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
38326 (g_array_event(p_event_id).array_value_num('header_index'));
38327 IF l_acc_rev_flag IS NULL THEN
38328 l_acc_rev_flag := 'N';
38329 END IF;
38330 EXCEPTION
38331 WHEN OTHERS THEN
38332 l_acc_rev_flag := 'N';
38333 END;
38334 --
38335 IF (l_acc_rev_flag = 'Y') THEN
38336
38337 -- 4645092 ------------------------------------------------------------------------------
38338 -- To allow MPA report to determine if it should generate report process
38339 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
38340 ------------------------------------------------------------------------------------------
38341
38342 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
38343 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
38344 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
38345 -- call ADRs
38346 -- Bug 4922099
38347 --
38348 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38349 (NVL(l_actual_upg_option, 'N') = 'O') OR
38350 (NVL(l_enc_upg_option, 'N') = 'O')
38351 )
38352 THEN
38353 NULL;
38354 --
38355 --
38356
38357 l_ccid := AcctDerRule_28(
38358 p_application_id => p_application_id
38359 , p_ae_header_id => l_ae_header_id
38360 , p_source_19 => p_source_19
38361 , x_transaction_coa_id => l_adr_transaction_coa_id
38362 , x_accounting_coa_id => l_adr_accounting_coa_id
38363 , x_value_type_code => l_adr_value_type_code
38364 , p_side => 'NA'
38365 );
38366
38367 xla_ae_lines_pkg.set_ccid(
38368 p_code_combination_id => l_ccid
38369 , p_value_type_code => l_adr_value_type_code
38370 , p_transaction_coa_id => l_adr_transaction_coa_id
38371 , p_accounting_coa_id => l_adr_accounting_coa_id
38372 , p_adr_code => 'TRX_DIST_CCID'
38373 , p_adr_type_code => 'S'
38374 , p_component_type => l_component_type
38375 , p_component_code => l_component_code
38376 , p_component_type_code => l_component_type_code
38377 , p_component_appl_id => l_component_appl_id
38378 , p_amb_context_code => l_amb_context_code
38379 , p_side => 'NA'
38380 );
38381
38382
38383 --
38384 --
38385 END IF;
38386
38387 --
38388 -- Update the line information that should be overwritten
38389 --
38390 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
38391 p_header_num => 1);
38392 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
38393
38394 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
38395
38396 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
38397 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
38398 END IF;
38399
38400 --
38401 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
38402 --
38403 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
38404 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
38405 ELSE
38406 ---------------------------------------------------------------------------------------------------
38407 -- 4262811a Switch Sign
38408 ---------------------------------------------------------------------------------------------------
38409 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
38410 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38411 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38412 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38413 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38414 -- 5132302
38415 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
38416 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38417
38418 END IF;
38419
38420 -- 4955764
38421 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38422 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
38423
38424
38425 XLA_AE_LINES_PKG.ValidateCurrentLine;
38426 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38427
38428 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38429 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
38430 ,p_balance_type_code => l_balance_type_code);
38431
38432 END IF;
38433
38434 -----------------------------------------------------------------------------------------
38435 -- 4262811 Multiperiod Accounting
38436 -----------------------------------------------------------------------------------------
38437 -- No MPA option is assigned.
38438
38439
38440 END IF;
38441 END IF;
38442 --
38443
38444 --
38445 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38446 trace
38447 (p_msg => 'END of AcctLineType_85'
38448 ,p_level => C_LEVEL_PROCEDURE
38449 ,p_module => l_log_module);
38450 END IF;
38454 RAISE;
38451 --
38452 EXCEPTION
38453 WHEN xla_exceptions_pkg.application_exception THEN
38455 WHEN OTHERS THEN
38456 xla_exceptions_pkg.raise_message
38457 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_85');
38458 END AcctLineType_85;
38459 --
38460
38461 ---------------------------------------
38462 --
38463 -- PRIVATE FUNCTION
38464 -- AcctLineType_86
38465 --
38466 ---------------------------------------
38467 PROCEDURE AcctLineType_86 (
38468 p_application_id IN NUMBER
38469 ,p_event_id IN NUMBER
38470 ,p_calculate_acctd_flag IN VARCHAR2
38471 ,p_calculate_g_l_flag IN VARCHAR2
38472 ,p_actual_flag IN OUT VARCHAR2
38473 ,p_balance_type_code OUT VARCHAR2
38474 ,p_gain_or_loss_ref OUT VARCHAR2
38475
38476 --Transaction Distribution GL Account
38477 , p_source_19 IN NUMBER
38478 --Bill To Customer Account Identifier
38479 , p_source_30 IN NUMBER
38480 --Bill To Customer Site Use Identifier
38481 , p_source_31 IN NUMBER
38482 --SLA Party Type
38483 , p_source_32 IN VARCHAR2
38484 --Transaction Distribution Account Class
38485 , p_source_33 IN VARCHAR2
38486 --Transaction Distribution Identifier
38487 , p_source_34 IN NUMBER
38488 --Transaction Distribution Type
38489 , p_source_35 IN VARCHAR2
38490 --Transaction Distribution Entered Amount
38491 , p_source_36 IN NUMBER
38492 --Transaction Currency Code
38493 , p_source_37 IN VARCHAR2
38494 --Transaction Exchange Date
38495 , p_source_38 IN DATE
38496 --Transaction Exchange Rate
38497 , p_source_39 IN NUMBER
38498 --Transaction Exchange Rate Type
38499 , p_source_40 IN VARCHAR2
38500 --Transaction Accounting Amount
38501 , p_source_41 IN NUMBER
38502 --Transaction Tax Line Identifier
38503 , p_source_55 IN NUMBER
38504 )
38505 IS
38506
38507 l_component_type VARCHAR2(80);
38508 l_component_code VARCHAR2(30);
38509 l_component_type_code VARCHAR2(1);
38510 l_component_appl_id INTEGER;
38511 l_amb_context_code VARCHAR2(30);
38512 l_entity_code VARCHAR2(30);
38513 l_event_class_code VARCHAR2(30);
38514 l_ae_header_id NUMBER;
38515 l_event_type_code VARCHAR2(30);
38516 l_line_definition_code VARCHAR2(30);
38517 l_line_definition_owner_code VARCHAR2(1);
38518 --
38519 -- adr variables
38520 l_segment VARCHAR2(30);
38521 l_ccid NUMBER;
38522 l_adr_transaction_coa_id NUMBER;
38523 l_adr_accounting_coa_id NUMBER;
38524 l_adr_flexfield_segment_code VARCHAR2(30);
38525 l_adr_flex_value_set_id NUMBER;
38526 l_adr_value_type_code VARCHAR2(30);
38527 l_adr_value_combination_id NUMBER;
38528 l_adr_value_segment_code VARCHAR2(30);
38529
38530 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
38531 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
38532 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
38533 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
38534
38535 -- 4262811 Variables ------------------------------------------------------------------------------------------
38536 l_entered_amt_idx NUMBER;
38537 l_accted_amt_idx NUMBER;
38538 l_acc_rev_flag VARCHAR2(1);
38539 l_accrual_line_num NUMBER;
38540 l_tmp_amt NUMBER;
38541 l_acc_rev_natural_side_code VARCHAR2(1);
38542
38543 l_num_entries NUMBER;
38544 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
38545 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
38546 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
38547 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
38548 l_recog_line_1 NUMBER;
38549 l_recog_line_2 NUMBER;
38550
38551 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
38552 l_bflow_applied_to_amt NUMBER; -- 5132302
38553 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
38554
38555 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
38556
38557 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
38558 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
38559
38560 ---------------------------------------------------------------------------------------------------------------
38561
38562
38563 --
38564 -- bulk performance
38565 --
38566 l_balance_type_code VARCHAR2(1);
38567 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
38568 l_log_module VARCHAR2(240);
38569
38570 --
38571 -- Upgrade strategy
38572 --
38573 l_actual_upg_option VARCHAR2(1);
38574 l_enc_upg_option VARCHAR2(1);
38575
38576 --
38577 BEGIN
38578 --
38579 IF g_log_enabled THEN
38580 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_86';
38581 END IF;
38582 --
38583 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
38584
38585 trace
38586 (p_msg => 'BEGIN of AcctLineType_86'
38587 ,p_level => C_LEVEL_PROCEDURE
38588 ,p_module => l_log_module);
38589
38590 END IF;
38591 --
38592 l_component_type := 'AMB_JLT';
38596 l_amb_context_code := 'DEFAULT';
38593 l_component_code := 'INV_FREIGHT';
38594 l_component_type_code := 'S';
38595 l_component_appl_id := 222;
38597 l_entity_code := 'TRANSACTIONS';
38598 l_event_class_code := 'INVOICE';
38599 l_event_type_code := 'INVOICE_ALL';
38600 l_line_definition_owner_code := 'S';
38601 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
38602 --
38603 l_balance_type_code := 'A';
38604 l_segment := NULL;
38605 l_ccid := NULL;
38606 l_adr_transaction_coa_id := NULL;
38607 l_adr_accounting_coa_id := NULL;
38608 l_adr_flexfield_segment_code := NULL;
38609 l_adr_flex_value_set_id := NULL;
38610 l_adr_value_type_code := NULL;
38611 l_adr_value_combination_id := NULL;
38612 l_adr_value_segment_code := NULL;
38613
38614 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
38615 l_bflow_class_code := 'FREIGHT'; -- 4219869 Business Flow
38616 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
38617 l_budgetary_control_flag := 'N';
38618
38619 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38620 l_bflow_applied_to_amt := NULL; -- 5132302
38621 l_entered_amt_idx := NULL; -- 4262811
38622 l_accted_amt_idx := NULL; -- 4262811
38623 l_acc_rev_flag := NULL; -- 4262811
38624 l_accrual_line_num := NULL; -- 4262811
38625 l_tmp_amt := NULL; -- 4262811
38626 --
38627
38628 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
38629 l_balance_type_code <> 'B' THEN
38630 IF NVL(p_source_33,'
38631 ') = 'FREIGHT'
38632 THEN
38633
38634 --
38635 XLA_AE_LINES_PKG.SetNewLine;
38636
38637 p_balance_type_code := l_balance_type_code;
38638 -- set the flag so later we will know whether the gain loss line needs to be created
38639
38640 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
38641 p_actual_flag :='A';
38642 END IF;
38643
38644 --
38645 -- bulk performance
38646 --
38647 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
38648 p_header_num => 0); -- 4262811
38649 --
38650 -- set accounting line options
38651 --
38652 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
38653 p_natural_side_code => 'C'
38654 , p_gain_or_loss_flag => 'N'
38655 , p_gl_transfer_mode_code => 'S'
38656 , p_acct_entry_type_code => 'A'
38657 , p_switch_side_flag => 'Y'
38658 , p_merge_duplicate_code => 'A'
38659 );
38660 --
38661 l_acc_rev_natural_side_code := 'D'; -- 4262811
38662 --
38663 --
38664 -- set accounting line type info
38665 --
38666 xla_ae_lines_pkg.SetAcctLineType
38667 (p_component_type => l_component_type
38668 ,p_event_type_code => l_event_type_code
38669 ,p_line_definition_owner_code => l_line_definition_owner_code
38670 ,p_line_definition_code => l_line_definition_code
38671 ,p_accounting_line_code => l_component_code
38672 ,p_accounting_line_type_code => l_component_type_code
38673 ,p_accounting_line_appl_id => l_component_appl_id
38674 ,p_amb_context_code => l_amb_context_code
38675 ,p_entity_code => l_entity_code
38676 ,p_event_class_code => l_event_class_code);
38677 --
38678 -- set accounting class
38679 --
38680 xla_ae_lines_pkg.SetAcctClass(
38681 p_accounting_class_code => 'FREIGHT'
38682 , p_ae_header_id => l_ae_header_id
38683 );
38684
38685 --
38686 -- set rounding class
38687 --
38688 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
38689 'RECEIVABLE';
38690
38691 --
38692 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
38693 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
38694 --
38695 -- bulk performance
38696 --
38697 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
38698
38699 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
38700 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
38701
38702 -- 4955764
38703 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38704 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
38705
38706 -- 4458381 Public Sector Enh
38707
38708 --
38709 -- set accounting attributes for the line type
38710 --
38711 l_entered_amt_idx := 3;
38712 l_accted_amt_idx := 8;
38713 l_bflow_applied_to_amt_idx := NULL; -- 5132302
38714 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
38715 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
38716 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
38717 l_rec_acct_attrs.array_char_value(2) := p_source_35;
38718 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
38719 l_rec_acct_attrs.array_num_value(3) := p_source_36;
38720 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
38721 l_rec_acct_attrs.array_char_value(4) := p_source_37;
38722 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
38723 l_rec_acct_attrs.array_date_value(5) := p_source_38;
38724 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
38725 l_rec_acct_attrs.array_num_value(6) := p_source_39;
38726 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
38727 l_rec_acct_attrs.array_char_value(7) := p_source_40;
38728 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
38729 l_rec_acct_attrs.array_num_value(8) := p_source_41;
38730 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
38731 l_rec_acct_attrs.array_num_value(9) := p_source_30;
38732 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
38733 l_rec_acct_attrs.array_num_value(10) := p_source_31;
38734 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
38735 l_rec_acct_attrs.array_char_value(11) := p_source_32;
38736 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
38737 l_rec_acct_attrs.array_num_value(12) := p_source_55;
38738
38739 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
38740 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
38741
38742 ---------------------------------------------------------------------------------------------------------------
38743 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
38744 ---------------------------------------------------------------------------------------------------------------
38745 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
38746
38747 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38748 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
38749
38750 IF xla_accounting_cache_pkg.GetValueChar
38751 (p_source_code => 'LEDGER_CATEGORY_CODE'
38752 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
38753 AND l_bflow_method_code = 'PRIOR_ENTRY'
38754 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
38755 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
38756 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
38757 )
38758 THEN
38759 xla_ae_lines_pkg.BflowUpgEntry
38760 (p_business_method_code => l_bflow_method_code
38761 ,p_business_class_code => l_bflow_class_code
38762 ,p_balance_type => l_balance_type_code);
38763 ELSE
38764 NULL;
38765 -- No business flow processing for business flow method of NONE.
38766 END IF;
38767
38768 --
38769 -- call analytical criteria
38770 --
38771
38772 --
38773 -- call description
38774 --
38775 -- No description or it is inherited.
38776 --
38777 -- call ADRs
38778 -- Bug 4922099
38779 --
38780 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38781 (NVL(l_actual_upg_option, 'N') = 'O') OR
38782 (NVL(l_enc_upg_option, 'N') = 'O')
38783 )
38784 THEN
38785 NULL;
38786 --
38787 --
38788
38789 l_ccid := AcctDerRule_28(
38790 p_application_id => p_application_id
38791 , p_ae_header_id => l_ae_header_id
38792 , p_source_19 => p_source_19
38793 , x_transaction_coa_id => l_adr_transaction_coa_id
38794 , x_accounting_coa_id => l_adr_accounting_coa_id
38795 , x_value_type_code => l_adr_value_type_code
38796 , p_side => 'NA'
38797 );
38798
38799 xla_ae_lines_pkg.set_ccid(
38800 p_code_combination_id => l_ccid
38801 , p_value_type_code => l_adr_value_type_code
38805 , p_adr_type_code => 'S'
38802 , p_transaction_coa_id => l_adr_transaction_coa_id
38803 , p_accounting_coa_id => l_adr_accounting_coa_id
38804 , p_adr_code => 'TRX_DIST_CCID'
38806 , p_component_type => l_component_type
38807 , p_component_code => l_component_code
38808 , p_component_type_code => l_component_type_code
38809 , p_component_appl_id => l_component_appl_id
38810 , p_amb_context_code => l_amb_context_code
38811 , p_side => 'NA'
38812 );
38813
38814
38815 --
38816 --
38817 END IF;
38818 --
38819 -- Bug 4922099
38820 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
38821 (NVL(l_enc_upg_option, 'N') = 'O')
38822 ) AND
38823 (l_bflow_method_code = 'PRIOR_ENTRY')
38824 )
38825 THEN
38826 IF
38827 --
38828 1 = 2
38829 --
38830 THEN
38831 xla_accounting_err_pkg.build_message
38832 (p_appli_s_name => 'XLA'
38833 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38834 ,p_token_1 => 'LINE_NUMBER'
38835 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
38836 ,p_token_2 => 'LINE_TYPE_NAME'
38837 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
38838 l_component_type
38839 ,l_component_code
38840 ,l_component_type_code
38841 ,l_component_appl_id
38842 ,l_amb_context_code
38843 ,l_entity_code
38844 ,l_event_class_code
38845 )
38849 ,p_lookup_code => l_component_type_code
38846 ,p_token_3 => 'OWNER'
38847 ,p_value_3 => xla_lookups_pkg.get_meaning(
38848 p_lookup_type => 'XLA_OWNER_TYPE'
38850 )
38851 ,p_token_4 => 'PRODUCT_NAME'
38852 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
38853 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
38854 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
38855 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
38856 ,p_ae_header_id => NULL
38857 );
38858
38859 IF (C_LEVEL_ERROR>= g_log_level) THEN
38860 trace
38861 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
38862 ,p_level => C_LEVEL_ERROR
38863 ,p_module => l_log_module);
38864 END IF;
38865 END IF;
38866 END IF;
38867 --
38868 --
38869 ------------------------------------------------------------------------------------------------
38870 -- 4219869 Business Flow
38871 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
38872 -- Prior Entry. Currently, the following code is always generated.
38873 ------------------------------------------------------------------------------------------------
38874 XLA_AE_LINES_PKG.ValidateCurrentLine;
38875
38876 ------------------------------------------------------------------------------------
38877 -- 4219869 Business Flow
38878 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
38879 ------------------------------------------------------------------------------------
38880 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38881
38882 ----------------------------------------------------------------------------------
38883 -- 4219869 Business Flow
38884 -- Update journal entry status -- Need to generate this within IF <condition>
38888 ,p_balance_type_code => l_balance_type_code
38885 ----------------------------------------------------------------------------------
38886 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38887 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
38889 );
38890
38891 -------------------------------------------------------------------------------------------
38892 -- 4262811 - Generate the Accrual Reversal lines
38893 -------------------------------------------------------------------------------------------
38894 BEGIN
38895 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
38896 (g_array_event(p_event_id).array_value_num('header_index'));
38897 IF l_acc_rev_flag IS NULL THEN
38898 l_acc_rev_flag := 'N';
38899 END IF;
38900 EXCEPTION
38901 WHEN OTHERS THEN
38902 l_acc_rev_flag := 'N';
38903 END;
38904 --
38905 IF (l_acc_rev_flag = 'Y') THEN
38906
38907 -- 4645092 ------------------------------------------------------------------------------
38908 -- To allow MPA report to determine if it should generate report process
38909 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
38910 ------------------------------------------------------------------------------------------
38911
38912 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
38913 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
38914 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
38915 -- call ADRs
38916 -- Bug 4922099
38917 --
38918 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
38919 (NVL(l_actual_upg_option, 'N') = 'O') OR
38920 (NVL(l_enc_upg_option, 'N') = 'O')
38921 )
38922 THEN
38923 NULL;
38924 --
38925 --
38926
38927 l_ccid := AcctDerRule_28(
38928 p_application_id => p_application_id
38929 , p_ae_header_id => l_ae_header_id
38930 , p_source_19 => p_source_19
38931 , x_transaction_coa_id => l_adr_transaction_coa_id
38932 , x_accounting_coa_id => l_adr_accounting_coa_id
38933 , x_value_type_code => l_adr_value_type_code
38934 , p_side => 'NA'
38935 );
38936
38937 xla_ae_lines_pkg.set_ccid(
38938 p_code_combination_id => l_ccid
38939 , p_value_type_code => l_adr_value_type_code
38940 , p_transaction_coa_id => l_adr_transaction_coa_id
38941 , p_accounting_coa_id => l_adr_accounting_coa_id
38942 , p_adr_code => 'TRX_DIST_CCID'
38943 , p_adr_type_code => 'S'
38944 , p_component_type => l_component_type
38945 , p_component_code => l_component_code
38946 , p_component_type_code => l_component_type_code
38947 , p_component_appl_id => l_component_appl_id
38948 , p_amb_context_code => l_amb_context_code
38949 , p_side => 'NA'
38950 );
38951
38952
38953 --
38954 --
38955 END IF;
38956
38957 --
38958 -- Update the line information that should be overwritten
38959 --
38960 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
38961 p_header_num => 1);
38962 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
38963
38964 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
38965
38966 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
38967 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
38968 END IF;
38969
38970 --
38971 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
38972 --
38973 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
38974 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
38975 ELSE
38979 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
38976 ---------------------------------------------------------------------------------------------------
38977 -- 4262811a Switch Sign
38978 ---------------------------------------------------------------------------------------------------
38980 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38981 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38982 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
38983 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38984 -- 5132302
38985 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
38986 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
38987
38988 END IF;
38989
38990 -- 4955764
38991 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
38992 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
38993
38994
38995 XLA_AE_LINES_PKG.ValidateCurrentLine;
38996 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
38997
38998 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
38999 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
39000 ,p_balance_type_code => l_balance_type_code);
39001
39002 END IF;
39003
39004 -----------------------------------------------------------------------------------------
39005 -- 4262811 Multiperiod Accounting
39006 -----------------------------------------------------------------------------------------
39007 -- No MPA option is assigned.
39008
39009
39010 END IF;
39011 END IF;
39012 --
39013
39014 --
39015 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39016 trace
39017 (p_msg => 'END of AcctLineType_86'
39018 ,p_level => C_LEVEL_PROCEDURE
39019 ,p_module => l_log_module);
39020 END IF;
39021 --
39022 EXCEPTION
39023 WHEN xla_exceptions_pkg.application_exception THEN
39024 RAISE;
39025 WHEN OTHERS THEN
39026 xla_exceptions_pkg.raise_message
39027 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_86');
39028 END AcctLineType_86;
39029 --
39030
39031 ---------------------------------------
39032 --
39033 -- PRIVATE FUNCTION
39034 -- AcctLineType_87
39035 --
39036 ---------------------------------------
39037 PROCEDURE AcctLineType_87 (
39038 p_application_id IN NUMBER
39039 ,p_event_id IN NUMBER
39040 ,p_calculate_acctd_flag IN VARCHAR2
39041 ,p_calculate_g_l_flag IN VARCHAR2
39042 ,p_actual_flag IN OUT VARCHAR2
39043 ,p_balance_type_code OUT VARCHAR2
39044 ,p_gain_or_loss_ref OUT VARCHAR2
39045
39046 --Transaction Distribution GL Account
39047 , p_source_19 IN NUMBER
39048 --Bill To Customer Account Identifier
39049 , p_source_30 IN NUMBER
39050 --Bill To Customer Site Use Identifier
39051 , p_source_31 IN NUMBER
39052 --SLA Party Type
39053 , p_source_32 IN VARCHAR2
39054 --Transaction Distribution Account Class
39055 , p_source_33 IN VARCHAR2
39056 --Transaction Distribution Identifier
39057 , p_source_34 IN NUMBER
39058 --Transaction Distribution Type
39059 , p_source_35 IN VARCHAR2
39060 --Transaction Distribution Entered Amount
39061 , p_source_36 IN NUMBER
39062 --Transaction Currency Code
39063 , p_source_37 IN VARCHAR2
39064 --Transaction Exchange Date
39065 , p_source_38 IN DATE
39066 --Transaction Exchange Rate
39067 , p_source_39 IN NUMBER
39068 --Transaction Exchange Rate Type
39069 , p_source_40 IN VARCHAR2
39070 --Transaction Accounting Amount
39071 , p_source_41 IN NUMBER
39072 --Transaction Tax Line Identifier
39073 , p_source_55 IN NUMBER
39074 --Rounding Correction Flag
39075 , p_source_66 IN VARCHAR2
39076 )
39077 IS
39078
39079 l_component_type VARCHAR2(80);
39080 l_component_code VARCHAR2(30);
39081 l_component_type_code VARCHAR2(1);
39082 l_component_appl_id INTEGER;
39083 l_amb_context_code VARCHAR2(30);
39084 l_entity_code VARCHAR2(30);
39085 l_event_class_code VARCHAR2(30);
39086 l_ae_header_id NUMBER;
39087 l_event_type_code VARCHAR2(30);
39088 l_line_definition_code VARCHAR2(30);
39089 l_line_definition_owner_code VARCHAR2(1);
39090 --
39091 -- adr variables
39092 l_segment VARCHAR2(30);
39093 l_ccid NUMBER;
39094 l_adr_transaction_coa_id NUMBER;
39095 l_adr_accounting_coa_id NUMBER;
39096 l_adr_flexfield_segment_code VARCHAR2(30);
39097 l_adr_flex_value_set_id NUMBER;
39098 l_adr_value_type_code VARCHAR2(30);
39099 l_adr_value_combination_id NUMBER;
39100 l_adr_value_segment_code VARCHAR2(30);
39101
39102 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
39103 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
39104 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
39105 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
39106
39107 -- 4262811 Variables ------------------------------------------------------------------------------------------
39108 l_entered_amt_idx NUMBER;
39109 l_accted_amt_idx NUMBER;
39110 l_acc_rev_flag VARCHAR2(1);
39111 l_accrual_line_num NUMBER;
39112 l_tmp_amt NUMBER;
39113 l_acc_rev_natural_side_code VARCHAR2(1);
39114
39115 l_num_entries NUMBER;
39116 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
39117 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
39118 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
39119 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
39120 l_recog_line_1 NUMBER;
39121 l_recog_line_2 NUMBER;
39122
39123 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
39124 l_bflow_applied_to_amt NUMBER; -- 5132302
39125 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
39126
39127 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
39128
39129 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
39130 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
39131
39132 ---------------------------------------------------------------------------------------------------------------
39133
39134
39135 --
39136 -- bulk performance
39137 --
39138 l_balance_type_code VARCHAR2(1);
39139 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
39140 l_log_module VARCHAR2(240);
39141
39142 --
39143 -- Upgrade strategy
39144 --
39145 l_actual_upg_option VARCHAR2(1);
39146 l_enc_upg_option VARCHAR2(1);
39147
39148 --
39149 BEGIN
39150 --
39151 IF g_log_enabled THEN
39152 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_87';
39153 END IF;
39154 --
39155 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39156
39157 trace
39158 (p_msg => 'BEGIN of AcctLineType_87'
39159 ,p_level => C_LEVEL_PROCEDURE
39160 ,p_module => l_log_module);
39161
39162 END IF;
39163 --
39164 l_component_type := 'AMB_JLT';
39165 l_component_code := 'INV_REV';
39166 l_component_type_code := 'S';
39167 l_component_appl_id := 222;
39168 l_amb_context_code := 'DEFAULT';
39169 l_entity_code := 'TRANSACTIONS';
39170 l_event_class_code := 'INVOICE';
39171 l_event_type_code := 'INVOICE_ALL';
39172 l_line_definition_owner_code := 'S';
39173 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
39174 --
39175 l_balance_type_code := 'A';
39176 l_segment := NULL;
39177 l_ccid := NULL;
39178 l_adr_transaction_coa_id := NULL;
39179 l_adr_accounting_coa_id := NULL;
39180 l_adr_flexfield_segment_code := NULL;
39181 l_adr_flex_value_set_id := NULL;
39182 l_adr_value_type_code := NULL;
39183 l_adr_value_combination_id := NULL;
39184 l_adr_value_segment_code := NULL;
39185
39186 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
39187 l_bflow_class_code := 'REVENUE'; -- 4219869 Business Flow
39188 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
39192 l_bflow_applied_to_amt := NULL; -- 5132302
39189 l_budgetary_control_flag := 'N';
39190
39191 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39193 l_entered_amt_idx := NULL; -- 4262811
39194 l_accted_amt_idx := NULL; -- 4262811
39195 l_acc_rev_flag := NULL; -- 4262811
39196 l_accrual_line_num := NULL; -- 4262811
39197 l_tmp_amt := NULL; -- 4262811
39198 --
39199
39200 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
39201 l_balance_type_code <> 'B' THEN
39202 IF NVL(p_source_33,'
39203 ') = 'REV' AND
39204 p_source_66 IS NULL
39205 THEN
39206
39207 --
39208 XLA_AE_LINES_PKG.SetNewLine;
39209
39210 p_balance_type_code := l_balance_type_code;
39211 -- set the flag so later we will know whether the gain loss line needs to be created
39212
39213 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
39214 p_actual_flag :='A';
39215 END IF;
39216
39217 --
39218 -- bulk performance
39219 --
39220 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
39221 p_header_num => 0); -- 4262811
39222 --
39223 -- set accounting line options
39224 --
39225 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
39226 p_natural_side_code => 'C'
39227 , p_gain_or_loss_flag => 'N'
39228 , p_gl_transfer_mode_code => 'S'
39229 , p_acct_entry_type_code => 'A'
39230 , p_switch_side_flag => 'Y'
39231 , p_merge_duplicate_code => 'A'
39232 );
39233 --
39234 l_acc_rev_natural_side_code := 'D'; -- 4262811
39235 --
39236 --
39237 -- set accounting line type info
39238 --
39239 xla_ae_lines_pkg.SetAcctLineType
39240 (p_component_type => l_component_type
39241 ,p_event_type_code => l_event_type_code
39242 ,p_line_definition_owner_code => l_line_definition_owner_code
39243 ,p_line_definition_code => l_line_definition_code
39244 ,p_accounting_line_code => l_component_code
39245 ,p_accounting_line_type_code => l_component_type_code
39246 ,p_accounting_line_appl_id => l_component_appl_id
39247 ,p_amb_context_code => l_amb_context_code
39248 ,p_entity_code => l_entity_code
39249 ,p_event_class_code => l_event_class_code);
39250 --
39251 -- set accounting class
39252 --
39253 xla_ae_lines_pkg.SetAcctClass(
39254 p_accounting_class_code => 'REVENUE'
39255 , p_ae_header_id => l_ae_header_id
39256 );
39257
39258 --
39259 -- set rounding class
39260 --
39261 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
39262 'RECEIVABLE';
39263
39264 --
39265 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
39266 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
39267 --
39268 -- bulk performance
39269 --
39270 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
39271
39272 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
39273 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
39274
39275 -- 4955764
39276 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39277 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
39278
39279 -- 4458381 Public Sector Enh
39280
39281 --
39282 -- set accounting attributes for the line type
39283 --
39284 l_entered_amt_idx := 3;
39285 l_accted_amt_idx := 8;
39286 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39287 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
39288 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
39289 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
39290 l_rec_acct_attrs.array_char_value(2) := p_source_35;
39291 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
39292 l_rec_acct_attrs.array_num_value(3) := p_source_36;
39293 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
39294 l_rec_acct_attrs.array_char_value(4) := p_source_37;
39295 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
39296 l_rec_acct_attrs.array_date_value(5) := p_source_38;
39297 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
39298 l_rec_acct_attrs.array_num_value(6) := p_source_39;
39299 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
39300 l_rec_acct_attrs.array_char_value(7) := p_source_40;
39301 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
39302 l_rec_acct_attrs.array_num_value(8) := p_source_41;
39303 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
39304 l_rec_acct_attrs.array_num_value(9) := p_source_30;
39305 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
39306 l_rec_acct_attrs.array_num_value(10) := p_source_31;
39307 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
39308 l_rec_acct_attrs.array_char_value(11) := p_source_32;
39309 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
39310 l_rec_acct_attrs.array_num_value(12) := p_source_55;
39311
39312 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
39313 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
39314
39315 ---------------------------------------------------------------------------------------------------------------
39316 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
39317 ---------------------------------------------------------------------------------------------------------------
39318 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
39319
39320 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39321 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39322
39323 IF xla_accounting_cache_pkg.GetValueChar
39324 (p_source_code => 'LEDGER_CATEGORY_CODE'
39325 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
39326 AND l_bflow_method_code = 'PRIOR_ENTRY'
39327 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
39328 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
39329 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
39330 )
39331 THEN
39332 xla_ae_lines_pkg.BflowUpgEntry
39333 (p_business_method_code => l_bflow_method_code
39334 ,p_business_class_code => l_bflow_class_code
39335 ,p_balance_type => l_balance_type_code);
39336 ELSE
39337 NULL;
39338 -- No business flow processing for business flow method of NONE.
39339 END IF;
39340
39341 --
39342 -- call analytical criteria
39343 --
39344
39345 --
39346 -- call description
39347 --
39348 -- No description or it is inherited.
39349 --
39350 -- call ADRs
39351 -- Bug 4922099
39352 --
39353 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39354 (NVL(l_actual_upg_option, 'N') = 'O') OR
39355 (NVL(l_enc_upg_option, 'N') = 'O')
39356 )
39357 THEN
39358 NULL;
39359 --
39360 --
39361
39362 l_ccid := AcctDerRule_28(
39363 p_application_id => p_application_id
39364 , p_ae_header_id => l_ae_header_id
39365 , p_source_19 => p_source_19
39366 , x_transaction_coa_id => l_adr_transaction_coa_id
39367 , x_accounting_coa_id => l_adr_accounting_coa_id
39368 , x_value_type_code => l_adr_value_type_code
39369 , p_side => 'NA'
39370 );
39371
39372 xla_ae_lines_pkg.set_ccid(
39373 p_code_combination_id => l_ccid
39374 , p_value_type_code => l_adr_value_type_code
39375 , p_transaction_coa_id => l_adr_transaction_coa_id
39376 , p_accounting_coa_id => l_adr_accounting_coa_id
39377 , p_adr_code => 'TRX_DIST_CCID'
39381 , p_component_type_code => l_component_type_code
39378 , p_adr_type_code => 'S'
39379 , p_component_type => l_component_type
39380 , p_component_code => l_component_code
39382 , p_component_appl_id => l_component_appl_id
39383 , p_amb_context_code => l_amb_context_code
39384 , p_side => 'NA'
39385 );
39386
39387
39388 --
39389 --
39390 END IF;
39391 --
39392 -- Bug 4922099
39393 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
39394 (NVL(l_enc_upg_option, 'N') = 'O')
39395 ) AND
39396 (l_bflow_method_code = 'PRIOR_ENTRY')
39397 )
39398 THEN
39399 IF
39400 --
39401 1 = 2
39402 --
39403 THEN
39404 xla_accounting_err_pkg.build_message
39405 (p_appli_s_name => 'XLA'
39406 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
39407 ,p_token_1 => 'LINE_NUMBER'
39408 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
39409 ,p_token_2 => 'LINE_TYPE_NAME'
39410 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
39411 l_component_type
39412 ,l_component_code
39413 ,l_component_type_code
39414 ,l_component_appl_id
39415 ,l_amb_context_code
39416 ,l_entity_code
39417 ,l_event_class_code
39418 )
39419 ,p_token_3 => 'OWNER'
39420 ,p_value_3 => xla_lookups_pkg.get_meaning(
39421 p_lookup_type => 'XLA_OWNER_TYPE'
39422 ,p_lookup_code => l_component_type_code
39423 )
39424 ,p_token_4 => 'PRODUCT_NAME'
39425 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
39426 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
39427 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
39428 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
39429 ,p_ae_header_id => NULL
39430 );
39431
39432 IF (C_LEVEL_ERROR>= g_log_level) THEN
39433 trace
39434 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
39435 ,p_level => C_LEVEL_ERROR
39436 ,p_module => l_log_module);
39437 END IF;
39438 END IF;
39439 END IF;
39440 --
39441 --
39442 ------------------------------------------------------------------------------------------------
39443 -- 4219869 Business Flow
39444 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
39445 -- Prior Entry. Currently, the following code is always generated.
39446 ------------------------------------------------------------------------------------------------
39447 XLA_AE_LINES_PKG.ValidateCurrentLine;
39448
39449 ------------------------------------------------------------------------------------
39450 -- 4219869 Business Flow
39451 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
39452 ------------------------------------------------------------------------------------
39453 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
39454
39455 ----------------------------------------------------------------------------------
39456 -- 4219869 Business Flow
39457 -- Update journal entry status -- Need to generate this within IF <condition>
39458 ----------------------------------------------------------------------------------
39459 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
39460 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
39461 ,p_balance_type_code => l_balance_type_code
39462 );
39463
39464 -------------------------------------------------------------------------------------------
39465 -- 4262811 - Generate the Accrual Reversal lines
39466 -------------------------------------------------------------------------------------------
39467 BEGIN
39468 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
39469 (g_array_event(p_event_id).array_value_num('header_index'));
39470 IF l_acc_rev_flag IS NULL THEN
39471 l_acc_rev_flag := 'N';
39472 END IF;
39473 EXCEPTION
39474 WHEN OTHERS THEN
39475 l_acc_rev_flag := 'N';
39476 END;
39477 --
39478 IF (l_acc_rev_flag = 'Y') THEN
39479
39480 -- 4645092 ------------------------------------------------------------------------------
39481 -- To allow MPA report to determine if it should generate report process
39482 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
39483 ------------------------------------------------------------------------------------------
39484
39485 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
39486 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
39487 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
39488 -- call ADRs
39489 -- Bug 4922099
39490 --
39491 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39492 (NVL(l_actual_upg_option, 'N') = 'O') OR
39493 (NVL(l_enc_upg_option, 'N') = 'O')
39494 )
39495 THEN
39496 NULL;
39497 --
39498 --
39499
39500 l_ccid := AcctDerRule_28(
39501 p_application_id => p_application_id
39502 , p_ae_header_id => l_ae_header_id
39503 , p_source_19 => p_source_19
39504 , x_transaction_coa_id => l_adr_transaction_coa_id
39505 , x_accounting_coa_id => l_adr_accounting_coa_id
39506 , x_value_type_code => l_adr_value_type_code
39507 , p_side => 'NA'
39508 );
39509
39510 xla_ae_lines_pkg.set_ccid(
39511 p_code_combination_id => l_ccid
39512 , p_value_type_code => l_adr_value_type_code
39513 , p_transaction_coa_id => l_adr_transaction_coa_id
39514 , p_accounting_coa_id => l_adr_accounting_coa_id
39515 , p_adr_code => 'TRX_DIST_CCID'
39516 , p_adr_type_code => 'S'
39517 , p_component_type => l_component_type
39518 , p_component_code => l_component_code
39519 , p_component_type_code => l_component_type_code
39520 , p_component_appl_id => l_component_appl_id
39521 , p_amb_context_code => l_amb_context_code
39522 , p_side => 'NA'
39523 );
39524
39525
39526 --
39527 --
39528 END IF;
39529
39530 --
39531 -- Update the line information that should be overwritten
39532 --
39533 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
39534 p_header_num => 1);
39535 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
39536
39537 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
39538
39539 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
39540 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
39541 END IF;
39542
39543 --
39544 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
39545 --
39546 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
39547 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
39548 ELSE
39549 ---------------------------------------------------------------------------------------------------
39550 -- 4262811a Switch Sign
39551 ---------------------------------------------------------------------------------------------------
39552 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
39553 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39554 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39555 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
39556 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39557 -- 5132302
39558 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
39559 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
39560
39561 END IF;
39562
39563 -- 4955764
39564 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39565 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
39566
39567
39568 XLA_AE_LINES_PKG.ValidateCurrentLine;
39569 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
39570
39571 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
39572 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
39573 ,p_balance_type_code => l_balance_type_code);
39574
39575 END IF;
39576
39577 -----------------------------------------------------------------------------------------
39578 -- 4262811 Multiperiod Accounting
39579 -----------------------------------------------------------------------------------------
39580 -- No MPA option is assigned.
39581
39582
39583 END IF;
39584 END IF;
39585 --
39586
39587 --
39588 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39589 trace
39590 (p_msg => 'END of AcctLineType_87'
39591 ,p_level => C_LEVEL_PROCEDURE
39592 ,p_module => l_log_module);
39593 END IF;
39594 --
39595 EXCEPTION
39596 WHEN xla_exceptions_pkg.application_exception THEN
39597 RAISE;
39598 WHEN OTHERS THEN
39599 xla_exceptions_pkg.raise_message
39600 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_87');
39601 END AcctLineType_87;
39602 --
39603
39604 ---------------------------------------
39605 --
39606 -- PRIVATE FUNCTION
39607 -- AcctLineType_88
39608 --
39609 ---------------------------------------
39610 PROCEDURE AcctLineType_88 (
39611 p_application_id IN NUMBER
39612 ,p_event_id IN NUMBER
39613 ,p_calculate_acctd_flag IN VARCHAR2
39614 ,p_calculate_g_l_flag IN VARCHAR2
39615 ,p_actual_flag IN OUT VARCHAR2
39616 ,p_balance_type_code OUT VARCHAR2
39617 ,p_gain_or_loss_ref OUT VARCHAR2
39618
39619 --Transaction Distribution GL Account
39620 , p_source_19 IN NUMBER
39621 --Bill To Customer Account Identifier
39622 , p_source_30 IN NUMBER
39623 --Bill To Customer Site Use Identifier
39624 , p_source_31 IN NUMBER
39625 --SLA Party Type
39626 , p_source_32 IN VARCHAR2
39627 --Transaction Distribution Account Class
39628 , p_source_33 IN VARCHAR2
39629 --Transaction Distribution Identifier
39630 , p_source_34 IN NUMBER
39631 --Transaction Distribution Type
39632 , p_source_35 IN VARCHAR2
39633 --Transaction Distribution Entered Amount
39634 , p_source_36 IN NUMBER
39635 --Transaction Currency Code
39636 , p_source_37 IN VARCHAR2
39637 --Transaction Exchange Date
39638 , p_source_38 IN DATE
39639 --Transaction Exchange Rate
39640 , p_source_39 IN NUMBER
39641 --Transaction Exchange Rate Type
39642 , p_source_40 IN VARCHAR2
39643 --Transaction Accounting Amount
39644 , p_source_41 IN NUMBER
39645 --Transaction Tax Line Identifier
39646 , p_source_55 IN NUMBER
39647 --Rounding Correction Flag
39648 , p_source_66 IN VARCHAR2
39649 )
39650 IS
39651
39652 l_component_type VARCHAR2(80);
39653 l_component_code VARCHAR2(30);
39654 l_component_type_code VARCHAR2(1);
39655 l_component_appl_id INTEGER;
39656 l_amb_context_code VARCHAR2(30);
39657 l_entity_code VARCHAR2(30);
39658 l_event_class_code VARCHAR2(30);
39659 l_ae_header_id NUMBER;
39660 l_event_type_code VARCHAR2(30);
39661 l_line_definition_code VARCHAR2(30);
39662 l_line_definition_owner_code VARCHAR2(1);
39663 --
39664 -- adr variables
39665 l_segment VARCHAR2(30);
39666 l_ccid NUMBER;
39667 l_adr_transaction_coa_id NUMBER;
39668 l_adr_accounting_coa_id NUMBER;
39669 l_adr_flexfield_segment_code VARCHAR2(30);
39670 l_adr_flex_value_set_id NUMBER;
39671 l_adr_value_type_code VARCHAR2(30);
39672 l_adr_value_combination_id NUMBER;
39673 l_adr_value_segment_code VARCHAR2(30);
39674
39675 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
39676 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
39677 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
39678 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
39679
39680 -- 4262811 Variables ------------------------------------------------------------------------------------------
39681 l_entered_amt_idx NUMBER;
39682 l_accted_amt_idx NUMBER;
39683 l_acc_rev_flag VARCHAR2(1);
39684 l_accrual_line_num NUMBER;
39685 l_tmp_amt NUMBER;
39686 l_acc_rev_natural_side_code VARCHAR2(1);
39687
39688 l_num_entries NUMBER;
39689 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
39690 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
39691 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
39692 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
39693 l_recog_line_1 NUMBER;
39694 l_recog_line_2 NUMBER;
39695
39696 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
39697 l_bflow_applied_to_amt NUMBER; -- 5132302
39698 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
39699
39703 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
39700 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
39701
39702 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
39704
39705 ---------------------------------------------------------------------------------------------------------------
39706
39707
39708 --
39709 -- bulk performance
39710 --
39711 l_balance_type_code VARCHAR2(1);
39712 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
39713 l_log_module VARCHAR2(240);
39714
39715 --
39716 -- Upgrade strategy
39717 --
39718 l_actual_upg_option VARCHAR2(1);
39719 l_enc_upg_option VARCHAR2(1);
39720
39721 --
39722 BEGIN
39723 --
39724 IF g_log_enabled THEN
39725 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_88';
39726 END IF;
39727 --
39728 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
39729
39730 trace
39731 (p_msg => 'BEGIN of AcctLineType_88'
39732 ,p_level => C_LEVEL_PROCEDURE
39733 ,p_module => l_log_module);
39734
39735 END IF;
39736 --
39737 l_component_type := 'AMB_JLT';
39738 l_component_code := 'INV_REV_ROUND';
39739 l_component_type_code := 'S';
39740 l_component_appl_id := 222;
39741 l_amb_context_code := 'DEFAULT';
39742 l_entity_code := 'TRANSACTIONS';
39743 l_event_class_code := 'INVOICE';
39744 l_event_type_code := 'INVOICE_ALL';
39745 l_line_definition_owner_code := 'S';
39746 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
39747 --
39748 l_balance_type_code := 'A';
39749 l_segment := NULL;
39750 l_ccid := NULL;
39751 l_adr_transaction_coa_id := NULL;
39752 l_adr_accounting_coa_id := NULL;
39753 l_adr_flexfield_segment_code := NULL;
39754 l_adr_flex_value_set_id := NULL;
39755 l_adr_value_type_code := NULL;
39756 l_adr_value_combination_id := NULL;
39757 l_adr_value_segment_code := NULL;
39758
39759 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
39760 l_bflow_class_code := 'REVENUE'; -- 4219869 Business Flow
39761 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
39762 l_budgetary_control_flag := 'N';
39763
39764 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39765 l_bflow_applied_to_amt := NULL; -- 5132302
39769 l_accrual_line_num := NULL; -- 4262811
39766 l_entered_amt_idx := NULL; -- 4262811
39767 l_accted_amt_idx := NULL; -- 4262811
39768 l_acc_rev_flag := NULL; -- 4262811
39770 l_tmp_amt := NULL; -- 4262811
39771 --
39772
39773 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
39774 l_balance_type_code <> 'B' THEN
39775 IF NVL(p_source_33,'
39776 ') = 'REV' AND
39777 NVL(p_source_66,'
39778 ') = 'Y'
39779 THEN
39780
39781 --
39782 XLA_AE_LINES_PKG.SetNewLine;
39783
39784 p_balance_type_code := l_balance_type_code;
39785 -- set the flag so later we will know whether the gain loss line needs to be created
39786
39787 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
39788 p_actual_flag :='A';
39789 END IF;
39790
39791 --
39792 -- bulk performance
39793 --
39794 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
39795 p_header_num => 0); -- 4262811
39796 --
39797 -- set accounting line options
39798 --
39799 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
39800 p_natural_side_code => 'C'
39801 , p_gain_or_loss_flag => 'N'
39802 , p_gl_transfer_mode_code => 'S'
39803 , p_acct_entry_type_code => 'A'
39804 , p_switch_side_flag => 'Y'
39805 , p_merge_duplicate_code => 'N'
39806 );
39807 --
39808 l_acc_rev_natural_side_code := 'D'; -- 4262811
39809 --
39810 --
39811 -- set accounting line type info
39812 --
39813 xla_ae_lines_pkg.SetAcctLineType
39814 (p_component_type => l_component_type
39815 ,p_event_type_code => l_event_type_code
39816 ,p_line_definition_owner_code => l_line_definition_owner_code
39817 ,p_line_definition_code => l_line_definition_code
39818 ,p_accounting_line_code => l_component_code
39819 ,p_accounting_line_type_code => l_component_type_code
39820 ,p_accounting_line_appl_id => l_component_appl_id
39821 ,p_amb_context_code => l_amb_context_code
39822 ,p_entity_code => l_entity_code
39823 ,p_event_class_code => l_event_class_code);
39824 --
39825 -- set accounting class
39826 --
39827 xla_ae_lines_pkg.SetAcctClass(
39828 p_accounting_class_code => 'REVENUE'
39829 , p_ae_header_id => l_ae_header_id
39830 );
39831
39832 --
39833 -- set rounding class
39834 --
39835 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
39836 'RECEIVABLE';
39837
39838 --
39839 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
39840 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
39841 --
39842 -- bulk performance
39843 --
39844 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
39845
39846 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
39847 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
39848
39849 -- 4955764
39850 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
39851 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
39852
39853 -- 4458381 Public Sector Enh
39854
39855 --
39856 -- set accounting attributes for the line type
39857 --
39858 l_entered_amt_idx := 3;
39859 l_accted_amt_idx := 8;
39860 l_bflow_applied_to_amt_idx := NULL; -- 5132302
39861 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
39862 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
39863 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
39864 l_rec_acct_attrs.array_char_value(2) := p_source_35;
39865 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
39866 l_rec_acct_attrs.array_num_value(3) := p_source_36;
39867 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
39868 l_rec_acct_attrs.array_char_value(4) := p_source_37;
39869 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
39870 l_rec_acct_attrs.array_date_value(5) := p_source_38;
39871 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
39872 l_rec_acct_attrs.array_num_value(6) := p_source_39;
39873 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
39874 l_rec_acct_attrs.array_char_value(7) := p_source_40;
39875 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
39876 l_rec_acct_attrs.array_num_value(8) := p_source_41;
39877 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
39878 l_rec_acct_attrs.array_num_value(9) := p_source_30;
39879 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
39880 l_rec_acct_attrs.array_num_value(10) := p_source_31;
39881 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
39882 l_rec_acct_attrs.array_char_value(11) := p_source_32;
39883 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
39884 l_rec_acct_attrs.array_num_value(12) := p_source_55;
39885
39886 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
39887 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
39888
39889 ---------------------------------------------------------------------------------------------------------------
39890 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
39891 ---------------------------------------------------------------------------------------------------------------
39892 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
39893
39894 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39895 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
39896
39897 IF xla_accounting_cache_pkg.GetValueChar
39898 (p_source_code => 'LEDGER_CATEGORY_CODE'
39899 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
39900 AND l_bflow_method_code = 'PRIOR_ENTRY'
39901 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
39902 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
39903 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
39904 )
39905 THEN
39906 xla_ae_lines_pkg.BflowUpgEntry
39907 (p_business_method_code => l_bflow_method_code
39908 ,p_business_class_code => l_bflow_class_code
39909 ,p_balance_type => l_balance_type_code);
39910 ELSE
39911 NULL;
39912 -- No business flow processing for business flow method of NONE.
39913 END IF;
39914
39915 --
39916 -- call analytical criteria
39917 --
39918
39919 --
39920 -- call description
39921 --
39922 -- No description or it is inherited.
39923 --
39924 -- call ADRs
39925 -- Bug 4922099
39926 --
39927 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
39928 (NVL(l_actual_upg_option, 'N') = 'O') OR
39929 (NVL(l_enc_upg_option, 'N') = 'O')
39930 )
39931 THEN
39932 NULL;
39933 --
39934 --
39935
39936 l_ccid := AcctDerRule_28(
39937 p_application_id => p_application_id
39938 , p_ae_header_id => l_ae_header_id
39939 , p_source_19 => p_source_19
39940 , x_transaction_coa_id => l_adr_transaction_coa_id
39941 , x_accounting_coa_id => l_adr_accounting_coa_id
39942 , x_value_type_code => l_adr_value_type_code
39943 , p_side => 'NA'
39944 );
39945
39946 xla_ae_lines_pkg.set_ccid(
39947 p_code_combination_id => l_ccid
39948 , p_value_type_code => l_adr_value_type_code
39949 , p_transaction_coa_id => l_adr_transaction_coa_id
39950 , p_accounting_coa_id => l_adr_accounting_coa_id
39951 , p_adr_code => 'TRX_DIST_CCID'
39952 , p_adr_type_code => 'S'
39956 , p_component_appl_id => l_component_appl_id
39953 , p_component_type => l_component_type
39954 , p_component_code => l_component_code
39955 , p_component_type_code => l_component_type_code
39957 , p_amb_context_code => l_amb_context_code
39958 , p_side => 'NA'
39959 );
39960
39961
39962 --
39963 --
39964 END IF;
39965 --
39966 -- Bug 4922099
39967 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
39968 (NVL(l_enc_upg_option, 'N') = 'O')
39969 ) AND
39970 (l_bflow_method_code = 'PRIOR_ENTRY')
39971 )
39972 THEN
39973 IF
39974 --
39975 1 = 2
39976 --
39977 THEN
39978 xla_accounting_err_pkg.build_message
39979 (p_appli_s_name => 'XLA'
39980 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
39981 ,p_token_1 => 'LINE_NUMBER'
39982 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
39983 ,p_token_2 => 'LINE_TYPE_NAME'
39984 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
39985 l_component_type
39986 ,l_component_code
39987 ,l_component_type_code
39988 ,l_component_appl_id
39989 ,l_amb_context_code
39990 ,l_entity_code
39991 ,l_event_class_code
39992 )
39993 ,p_token_3 => 'OWNER'
39994 ,p_value_3 => xla_lookups_pkg.get_meaning(
39995 p_lookup_type => 'XLA_OWNER_TYPE'
39996 ,p_lookup_code => l_component_type_code
39997 )
39998 ,p_token_4 => 'PRODUCT_NAME'
39999 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
40000 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
40001 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
40002 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
40003 ,p_ae_header_id => NULL
40004 );
40005
40006 IF (C_LEVEL_ERROR>= g_log_level) THEN
40007 trace
40008 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40009 ,p_level => C_LEVEL_ERROR
40010 ,p_module => l_log_module);
40011 END IF;
40012 END IF;
40013 END IF;
40014 --
40015 --
40016 ------------------------------------------------------------------------------------------------
40017 -- 4219869 Business Flow
40018 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
40019 -- Prior Entry. Currently, the following code is always generated.
40020 ------------------------------------------------------------------------------------------------
40021 XLA_AE_LINES_PKG.ValidateCurrentLine;
40022
40023 ------------------------------------------------------------------------------------
40024 -- 4219869 Business Flow
40025 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
40026 ------------------------------------------------------------------------------------
40027 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40028
40029 ----------------------------------------------------------------------------------
40030 -- 4219869 Business Flow
40031 -- Update journal entry status -- Need to generate this within IF <condition>
40032 ----------------------------------------------------------------------------------
40033 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40034 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
40035 ,p_balance_type_code => l_balance_type_code
40036 );
40037
40038 -------------------------------------------------------------------------------------------
40039 -- 4262811 - Generate the Accrual Reversal lines
40040 -------------------------------------------------------------------------------------------
40041 BEGIN
40042 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
40043 (g_array_event(p_event_id).array_value_num('header_index'));
40044 IF l_acc_rev_flag IS NULL THEN
40045 l_acc_rev_flag := 'N';
40046 END IF;
40047 EXCEPTION
40048 WHEN OTHERS THEN
40049 l_acc_rev_flag := 'N';
40050 END;
40051 --
40052 IF (l_acc_rev_flag = 'Y') THEN
40053
40054 -- 4645092 ------------------------------------------------------------------------------
40055 -- To allow MPA report to determine if it should generate report process
40059 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
40056 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
40057 ------------------------------------------------------------------------------------------
40058
40060 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
40061 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
40062 -- call ADRs
40063 -- Bug 4922099
40064 --
40065 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40066 (NVL(l_actual_upg_option, 'N') = 'O') OR
40067 (NVL(l_enc_upg_option, 'N') = 'O')
40068 )
40069 THEN
40070 NULL;
40071 --
40072 --
40073
40074 l_ccid := AcctDerRule_28(
40075 p_application_id => p_application_id
40076 , p_ae_header_id => l_ae_header_id
40077 , p_source_19 => p_source_19
40078 , x_transaction_coa_id => l_adr_transaction_coa_id
40079 , x_accounting_coa_id => l_adr_accounting_coa_id
40080 , x_value_type_code => l_adr_value_type_code
40081 , p_side => 'NA'
40082 );
40083
40084 xla_ae_lines_pkg.set_ccid(
40085 p_code_combination_id => l_ccid
40086 , p_value_type_code => l_adr_value_type_code
40087 , p_transaction_coa_id => l_adr_transaction_coa_id
40088 , p_accounting_coa_id => l_adr_accounting_coa_id
40089 , p_adr_code => 'TRX_DIST_CCID'
40090 , p_adr_type_code => 'S'
40091 , p_component_type => l_component_type
40092 , p_component_code => l_component_code
40093 , p_component_type_code => l_component_type_code
40094 , p_component_appl_id => l_component_appl_id
40095 , p_amb_context_code => l_amb_context_code
40096 , p_side => 'NA'
40097 );
40098
40099
40100 --
40101 --
40102 END IF;
40103
40104 --
40105 -- Update the line information that should be overwritten
40106 --
40107 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
40108 p_header_num => 1);
40109 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
40110
40111 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
40112
40113 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
40114 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
40115 END IF;
40116
40117 --
40118 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
40119 --
40120 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
40121 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
40122 ELSE
40123 ---------------------------------------------------------------------------------------------------
40124 -- 4262811a Switch Sign
40125 ---------------------------------------------------------------------------------------------------
40126 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
40127 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40128 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40129 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40130 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40131 -- 5132302
40132 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
40133 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40134
40135 END IF;
40136
40137 -- 4955764
40138 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40139 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
40140
40141
40142 XLA_AE_LINES_PKG.ValidateCurrentLine;
40143 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40144
40145 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40146 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
40147 ,p_balance_type_code => l_balance_type_code);
40148
40149 END IF;
40150
40151 -----------------------------------------------------------------------------------------
40152 -- 4262811 Multiperiod Accounting
40153 -----------------------------------------------------------------------------------------
40154 -- No MPA option is assigned.
40155
40156
40157 END IF;
40158 END IF;
40159 --
40160
40161 --
40162 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40163 trace
40164 (p_msg => 'END of AcctLineType_88'
40165 ,p_level => C_LEVEL_PROCEDURE
40166 ,p_module => l_log_module);
40167 END IF;
40168 --
40169 EXCEPTION
40170 WHEN xla_exceptions_pkg.application_exception THEN
40171 RAISE;
40172 WHEN OTHERS THEN
40173 xla_exceptions_pkg.raise_message
40174 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_88');
40175 END AcctLineType_88;
40176 --
40177
40178 ---------------------------------------
40179 --
40180 -- PRIVATE FUNCTION
40181 -- AcctLineType_89
40182 --
40186 ,p_event_id IN NUMBER
40183 ---------------------------------------
40184 PROCEDURE AcctLineType_89 (
40185 p_application_id IN NUMBER
40187 ,p_calculate_acctd_flag IN VARCHAR2
40188 ,p_calculate_g_l_flag IN VARCHAR2
40189 ,p_actual_flag IN OUT VARCHAR2
40190 ,p_balance_type_code OUT VARCHAR2
40191 ,p_gain_or_loss_ref OUT VARCHAR2
40192
40193 --Transaction Distribution GL Account
40194 , p_source_19 IN NUMBER
40195 --Bill To Customer Account Identifier
40196 , p_source_30 IN NUMBER
40197 --Bill To Customer Site Use Identifier
40198 , p_source_31 IN NUMBER
40199 --SLA Party Type
40200 , p_source_32 IN VARCHAR2
40201 --Transaction Distribution Account Class
40202 , p_source_33 IN VARCHAR2
40203 --Transaction Distribution Identifier
40204 , p_source_34 IN NUMBER
40205 --Transaction Distribution Type
40206 , p_source_35 IN VARCHAR2
40207 --Transaction Distribution Entered Amount
40208 , p_source_36 IN NUMBER
40209 --Transaction Currency Code
40210 , p_source_37 IN VARCHAR2
40211 --Transaction Exchange Date
40212 , p_source_38 IN DATE
40213 --Transaction Exchange Rate
40214 , p_source_39 IN NUMBER
40215 --Transaction Exchange Rate Type
40216 , p_source_40 IN VARCHAR2
40217 --Transaction Accounting Amount
40218 , p_source_41 IN NUMBER
40219 --Transaction Tax Line Identifier
40220 , p_source_55 IN NUMBER
40221 )
40222 IS
40223
40224 l_component_type VARCHAR2(80);
40225 l_component_code VARCHAR2(30);
40226 l_component_type_code VARCHAR2(1);
40227 l_component_appl_id INTEGER;
40228 l_amb_context_code VARCHAR2(30);
40229 l_entity_code VARCHAR2(30);
40230 l_event_class_code VARCHAR2(30);
40231 l_ae_header_id NUMBER;
40232 l_event_type_code VARCHAR2(30);
40233 l_line_definition_code VARCHAR2(30);
40234 l_line_definition_owner_code VARCHAR2(1);
40235 --
40236 -- adr variables
40237 l_segment VARCHAR2(30);
40238 l_ccid NUMBER;
40239 l_adr_transaction_coa_id NUMBER;
40240 l_adr_accounting_coa_id NUMBER;
40241 l_adr_flexfield_segment_code VARCHAR2(30);
40242 l_adr_flex_value_set_id NUMBER;
40243 l_adr_value_type_code VARCHAR2(30);
40244 l_adr_value_combination_id NUMBER;
40245 l_adr_value_segment_code VARCHAR2(30);
40246
40247 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
40248 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
40249 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
40250 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
40251
40252 -- 4262811 Variables ------------------------------------------------------------------------------------------
40253 l_entered_amt_idx NUMBER;
40254 l_accted_amt_idx NUMBER;
40255 l_acc_rev_flag VARCHAR2(1);
40256 l_accrual_line_num NUMBER;
40257 l_tmp_amt NUMBER;
40258 l_acc_rev_natural_side_code VARCHAR2(1);
40259
40260 l_num_entries NUMBER;
40261 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
40262 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
40263 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
40264 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
40265 l_recog_line_1 NUMBER;
40266 l_recog_line_2 NUMBER;
40267
40268 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
40269 l_bflow_applied_to_amt NUMBER; -- 5132302
40270 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
40271
40272 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
40273
40274 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
40275 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
40276
40277 ---------------------------------------------------------------------------------------------------------------
40278
40279
40280 --
40281 -- bulk performance
40282 --
40283 l_balance_type_code VARCHAR2(1);
40284 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
40285 l_log_module VARCHAR2(240);
40286
40287 --
40288 -- Upgrade strategy
40289 --
40290 l_actual_upg_option VARCHAR2(1);
40291 l_enc_upg_option VARCHAR2(1);
40292
40293 --
40294 BEGIN
40295 --
40296 IF g_log_enabled THEN
40297 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_89';
40298 END IF;
40299 --
40300 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40301
40302 trace
40303 (p_msg => 'BEGIN of AcctLineType_89'
40304 ,p_level => C_LEVEL_PROCEDURE
40305 ,p_module => l_log_module);
40306
40307 END IF;
40308 --
40309 l_component_type := 'AMB_JLT';
40310 l_component_code := 'INV_ROUND';
40311 l_component_type_code := 'S';
40312 l_component_appl_id := 222;
40313 l_amb_context_code := 'DEFAULT';
40314 l_entity_code := 'TRANSACTIONS';
40315 l_event_class_code := 'INVOICE';
40316 l_event_type_code := 'INVOICE_ALL';
40317 l_line_definition_owner_code := 'S';
40318 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
40319 --
40323 l_adr_transaction_coa_id := NULL;
40320 l_balance_type_code := 'A';
40321 l_segment := NULL;
40322 l_ccid := NULL;
40324 l_adr_accounting_coa_id := NULL;
40325 l_adr_flexfield_segment_code := NULL;
40326 l_adr_flex_value_set_id := NULL;
40327 l_adr_value_type_code := NULL;
40328 l_adr_value_combination_id := NULL;
40329 l_adr_value_segment_code := NULL;
40330
40331 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
40332 l_bflow_class_code := ''; -- 4219869 Business Flow
40333 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
40334 l_budgetary_control_flag := 'N';
40335
40336 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40337 l_bflow_applied_to_amt := NULL; -- 5132302
40338 l_entered_amt_idx := NULL; -- 4262811
40339 l_accted_amt_idx := NULL; -- 4262811
40340 l_acc_rev_flag := NULL; -- 4262811
40341 l_accrual_line_num := NULL; -- 4262811
40342 l_tmp_amt := NULL; -- 4262811
40343 --
40344
40345 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
40346 l_balance_type_code <> 'B' THEN
40347 IF NVL(p_source_33,'
40348 ') = 'ROUND'
40349 THEN
40350
40351 --
40352 XLA_AE_LINES_PKG.SetNewLine;
40353
40354 p_balance_type_code := l_balance_type_code;
40355 -- set the flag so later we will know whether the gain loss line needs to be created
40356
40357 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
40358 p_actual_flag :='A';
40359 END IF;
40360
40361 --
40362 -- bulk performance
40363 --
40364 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
40365 p_header_num => 0); -- 4262811
40366 --
40367 -- set accounting line options
40368 --
40369 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
40370 p_natural_side_code => 'C'
40371 , p_gain_or_loss_flag => 'N'
40372 , p_gl_transfer_mode_code => 'S'
40373 , p_acct_entry_type_code => 'A'
40374 , p_switch_side_flag => 'Y'
40375 , p_merge_duplicate_code => 'A'
40376 );
40377 --
40378 l_acc_rev_natural_side_code := 'D'; -- 4262811
40379 --
40380 --
40381 -- set accounting line type info
40382 --
40383 xla_ae_lines_pkg.SetAcctLineType
40384 (p_component_type => l_component_type
40385 ,p_event_type_code => l_event_type_code
40386 ,p_line_definition_owner_code => l_line_definition_owner_code
40387 ,p_line_definition_code => l_line_definition_code
40388 ,p_accounting_line_code => l_component_code
40389 ,p_accounting_line_type_code => l_component_type_code
40390 ,p_accounting_line_appl_id => l_component_appl_id
40391 ,p_amb_context_code => l_amb_context_code
40392 ,p_entity_code => l_entity_code
40393 ,p_event_class_code => l_event_class_code);
40394 --
40395 -- set accounting class
40396 --
40397 xla_ae_lines_pkg.SetAcctClass(
40398 p_accounting_class_code => 'ROUNDING'
40399 , p_ae_header_id => l_ae_header_id
40400 );
40401
40402 --
40403 -- set rounding class
40404 --
40405 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
40406 'RECEIVABLE';
40407
40408 --
40409 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
40410 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
40411 --
40412 -- bulk performance
40413 --
40414 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
40415
40416 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
40417 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
40418
40419 -- 4955764
40420 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40421 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
40422
40423 -- 4458381 Public Sector Enh
40424
40425 --
40426 -- set accounting attributes for the line type
40427 --
40428 l_entered_amt_idx := 3;
40429 l_accted_amt_idx := 8;
40430 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40431 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
40432 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
40433 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
40437 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
40434 l_rec_acct_attrs.array_char_value(2) := p_source_35;
40435 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
40436 l_rec_acct_attrs.array_num_value(3) := p_source_36;
40438 l_rec_acct_attrs.array_char_value(4) := p_source_37;
40439 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
40440 l_rec_acct_attrs.array_date_value(5) := p_source_38;
40441 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
40442 l_rec_acct_attrs.array_num_value(6) := p_source_39;
40443 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
40444 l_rec_acct_attrs.array_char_value(7) := p_source_40;
40445 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
40446 l_rec_acct_attrs.array_num_value(8) := p_source_41;
40447 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
40448 l_rec_acct_attrs.array_num_value(9) := p_source_30;
40449 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
40450 l_rec_acct_attrs.array_num_value(10) := p_source_31;
40451 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
40452 l_rec_acct_attrs.array_char_value(11) := p_source_32;
40453 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
40454 l_rec_acct_attrs.array_num_value(12) := p_source_55;
40455
40456 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
40457 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
40458
40459 ---------------------------------------------------------------------------------------------------------------
40460 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
40461 ---------------------------------------------------------------------------------------------------------------
40462 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
40463
40464 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
40465 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
40466
40467 IF xla_accounting_cache_pkg.GetValueChar
40468 (p_source_code => 'LEDGER_CATEGORY_CODE'
40469 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
40470 AND l_bflow_method_code = 'PRIOR_ENTRY'
40471 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
40472 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
40473 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
40474 )
40475 THEN
40476 xla_ae_lines_pkg.BflowUpgEntry
40477 (p_business_method_code => l_bflow_method_code
40478 ,p_business_class_code => l_bflow_class_code
40479 ,p_balance_type => l_balance_type_code);
40480 ELSE
40481 NULL;
40482 -- No business flow processing for business flow method of NONE.
40483 END IF;
40484
40485 --
40486 -- call analytical criteria
40487 --
40488
40489 --
40490 -- call description
40491 --
40492 -- No description or it is inherited.
40493 --
40494 -- call ADRs
40495 -- Bug 4922099
40496 --
40497 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40498 (NVL(l_actual_upg_option, 'N') = 'O') OR
40499 (NVL(l_enc_upg_option, 'N') = 'O')
40500 )
40501 THEN
40502 NULL;
40503 --
40504 --
40505
40506 l_ccid := AcctDerRule_28(
40507 p_application_id => p_application_id
40508 , p_ae_header_id => l_ae_header_id
40509 , p_source_19 => p_source_19
40510 , x_transaction_coa_id => l_adr_transaction_coa_id
40511 , x_accounting_coa_id => l_adr_accounting_coa_id
40512 , x_value_type_code => l_adr_value_type_code
40513 , p_side => 'NA'
40514 );
40515
40516 xla_ae_lines_pkg.set_ccid(
40517 p_code_combination_id => l_ccid
40518 , p_value_type_code => l_adr_value_type_code
40519 , p_transaction_coa_id => l_adr_transaction_coa_id
40520 , p_accounting_coa_id => l_adr_accounting_coa_id
40521 , p_adr_code => 'TRX_DIST_CCID'
40522 , p_adr_type_code => 'S'
40523 , p_component_type => l_component_type
40524 , p_component_code => l_component_code
40525 , p_component_type_code => l_component_type_code
40526 , p_component_appl_id => l_component_appl_id
40527 , p_amb_context_code => l_amb_context_code
40528 , p_side => 'NA'
40529 );
40530
40531
40532 --
40533 --
40534 END IF;
40535 --
40536 -- Bug 4922099
40537 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
40538 (NVL(l_enc_upg_option, 'N') = 'O')
40539 ) AND
40540 (l_bflow_method_code = 'PRIOR_ENTRY')
40541 )
40542 THEN
40543 IF
40544 --
40545 1 = 2
40546 --
40547 THEN
40548 xla_accounting_err_pkg.build_message
40549 (p_appli_s_name => 'XLA'
40550 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40551 ,p_token_1 => 'LINE_NUMBER'
40552 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
40553 ,p_token_2 => 'LINE_TYPE_NAME'
40554 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
40555 l_component_type
40556 ,l_component_code
40557 ,l_component_type_code
40558 ,l_component_appl_id
40559 ,l_amb_context_code
40560 ,l_entity_code
40561 ,l_event_class_code
40562 )
40563 ,p_token_3 => 'OWNER'
40564 ,p_value_3 => xla_lookups_pkg.get_meaning(
40568 ,p_token_4 => 'PRODUCT_NAME'
40565 p_lookup_type => 'XLA_OWNER_TYPE'
40566 ,p_lookup_code => l_component_type_code
40567 )
40569 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
40570 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
40571 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
40572 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
40573 ,p_ae_header_id => NULL
40574 );
40575
40576 IF (C_LEVEL_ERROR>= g_log_level) THEN
40577 trace
40578 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
40579 ,p_level => C_LEVEL_ERROR
40580 ,p_module => l_log_module);
40581 END IF;
40582 END IF;
40583 END IF;
40584 --
40585 --
40586 ------------------------------------------------------------------------------------------------
40587 -- 4219869 Business Flow
40588 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
40589 -- Prior Entry. Currently, the following code is always generated.
40590 ------------------------------------------------------------------------------------------------
40591 XLA_AE_LINES_PKG.ValidateCurrentLine;
40592
40593 ------------------------------------------------------------------------------------
40594 -- 4219869 Business Flow
40595 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
40596 ------------------------------------------------------------------------------------
40597 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40598
40599 ----------------------------------------------------------------------------------
40600 -- 4219869 Business Flow
40601 -- Update journal entry status -- Need to generate this within IF <condition>
40602 ----------------------------------------------------------------------------------
40603 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40604 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
40605 ,p_balance_type_code => l_balance_type_code
40606 );
40607
40608 -------------------------------------------------------------------------------------------
40609 -- 4262811 - Generate the Accrual Reversal lines
40610 -------------------------------------------------------------------------------------------
40611 BEGIN
40612 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
40613 (g_array_event(p_event_id).array_value_num('header_index'));
40614 IF l_acc_rev_flag IS NULL THEN
40615 l_acc_rev_flag := 'N';
40616 END IF;
40617 EXCEPTION
40618 WHEN OTHERS THEN
40619 l_acc_rev_flag := 'N';
40620 END;
40621 --
40622 IF (l_acc_rev_flag = 'Y') THEN
40623
40624 -- 4645092 ------------------------------------------------------------------------------
40625 -- To allow MPA report to determine if it should generate report process
40626 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
40627 ------------------------------------------------------------------------------------------
40628
40629 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
40630 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
40631 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
40632 -- call ADRs
40633 -- Bug 4922099
40634 --
40635 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
40636 (NVL(l_actual_upg_option, 'N') = 'O') OR
40637 (NVL(l_enc_upg_option, 'N') = 'O')
40638 )
40639 THEN
40640 NULL;
40641 --
40642 --
40643
40644 l_ccid := AcctDerRule_28(
40645 p_application_id => p_application_id
40646 , p_ae_header_id => l_ae_header_id
40647 , p_source_19 => p_source_19
40648 , x_transaction_coa_id => l_adr_transaction_coa_id
40649 , x_accounting_coa_id => l_adr_accounting_coa_id
40650 , x_value_type_code => l_adr_value_type_code
40651 , p_side => 'NA'
40652 );
40653
40654 xla_ae_lines_pkg.set_ccid(
40655 p_code_combination_id => l_ccid
40656 , p_value_type_code => l_adr_value_type_code
40657 , p_transaction_coa_id => l_adr_transaction_coa_id
40658 , p_accounting_coa_id => l_adr_accounting_coa_id
40659 , p_adr_code => 'TRX_DIST_CCID'
40660 , p_adr_type_code => 'S'
40661 , p_component_type => l_component_type
40662 , p_component_code => l_component_code
40663 , p_component_type_code => l_component_type_code
40664 , p_component_appl_id => l_component_appl_id
40665 , p_amb_context_code => l_amb_context_code
40666 , p_side => 'NA'
40667 );
40668
40669
40670 --
40671 --
40672 END IF;
40673
40674 --
40675 -- Update the line information that should be overwritten
40676 --
40677 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
40678 p_header_num => 1);
40679 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
40680
40681 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
40682
40683 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
40684 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
40685 END IF;
40686
40687 --
40688 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
40689 --
40690 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
40691 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
40692 ELSE
40693 ---------------------------------------------------------------------------------------------------
40694 -- 4262811a Switch Sign
40698 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40695 ---------------------------------------------------------------------------------------------------
40696 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
40697 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40699 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
40700 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40701 -- 5132302
40702 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
40703 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
40704
40705 END IF;
40706
40707 -- 4955764
40708 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40709 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
40710
40711
40712 XLA_AE_LINES_PKG.ValidateCurrentLine;
40713 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
40714
40715 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
40716 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
40717 ,p_balance_type_code => l_balance_type_code);
40718
40719 END IF;
40720
40721 -----------------------------------------------------------------------------------------
40722 -- 4262811 Multiperiod Accounting
40723 -----------------------------------------------------------------------------------------
40724 -- No MPA option is assigned.
40725
40726
40727 END IF;
40728 END IF;
40729 --
40730
40731 --
40732 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40733 trace
40734 (p_msg => 'END of AcctLineType_89'
40735 ,p_level => C_LEVEL_PROCEDURE
40736 ,p_module => l_log_module);
40737 END IF;
40738 --
40739 EXCEPTION
40740 WHEN xla_exceptions_pkg.application_exception THEN
40741 RAISE;
40742 WHEN OTHERS THEN
40743 xla_exceptions_pkg.raise_message
40744 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_89');
40745 END AcctLineType_89;
40746 --
40747
40748 ---------------------------------------
40749 --
40750 -- PRIVATE FUNCTION
40751 -- AcctLineType_90
40752 --
40753 ---------------------------------------
40754 PROCEDURE AcctLineType_90 (
40755 p_application_id IN NUMBER
40756 ,p_event_id IN NUMBER
40757 ,p_calculate_acctd_flag IN VARCHAR2
40758 ,p_calculate_g_l_flag IN VARCHAR2
40759 ,p_actual_flag IN OUT VARCHAR2
40760 ,p_balance_type_code OUT VARCHAR2
40761 ,p_gain_or_loss_ref OUT VARCHAR2
40762
40763 --Transaction Distribution GL Account
40764 , p_source_19 IN NUMBER
40765 --Bill To Customer Account Identifier
40766 , p_source_30 IN NUMBER
40767 --Bill To Customer Site Use Identifier
40768 , p_source_31 IN NUMBER
40769 --SLA Party Type
40770 , p_source_32 IN VARCHAR2
40771 --Transaction Distribution Account Class
40772 , p_source_33 IN VARCHAR2
40773 --Transaction Distribution Identifier
40774 , p_source_34 IN NUMBER
40775 --Transaction Distribution Type
40776 , p_source_35 IN VARCHAR2
40777 --Transaction Distribution Entered Amount
40778 , p_source_36 IN NUMBER
40779 --Transaction Currency Code
40780 , p_source_37 IN VARCHAR2
40781 --Transaction Exchange Date
40782 , p_source_38 IN DATE
40783 --Transaction Exchange Rate
40784 , p_source_39 IN NUMBER
40785 --Transaction Exchange Rate Type
40786 , p_source_40 IN VARCHAR2
40787 --Transaction Accounting Amount
40788 , p_source_41 IN NUMBER
40789 --Transaction Tax Line Identifier
40790 , p_source_55 IN NUMBER
40791 )
40792 IS
40793
40794 l_component_type VARCHAR2(80);
40795 l_component_code VARCHAR2(30);
40796 l_component_type_code VARCHAR2(1);
40797 l_component_appl_id INTEGER;
40798 l_amb_context_code VARCHAR2(30);
40799 l_entity_code VARCHAR2(30);
40800 l_event_class_code VARCHAR2(30);
40801 l_ae_header_id NUMBER;
40802 l_event_type_code VARCHAR2(30);
40803 l_line_definition_code VARCHAR2(30);
40804 l_line_definition_owner_code VARCHAR2(1);
40805 --
40806 -- adr variables
40807 l_segment VARCHAR2(30);
40808 l_ccid NUMBER;
40809 l_adr_transaction_coa_id NUMBER;
40810 l_adr_accounting_coa_id NUMBER;
40811 l_adr_flexfield_segment_code VARCHAR2(30);
40812 l_adr_flex_value_set_id NUMBER;
40813 l_adr_value_type_code VARCHAR2(30);
40814 l_adr_value_combination_id NUMBER;
40815 l_adr_value_segment_code VARCHAR2(30);
40816
40817 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
40818 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
40819 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
40820 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
40821
40822 -- 4262811 Variables ------------------------------------------------------------------------------------------
40823 l_entered_amt_idx NUMBER;
40824 l_accted_amt_idx NUMBER;
40825 l_acc_rev_flag VARCHAR2(1);
40826 l_accrual_line_num NUMBER;
40827 l_tmp_amt NUMBER;
40828 l_acc_rev_natural_side_code VARCHAR2(1);
40829
40830 l_num_entries NUMBER;
40831 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
40832 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
40833 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
40834 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
40835 l_recog_line_1 NUMBER;
40836 l_recog_line_2 NUMBER;
40837
40838 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
40839 l_bflow_applied_to_amt NUMBER; -- 5132302
40840 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
40841
40842 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
40843
40844 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
40848
40845 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
40846
40847 ---------------------------------------------------------------------------------------------------------------
40849
40850 --
40851 -- bulk performance
40852 --
40853 l_balance_type_code VARCHAR2(1);
40854 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
40855 l_log_module VARCHAR2(240);
40856
40857 --
40858 -- Upgrade strategy
40859 --
40860 l_actual_upg_option VARCHAR2(1);
40861 l_enc_upg_option VARCHAR2(1);
40862
40863 --
40864 BEGIN
40865 --
40866 IF g_log_enabled THEN
40867 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_90';
40868 END IF;
40869 --
40870 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
40871
40872 trace
40873 (p_msg => 'BEGIN of AcctLineType_90'
40874 ,p_level => C_LEVEL_PROCEDURE
40875 ,p_module => l_log_module);
40876
40877 END IF;
40878 --
40879 l_component_type := 'AMB_JLT';
40880 l_component_code := 'INV_SUSPENSE';
40881 l_component_type_code := 'S';
40882 l_component_appl_id := 222;
40883 l_amb_context_code := 'DEFAULT';
40884 l_entity_code := 'TRANSACTIONS';
40885 l_event_class_code := 'INVOICE';
40886 l_event_type_code := 'INVOICE_ALL';
40887 l_line_definition_owner_code := 'S';
40888 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
40889 --
40890 l_balance_type_code := 'A';
40891 l_segment := NULL;
40892 l_ccid := NULL;
40893 l_adr_transaction_coa_id := NULL;
40894 l_adr_accounting_coa_id := NULL;
40895 l_adr_flexfield_segment_code := NULL;
40896 l_adr_flex_value_set_id := NULL;
40897 l_adr_value_type_code := NULL;
40898 l_adr_value_combination_id := NULL;
40899 l_adr_value_segment_code := NULL;
40900
40901 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
40902 l_bflow_class_code := ''; -- 4219869 Business Flow
40903 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
40904 l_budgetary_control_flag := 'N';
40905
40906 l_bflow_applied_to_amt_idx := NULL; -- 5132302
40907 l_bflow_applied_to_amt := NULL; -- 5132302
40908 l_entered_amt_idx := NULL; -- 4262811
40909 l_accted_amt_idx := NULL; -- 4262811
40910 l_acc_rev_flag := NULL; -- 4262811
40911 l_accrual_line_num := NULL; -- 4262811
40912 l_tmp_amt := NULL; -- 4262811
40913 --
40914
40915 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
40916 l_balance_type_code <> 'B' THEN
40917 IF NVL(p_source_33,'
40918 ') = 'SUSPENSE'
40919 THEN
40920
40921 --
40922 XLA_AE_LINES_PKG.SetNewLine;
40923
40924 p_balance_type_code := l_balance_type_code;
40925 -- set the flag so later we will know whether the gain loss line needs to be created
40926
40927 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
40928 p_actual_flag :='A';
40929 END IF;
40930
40931 --
40932 -- bulk performance
40933 --
40934 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
40935 p_header_num => 0); -- 4262811
40936 --
40937 -- set accounting line options
40938 --
40939 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
40940 p_natural_side_code => 'C'
40941 , p_gain_or_loss_flag => 'N'
40942 , p_gl_transfer_mode_code => 'S'
40943 , p_acct_entry_type_code => 'A'
40944 , p_switch_side_flag => 'Y'
40945 , p_merge_duplicate_code => 'A'
40946 );
40947 --
40948 l_acc_rev_natural_side_code := 'D'; -- 4262811
40949 --
40950 --
40951 -- set accounting line type info
40952 --
40953 xla_ae_lines_pkg.SetAcctLineType
40954 (p_component_type => l_component_type
40955 ,p_event_type_code => l_event_type_code
40956 ,p_line_definition_owner_code => l_line_definition_owner_code
40957 ,p_line_definition_code => l_line_definition_code
40958 ,p_accounting_line_code => l_component_code
40959 ,p_accounting_line_type_code => l_component_type_code
40960 ,p_accounting_line_appl_id => l_component_appl_id
40961 ,p_amb_context_code => l_amb_context_code
40962 ,p_entity_code => l_entity_code
40963 ,p_event_class_code => l_event_class_code);
40964 --
40965 -- set accounting class
40966 --
40967 xla_ae_lines_pkg.SetAcctClass(
40968 p_accounting_class_code => 'SUSPENSE'
40969 , p_ae_header_id => l_ae_header_id
40970 );
40971
40972 --
40973 -- set rounding class
40974 --
40975 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
40976 'RECEIVABLE';
40977
40978 --
40979 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
40980 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
40981 --
40982 -- bulk performance
40983 --
40984 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
40985
40986 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
40987 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
40988
40989 -- 4955764
40990 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
40991 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
40992
40993 -- 4458381 Public Sector Enh
40994
40995 --
40996 -- set accounting attributes for the line type
40997 --
40998 l_entered_amt_idx := 3;
40999 l_accted_amt_idx := 8;
41000 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41001 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
41002 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
41003 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
41004 l_rec_acct_attrs.array_char_value(2) := p_source_35;
41005 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
41006 l_rec_acct_attrs.array_num_value(3) := p_source_36;
41007 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
41008 l_rec_acct_attrs.array_char_value(4) := p_source_37;
41009 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
41010 l_rec_acct_attrs.array_date_value(5) := p_source_38;
41011 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
41012 l_rec_acct_attrs.array_num_value(6) := p_source_39;
41016 l_rec_acct_attrs.array_num_value(8) := p_source_41;
41013 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
41014 l_rec_acct_attrs.array_char_value(7) := p_source_40;
41015 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
41017 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
41018 l_rec_acct_attrs.array_num_value(9) := p_source_30;
41019 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
41020 l_rec_acct_attrs.array_num_value(10) := p_source_31;
41021 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
41022 l_rec_acct_attrs.array_char_value(11) := p_source_32;
41023 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
41024 l_rec_acct_attrs.array_num_value(12) := p_source_55;
41025
41026 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
41027 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
41028
41029 ---------------------------------------------------------------------------------------------------------------
41030 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
41031 ---------------------------------------------------------------------------------------------------------------
41032 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
41033
41034 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41035 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41036
41037 IF xla_accounting_cache_pkg.GetValueChar
41038 (p_source_code => 'LEDGER_CATEGORY_CODE'
41039 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
41040 AND l_bflow_method_code = 'PRIOR_ENTRY'
41041 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
41042 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
41043 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
41044 )
41045 THEN
41046 xla_ae_lines_pkg.BflowUpgEntry
41047 (p_business_method_code => l_bflow_method_code
41048 ,p_business_class_code => l_bflow_class_code
41049 ,p_balance_type => l_balance_type_code);
41050 ELSE
41051 NULL;
41052 -- No business flow processing for business flow method of NONE.
41053 END IF;
41054
41055 --
41056 -- call analytical criteria
41057 --
41058
41059 --
41060 -- call description
41061 --
41062 -- No description or it is inherited.
41063 --
41064 -- call ADRs
41065 -- Bug 4922099
41066 --
41067 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41068 (NVL(l_actual_upg_option, 'N') = 'O') OR
41069 (NVL(l_enc_upg_option, 'N') = 'O')
41070 )
41071 THEN
41072 NULL;
41073 --
41074 --
41075
41076 l_ccid := AcctDerRule_28(
41077 p_application_id => p_application_id
41078 , p_ae_header_id => l_ae_header_id
41079 , p_source_19 => p_source_19
41080 , x_transaction_coa_id => l_adr_transaction_coa_id
41081 , x_accounting_coa_id => l_adr_accounting_coa_id
41082 , x_value_type_code => l_adr_value_type_code
41083 , p_side => 'NA'
41084 );
41085
41086 xla_ae_lines_pkg.set_ccid(
41087 p_code_combination_id => l_ccid
41088 , p_value_type_code => l_adr_value_type_code
41089 , p_transaction_coa_id => l_adr_transaction_coa_id
41090 , p_accounting_coa_id => l_adr_accounting_coa_id
41091 , p_adr_code => 'TRX_DIST_CCID'
41092 , p_adr_type_code => 'S'
41093 , p_component_type => l_component_type
41094 , p_component_code => l_component_code
41095 , p_component_type_code => l_component_type_code
41096 , p_component_appl_id => l_component_appl_id
41097 , p_amb_context_code => l_amb_context_code
41098 , p_side => 'NA'
41099 );
41100
41101
41102 --
41103 --
41104 END IF;
41105 --
41106 -- Bug 4922099
41107 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
41108 (NVL(l_enc_upg_option, 'N') = 'O')
41109 ) AND
41110 (l_bflow_method_code = 'PRIOR_ENTRY')
41111 )
41112 THEN
41113 IF
41114 --
41115 1 = 2
41116 --
41117 THEN
41118 xla_accounting_err_pkg.build_message
41119 (p_appli_s_name => 'XLA'
41120 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41121 ,p_token_1 => 'LINE_NUMBER'
41122 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
41123 ,p_token_2 => 'LINE_TYPE_NAME'
41124 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
41125 l_component_type
41126 ,l_component_code
41127 ,l_component_type_code
41128 ,l_component_appl_id
41129 ,l_amb_context_code
41130 ,l_entity_code
41134 ,p_value_3 => xla_lookups_pkg.get_meaning(
41131 ,l_event_class_code
41132 )
41133 ,p_token_3 => 'OWNER'
41135 p_lookup_type => 'XLA_OWNER_TYPE'
41136 ,p_lookup_code => l_component_type_code
41137 )
41138 ,p_token_4 => 'PRODUCT_NAME'
41139 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
41140 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
41141 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
41142 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
41143 ,p_ae_header_id => NULL
41144 );
41145
41146 IF (C_LEVEL_ERROR>= g_log_level) THEN
41147 trace
41148 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41149 ,p_level => C_LEVEL_ERROR
41150 ,p_module => l_log_module);
41151 END IF;
41152 END IF;
41153 END IF;
41154 --
41155 --
41156 ------------------------------------------------------------------------------------------------
41157 -- 4219869 Business Flow
41158 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
41159 -- Prior Entry. Currently, the following code is always generated.
41160 ------------------------------------------------------------------------------------------------
41161 XLA_AE_LINES_PKG.ValidateCurrentLine;
41162
41163 ------------------------------------------------------------------------------------
41164 -- 4219869 Business Flow
41165 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
41166 ------------------------------------------------------------------------------------
41167 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41168
41169 ----------------------------------------------------------------------------------
41170 -- 4219869 Business Flow
41171 -- Update journal entry status -- Need to generate this within IF <condition>
41172 ----------------------------------------------------------------------------------
41173 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41174 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
41175 ,p_balance_type_code => l_balance_type_code
41176 );
41177
41178 -------------------------------------------------------------------------------------------
41179 -- 4262811 - Generate the Accrual Reversal lines
41180 -------------------------------------------------------------------------------------------
41181 BEGIN
41182 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
41183 (g_array_event(p_event_id).array_value_num('header_index'));
41184 IF l_acc_rev_flag IS NULL THEN
41185 l_acc_rev_flag := 'N';
41186 END IF;
41187 EXCEPTION
41188 WHEN OTHERS THEN
41189 l_acc_rev_flag := 'N';
41190 END;
41191 --
41192 IF (l_acc_rev_flag = 'Y') THEN
41193
41194 -- 4645092 ------------------------------------------------------------------------------
41195 -- To allow MPA report to determine if it should generate report process
41196 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
41197 ------------------------------------------------------------------------------------------
41198
41199 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
41200 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
41201 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
41202 -- call ADRs
41203 -- Bug 4922099
41204 --
41205 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41206 (NVL(l_actual_upg_option, 'N') = 'O') OR
41207 (NVL(l_enc_upg_option, 'N') = 'O')
41208 )
41209 THEN
41210 NULL;
41211 --
41212 --
41213
41214 l_ccid := AcctDerRule_28(
41215 p_application_id => p_application_id
41216 , p_ae_header_id => l_ae_header_id
41217 , p_source_19 => p_source_19
41218 , x_transaction_coa_id => l_adr_transaction_coa_id
41219 , x_accounting_coa_id => l_adr_accounting_coa_id
41220 , x_value_type_code => l_adr_value_type_code
41221 , p_side => 'NA'
41222 );
41223
41224 xla_ae_lines_pkg.set_ccid(
41225 p_code_combination_id => l_ccid
41226 , p_value_type_code => l_adr_value_type_code
41227 , p_transaction_coa_id => l_adr_transaction_coa_id
41228 , p_accounting_coa_id => l_adr_accounting_coa_id
41229 , p_adr_code => 'TRX_DIST_CCID'
41230 , p_adr_type_code => 'S'
41231 , p_component_type => l_component_type
41232 , p_component_code => l_component_code
41233 , p_component_type_code => l_component_type_code
41234 , p_component_appl_id => l_component_appl_id
41235 , p_amb_context_code => l_amb_context_code
41236 , p_side => 'NA'
41237 );
41238
41239
41240 --
41244 --
41241 --
41242 END IF;
41243
41245 -- Update the line information that should be overwritten
41246 --
41247 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
41248 p_header_num => 1);
41249 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
41250
41251 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
41252
41253 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
41254 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
41255 END IF;
41256
41257 --
41258 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
41259 --
41260 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
41261 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
41262 ELSE
41263 ---------------------------------------------------------------------------------------------------
41264 -- 4262811a Switch Sign
41265 ---------------------------------------------------------------------------------------------------
41266 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
41267 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41268 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41269 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41270 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41271 -- 5132302
41272 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
41273 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41274
41275 END IF;
41276
41277 -- 4955764
41278 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41279 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
41280
41281
41282 XLA_AE_LINES_PKG.ValidateCurrentLine;
41283 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41284
41285 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41286 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
41287 ,p_balance_type_code => l_balance_type_code);
41288
41289 END IF;
41290
41291 -----------------------------------------------------------------------------------------
41292 -- 4262811 Multiperiod Accounting
41293 -----------------------------------------------------------------------------------------
41294 -- No MPA option is assigned.
41295
41296
41297 END IF;
41298 END IF;
41299 --
41300
41301 --
41302 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41303 trace
41304 (p_msg => 'END of AcctLineType_90'
41305 ,p_level => C_LEVEL_PROCEDURE
41306 ,p_module => l_log_module);
41307 END IF;
41308 --
41309 EXCEPTION
41310 WHEN xla_exceptions_pkg.application_exception THEN
41311 RAISE;
41312 WHEN OTHERS THEN
41313 xla_exceptions_pkg.raise_message
41314 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_90');
41315 END AcctLineType_90;
41316 --
41317
41318 ---------------------------------------
41319 --
41320 -- PRIVATE FUNCTION
41321 -- AcctLineType_91
41322 --
41323 ---------------------------------------
41324 PROCEDURE AcctLineType_91 (
41325 p_application_id IN NUMBER
41326 ,p_event_id IN NUMBER
41327 ,p_calculate_acctd_flag IN VARCHAR2
41328 ,p_calculate_g_l_flag IN VARCHAR2
41329 ,p_actual_flag IN OUT VARCHAR2
41330 ,p_balance_type_code OUT VARCHAR2
41331 ,p_gain_or_loss_ref OUT VARCHAR2
41332
41333 --Transaction Distribution GL Account
41334 , p_source_19 IN NUMBER
41335 --Bill To Customer Account Identifier
41336 , p_source_30 IN NUMBER
41337 --Bill To Customer Site Use Identifier
41338 , p_source_31 IN NUMBER
41339 --SLA Party Type
41340 , p_source_32 IN VARCHAR2
41341 --Transaction Distribution Account Class
41342 , p_source_33 IN VARCHAR2
41343 --Transaction Distribution Identifier
41344 , p_source_34 IN NUMBER
41345 --Transaction Distribution Type
41346 , p_source_35 IN VARCHAR2
41347 --Transaction Distribution Entered Amount
41348 , p_source_36 IN NUMBER
41349 --Transaction Currency Code
41350 , p_source_37 IN VARCHAR2
41351 --Transaction Exchange Date
41352 , p_source_38 IN DATE
41353 --Transaction Exchange Rate
41354 , p_source_39 IN NUMBER
41355 --Transaction Exchange Rate Type
41356 , p_source_40 IN VARCHAR2
41357 --Transaction Accounting Amount
41358 , p_source_41 IN NUMBER
41359 --Transaction Tax Line Identifier
41360 , p_source_55 IN NUMBER
41361 )
41362 IS
41363
41364 l_component_type VARCHAR2(80);
41365 l_component_code VARCHAR2(30);
41366 l_component_type_code VARCHAR2(1);
41367 l_component_appl_id INTEGER;
41368 l_amb_context_code VARCHAR2(30);
41369 l_entity_code VARCHAR2(30);
41370 l_event_class_code VARCHAR2(30);
41371 l_ae_header_id NUMBER;
41372 l_event_type_code VARCHAR2(30);
41373 l_line_definition_code VARCHAR2(30);
41374 l_line_definition_owner_code VARCHAR2(1);
41375 --
41376 -- adr variables
41377 l_segment VARCHAR2(30);
41378 l_ccid NUMBER;
41379 l_adr_transaction_coa_id NUMBER;
41380 l_adr_accounting_coa_id NUMBER;
41381 l_adr_flexfield_segment_code VARCHAR2(30);
41382 l_adr_flex_value_set_id NUMBER;
41383 l_adr_value_type_code VARCHAR2(30);
41384 l_adr_value_combination_id NUMBER;
41385 l_adr_value_segment_code VARCHAR2(30);
41386
41387 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
41388 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
41389 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
41390 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
41391
41392 -- 4262811 Variables ------------------------------------------------------------------------------------------
41393 l_entered_amt_idx NUMBER;
41394 l_accted_amt_idx NUMBER;
41395 l_acc_rev_flag VARCHAR2(1);
41396 l_accrual_line_num NUMBER;
41397 l_tmp_amt NUMBER;
41398 l_acc_rev_natural_side_code VARCHAR2(1);
41399
41400 l_num_entries NUMBER;
41401 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
41402 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
41403 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
41404 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
41405 l_recog_line_1 NUMBER;
41406 l_recog_line_2 NUMBER;
41407
41408 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
41409 l_bflow_applied_to_amt NUMBER; -- 5132302
41410 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
41411
41412 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
41413
41414 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
41415 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
41416
41417 ---------------------------------------------------------------------------------------------------------------
41418
41419
41420 --
41421 -- bulk performance
41422 --
41423 l_balance_type_code VARCHAR2(1);
41424 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
41425 l_log_module VARCHAR2(240);
41426
41427 --
41428 -- Upgrade strategy
41429 --
41430 l_actual_upg_option VARCHAR2(1);
41431 l_enc_upg_option VARCHAR2(1);
41432
41433 --
41434 BEGIN
41435 --
41436 IF g_log_enabled THEN
41437 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_91';
41438 END IF;
41439 --
41440 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41441
41442 trace
41443 (p_msg => 'BEGIN of AcctLineType_91'
41444 ,p_level => C_LEVEL_PROCEDURE
41445 ,p_module => l_log_module);
41446
41447 END IF;
41448 --
41449 l_component_type := 'AMB_JLT';
41453 l_amb_context_code := 'DEFAULT';
41450 l_component_code := 'INV_TAX';
41451 l_component_type_code := 'S';
41452 l_component_appl_id := 222;
41454 l_entity_code := 'TRANSACTIONS';
41455 l_event_class_code := 'INVOICE';
41456 l_event_type_code := 'INVOICE_ALL';
41457 l_line_definition_owner_code := 'S';
41458 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
41459 --
41460 l_balance_type_code := 'A';
41461 l_segment := NULL;
41462 l_ccid := NULL;
41463 l_adr_transaction_coa_id := NULL;
41464 l_adr_accounting_coa_id := NULL;
41465 l_adr_flexfield_segment_code := NULL;
41466 l_adr_flex_value_set_id := NULL;
41467 l_adr_value_type_code := NULL;
41468 l_adr_value_combination_id := NULL;
41469 l_adr_value_segment_code := NULL;
41470
41471 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
41472 l_bflow_class_code := 'TAX'; -- 4219869 Business Flow
41473 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
41474 l_budgetary_control_flag := 'N';
41475
41476 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41477 l_bflow_applied_to_amt := NULL; -- 5132302
41478 l_entered_amt_idx := NULL; -- 4262811
41479 l_accted_amt_idx := NULL; -- 4262811
41480 l_acc_rev_flag := NULL; -- 4262811
41481 l_accrual_line_num := NULL; -- 4262811
41482 l_tmp_amt := NULL; -- 4262811
41483 --
41484
41485 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
41486 l_balance_type_code <> 'B' THEN
41487 IF NVL(p_source_33,'
41488 ') = 'TAX'
41489 THEN
41490
41491 --
41492 XLA_AE_LINES_PKG.SetNewLine;
41493
41494 p_balance_type_code := l_balance_type_code;
41495 -- set the flag so later we will know whether the gain loss line needs to be created
41496
41497 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
41498 p_actual_flag :='A';
41499 END IF;
41500
41501 --
41502 -- bulk performance
41503 --
41504 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
41505 p_header_num => 0); -- 4262811
41506 --
41507 -- set accounting line options
41508 --
41509 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
41510 p_natural_side_code => 'C'
41511 , p_gain_or_loss_flag => 'N'
41512 , p_gl_transfer_mode_code => 'S'
41513 , p_acct_entry_type_code => 'A'
41514 , p_switch_side_flag => 'Y'
41515 , p_merge_duplicate_code => 'A'
41516 );
41517 --
41518 l_acc_rev_natural_side_code := 'D'; -- 4262811
41519 --
41520 --
41521 -- set accounting line type info
41522 --
41523 xla_ae_lines_pkg.SetAcctLineType
41524 (p_component_type => l_component_type
41525 ,p_event_type_code => l_event_type_code
41526 ,p_line_definition_owner_code => l_line_definition_owner_code
41527 ,p_line_definition_code => l_line_definition_code
41528 ,p_accounting_line_code => l_component_code
41529 ,p_accounting_line_type_code => l_component_type_code
41530 ,p_accounting_line_appl_id => l_component_appl_id
41531 ,p_amb_context_code => l_amb_context_code
41532 ,p_entity_code => l_entity_code
41533 ,p_event_class_code => l_event_class_code);
41534 --
41535 -- set accounting class
41536 --
41537 xla_ae_lines_pkg.SetAcctClass(
41538 p_accounting_class_code => 'TAX'
41539 , p_ae_header_id => l_ae_header_id
41540 );
41541
41542 --
41543 -- set rounding class
41544 --
41545 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
41546 'RECEIVABLE';
41547
41548 --
41549 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
41550 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
41551 --
41552 -- bulk performance
41553 --
41554 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
41555
41556 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
41557 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
41558
41559 -- 4955764
41560 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41561 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
41562
41563 -- 4458381 Public Sector Enh
41564
41565 --
41566 -- set accounting attributes for the line type
41567 --
41568 l_entered_amt_idx := 3;
41569 l_accted_amt_idx := 8;
41570 l_bflow_applied_to_amt_idx := NULL; -- 5132302
41571 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
41572 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
41573 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
41574 l_rec_acct_attrs.array_char_value(2) := p_source_35;
41575 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
41576 l_rec_acct_attrs.array_num_value(3) := p_source_36;
41577 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
41578 l_rec_acct_attrs.array_char_value(4) := p_source_37;
41584 l_rec_acct_attrs.array_char_value(7) := p_source_40;
41579 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
41580 l_rec_acct_attrs.array_date_value(5) := p_source_38;
41581 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
41582 l_rec_acct_attrs.array_num_value(6) := p_source_39;
41583 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
41585 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
41586 l_rec_acct_attrs.array_num_value(8) := p_source_41;
41587 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
41588 l_rec_acct_attrs.array_num_value(9) := p_source_30;
41589 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
41590 l_rec_acct_attrs.array_num_value(10) := p_source_31;
41591 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
41592 l_rec_acct_attrs.array_char_value(11) := p_source_32;
41593 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
41594 l_rec_acct_attrs.array_num_value(12) := p_source_55;
41595
41596 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
41597 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
41598
41599 ---------------------------------------------------------------------------------------------------------------
41600 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
41601 ---------------------------------------------------------------------------------------------------------------
41602 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
41603
41604 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41605 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
41606
41607 IF xla_accounting_cache_pkg.GetValueChar
41608 (p_source_code => 'LEDGER_CATEGORY_CODE'
41609 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
41610 AND l_bflow_method_code = 'PRIOR_ENTRY'
41611 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
41612 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
41613 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
41614 )
41615 THEN
41616 xla_ae_lines_pkg.BflowUpgEntry
41617 (p_business_method_code => l_bflow_method_code
41618 ,p_business_class_code => l_bflow_class_code
41619 ,p_balance_type => l_balance_type_code);
41620 ELSE
41621 NULL;
41622 -- No business flow processing for business flow method of NONE.
41623 END IF;
41624
41625 --
41626 -- call analytical criteria
41627 --
41628
41629 --
41630 -- call description
41631 --
41632 -- No description or it is inherited.
41633 --
41634 -- call ADRs
41635 -- Bug 4922099
41636 --
41637 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41638 (NVL(l_actual_upg_option, 'N') = 'O') OR
41639 (NVL(l_enc_upg_option, 'N') = 'O')
41640 )
41641 THEN
41642 NULL;
41643 --
41644 --
41645
41646 l_ccid := AcctDerRule_28(
41647 p_application_id => p_application_id
41648 , p_ae_header_id => l_ae_header_id
41649 , p_source_19 => p_source_19
41650 , x_transaction_coa_id => l_adr_transaction_coa_id
41651 , x_accounting_coa_id => l_adr_accounting_coa_id
41652 , x_value_type_code => l_adr_value_type_code
41653 , p_side => 'NA'
41654 );
41655
41656 xla_ae_lines_pkg.set_ccid(
41657 p_code_combination_id => l_ccid
41658 , p_value_type_code => l_adr_value_type_code
41659 , p_transaction_coa_id => l_adr_transaction_coa_id
41660 , p_accounting_coa_id => l_adr_accounting_coa_id
41661 , p_adr_code => 'TRX_DIST_CCID'
41662 , p_adr_type_code => 'S'
41663 , p_component_type => l_component_type
41664 , p_component_code => l_component_code
41665 , p_component_type_code => l_component_type_code
41666 , p_component_appl_id => l_component_appl_id
41667 , p_amb_context_code => l_amb_context_code
41668 , p_side => 'NA'
41669 );
41670
41671
41672 --
41673 --
41674 END IF;
41675 --
41676 -- Bug 4922099
41677 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
41678 (NVL(l_enc_upg_option, 'N') = 'O')
41679 ) AND
41680 (l_bflow_method_code = 'PRIOR_ENTRY')
41681 )
41682 THEN
41683 IF
41684 --
41685 1 = 2
41686 --
41687 THEN
41688 xla_accounting_err_pkg.build_message
41689 (p_appli_s_name => 'XLA'
41690 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41691 ,p_token_1 => 'LINE_NUMBER'
41692 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
41693 ,p_token_2 => 'LINE_TYPE_NAME'
41694 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
41695 l_component_type
41696 ,l_component_code
41697 ,l_component_type_code
41698 ,l_component_appl_id
41699 ,l_amb_context_code
41700 ,l_entity_code
41701 ,l_event_class_code
41702 )
41703 ,p_token_3 => 'OWNER'
41704 ,p_value_3 => xla_lookups_pkg.get_meaning(
41705 p_lookup_type => 'XLA_OWNER_TYPE'
41706 ,p_lookup_code => l_component_type_code
41707 )
41708 ,p_token_4 => 'PRODUCT_NAME'
41709 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
41710 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
41711 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
41712 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
41713 ,p_ae_header_id => NULL
41714 );
41715
41716 IF (C_LEVEL_ERROR>= g_log_level) THEN
41717 trace
41718 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
41719 ,p_level => C_LEVEL_ERROR
41720 ,p_module => l_log_module);
41721 END IF;
41722 END IF;
41723 END IF;
41724 --
41725 --
41726 ------------------------------------------------------------------------------------------------
41727 -- 4219869 Business Flow
41728 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
41729 -- Prior Entry. Currently, the following code is always generated.
41730 ------------------------------------------------------------------------------------------------
41731 XLA_AE_LINES_PKG.ValidateCurrentLine;
41732
41733 ------------------------------------------------------------------------------------
41734 -- 4219869 Business Flow
41735 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
41736 ------------------------------------------------------------------------------------
41737 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41738
41739 ----------------------------------------------------------------------------------
41740 -- 4219869 Business Flow
41741 -- Update journal entry status -- Need to generate this within IF <condition>
41742 ----------------------------------------------------------------------------------
41743 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41744 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
41745 ,p_balance_type_code => l_balance_type_code
41746 );
41747
41748 -------------------------------------------------------------------------------------------
41749 -- 4262811 - Generate the Accrual Reversal lines
41750 -------------------------------------------------------------------------------------------
41751 BEGIN
41752 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
41753 (g_array_event(p_event_id).array_value_num('header_index'));
41754 IF l_acc_rev_flag IS NULL THEN
41755 l_acc_rev_flag := 'N';
41756 END IF;
41757 EXCEPTION
41758 WHEN OTHERS THEN
41759 l_acc_rev_flag := 'N';
41760 END;
41761 --
41762 IF (l_acc_rev_flag = 'Y') THEN
41763
41764 -- 4645092 ------------------------------------------------------------------------------
41765 -- To allow MPA report to determine if it should generate report process
41766 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
41767 ------------------------------------------------------------------------------------------
41768
41769 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
41770 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
41771 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
41772 -- call ADRs
41773 -- Bug 4922099
41774 --
41775 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
41776 (NVL(l_actual_upg_option, 'N') = 'O') OR
41777 (NVL(l_enc_upg_option, 'N') = 'O')
41778 )
41779 THEN
41780 NULL;
41781 --
41782 --
41783
41784 l_ccid := AcctDerRule_28(
41785 p_application_id => p_application_id
41786 , p_ae_header_id => l_ae_header_id
41787 , p_source_19 => p_source_19
41788 , x_transaction_coa_id => l_adr_transaction_coa_id
41789 , x_accounting_coa_id => l_adr_accounting_coa_id
41790 , x_value_type_code => l_adr_value_type_code
41791 , p_side => 'NA'
41792 );
41793
41794 xla_ae_lines_pkg.set_ccid(
41795 p_code_combination_id => l_ccid
41796 , p_value_type_code => l_adr_value_type_code
41797 , p_transaction_coa_id => l_adr_transaction_coa_id
41798 , p_accounting_coa_id => l_adr_accounting_coa_id
41799 , p_adr_code => 'TRX_DIST_CCID'
41800 , p_adr_type_code => 'S'
41801 , p_component_type => l_component_type
41802 , p_component_code => l_component_code
41803 , p_component_type_code => l_component_type_code
41804 , p_component_appl_id => l_component_appl_id
41805 , p_amb_context_code => l_amb_context_code
41806 , p_side => 'NA'
41807 );
41808
41809
41810 --
41811 --
41812 END IF;
41813
41814 --
41815 -- Update the line information that should be overwritten
41816 --
41817 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
41818 p_header_num => 1);
41819 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
41820
41821 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
41822
41823 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
41824 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
41825 END IF;
41826
41827 --
41828 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
41829 --
41830 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
41831 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
41832 ELSE
41833 ---------------------------------------------------------------------------------------------------
41834 -- 4262811a Switch Sign
41835 ---------------------------------------------------------------------------------------------------
41836 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
41837 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41841 -- 5132302
41838 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41839 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
41840 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41842 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
41843 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
41844
41845 END IF;
41846
41847 -- 4955764
41848 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
41849 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
41850
41851
41852 XLA_AE_LINES_PKG.ValidateCurrentLine;
41853 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
41854
41855 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
41859 END IF;
41856 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
41857 ,p_balance_type_code => l_balance_type_code);
41858
41860
41861 -----------------------------------------------------------------------------------------
41862 -- 4262811 Multiperiod Accounting
41863 -----------------------------------------------------------------------------------------
41864 -- No MPA option is assigned.
41865
41866
41867 END IF;
41868 END IF;
41869 --
41870
41871 --
41872 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
41873 trace
41874 (p_msg => 'END of AcctLineType_91'
41875 ,p_level => C_LEVEL_PROCEDURE
41876 ,p_module => l_log_module);
41877 END IF;
41878 --
41879 EXCEPTION
41880 WHEN xla_exceptions_pkg.application_exception THEN
41881 RAISE;
41882 WHEN OTHERS THEN
41883 xla_exceptions_pkg.raise_message
41884 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_91');
41885 END AcctLineType_91;
41886 --
41887
41888 ---------------------------------------
41889 --
41890 -- PRIVATE FUNCTION
41891 -- AcctLineType_92
41892 --
41893 ---------------------------------------
41894 PROCEDURE AcctLineType_92 (
41895 p_application_id IN NUMBER
41896 ,p_event_id IN NUMBER
41897 ,p_calculate_acctd_flag IN VARCHAR2
41898 ,p_calculate_g_l_flag IN VARCHAR2
41899 ,p_actual_flag IN OUT VARCHAR2
41900 ,p_balance_type_code OUT VARCHAR2
41901 ,p_gain_or_loss_ref OUT VARCHAR2
41902
41903 --Transaction Distribution GL Account
41904 , p_source_19 IN NUMBER
41905 --Bill To Customer Account Identifier
41906 , p_source_30 IN NUMBER
41907 --Bill To Customer Site Use Identifier
41908 , p_source_31 IN NUMBER
41909 --SLA Party Type
41910 , p_source_32 IN VARCHAR2
41911 --Transaction Distribution Account Class
41912 , p_source_33 IN VARCHAR2
41913 --Transaction Distribution Identifier
41914 , p_source_34 IN NUMBER
41915 --Transaction Distribution Type
41916 , p_source_35 IN VARCHAR2
41917 --Transaction Distribution Entered Amount
41918 , p_source_36 IN NUMBER
41919 --Transaction Currency Code
41920 , p_source_37 IN VARCHAR2
41921 --Transaction Exchange Date
41922 , p_source_38 IN DATE
41923 --Transaction Exchange Rate
41924 , p_source_39 IN NUMBER
41925 --Transaction Exchange Rate Type
41926 , p_source_40 IN VARCHAR2
41927 --Transaction Accounting Amount
41928 , p_source_41 IN NUMBER
41929 --Transaction Tax Line Identifier
41930 , p_source_55 IN NUMBER
41931 --Rounding Correction Flag
41932 , p_source_66 IN VARCHAR2
41933 )
41934 IS
41935
41936 l_component_type VARCHAR2(80);
41937 l_component_code VARCHAR2(30);
41938 l_component_type_code VARCHAR2(1);
41939 l_component_appl_id INTEGER;
41940 l_amb_context_code VARCHAR2(30);
41941 l_entity_code VARCHAR2(30);
41942 l_event_class_code VARCHAR2(30);
41943 l_ae_header_id NUMBER;
41944 l_event_type_code VARCHAR2(30);
41945 l_line_definition_code VARCHAR2(30);
41946 l_line_definition_owner_code VARCHAR2(1);
41947 --
41948 -- adr variables
41949 l_segment VARCHAR2(30);
41950 l_ccid NUMBER;
41951 l_adr_transaction_coa_id NUMBER;
41952 l_adr_accounting_coa_id NUMBER;
41953 l_adr_flexfield_segment_code VARCHAR2(30);
41954 l_adr_flex_value_set_id NUMBER;
41955 l_adr_value_type_code VARCHAR2(30);
41956 l_adr_value_combination_id NUMBER;
41957 l_adr_value_segment_code VARCHAR2(30);
41958
41959 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
41960 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
41961 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
41962 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
41963
41964 -- 4262811 Variables ------------------------------------------------------------------------------------------
41965 l_entered_amt_idx NUMBER;
41966 l_accted_amt_idx NUMBER;
41967 l_acc_rev_flag VARCHAR2(1);
41968 l_accrual_line_num NUMBER;
41969 l_tmp_amt NUMBER;
41970 l_acc_rev_natural_side_code VARCHAR2(1);
41971
41972 l_num_entries NUMBER;
41973 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
41974 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
41975 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
41976 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
41977 l_recog_line_1 NUMBER;
41978 l_recog_line_2 NUMBER;
41979
41980 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
41981 l_bflow_applied_to_amt NUMBER; -- 5132302
41982 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
41983
41984 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
41985
41986 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
41987 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
41988
41992 --
41989 ---------------------------------------------------------------------------------------------------------------
41990
41991
41993 -- bulk performance
41994 --
41995 l_balance_type_code VARCHAR2(1);
41996 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
41997 l_log_module VARCHAR2(240);
41998
41999 --
42000 -- Upgrade strategy
42001 --
42002 l_actual_upg_option VARCHAR2(1);
42003 l_enc_upg_option VARCHAR2(1);
42004
42005 --
42006 BEGIN
42007 --
42008 IF g_log_enabled THEN
42009 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_92';
42010 END IF;
42011 --
42012 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42013
42014 trace
42015 (p_msg => 'BEGIN of AcctLineType_92'
42016 ,p_level => C_LEVEL_PROCEDURE
42017 ,p_module => l_log_module);
42018
42019 END IF;
42020 --
42021 l_component_type := 'AMB_JLT';
42022 l_component_code := 'INV_UNBILL';
42023 l_component_type_code := 'S';
42024 l_component_appl_id := 222;
42025 l_amb_context_code := 'DEFAULT';
42026 l_entity_code := 'TRANSACTIONS';
42027 l_event_class_code := 'INVOICE';
42028 l_event_type_code := 'INVOICE_ALL';
42029 l_line_definition_owner_code := 'S';
42030 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
42031 --
42032 l_balance_type_code := 'A';
42033 l_segment := NULL;
42034 l_ccid := NULL;
42035 l_adr_transaction_coa_id := NULL;
42036 l_adr_accounting_coa_id := NULL;
42037 l_adr_flexfield_segment_code := NULL;
42038 l_adr_flex_value_set_id := NULL;
42039 l_adr_value_type_code := NULL;
42040 l_adr_value_combination_id := NULL;
42041 l_adr_value_segment_code := NULL;
42042
42043 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
42044 l_bflow_class_code := ''; -- 4219869 Business Flow
42045 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
42046 l_budgetary_control_flag := 'N';
42047
42048 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42049 l_bflow_applied_to_amt := NULL; -- 5132302
42050 l_entered_amt_idx := NULL; -- 4262811
42051 l_accted_amt_idx := NULL; -- 4262811
42052 l_acc_rev_flag := NULL; -- 4262811
42053 l_accrual_line_num := NULL; -- 4262811
42054 l_tmp_amt := NULL; -- 4262811
42055 --
42056
42057 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
42058 l_balance_type_code <> 'B' THEN
42059 IF NVL(p_source_33,'
42060 ') = 'UNBILL' AND
42061 p_source_66 IS NULL
42062 THEN
42063
42064 --
42065 XLA_AE_LINES_PKG.SetNewLine;
42066
42067 p_balance_type_code := l_balance_type_code;
42068 -- set the flag so later we will know whether the gain loss line needs to be created
42069
42070 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
42071 p_actual_flag :='A';
42072 END IF;
42073
42074 --
42075 -- bulk performance
42076 --
42077 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
42078 p_header_num => 0); -- 4262811
42079 --
42080 -- set accounting line options
42081 --
42082 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
42083 p_natural_side_code => 'C'
42084 , p_gain_or_loss_flag => 'N'
42085 , p_gl_transfer_mode_code => 'S'
42086 , p_acct_entry_type_code => 'A'
42090 --
42087 , p_switch_side_flag => 'Y'
42088 , p_merge_duplicate_code => 'A'
42089 );
42091 l_acc_rev_natural_side_code := 'D'; -- 4262811
42092 --
42093 --
42094 -- set accounting line type info
42095 --
42096 xla_ae_lines_pkg.SetAcctLineType
42097 (p_component_type => l_component_type
42098 ,p_event_type_code => l_event_type_code
42099 ,p_line_definition_owner_code => l_line_definition_owner_code
42100 ,p_line_definition_code => l_line_definition_code
42101 ,p_accounting_line_code => l_component_code
42102 ,p_accounting_line_type_code => l_component_type_code
42103 ,p_accounting_line_appl_id => l_component_appl_id
42104 ,p_amb_context_code => l_amb_context_code
42105 ,p_entity_code => l_entity_code
42106 ,p_event_class_code => l_event_class_code);
42107 --
42108 -- set accounting class
42109 --
42110 xla_ae_lines_pkg.SetAcctClass(
42111 p_accounting_class_code => 'UNBILL'
42112 , p_ae_header_id => l_ae_header_id
42113 );
42114
42115 --
42116 -- set rounding class
42117 --
42118 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
42119 'UNBILL';
42120
42121 --
42122 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
42123 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
42124 --
42125 -- bulk performance
42126 --
42127 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
42128
42129 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
42130 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
42131
42132 -- 4955764
42133 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42134 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
42135
42136 -- 4458381 Public Sector Enh
42137
42138 --
42139 -- set accounting attributes for the line type
42140 --
42141 l_entered_amt_idx := 3;
42142 l_accted_amt_idx := 8;
42143 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42144 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
42145 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
42146 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
42147 l_rec_acct_attrs.array_char_value(2) := p_source_35;
42148 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
42149 l_rec_acct_attrs.array_num_value(3) := p_source_36;
42150 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
42151 l_rec_acct_attrs.array_char_value(4) := p_source_37;
42152 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
42153 l_rec_acct_attrs.array_date_value(5) := p_source_38;
42154 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
42155 l_rec_acct_attrs.array_num_value(6) := p_source_39;
42156 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
42157 l_rec_acct_attrs.array_char_value(7) := p_source_40;
42158 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
42159 l_rec_acct_attrs.array_num_value(8) := p_source_41;
42160 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
42161 l_rec_acct_attrs.array_num_value(9) := p_source_30;
42162 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
42163 l_rec_acct_attrs.array_num_value(10) := p_source_31;
42164 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
42165 l_rec_acct_attrs.array_char_value(11) := p_source_32;
42166 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
42167 l_rec_acct_attrs.array_num_value(12) := p_source_55;
42168
42169 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
42170 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
42171
42172 ---------------------------------------------------------------------------------------------------------------
42173 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
42174 ---------------------------------------------------------------------------------------------------------------
42175 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
42176
42177 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42178 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42179
42180 IF xla_accounting_cache_pkg.GetValueChar
42181 (p_source_code => 'LEDGER_CATEGORY_CODE'
42182 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
42183 AND l_bflow_method_code = 'PRIOR_ENTRY'
42184 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
42185 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
42186 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
42187 )
42188 THEN
42189 xla_ae_lines_pkg.BflowUpgEntry
42190 (p_business_method_code => l_bflow_method_code
42191 ,p_business_class_code => l_bflow_class_code
42192 ,p_balance_type => l_balance_type_code);
42193 ELSE
42194 NULL;
42195 -- No business flow processing for business flow method of NONE.
42196 END IF;
42197
42198 --
42199 -- call analytical criteria
42200 --
42201
42202 --
42203 -- call description
42204 --
42205 -- No description or it is inherited.
42206 --
42207 -- call ADRs
42208 -- Bug 4922099
42209 --
42210 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42211 (NVL(l_actual_upg_option, 'N') = 'O') OR
42212 (NVL(l_enc_upg_option, 'N') = 'O')
42213 )
42214 THEN
42215 NULL;
42216 --
42217 --
42218
42219 l_ccid := AcctDerRule_28(
42220 p_application_id => p_application_id
42221 , p_ae_header_id => l_ae_header_id
42222 , p_source_19 => p_source_19
42223 , x_transaction_coa_id => l_adr_transaction_coa_id
42224 , x_accounting_coa_id => l_adr_accounting_coa_id
42225 , x_value_type_code => l_adr_value_type_code
42226 , p_side => 'NA'
42227 );
42228
42229 xla_ae_lines_pkg.set_ccid(
42230 p_code_combination_id => l_ccid
42231 , p_value_type_code => l_adr_value_type_code
42232 , p_transaction_coa_id => l_adr_transaction_coa_id
42233 , p_accounting_coa_id => l_adr_accounting_coa_id
42234 , p_adr_code => 'TRX_DIST_CCID'
42235 , p_adr_type_code => 'S'
42236 , p_component_type => l_component_type
42237 , p_component_code => l_component_code
42238 , p_component_type_code => l_component_type_code
42239 , p_component_appl_id => l_component_appl_id
42240 , p_amb_context_code => l_amb_context_code
42241 , p_side => 'NA'
42242 );
42243
42244
42245 --
42246 --
42247 END IF;
42248 --
42249 -- Bug 4922099
42250 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
42251 (NVL(l_enc_upg_option, 'N') = 'O')
42252 ) AND
42253 (l_bflow_method_code = 'PRIOR_ENTRY')
42254 )
42255 THEN
42256 IF
42257 --
42258 1 = 2
42259 --
42260 THEN
42261 xla_accounting_err_pkg.build_message
42262 (p_appli_s_name => 'XLA'
42263 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42264 ,p_token_1 => 'LINE_NUMBER'
42265 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
42266 ,p_token_2 => 'LINE_TYPE_NAME'
42267 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
42268 l_component_type
42269 ,l_component_code
42270 ,l_component_type_code
42271 ,l_component_appl_id
42272 ,l_amb_context_code
42273 ,l_entity_code
42274 ,l_event_class_code
42275 )
42276 ,p_token_3 => 'OWNER'
42277 ,p_value_3 => xla_lookups_pkg.get_meaning(
42278 p_lookup_type => 'XLA_OWNER_TYPE'
42279 ,p_lookup_code => l_component_type_code
42280 )
42281 ,p_token_4 => 'PRODUCT_NAME'
42282 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
42283 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
42284 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
42285 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
42286 ,p_ae_header_id => NULL
42287 );
42288
42289 IF (C_LEVEL_ERROR>= g_log_level) THEN
42290 trace
42291 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42292 ,p_level => C_LEVEL_ERROR
42293 ,p_module => l_log_module);
42294 END IF;
42295 END IF;
42296 END IF;
42297 --
42298 --
42299 ------------------------------------------------------------------------------------------------
42300 -- 4219869 Business Flow
42301 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
42302 -- Prior Entry. Currently, the following code is always generated.
42303 ------------------------------------------------------------------------------------------------
42304 XLA_AE_LINES_PKG.ValidateCurrentLine;
42305
42306 ------------------------------------------------------------------------------------
42307 -- 4219869 Business Flow
42308 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
42309 ------------------------------------------------------------------------------------
42310 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42311
42312 ----------------------------------------------------------------------------------
42313 -- 4219869 Business Flow
42314 -- Update journal entry status -- Need to generate this within IF <condition>
42315 ----------------------------------------------------------------------------------
42316 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42317 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
42318 ,p_balance_type_code => l_balance_type_code
42319 );
42320
42321 -------------------------------------------------------------------------------------------
42322 -- 4262811 - Generate the Accrual Reversal lines
42323 -------------------------------------------------------------------------------------------
42324 BEGIN
42325 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
42326 (g_array_event(p_event_id).array_value_num('header_index'));
42327 IF l_acc_rev_flag IS NULL THEN
42328 l_acc_rev_flag := 'N';
42329 END IF;
42330 EXCEPTION
42331 WHEN OTHERS THEN
42332 l_acc_rev_flag := 'N';
42333 END;
42334 --
42335 IF (l_acc_rev_flag = 'Y') THEN
42336
42337 -- 4645092 ------------------------------------------------------------------------------
42338 -- To allow MPA report to determine if it should generate report process
42339 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
42340 ------------------------------------------------------------------------------------------
42341
42342 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
42343 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
42344 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
42345 -- call ADRs
42346 -- Bug 4922099
42347 --
42348 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42349 (NVL(l_actual_upg_option, 'N') = 'O') OR
42350 (NVL(l_enc_upg_option, 'N') = 'O')
42351 )
42352 THEN
42353 NULL;
42354 --
42355 --
42356
42357 l_ccid := AcctDerRule_28(
42358 p_application_id => p_application_id
42359 , p_ae_header_id => l_ae_header_id
42360 , p_source_19 => p_source_19
42361 , x_transaction_coa_id => l_adr_transaction_coa_id
42362 , x_accounting_coa_id => l_adr_accounting_coa_id
42363 , x_value_type_code => l_adr_value_type_code
42364 , p_side => 'NA'
42365 );
42366
42367 xla_ae_lines_pkg.set_ccid(
42368 p_code_combination_id => l_ccid
42369 , p_value_type_code => l_adr_value_type_code
42370 , p_transaction_coa_id => l_adr_transaction_coa_id
42371 , p_accounting_coa_id => l_adr_accounting_coa_id
42372 , p_adr_code => 'TRX_DIST_CCID'
42373 , p_adr_type_code => 'S'
42374 , p_component_type => l_component_type
42375 , p_component_code => l_component_code
42376 , p_component_type_code => l_component_type_code
42377 , p_component_appl_id => l_component_appl_id
42378 , p_amb_context_code => l_amb_context_code
42379 , p_side => 'NA'
42380 );
42381
42382
42383 --
42384 --
42385 END IF;
42386
42387 --
42388 -- Update the line information that should be overwritten
42389 --
42390 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
42391 p_header_num => 1);
42392 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
42393
42394 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
42395
42396 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
42397 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
42398 END IF;
42399
42400 --
42401 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
42402 --
42403 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
42404 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
42405 ELSE
42406 ---------------------------------------------------------------------------------------------------
42407 -- 4262811a Switch Sign
42408 ---------------------------------------------------------------------------------------------------
42409 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
42410 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42414 -- 5132302
42411 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42412 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42413 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42415 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
42416 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42417
42418 END IF;
42419
42420 -- 4955764
42421 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42422 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
42423
42424
42425 XLA_AE_LINES_PKG.ValidateCurrentLine;
42426 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42427
42428 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42429 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
42430 ,p_balance_type_code => l_balance_type_code);
42431
42432 END IF;
42433
42434 -----------------------------------------------------------------------------------------
42435 -- 4262811 Multiperiod Accounting
42436 -----------------------------------------------------------------------------------------
42437 -- No MPA option is assigned.
42438
42439
42440 END IF;
42441 END IF;
42442 --
42443
42444 --
42445 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42446 trace
42447 (p_msg => 'END of AcctLineType_92'
42448 ,p_level => C_LEVEL_PROCEDURE
42449 ,p_module => l_log_module);
42450 END IF;
42451 --
42452 EXCEPTION
42453 WHEN xla_exceptions_pkg.application_exception THEN
42454 RAISE;
42455 WHEN OTHERS THEN
42456 xla_exceptions_pkg.raise_message
42457 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_92');
42458 END AcctLineType_92;
42459 --
42460
42461 ---------------------------------------
42462 --
42463 -- PRIVATE FUNCTION
42464 -- AcctLineType_93
42465 --
42466 ---------------------------------------
42467 PROCEDURE AcctLineType_93 (
42468 p_application_id IN NUMBER
42469 ,p_event_id IN NUMBER
42470 ,p_calculate_acctd_flag IN VARCHAR2
42471 ,p_calculate_g_l_flag IN VARCHAR2
42472 ,p_actual_flag IN OUT VARCHAR2
42473 ,p_balance_type_code OUT VARCHAR2
42474 ,p_gain_or_loss_ref OUT VARCHAR2
42475
42476 --Transaction Distribution GL Account
42477 , p_source_19 IN NUMBER
42478 --Bill To Customer Account Identifier
42479 , p_source_30 IN NUMBER
42480 --Bill To Customer Site Use Identifier
42481 , p_source_31 IN NUMBER
42482 --SLA Party Type
42483 , p_source_32 IN VARCHAR2
42484 --Transaction Distribution Account Class
42485 , p_source_33 IN VARCHAR2
42486 --Transaction Distribution Identifier
42487 , p_source_34 IN NUMBER
42488 --Transaction Distribution Type
42489 , p_source_35 IN VARCHAR2
42490 --Transaction Distribution Entered Amount
42491 , p_source_36 IN NUMBER
42492 --Transaction Currency Code
42493 , p_source_37 IN VARCHAR2
42494 --Transaction Exchange Date
42495 , p_source_38 IN DATE
42496 --Transaction Exchange Rate
42497 , p_source_39 IN NUMBER
42498 --Transaction Exchange Rate Type
42499 , p_source_40 IN VARCHAR2
42500 --Transaction Accounting Amount
42501 , p_source_41 IN NUMBER
42502 --Transaction Tax Line Identifier
42503 , p_source_55 IN NUMBER
42504 --Rounding Correction Flag
42505 , p_source_66 IN VARCHAR2
42506 )
42507 IS
42508
42509 l_component_type VARCHAR2(80);
42510 l_component_code VARCHAR2(30);
42511 l_component_type_code VARCHAR2(1);
42512 l_component_appl_id INTEGER;
42513 l_amb_context_code VARCHAR2(30);
42514 l_entity_code VARCHAR2(30);
42515 l_event_class_code VARCHAR2(30);
42516 l_ae_header_id NUMBER;
42517 l_event_type_code VARCHAR2(30);
42518 l_line_definition_code VARCHAR2(30);
42519 l_line_definition_owner_code VARCHAR2(1);
42520 --
42521 -- adr variables
42522 l_segment VARCHAR2(30);
42523 l_ccid NUMBER;
42524 l_adr_transaction_coa_id NUMBER;
42525 l_adr_accounting_coa_id NUMBER;
42526 l_adr_flexfield_segment_code VARCHAR2(30);
42527 l_adr_flex_value_set_id NUMBER;
42528 l_adr_value_type_code VARCHAR2(30);
42529 l_adr_value_combination_id NUMBER;
42530 l_adr_value_segment_code VARCHAR2(30);
42531
42532 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
42533 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
42534 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
42535 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
42536
42537 -- 4262811 Variables ------------------------------------------------------------------------------------------
42538 l_entered_amt_idx NUMBER;
42539 l_accted_amt_idx NUMBER;
42540 l_acc_rev_flag VARCHAR2(1);
42541 l_accrual_line_num NUMBER;
42542 l_tmp_amt NUMBER;
42543 l_acc_rev_natural_side_code VARCHAR2(1);
42544
42545 l_num_entries NUMBER;
42546 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
42547 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
42548 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
42549 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
42550 l_recog_line_1 NUMBER;
42551 l_recog_line_2 NUMBER;
42552
42553 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
42554 l_bflow_applied_to_amt NUMBER; -- 5132302
42555 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
42556
42557 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
42558
42559 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
42560 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
42561
42562 ---------------------------------------------------------------------------------------------------------------
42563
42564
42565 --
42569 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
42566 -- bulk performance
42567 --
42568 l_balance_type_code VARCHAR2(1);
42570 l_log_module VARCHAR2(240);
42571
42572 --
42573 -- Upgrade strategy
42574 --
42575 l_actual_upg_option VARCHAR2(1);
42576 l_enc_upg_option VARCHAR2(1);
42577
42578 --
42579 BEGIN
42580 --
42581 IF g_log_enabled THEN
42582 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_93';
42583 END IF;
42584 --
42585 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
42586
42587 trace
42588 (p_msg => 'BEGIN of AcctLineType_93'
42589 ,p_level => C_LEVEL_PROCEDURE
42590 ,p_module => l_log_module);
42591
42592 END IF;
42593 --
42594 l_component_type := 'AMB_JLT';
42595 l_component_code := 'INV_UNBILL_ROUND';
42596 l_component_type_code := 'S';
42597 l_component_appl_id := 222;
42598 l_amb_context_code := 'DEFAULT';
42599 l_entity_code := 'TRANSACTIONS';
42600 l_event_class_code := 'INVOICE';
42601 l_event_type_code := 'INVOICE_ALL';
42602 l_line_definition_owner_code := 'S';
42603 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
42604 --
42605 l_balance_type_code := 'A';
42606 l_segment := NULL;
42607 l_ccid := NULL;
42608 l_adr_transaction_coa_id := NULL;
42609 l_adr_accounting_coa_id := NULL;
42610 l_adr_flexfield_segment_code := NULL;
42611 l_adr_flex_value_set_id := NULL;
42612 l_adr_value_type_code := NULL;
42613 l_adr_value_combination_id := NULL;
42614 l_adr_value_segment_code := NULL;
42615
42616 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
42617 l_bflow_class_code := ''; -- 4219869 Business Flow
42618 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
42619 l_budgetary_control_flag := 'N';
42620
42621 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42622 l_bflow_applied_to_amt := NULL; -- 5132302
42623 l_entered_amt_idx := NULL; -- 4262811
42624 l_accted_amt_idx := NULL; -- 4262811
42625 l_acc_rev_flag := NULL; -- 4262811
42626 l_accrual_line_num := NULL; -- 4262811
42627 l_tmp_amt := NULL; -- 4262811
42628 --
42629
42630 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
42631 l_balance_type_code <> 'B' THEN
42632 IF NVL(p_source_33,'
42633 ') = 'UNBILL' AND
42634 NVL(p_source_66,'
42635 ') = 'Y'
42636 THEN
42637
42638 --
42639 XLA_AE_LINES_PKG.SetNewLine;
42640
42644 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
42641 p_balance_type_code := l_balance_type_code;
42642 -- set the flag so later we will know whether the gain loss line needs to be created
42643
42645 p_actual_flag :='A';
42646 END IF;
42647
42648 --
42649 -- bulk performance
42650 --
42651 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
42652 p_header_num => 0); -- 4262811
42653 --
42654 -- set accounting line options
42655 --
42656 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
42657 p_natural_side_code => 'C'
42658 , p_gain_or_loss_flag => 'N'
42659 , p_gl_transfer_mode_code => 'S'
42660 , p_acct_entry_type_code => 'A'
42661 , p_switch_side_flag => 'Y'
42662 , p_merge_duplicate_code => 'N'
42663 );
42664 --
42665 l_acc_rev_natural_side_code := 'D'; -- 4262811
42666 --
42667 --
42668 -- set accounting line type info
42669 --
42670 xla_ae_lines_pkg.SetAcctLineType
42671 (p_component_type => l_component_type
42672 ,p_event_type_code => l_event_type_code
42673 ,p_line_definition_owner_code => l_line_definition_owner_code
42674 ,p_line_definition_code => l_line_definition_code
42675 ,p_accounting_line_code => l_component_code
42676 ,p_accounting_line_type_code => l_component_type_code
42677 ,p_accounting_line_appl_id => l_component_appl_id
42678 ,p_amb_context_code => l_amb_context_code
42679 ,p_entity_code => l_entity_code
42680 ,p_event_class_code => l_event_class_code);
42681 --
42682 -- set accounting class
42683 --
42684 xla_ae_lines_pkg.SetAcctClass(
42685 p_accounting_class_code => 'UNBILL'
42686 , p_ae_header_id => l_ae_header_id
42687 );
42688
42689 --
42690 -- set rounding class
42691 --
42692 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
42693 'UNBILL';
42694
42695 --
42696 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
42697 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
42698 --
42699 -- bulk performance
42700 --
42701 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
42702
42703 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
42704 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
42705
42706 -- 4955764
42707 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42708 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
42709
42710 -- 4458381 Public Sector Enh
42711
42712 --
42713 -- set accounting attributes for the line type
42714 --
42715 l_entered_amt_idx := 3;
42716 l_accted_amt_idx := 8;
42717 l_bflow_applied_to_amt_idx := NULL; -- 5132302
42718 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
42719 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
42720 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
42721 l_rec_acct_attrs.array_char_value(2) := p_source_35;
42722 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
42723 l_rec_acct_attrs.array_num_value(3) := p_source_36;
42724 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
42725 l_rec_acct_attrs.array_char_value(4) := p_source_37;
42726 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
42727 l_rec_acct_attrs.array_date_value(5) := p_source_38;
42728 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
42729 l_rec_acct_attrs.array_num_value(6) := p_source_39;
42730 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
42731 l_rec_acct_attrs.array_char_value(7) := p_source_40;
42732 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
42733 l_rec_acct_attrs.array_num_value(8) := p_source_41;
42734 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
42735 l_rec_acct_attrs.array_num_value(9) := p_source_30;
42736 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
42737 l_rec_acct_attrs.array_num_value(10) := p_source_31;
42738 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
42739 l_rec_acct_attrs.array_char_value(11) := p_source_32;
42740 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
42741 l_rec_acct_attrs.array_num_value(12) := p_source_55;
42742
42743 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
42744 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
42745
42746 ---------------------------------------------------------------------------------------------------------------
42747 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
42748 ---------------------------------------------------------------------------------------------------------------
42749 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
42750
42751 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42752 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
42753
42754 IF xla_accounting_cache_pkg.GetValueChar
42755 (p_source_code => 'LEDGER_CATEGORY_CODE'
42756 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
42757 AND l_bflow_method_code = 'PRIOR_ENTRY'
42758 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
42759 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
42760 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
42761 )
42762 THEN
42763 xla_ae_lines_pkg.BflowUpgEntry
42764 (p_business_method_code => l_bflow_method_code
42765 ,p_business_class_code => l_bflow_class_code
42766 ,p_balance_type => l_balance_type_code);
42767 ELSE
42768 NULL;
42769 -- No business flow processing for business flow method of NONE.
42770 END IF;
42771
42772 --
42773 -- call analytical criteria
42774 --
42775
42776 --
42777 -- call description
42778 --
42779 -- No description or it is inherited.
42780 --
42781 -- call ADRs
42782 -- Bug 4922099
42783 --
42784 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42785 (NVL(l_actual_upg_option, 'N') = 'O') OR
42786 (NVL(l_enc_upg_option, 'N') = 'O')
42787 )
42788 THEN
42789 NULL;
42790 --
42791 --
42792
42793 l_ccid := AcctDerRule_28(
42794 p_application_id => p_application_id
42795 , p_ae_header_id => l_ae_header_id
42796 , p_source_19 => p_source_19
42797 , x_transaction_coa_id => l_adr_transaction_coa_id
42798 , x_accounting_coa_id => l_adr_accounting_coa_id
42799 , x_value_type_code => l_adr_value_type_code
42800 , p_side => 'NA'
42801 );
42802
42803 xla_ae_lines_pkg.set_ccid(
42804 p_code_combination_id => l_ccid
42805 , p_value_type_code => l_adr_value_type_code
42806 , p_transaction_coa_id => l_adr_transaction_coa_id
42807 , p_accounting_coa_id => l_adr_accounting_coa_id
42808 , p_adr_code => 'TRX_DIST_CCID'
42809 , p_adr_type_code => 'S'
42810 , p_component_type => l_component_type
42811 , p_component_code => l_component_code
42812 , p_component_type_code => l_component_type_code
42813 , p_component_appl_id => l_component_appl_id
42814 , p_amb_context_code => l_amb_context_code
42815 , p_side => 'NA'
42816 );
42817
42818
42819 --
42820 --
42821 END IF;
42822 --
42823 -- Bug 4922099
42824 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
42825 (NVL(l_enc_upg_option, 'N') = 'O')
42826 ) AND
42827 (l_bflow_method_code = 'PRIOR_ENTRY')
42828 )
42829 THEN
42830 IF
42831 --
42832 1 = 2
42833 --
42834 THEN
42835 xla_accounting_err_pkg.build_message
42836 (p_appli_s_name => 'XLA'
42837 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42838 ,p_token_1 => 'LINE_NUMBER'
42839 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
42840 ,p_token_2 => 'LINE_TYPE_NAME'
42841 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
42842 l_component_type
42843 ,l_component_code
42844 ,l_component_type_code
42845 ,l_component_appl_id
42846 ,l_amb_context_code
42847 ,l_entity_code
42848 ,l_event_class_code
42849 )
42850 ,p_token_3 => 'OWNER'
42851 ,p_value_3 => xla_lookups_pkg.get_meaning(
42852 p_lookup_type => 'XLA_OWNER_TYPE'
42853 ,p_lookup_code => l_component_type_code
42854 )
42855 ,p_token_4 => 'PRODUCT_NAME'
42859 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
42856 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
42857 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
42858 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
42860 ,p_ae_header_id => NULL
42861 );
42862
42863 IF (C_LEVEL_ERROR>= g_log_level) THEN
42864 trace
42865 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
42866 ,p_level => C_LEVEL_ERROR
42867 ,p_module => l_log_module);
42868 END IF;
42869 END IF;
42870 END IF;
42871 --
42872 --
42873 ------------------------------------------------------------------------------------------------
42874 -- 4219869 Business Flow
42875 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
42876 -- Prior Entry. Currently, the following code is always generated.
42877 ------------------------------------------------------------------------------------------------
42878 XLA_AE_LINES_PKG.ValidateCurrentLine;
42879
42880 ------------------------------------------------------------------------------------
42881 -- 4219869 Business Flow
42882 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
42883 ------------------------------------------------------------------------------------
42884 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
42885
42886 ----------------------------------------------------------------------------------
42887 -- 4219869 Business Flow
42888 -- Update journal entry status -- Need to generate this within IF <condition>
42889 ----------------------------------------------------------------------------------
42890 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
42891 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
42892 ,p_balance_type_code => l_balance_type_code
42893 );
42894
42895 -------------------------------------------------------------------------------------------
42896 -- 4262811 - Generate the Accrual Reversal lines
42897 -------------------------------------------------------------------------------------------
42898 BEGIN
42899 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
42900 (g_array_event(p_event_id).array_value_num('header_index'));
42901 IF l_acc_rev_flag IS NULL THEN
42902 l_acc_rev_flag := 'N';
42903 END IF;
42904 EXCEPTION
42905 WHEN OTHERS THEN
42906 l_acc_rev_flag := 'N';
42907 END;
42908 --
42909 IF (l_acc_rev_flag = 'Y') THEN
42910
42911 -- 4645092 ------------------------------------------------------------------------------
42912 -- To allow MPA report to determine if it should generate report process
42913 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
42914 ------------------------------------------------------------------------------------------
42915
42916 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
42917 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
42918 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
42919 -- call ADRs
42920 -- Bug 4922099
42921 --
42922 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
42923 (NVL(l_actual_upg_option, 'N') = 'O') OR
42924 (NVL(l_enc_upg_option, 'N') = 'O')
42925 )
42926 THEN
42927 NULL;
42928 --
42929 --
42930
42931 l_ccid := AcctDerRule_28(
42932 p_application_id => p_application_id
42933 , p_ae_header_id => l_ae_header_id
42934 , p_source_19 => p_source_19
42935 , x_transaction_coa_id => l_adr_transaction_coa_id
42936 , x_accounting_coa_id => l_adr_accounting_coa_id
42937 , x_value_type_code => l_adr_value_type_code
42938 , p_side => 'NA'
42939 );
42940
42941 xla_ae_lines_pkg.set_ccid(
42942 p_code_combination_id => l_ccid
42943 , p_value_type_code => l_adr_value_type_code
42944 , p_transaction_coa_id => l_adr_transaction_coa_id
42945 , p_accounting_coa_id => l_adr_accounting_coa_id
42946 , p_adr_code => 'TRX_DIST_CCID'
42947 , p_adr_type_code => 'S'
42948 , p_component_type => l_component_type
42949 , p_component_code => l_component_code
42950 , p_component_type_code => l_component_type_code
42951 , p_component_appl_id => l_component_appl_id
42952 , p_amb_context_code => l_amb_context_code
42953 , p_side => 'NA'
42954 );
42955
42956
42957 --
42958 --
42959 END IF;
42960
42961 --
42962 -- Update the line information that should be overwritten
42963 --
42964 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
42965 p_header_num => 1);
42966 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
42967
42968 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
42969
42970 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
42971 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
42972 END IF;
42973
42974 --
42975 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
42976 --
42977 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
42978 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
42979 ELSE
42980 ---------------------------------------------------------------------------------------------------
42981 -- 4262811a Switch Sign
42982 ---------------------------------------------------------------------------------------------------
42983 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
42984 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42985 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42986 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
42987 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42988 -- 5132302
42989 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
42990 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
42991
42992 END IF;
42993
42994 -- 4955764
42995 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
42996 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
42997
42998
42999 XLA_AE_LINES_PKG.ValidateCurrentLine;
43000 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43001
43002 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43003 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
43004 ,p_balance_type_code => l_balance_type_code);
43005
43006 END IF;
43007
43008 -----------------------------------------------------------------------------------------
43009 -- 4262811 Multiperiod Accounting
43010 -----------------------------------------------------------------------------------------
43011 -- No MPA option is assigned.
43012
43013
43014 END IF;
43015 END IF;
43016 --
43017
43018 --
43019 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43020 trace
43021 (p_msg => 'END of AcctLineType_93'
43022 ,p_level => C_LEVEL_PROCEDURE
43023 ,p_module => l_log_module);
43024 END IF;
43025 --
43026 EXCEPTION
43027 WHEN xla_exceptions_pkg.application_exception THEN
43028 RAISE;
43029 WHEN OTHERS THEN
43030 xla_exceptions_pkg.raise_message
43031 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_93');
43032 END AcctLineType_93;
43033 --
43034
43035 ---------------------------------------
43036 --
43037 -- PRIVATE FUNCTION
43038 -- AcctLineType_94
43039 --
43040 ---------------------------------------
43041 PROCEDURE AcctLineType_94 (
43042 p_application_id IN NUMBER
43043 ,p_event_id IN NUMBER
43044 ,p_calculate_acctd_flag IN VARCHAR2
43045 ,p_calculate_g_l_flag IN VARCHAR2
43046 ,p_actual_flag IN OUT VARCHAR2
43047 ,p_balance_type_code OUT VARCHAR2
43048 ,p_gain_or_loss_ref OUT VARCHAR2
43049
43050 --Transaction Distribution GL Account
43051 , p_source_19 IN NUMBER
43052 --Bill To Customer Account Identifier
43053 , p_source_30 IN NUMBER
43054 --Bill To Customer Site Use Identifier
43055 , p_source_31 IN NUMBER
43056 --SLA Party Type
43057 , p_source_32 IN VARCHAR2
43058 --Transaction Distribution Account Class
43059 , p_source_33 IN VARCHAR2
43060 --Transaction Distribution Identifier
43061 , p_source_34 IN NUMBER
43062 --Transaction Distribution Type
43063 , p_source_35 IN VARCHAR2
43064 --Transaction Distribution Entered Amount
43065 , p_source_36 IN NUMBER
43066 --Transaction Currency Code
43067 , p_source_37 IN VARCHAR2
43068 --Transaction Exchange Date
43069 , p_source_38 IN DATE
43070 --Transaction Exchange Rate
43071 , p_source_39 IN NUMBER
43072 --Transaction Exchange Rate Type
43073 , p_source_40 IN VARCHAR2
43074 --Transaction Accounting Amount
43075 , p_source_41 IN NUMBER
43076 --Transaction Tax Line Identifier
43077 , p_source_55 IN NUMBER
43078 --Rounding Correction Flag
43079 , p_source_66 IN VARCHAR2
43080 )
43081 IS
43082
43083 l_component_type VARCHAR2(80);
43084 l_component_code VARCHAR2(30);
43088 l_entity_code VARCHAR2(30);
43085 l_component_type_code VARCHAR2(1);
43086 l_component_appl_id INTEGER;
43087 l_amb_context_code VARCHAR2(30);
43089 l_event_class_code VARCHAR2(30);
43090 l_ae_header_id NUMBER;
43091 l_event_type_code VARCHAR2(30);
43092 l_line_definition_code VARCHAR2(30);
43093 l_line_definition_owner_code VARCHAR2(1);
43094 --
43095 -- adr variables
43096 l_segment VARCHAR2(30);
43097 l_ccid NUMBER;
43098 l_adr_transaction_coa_id NUMBER;
43099 l_adr_accounting_coa_id NUMBER;
43100 l_adr_flexfield_segment_code VARCHAR2(30);
43101 l_adr_flex_value_set_id NUMBER;
43102 l_adr_value_type_code VARCHAR2(30);
43103 l_adr_value_combination_id NUMBER;
43104 l_adr_value_segment_code VARCHAR2(30);
43105
43106 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
43107 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
43108 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
43109 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
43110
43111 -- 4262811 Variables ------------------------------------------------------------------------------------------
43112 l_entered_amt_idx NUMBER;
43113 l_accted_amt_idx NUMBER;
43114 l_acc_rev_flag VARCHAR2(1);
43115 l_accrual_line_num NUMBER;
43116 l_tmp_amt NUMBER;
43117 l_acc_rev_natural_side_code VARCHAR2(1);
43118
43119 l_num_entries NUMBER;
43120 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
43121 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
43122 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
43123 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
43124 l_recog_line_1 NUMBER;
43125 l_recog_line_2 NUMBER;
43126
43127 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
43128 l_bflow_applied_to_amt NUMBER; -- 5132302
43129 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
43130
43131 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
43132
43133 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
43134 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
43135
43136 ---------------------------------------------------------------------------------------------------------------
43137
43138
43139 --
43140 -- bulk performance
43141 --
43142 l_balance_type_code VARCHAR2(1);
43143 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
43144 l_log_module VARCHAR2(240);
43145
43146 --
43147 -- Upgrade strategy
43148 --
43149 l_actual_upg_option VARCHAR2(1);
43150 l_enc_upg_option VARCHAR2(1);
43151
43152 --
43153 BEGIN
43154 --
43155 IF g_log_enabled THEN
43156 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_94';
43157 END IF;
43158 --
43159 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43160
43161 trace
43162 (p_msg => 'BEGIN of AcctLineType_94'
43163 ,p_level => C_LEVEL_PROCEDURE
43164 ,p_module => l_log_module);
43165
43166 END IF;
43167 --
43168 l_component_type := 'AMB_JLT';
43169 l_component_code := 'INV_UNEARN';
43170 l_component_type_code := 'S';
43171 l_component_appl_id := 222;
43172 l_amb_context_code := 'DEFAULT';
43173 l_entity_code := 'TRANSACTIONS';
43174 l_event_class_code := 'INVOICE';
43175 l_event_type_code := 'INVOICE_ALL';
43176 l_line_definition_owner_code := 'S';
43177 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
43178 --
43179 l_balance_type_code := 'A';
43180 l_segment := NULL;
43181 l_ccid := NULL;
43182 l_adr_transaction_coa_id := NULL;
43183 l_adr_accounting_coa_id := NULL;
43184 l_adr_flexfield_segment_code := NULL;
43185 l_adr_flex_value_set_id := NULL;
43186 l_adr_value_type_code := NULL;
43187 l_adr_value_combination_id := NULL;
43188 l_adr_value_segment_code := NULL;
43189
43190 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
43191 l_bflow_class_code := ''; -- 4219869 Business Flow
43192 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
43196 l_bflow_applied_to_amt := NULL; -- 5132302
43193 l_budgetary_control_flag := 'N';
43194
43195 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43197 l_entered_amt_idx := NULL; -- 4262811
43198 l_accted_amt_idx := NULL; -- 4262811
43199 l_acc_rev_flag := NULL; -- 4262811
43200 l_accrual_line_num := NULL; -- 4262811
43201 l_tmp_amt := NULL; -- 4262811
43202 --
43203
43204 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
43205 l_balance_type_code <> 'B' THEN
43206 IF NVL(p_source_33,'
43207 ') = 'UNEARN' AND
43208 p_source_66 IS NULL
43209 THEN
43210
43211 --
43212 XLA_AE_LINES_PKG.SetNewLine;
43213
43214 p_balance_type_code := l_balance_type_code;
43215 -- set the flag so later we will know whether the gain loss line needs to be created
43216
43217 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
43218 p_actual_flag :='A';
43219 END IF;
43220
43221 --
43222 -- bulk performance
43223 --
43224 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
43225 p_header_num => 0); -- 4262811
43226 --
43227 -- set accounting line options
43228 --
43229 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
43230 p_natural_side_code => 'C'
43231 , p_gain_or_loss_flag => 'N'
43232 , p_gl_transfer_mode_code => 'S'
43233 , p_acct_entry_type_code => 'A'
43234 , p_switch_side_flag => 'Y'
43235 , p_merge_duplicate_code => 'A'
43236 );
43237 --
43238 l_acc_rev_natural_side_code := 'D'; -- 4262811
43239 --
43240 --
43241 -- set accounting line type info
43242 --
43243 xla_ae_lines_pkg.SetAcctLineType
43244 (p_component_type => l_component_type
43245 ,p_event_type_code => l_event_type_code
43246 ,p_line_definition_owner_code => l_line_definition_owner_code
43247 ,p_line_definition_code => l_line_definition_code
43248 ,p_accounting_line_code => l_component_code
43249 ,p_accounting_line_type_code => l_component_type_code
43250 ,p_accounting_line_appl_id => l_component_appl_id
43251 ,p_amb_context_code => l_amb_context_code
43252 ,p_entity_code => l_entity_code
43253 ,p_event_class_code => l_event_class_code);
43254 --
43255 -- set accounting class
43256 --
43257 xla_ae_lines_pkg.SetAcctClass(
43258 p_accounting_class_code => 'UNEARNED_REVENUE'
43259 , p_ae_header_id => l_ae_header_id
43260 );
43261
43262 --
43263 -- set rounding class
43264 --
43265 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
43266 'RECEIVABLE';
43267
43268 --
43269 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
43270 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
43271 --
43272 -- bulk performance
43273 --
43274 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
43275
43276 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
43277 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
43278
43279 -- 4955764
43280 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43281 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
43282
43283 -- 4458381 Public Sector Enh
43284
43285 --
43286 -- set accounting attributes for the line type
43287 --
43288 l_entered_amt_idx := 3;
43289 l_accted_amt_idx := 8;
43290 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43291 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
43292 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
43293 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
43294 l_rec_acct_attrs.array_char_value(2) := p_source_35;
43295 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
43296 l_rec_acct_attrs.array_num_value(3) := p_source_36;
43297 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
43298 l_rec_acct_attrs.array_char_value(4) := p_source_37;
43299 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
43303 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
43300 l_rec_acct_attrs.array_date_value(5) := p_source_38;
43301 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
43302 l_rec_acct_attrs.array_num_value(6) := p_source_39;
43304 l_rec_acct_attrs.array_char_value(7) := p_source_40;
43305 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
43306 l_rec_acct_attrs.array_num_value(8) := p_source_41;
43307 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
43308 l_rec_acct_attrs.array_num_value(9) := p_source_30;
43309 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
43310 l_rec_acct_attrs.array_num_value(10) := p_source_31;
43311 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
43312 l_rec_acct_attrs.array_char_value(11) := p_source_32;
43313 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
43314 l_rec_acct_attrs.array_num_value(12) := p_source_55;
43315
43316 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
43317 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
43318
43319 ---------------------------------------------------------------------------------------------------------------
43320 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
43321 ---------------------------------------------------------------------------------------------------------------
43322 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
43323
43324 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43325 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43326
43327 IF xla_accounting_cache_pkg.GetValueChar
43328 (p_source_code => 'LEDGER_CATEGORY_CODE'
43329 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
43330 AND l_bflow_method_code = 'PRIOR_ENTRY'
43331 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
43332 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
43333 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
43334 )
43335 THEN
43336 xla_ae_lines_pkg.BflowUpgEntry
43337 (p_business_method_code => l_bflow_method_code
43338 ,p_business_class_code => l_bflow_class_code
43339 ,p_balance_type => l_balance_type_code);
43340 ELSE
43341 NULL;
43342 -- No business flow processing for business flow method of NONE.
43343 END IF;
43344
43345 --
43346 -- call analytical criteria
43347 --
43348
43349 --
43350 -- call description
43351 --
43352 -- No description or it is inherited.
43353 --
43354 -- call ADRs
43355 -- Bug 4922099
43356 --
43357 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43358 (NVL(l_actual_upg_option, 'N') = 'O') OR
43359 (NVL(l_enc_upg_option, 'N') = 'O')
43360 )
43361 THEN
43362 NULL;
43363 --
43364 --
43365
43366 l_ccid := AcctDerRule_28(
43367 p_application_id => p_application_id
43368 , p_ae_header_id => l_ae_header_id
43369 , p_source_19 => p_source_19
43370 , x_transaction_coa_id => l_adr_transaction_coa_id
43371 , x_accounting_coa_id => l_adr_accounting_coa_id
43372 , x_value_type_code => l_adr_value_type_code
43373 , p_side => 'NA'
43374 );
43375
43376 xla_ae_lines_pkg.set_ccid(
43377 p_code_combination_id => l_ccid
43378 , p_value_type_code => l_adr_value_type_code
43379 , p_transaction_coa_id => l_adr_transaction_coa_id
43380 , p_accounting_coa_id => l_adr_accounting_coa_id
43381 , p_adr_code => 'TRX_DIST_CCID'
43382 , p_adr_type_code => 'S'
43383 , p_component_type => l_component_type
43384 , p_component_code => l_component_code
43385 , p_component_type_code => l_component_type_code
43386 , p_component_appl_id => l_component_appl_id
43387 , p_amb_context_code => l_amb_context_code
43388 , p_side => 'NA'
43389 );
43390
43391
43392 --
43393 --
43394 END IF;
43395 --
43396 -- Bug 4922099
43397 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
43398 (NVL(l_enc_upg_option, 'N') = 'O')
43399 ) AND
43400 (l_bflow_method_code = 'PRIOR_ENTRY')
43401 )
43402 THEN
43403 IF
43404 --
43405 1 = 2
43406 --
43407 THEN
43408 xla_accounting_err_pkg.build_message
43409 (p_appli_s_name => 'XLA'
43410 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43411 ,p_token_1 => 'LINE_NUMBER'
43412 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
43413 ,p_token_2 => 'LINE_TYPE_NAME'
43414 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
43415 l_component_type
43416 ,l_component_code
43417 ,l_component_type_code
43418 ,l_component_appl_id
43419 ,l_amb_context_code
43420 ,l_entity_code
43421 ,l_event_class_code
43422 )
43423 ,p_token_3 => 'OWNER'
43424 ,p_value_3 => xla_lookups_pkg.get_meaning(
43425 p_lookup_type => 'XLA_OWNER_TYPE'
43426 ,p_lookup_code => l_component_type_code
43427 )
43428 ,p_token_4 => 'PRODUCT_NAME'
43429 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
43430 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
43431 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
43432 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
43433 ,p_ae_header_id => NULL
43434 );
43435
43436 IF (C_LEVEL_ERROR>= g_log_level) THEN
43437 trace
43438 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43439 ,p_level => C_LEVEL_ERROR
43440 ,p_module => l_log_module);
43441 END IF;
43442 END IF;
43443 END IF;
43444 --
43445 --
43446 ------------------------------------------------------------------------------------------------
43447 -- 4219869 Business Flow
43448 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
43449 -- Prior Entry. Currently, the following code is always generated.
43450 ------------------------------------------------------------------------------------------------
43451 XLA_AE_LINES_PKG.ValidateCurrentLine;
43452
43453 ------------------------------------------------------------------------------------
43454 -- 4219869 Business Flow
43455 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
43456 ------------------------------------------------------------------------------------
43457 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43458
43459 ----------------------------------------------------------------------------------
43460 -- 4219869 Business Flow
43461 -- Update journal entry status -- Need to generate this within IF <condition>
43462 ----------------------------------------------------------------------------------
43463 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43464 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
43465 ,p_balance_type_code => l_balance_type_code
43466 );
43467
43468 -------------------------------------------------------------------------------------------
43469 -- 4262811 - Generate the Accrual Reversal lines
43470 -------------------------------------------------------------------------------------------
43471 BEGIN
43472 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
43473 (g_array_event(p_event_id).array_value_num('header_index'));
43474 IF l_acc_rev_flag IS NULL THEN
43475 l_acc_rev_flag := 'N';
43476 END IF;
43477 EXCEPTION
43478 WHEN OTHERS THEN
43479 l_acc_rev_flag := 'N';
43480 END;
43481 --
43482 IF (l_acc_rev_flag = 'Y') THEN
43483
43484 -- 4645092 ------------------------------------------------------------------------------
43485 -- To allow MPA report to determine if it should generate report process
43486 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
43487 ------------------------------------------------------------------------------------------
43488
43489 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
43490 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
43491 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
43492 -- call ADRs
43493 -- Bug 4922099
43494 --
43495 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43496 (NVL(l_actual_upg_option, 'N') = 'O') OR
43497 (NVL(l_enc_upg_option, 'N') = 'O')
43498 )
43499 THEN
43500 NULL;
43501 --
43502 --
43503
43504 l_ccid := AcctDerRule_28(
43505 p_application_id => p_application_id
43506 , p_ae_header_id => l_ae_header_id
43507 , p_source_19 => p_source_19
43508 , x_transaction_coa_id => l_adr_transaction_coa_id
43509 , x_accounting_coa_id => l_adr_accounting_coa_id
43510 , x_value_type_code => l_adr_value_type_code
43511 , p_side => 'NA'
43512 );
43513
43514 xla_ae_lines_pkg.set_ccid(
43515 p_code_combination_id => l_ccid
43516 , p_value_type_code => l_adr_value_type_code
43517 , p_transaction_coa_id => l_adr_transaction_coa_id
43518 , p_accounting_coa_id => l_adr_accounting_coa_id
43519 , p_adr_code => 'TRX_DIST_CCID'
43520 , p_adr_type_code => 'S'
43521 , p_component_type => l_component_type
43522 , p_component_code => l_component_code
43523 , p_component_type_code => l_component_type_code
43524 , p_component_appl_id => l_component_appl_id
43525 , p_amb_context_code => l_amb_context_code
43526 , p_side => 'NA'
43527 );
43528
43529
43530 --
43531 --
43532 END IF;
43533
43534 --
43535 -- Update the line information that should be overwritten
43536 --
43537 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
43538 p_header_num => 1);
43539 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
43540
43541 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
43542
43543 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
43544 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
43545 END IF;
43546
43547 --
43548 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
43549 --
43550 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
43551 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
43552 ELSE
43553 ---------------------------------------------------------------------------------------------------
43554 -- 4262811a Switch Sign
43555 ---------------------------------------------------------------------------------------------------
43556 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
43557 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43558 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43559 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
43560 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43561 -- 5132302
43562 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
43563 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
43564
43565 END IF;
43566
43567 -- 4955764
43568 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43569 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
43570
43571
43572 XLA_AE_LINES_PKG.ValidateCurrentLine;
43573 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
43574
43575 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
43576 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
43577 ,p_balance_type_code => l_balance_type_code);
43578
43579 END IF;
43580
43581 -----------------------------------------------------------------------------------------
43582 -- 4262811 Multiperiod Accounting
43583 -----------------------------------------------------------------------------------------
43584 -- No MPA option is assigned.
43585
43586
43587 END IF;
43588 END IF;
43589 --
43590
43591 --
43592 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43593 trace
43594 (p_msg => 'END of AcctLineType_94'
43595 ,p_level => C_LEVEL_PROCEDURE
43596 ,p_module => l_log_module);
43597 END IF;
43598 --
43599 EXCEPTION
43600 WHEN xla_exceptions_pkg.application_exception THEN
43601 RAISE;
43602 WHEN OTHERS THEN
43603 xla_exceptions_pkg.raise_message
43604 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_94');
43605 END AcctLineType_94;
43606 --
43607
43608 ---------------------------------------
43609 --
43610 -- PRIVATE FUNCTION
43611 -- AcctLineType_95
43612 --
43613 ---------------------------------------
43614 PROCEDURE AcctLineType_95 (
43615 p_application_id IN NUMBER
43616 ,p_event_id IN NUMBER
43617 ,p_calculate_acctd_flag IN VARCHAR2
43618 ,p_calculate_g_l_flag IN VARCHAR2
43619 ,p_actual_flag IN OUT VARCHAR2
43620 ,p_balance_type_code OUT VARCHAR2
43621 ,p_gain_or_loss_ref OUT VARCHAR2
43622
43623 --Transaction Distribution GL Account
43624 , p_source_19 IN NUMBER
43625 --Bill To Customer Account Identifier
43626 , p_source_30 IN NUMBER
43627 --Bill To Customer Site Use Identifier
43628 , p_source_31 IN NUMBER
43629 --SLA Party Type
43630 , p_source_32 IN VARCHAR2
43631 --Transaction Distribution Account Class
43632 , p_source_33 IN VARCHAR2
43633 --Transaction Distribution Identifier
43634 , p_source_34 IN NUMBER
43635 --Transaction Distribution Type
43636 , p_source_35 IN VARCHAR2
43637 --Transaction Distribution Entered Amount
43638 , p_source_36 IN NUMBER
43639 --Transaction Currency Code
43640 , p_source_37 IN VARCHAR2
43641 --Transaction Exchange Date
43642 , p_source_38 IN DATE
43643 --Transaction Exchange Rate
43644 , p_source_39 IN NUMBER
43645 --Transaction Exchange Rate Type
43646 , p_source_40 IN VARCHAR2
43647 --Transaction Accounting Amount
43648 , p_source_41 IN NUMBER
43649 --Transaction Tax Line Identifier
43650 , p_source_55 IN NUMBER
43651 --Rounding Correction Flag
43652 , p_source_66 IN VARCHAR2
43653 )
43654 IS
43655
43656 l_component_type VARCHAR2(80);
43657 l_component_code VARCHAR2(30);
43658 l_component_type_code VARCHAR2(1);
43659 l_component_appl_id INTEGER;
43660 l_amb_context_code VARCHAR2(30);
43661 l_entity_code VARCHAR2(30);
43662 l_event_class_code VARCHAR2(30);
43663 l_ae_header_id NUMBER;
43664 l_event_type_code VARCHAR2(30);
43665 l_line_definition_code VARCHAR2(30);
43666 l_line_definition_owner_code VARCHAR2(1);
43667 --
43668 -- adr variables
43669 l_segment VARCHAR2(30);
43670 l_ccid NUMBER;
43671 l_adr_transaction_coa_id NUMBER;
43672 l_adr_accounting_coa_id NUMBER;
43673 l_adr_flexfield_segment_code VARCHAR2(30);
43674 l_adr_flex_value_set_id NUMBER;
43675 l_adr_value_type_code VARCHAR2(30);
43676 l_adr_value_combination_id NUMBER;
43680 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
43677 l_adr_value_segment_code VARCHAR2(30);
43678
43679 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
43681 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
43682 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
43683
43684 -- 4262811 Variables ------------------------------------------------------------------------------------------
43685 l_entered_amt_idx NUMBER;
43686 l_accted_amt_idx NUMBER;
43687 l_acc_rev_flag VARCHAR2(1);
43688 l_accrual_line_num NUMBER;
43689 l_tmp_amt NUMBER;
43690 l_acc_rev_natural_side_code VARCHAR2(1);
43691
43692 l_num_entries NUMBER;
43693 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
43694 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
43695 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
43696 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
43697 l_recog_line_1 NUMBER;
43698 l_recog_line_2 NUMBER;
43699
43700 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
43701 l_bflow_applied_to_amt NUMBER; -- 5132302
43702 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
43703
43704 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
43705
43706 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
43707 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
43708
43709 ---------------------------------------------------------------------------------------------------------------
43710
43711
43712 --
43713 -- bulk performance
43714 --
43715 l_balance_type_code VARCHAR2(1);
43716 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
43717 l_log_module VARCHAR2(240);
43718
43719 --
43720 -- Upgrade strategy
43721 --
43722 l_actual_upg_option VARCHAR2(1);
43723 l_enc_upg_option VARCHAR2(1);
43724
43725 --
43726 BEGIN
43727 --
43728 IF g_log_enabled THEN
43729 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_95';
43730 END IF;
43731 --
43732 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
43733
43734 trace
43735 (p_msg => 'BEGIN of AcctLineType_95'
43736 ,p_level => C_LEVEL_PROCEDURE
43737 ,p_module => l_log_module);
43738
43739 END IF;
43740 --
43741 l_component_type := 'AMB_JLT';
43742 l_component_code := 'INV_UNEARN_ROUND';
43743 l_component_type_code := 'S';
43744 l_component_appl_id := 222;
43745 l_amb_context_code := 'DEFAULT';
43746 l_entity_code := 'TRANSACTIONS';
43747 l_event_class_code := 'INVOICE';
43748 l_event_type_code := 'INVOICE_ALL';
43749 l_line_definition_owner_code := 'S';
43750 l_line_definition_code := 'AR_INV_DEFAULT_ACCRUAL';
43751 --
43752 l_balance_type_code := 'A';
43753 l_segment := NULL;
43754 l_ccid := NULL;
43755 l_adr_transaction_coa_id := NULL;
43756 l_adr_accounting_coa_id := NULL;
43757 l_adr_flexfield_segment_code := NULL;
43758 l_adr_flex_value_set_id := NULL;
43759 l_adr_value_type_code := NULL;
43760 l_adr_value_combination_id := NULL;
43761 l_adr_value_segment_code := NULL;
43762
43763 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
43764 l_bflow_class_code := ''; -- 4219869 Business Flow
43765 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
43766 l_budgetary_control_flag := 'N';
43767
43768 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43769 l_bflow_applied_to_amt := NULL; -- 5132302
43770 l_entered_amt_idx := NULL; -- 4262811
43771 l_accted_amt_idx := NULL; -- 4262811
43772 l_acc_rev_flag := NULL; -- 4262811
43773 l_accrual_line_num := NULL; -- 4262811
43774 l_tmp_amt := NULL; -- 4262811
43775 --
43776
43777 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
43778 l_balance_type_code <> 'B' THEN
43779 IF NVL(p_source_33,'
43780 ') = 'UNEARN' AND
43781 NVL(p_source_66,'
43782 ') = 'Y'
43783 THEN
43784
43785 --
43786 XLA_AE_LINES_PKG.SetNewLine;
43787
43788 p_balance_type_code := l_balance_type_code;
43789 -- set the flag so later we will know whether the gain loss line needs to be created
43790
43791 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
43792 p_actual_flag :='A';
43793 END IF;
43794
43795 --
43796 -- bulk performance
43797 --
43798 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
43799 p_header_num => 0); -- 4262811
43800 --
43801 -- set accounting line options
43802 --
43803 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
43804 p_natural_side_code => 'C'
43805 , p_gain_or_loss_flag => 'N'
43806 , p_gl_transfer_mode_code => 'S'
43807 , p_acct_entry_type_code => 'A'
43808 , p_switch_side_flag => 'Y'
43809 , p_merge_duplicate_code => 'N'
43810 );
43811 --
43812 l_acc_rev_natural_side_code := 'D'; -- 4262811
43813 --
43814 --
43815 -- set accounting line type info
43816 --
43817 xla_ae_lines_pkg.SetAcctLineType
43818 (p_component_type => l_component_type
43819 ,p_event_type_code => l_event_type_code
43820 ,p_line_definition_owner_code => l_line_definition_owner_code
43821 ,p_line_definition_code => l_line_definition_code
43822 ,p_accounting_line_code => l_component_code
43823 ,p_accounting_line_type_code => l_component_type_code
43824 ,p_accounting_line_appl_id => l_component_appl_id
43825 ,p_amb_context_code => l_amb_context_code
43826 ,p_entity_code => l_entity_code
43827 ,p_event_class_code => l_event_class_code);
43828 --
43829 -- set accounting class
43830 --
43831 xla_ae_lines_pkg.SetAcctClass(
43832 p_accounting_class_code => 'UNEARNED_REVENUE'
43833 , p_ae_header_id => l_ae_header_id
43834 );
43835
43836 --
43837 -- set rounding class
43838 --
43839 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
43840 'RECEIVABLE';
43841
43842 --
43843 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
43844 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
43845 --
43846 -- bulk performance
43847 --
43848 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
43849
43850 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
43851 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
43852
43853 -- 4955764
43854 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
43855 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
43856
43857 -- 4458381 Public Sector Enh
43858
43859 --
43860 -- set accounting attributes for the line type
43861 --
43862 l_entered_amt_idx := 3;
43863 l_accted_amt_idx := 8;
43864 l_bflow_applied_to_amt_idx := NULL; -- 5132302
43865 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
43866 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_34);
43867 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
43868 l_rec_acct_attrs.array_char_value(2) := p_source_35;
43869 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
43870 l_rec_acct_attrs.array_num_value(3) := p_source_36;
43871 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
43872 l_rec_acct_attrs.array_char_value(4) := p_source_37;
43876 l_rec_acct_attrs.array_num_value(6) := p_source_39;
43873 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
43874 l_rec_acct_attrs.array_date_value(5) := p_source_38;
43875 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
43877 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
43878 l_rec_acct_attrs.array_char_value(7) := p_source_40;
43879 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
43880 l_rec_acct_attrs.array_num_value(8) := p_source_41;
43881 l_rec_acct_attrs.array_acct_attr_code(9) := 'PARTY_ID';
43882 l_rec_acct_attrs.array_num_value(9) := p_source_30;
43883 l_rec_acct_attrs.array_acct_attr_code(10) := 'PARTY_SITE_ID';
43884 l_rec_acct_attrs.array_num_value(10) := p_source_31;
43885 l_rec_acct_attrs.array_acct_attr_code(11) := 'PARTY_TYPE';
43886 l_rec_acct_attrs.array_char_value(11) := p_source_32;
43887 l_rec_acct_attrs.array_acct_attr_code(12) := 'TAX_LINE_REF_ID';
43888 l_rec_acct_attrs.array_num_value(12) := p_source_55;
43889
43890 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
43891 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
43892
43893 ---------------------------------------------------------------------------------------------------------------
43894 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
43895 ---------------------------------------------------------------------------------------------------------------
43896 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
43897
43898 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43899 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
43900
43901 IF xla_accounting_cache_pkg.GetValueChar
43902 (p_source_code => 'LEDGER_CATEGORY_CODE'
43903 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
43904 AND l_bflow_method_code = 'PRIOR_ENTRY'
43905 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
43906 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
43907 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
43908 )
43909 THEN
43910 xla_ae_lines_pkg.BflowUpgEntry
43911 (p_business_method_code => l_bflow_method_code
43912 ,p_business_class_code => l_bflow_class_code
43913 ,p_balance_type => l_balance_type_code);
43914 ELSE
43915 NULL;
43916 -- No business flow processing for business flow method of NONE.
43917 END IF;
43918
43919 --
43920 -- call analytical criteria
43921 --
43922
43923 --
43924 -- call description
43925 --
43926 -- No description or it is inherited.
43927 --
43928 -- call ADRs
43929 -- Bug 4922099
43930 --
43931 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
43932 (NVL(l_actual_upg_option, 'N') = 'O') OR
43933 (NVL(l_enc_upg_option, 'N') = 'O')
43934 )
43935 THEN
43936 NULL;
43937 --
43938 --
43939
43940 l_ccid := AcctDerRule_28(
43941 p_application_id => p_application_id
43942 , p_ae_header_id => l_ae_header_id
43943 , p_source_19 => p_source_19
43944 , x_transaction_coa_id => l_adr_transaction_coa_id
43945 , x_accounting_coa_id => l_adr_accounting_coa_id
43946 , x_value_type_code => l_adr_value_type_code
43947 , p_side => 'NA'
43948 );
43949
43950 xla_ae_lines_pkg.set_ccid(
43951 p_code_combination_id => l_ccid
43952 , p_value_type_code => l_adr_value_type_code
43953 , p_transaction_coa_id => l_adr_transaction_coa_id
43954 , p_accounting_coa_id => l_adr_accounting_coa_id
43955 , p_adr_code => 'TRX_DIST_CCID'
43956 , p_adr_type_code => 'S'
43957 , p_component_type => l_component_type
43958 , p_component_code => l_component_code
43959 , p_component_type_code => l_component_type_code
43960 , p_component_appl_id => l_component_appl_id
43961 , p_amb_context_code => l_amb_context_code
43962 , p_side => 'NA'
43963 );
43964
43965
43966 --
43967 --
43968 END IF;
43969 --
43970 -- Bug 4922099
43971 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
43972 (NVL(l_enc_upg_option, 'N') = 'O')
43973 ) AND
43974 (l_bflow_method_code = 'PRIOR_ENTRY')
43975 )
43976 THEN
43977 IF
43978 --
43979 1 = 2
43980 --
43981 THEN
43982 xla_accounting_err_pkg.build_message
43983 (p_appli_s_name => 'XLA'
43984 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
43985 ,p_token_1 => 'LINE_NUMBER'
43986 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
43987 ,p_token_2 => 'LINE_TYPE_NAME'
43988 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
43989 l_component_type
43990 ,l_component_code
43991 ,l_component_type_code
43992 ,l_component_appl_id
43993 ,l_amb_context_code
43994 ,l_entity_code
43995 ,l_event_class_code
43996 )
43997 ,p_token_3 => 'OWNER'
43998 ,p_value_3 => xla_lookups_pkg.get_meaning(
43999 p_lookup_type => 'XLA_OWNER_TYPE'
44000 ,p_lookup_code => l_component_type_code
44001 )
44002 ,p_token_4 => 'PRODUCT_NAME'
44006 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
44003 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
44004 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
44005 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
44007 ,p_ae_header_id => NULL
44008 );
44009
44010 IF (C_LEVEL_ERROR>= g_log_level) THEN
44011 trace
44012 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44013 ,p_level => C_LEVEL_ERROR
44014 ,p_module => l_log_module);
44015 END IF;
44016 END IF;
44017 END IF;
44018 --
44019 --
44020 ------------------------------------------------------------------------------------------------
44021 -- 4219869 Business Flow
44022 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
44023 -- Prior Entry. Currently, the following code is always generated.
44024 ------------------------------------------------------------------------------------------------
44025 XLA_AE_LINES_PKG.ValidateCurrentLine;
44026
44027 ------------------------------------------------------------------------------------
44028 -- 4219869 Business Flow
44029 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
44030 ------------------------------------------------------------------------------------
44031 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44032
44033 ----------------------------------------------------------------------------------
44034 -- 4219869 Business Flow
44035 -- Update journal entry status -- Need to generate this within IF <condition>
44036 ----------------------------------------------------------------------------------
44037 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44038 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
44039 ,p_balance_type_code => l_balance_type_code
44040 );
44041
44042 -------------------------------------------------------------------------------------------
44043 -- 4262811 - Generate the Accrual Reversal lines
44044 -------------------------------------------------------------------------------------------
44045 BEGIN
44046 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
44047 (g_array_event(p_event_id).array_value_num('header_index'));
44048 IF l_acc_rev_flag IS NULL THEN
44049 l_acc_rev_flag := 'N';
44050 END IF;
44051 EXCEPTION
44052 WHEN OTHERS THEN
44053 l_acc_rev_flag := 'N';
44054 END;
44055 --
44056 IF (l_acc_rev_flag = 'Y') THEN
44057
44058 -- 4645092 ------------------------------------------------------------------------------
44059 -- To allow MPA report to determine if it should generate report process
44060 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
44061 ------------------------------------------------------------------------------------------
44062
44063 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
44064 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
44065 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
44066 -- call ADRs
44067 -- Bug 4922099
44068 --
44069 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44070 (NVL(l_actual_upg_option, 'N') = 'O') OR
44071 (NVL(l_enc_upg_option, 'N') = 'O')
44072 )
44073 THEN
44074 NULL;
44075 --
44076 --
44077
44078 l_ccid := AcctDerRule_28(
44079 p_application_id => p_application_id
44080 , p_ae_header_id => l_ae_header_id
44081 , p_source_19 => p_source_19
44082 , x_transaction_coa_id => l_adr_transaction_coa_id
44083 , x_accounting_coa_id => l_adr_accounting_coa_id
44084 , x_value_type_code => l_adr_value_type_code
44085 , p_side => 'NA'
44086 );
44087
44088 xla_ae_lines_pkg.set_ccid(
44089 p_code_combination_id => l_ccid
44090 , p_value_type_code => l_adr_value_type_code
44091 , p_transaction_coa_id => l_adr_transaction_coa_id
44092 , p_accounting_coa_id => l_adr_accounting_coa_id
44093 , p_adr_code => 'TRX_DIST_CCID'
44094 , p_adr_type_code => 'S'
44095 , p_component_type => l_component_type
44096 , p_component_code => l_component_code
44097 , p_component_type_code => l_component_type_code
44098 , p_component_appl_id => l_component_appl_id
44099 , p_amb_context_code => l_amb_context_code
44100 , p_side => 'NA'
44101 );
44102
44103
44104 --
44108 --
44105 --
44106 END IF;
44107
44109 -- Update the line information that should be overwritten
44110 --
44111 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
44112 p_header_num => 1);
44113 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
44114
44115 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
44116
44117 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
44118 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
44119 END IF;
44120
44121 --
44122 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
44123 --
44124 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
44125 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
44126 ELSE
44127 ---------------------------------------------------------------------------------------------------
44128 -- 4262811a Switch Sign
44129 ---------------------------------------------------------------------------------------------------
44130 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
44131 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44132 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44133 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44134 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44135 -- 5132302
44136 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
44137 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44138
44139 END IF;
44140
44141 -- 4955764
44142 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44143 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
44144
44145
44146 XLA_AE_LINES_PKG.ValidateCurrentLine;
44147 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44148
44149 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44150 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
44151 ,p_balance_type_code => l_balance_type_code);
44152
44153 END IF;
44154
44155 -----------------------------------------------------------------------------------------
44156 -- 4262811 Multiperiod Accounting
44157 -----------------------------------------------------------------------------------------
44158 -- No MPA option is assigned.
44159
44160
44161 END IF;
44162 END IF;
44163 --
44164
44165 --
44166 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44167 trace
44168 (p_msg => 'END of AcctLineType_95'
44169 ,p_level => C_LEVEL_PROCEDURE
44170 ,p_module => l_log_module);
44171 END IF;
44172 --
44173 EXCEPTION
44174 WHEN xla_exceptions_pkg.application_exception THEN
44175 RAISE;
44176 WHEN OTHERS THEN
44177 xla_exceptions_pkg.raise_message
44178 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_95');
44179 END AcctLineType_95;
44180 --
44181
44182 ---------------------------------------
44183 --
44184 -- PRIVATE FUNCTION
44185 -- AcctLineType_96
44186 --
44187 ---------------------------------------
44188 PROCEDURE AcctLineType_96 (
44189 p_application_id IN NUMBER
44190 ,p_event_id IN NUMBER
44191 ,p_calculate_acctd_flag IN VARCHAR2
44192 ,p_calculate_g_l_flag IN VARCHAR2
44193 ,p_actual_flag IN OUT VARCHAR2
44194 ,p_balance_type_code OUT VARCHAR2
44195 ,p_gain_or_loss_ref OUT VARCHAR2
44196
44197 --Distribution GL Account
44198 , p_source_5 IN NUMBER
44199 --Distribution Source Type
44200 , p_source_20 IN VARCHAR2
44201 --Distribution Line Identifier
44202 , p_source_22 IN NUMBER
44203 --Distribution Type
44204 , p_source_23 IN VARCHAR2
44205 --Entered Amount
44206 , p_source_24 IN NUMBER
44207 --Currency Code
44208 , p_source_25 IN VARCHAR2
44209 --Exchange Rate
44210 , p_source_27 IN NUMBER
44211 --Exchange Rate Type
44212 , p_source_28 IN VARCHAR2
44213 --Applied To Document Accounting Amount
44214 , p_source_29 IN NUMBER
44215 --Applied To Document Exchange Date
44216 , p_source_57 IN DATE
44217 --Distribution Multi Fund Additional Entry
44218 , p_source_67 IN VARCHAR2
44219 )
44220 IS
44221
44222 l_component_type VARCHAR2(80);
44223 l_component_code VARCHAR2(30);
44224 l_component_type_code VARCHAR2(1);
44225 l_component_appl_id INTEGER;
44226 l_amb_context_code VARCHAR2(30);
44227 l_entity_code VARCHAR2(30);
44228 l_event_class_code VARCHAR2(30);
44229 l_ae_header_id NUMBER;
44230 l_event_type_code VARCHAR2(30);
44231 l_line_definition_code VARCHAR2(30);
44232 l_line_definition_owner_code VARCHAR2(1);
44233 --
44234 -- adr variables
44235 l_segment VARCHAR2(30);
44236 l_ccid NUMBER;
44237 l_adr_transaction_coa_id NUMBER;
44238 l_adr_accounting_coa_id NUMBER;
44239 l_adr_flexfield_segment_code VARCHAR2(30);
44240 l_adr_flex_value_set_id NUMBER;
44241 l_adr_value_type_code VARCHAR2(30);
44242 l_adr_value_combination_id NUMBER;
44243 l_adr_value_segment_code VARCHAR2(30);
44244
44245 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
44246 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
44247 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
44248 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
44249
44250 -- 4262811 Variables ------------------------------------------------------------------------------------------
44251 l_entered_amt_idx NUMBER;
44252 l_accted_amt_idx NUMBER;
44253 l_acc_rev_flag VARCHAR2(1);
44254 l_accrual_line_num NUMBER;
44255 l_tmp_amt NUMBER;
44256 l_acc_rev_natural_side_code VARCHAR2(1);
44257
44258 l_num_entries NUMBER;
44259 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
44260 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
44261 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
44262 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
44263 l_recog_line_1 NUMBER;
44264 l_recog_line_2 NUMBER;
44265
44266 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
44267 l_bflow_applied_to_amt NUMBER; -- 5132302
44268 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
44269
44270 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
44271
44272 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
44273 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
44274
44275 ---------------------------------------------------------------------------------------------------------------
44276
44277
44278 --
44279 -- bulk performance
44280 --
44281 l_balance_type_code VARCHAR2(1);
44282 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
44283 l_log_module VARCHAR2(240);
44284
44285 --
44286 -- Upgrade strategy
44287 --
44288 l_actual_upg_option VARCHAR2(1);
44289 l_enc_upg_option VARCHAR2(1);
44290
44291 --
44292 BEGIN
44293 --
44294 IF g_log_enabled THEN
44295 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_96';
44296 END IF;
44297 --
44298 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44299
44300 trace
44301 (p_msg => 'BEGIN of AcctLineType_96'
44302 ,p_level => C_LEVEL_PROCEDURE
44303 ,p_module => l_log_module);
44304
44305 END IF;
44306 --
44307 l_component_type := 'AMB_JLT';
44308 l_component_code := 'MISC_RCT_BNK_CHG';
44309 l_component_type_code := 'S';
44310 l_component_appl_id := 222;
44311 l_amb_context_code := 'DEFAULT';
44312 l_entity_code := 'RECEIPTS';
44313 l_event_class_code := 'MISC_RECEIPT';
44314 l_event_type_code := 'MISC_RECEIPT_ALL';
44315 l_line_definition_owner_code := 'S';
44316 l_line_definition_code := 'AR_MISC_RECEIPTS';
44317 --
44318 l_balance_type_code := 'A';
44319 l_segment := NULL;
44320 l_ccid := NULL;
44321 l_adr_transaction_coa_id := NULL;
44322 l_adr_accounting_coa_id := NULL;
44323 l_adr_flexfield_segment_code := NULL;
44324 l_adr_flex_value_set_id := NULL;
44325 l_adr_value_type_code := NULL;
44326 l_adr_value_combination_id := NULL;
44327 l_adr_value_segment_code := NULL;
44328
44329 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
44330 l_bflow_class_code := ''; -- 4219869 Business Flow
44331 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
44332 l_budgetary_control_flag := 'N';
44333
44334 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44335 l_bflow_applied_to_amt := NULL; -- 5132302
44336 l_entered_amt_idx := NULL; -- 4262811
44337 l_accted_amt_idx := NULL; -- 4262811
44338 l_acc_rev_flag := NULL; -- 4262811
44339 l_accrual_line_num := NULL; -- 4262811
44340 l_tmp_amt := NULL; -- 4262811
44341 --
44342
44343 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
44344 l_balance_type_code <> 'B' THEN
44345 IF NVL(p_source_20,'
44346 ') = 'BANK_CHARGES' AND
44347 NVL(p_source_67,'
44348 ') = 'N'
44349 THEN
44350
44351 --
44352 XLA_AE_LINES_PKG.SetNewLine;
44353
44354 p_balance_type_code := l_balance_type_code;
44355 -- set the flag so later we will know whether the gain loss line needs to be created
44356
44357 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
44358 p_actual_flag :='A';
44359 END IF;
44360
44361 --
44362 -- bulk performance
44363 --
44364 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
44365 p_header_num => 0); -- 4262811
44366 --
44367 -- set accounting line options
44368 --
44369 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
44370 p_natural_side_code => 'C'
44371 , p_gain_or_loss_flag => 'N'
44372 , p_gl_transfer_mode_code => 'S'
44373 , p_acct_entry_type_code => 'A'
44374 , p_switch_side_flag => 'Y'
44375 , p_merge_duplicate_code => 'A'
44376 );
44377 --
44378 l_acc_rev_natural_side_code := 'D'; -- 4262811
44379 --
44380 --
44381 -- set accounting line type info
44382 --
44383 xla_ae_lines_pkg.SetAcctLineType
44384 (p_component_type => l_component_type
44385 ,p_event_type_code => l_event_type_code
44386 ,p_line_definition_owner_code => l_line_definition_owner_code
44387 ,p_line_definition_code => l_line_definition_code
44388 ,p_accounting_line_code => l_component_code
44389 ,p_accounting_line_type_code => l_component_type_code
44390 ,p_accounting_line_appl_id => l_component_appl_id
44391 ,p_amb_context_code => l_amb_context_code
44392 ,p_entity_code => l_entity_code
44393 ,p_event_class_code => l_event_class_code);
44394 --
44395 -- set accounting class
44396 --
44397 xla_ae_lines_pkg.SetAcctClass(
44398 p_accounting_class_code => 'BANK_CHG'
44399 , p_ae_header_id => l_ae_header_id
44400 );
44401
44402 --
44403 -- set rounding class
44404 --
44405 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
44406 'RECEIVABLE';
44407
44408 --
44409 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
44410 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
44411 --
44412 -- bulk performance
44413 --
44414 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
44415
44416 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
44417 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
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('header_index'));
44422
44423 -- 4458381 Public Sector Enh
44424
44425 --
44426 -- set accounting attributes for the line type
44427 --
44428 l_entered_amt_idx := 3;
44429 l_accted_amt_idx := 8;
44430 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44431 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
44432 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
44433 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
44434 l_rec_acct_attrs.array_char_value(2) := p_source_23;
44435 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
44436 l_rec_acct_attrs.array_num_value(3) := p_source_24;
44437 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
44438 l_rec_acct_attrs.array_char_value(4) := p_source_25;
44439 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
44440 l_rec_acct_attrs.array_date_value(5) := p_source_57;
44441 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
44442 l_rec_acct_attrs.array_num_value(6) := p_source_27;
44443 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
44444 l_rec_acct_attrs.array_char_value(7) := p_source_28;
44445 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
44449 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
44446 l_rec_acct_attrs.array_num_value(8) := p_source_29;
44447
44448 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
44450
44451 ---------------------------------------------------------------------------------------------------------------
44452 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
44453 ---------------------------------------------------------------------------------------------------------------
44457 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44454 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
44455
44456 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
44458
44459 IF xla_accounting_cache_pkg.GetValueChar
44460 (p_source_code => 'LEDGER_CATEGORY_CODE'
44461 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
44462 AND l_bflow_method_code = 'PRIOR_ENTRY'
44463 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
44464 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
44465 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
44466 )
44467 THEN
44468 xla_ae_lines_pkg.BflowUpgEntry
44469 (p_business_method_code => l_bflow_method_code
44470 ,p_business_class_code => l_bflow_class_code
44471 ,p_balance_type => l_balance_type_code);
44472 ELSE
44473 NULL;
44474 -- No business flow processing for business flow method of NONE.
44475 END IF;
44476
44477 --
44478 -- call analytical criteria
44479 --
44480
44481 --
44482 -- call description
44483 --
44484 -- No description or it is inherited.
44485 --
44486 -- call ADRs
44487 -- Bug 4922099
44488 --
44489 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44490 (NVL(l_actual_upg_option, 'N') = 'O') OR
44491 (NVL(l_enc_upg_option, 'N') = 'O')
44492 )
44493 THEN
44494 NULL;
44495 --
44496 --
44497
44498 l_ccid := AcctDerRule_4(
44499 p_application_id => p_application_id
44500 , p_ae_header_id => l_ae_header_id
44501 , p_source_5 => p_source_5
44502 , x_transaction_coa_id => l_adr_transaction_coa_id
44503 , x_accounting_coa_id => l_adr_accounting_coa_id
44504 , x_value_type_code => l_adr_value_type_code
44505 , p_side => 'NA'
44506 );
44507
44508 xla_ae_lines_pkg.set_ccid(
44509 p_code_combination_id => l_ccid
44510 , p_value_type_code => l_adr_value_type_code
44511 , p_transaction_coa_id => l_adr_transaction_coa_id
44512 , p_accounting_coa_id => l_adr_accounting_coa_id
44513 , p_adr_code => 'DIST_CCID'
44514 , p_adr_type_code => 'S'
44515 , p_component_type => l_component_type
44516 , p_component_code => l_component_code
44517 , p_component_type_code => l_component_type_code
44518 , p_component_appl_id => l_component_appl_id
44519 , p_amb_context_code => l_amb_context_code
44520 , p_side => 'NA'
44521 );
44522
44523
44524 --
44525 --
44526 END IF;
44527 --
44528 -- Bug 4922099
44529 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
44530 (NVL(l_enc_upg_option, 'N') = 'O')
44531 ) AND
44532 (l_bflow_method_code = 'PRIOR_ENTRY')
44533 )
44534 THEN
44535 IF
44536 --
44537 1 = 2
44538 --
44539 THEN
44540 xla_accounting_err_pkg.build_message
44541 (p_appli_s_name => 'XLA'
44542 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44543 ,p_token_1 => 'LINE_NUMBER'
44544 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
44545 ,p_token_2 => 'LINE_TYPE_NAME'
44546 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
44547 l_component_type
44548 ,l_component_code
44549 ,l_component_type_code
44550 ,l_component_appl_id
44551 ,l_amb_context_code
44552 ,l_entity_code
44553 ,l_event_class_code
44554 )
44555 ,p_token_3 => 'OWNER'
44556 ,p_value_3 => xla_lookups_pkg.get_meaning(
44557 p_lookup_type => 'XLA_OWNER_TYPE'
44558 ,p_lookup_code => l_component_type_code
44559 )
44560 ,p_token_4 => 'PRODUCT_NAME'
44561 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
44562 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
44563 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
44564 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
44565 ,p_ae_header_id => NULL
44566 );
44567
44568 IF (C_LEVEL_ERROR>= g_log_level) THEN
44569 trace
44570 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
44571 ,p_level => C_LEVEL_ERROR
44572 ,p_module => l_log_module);
44573 END IF;
44574 END IF;
44575 END IF;
44576 --
44577 --
44578 ------------------------------------------------------------------------------------------------
44579 -- 4219869 Business Flow
44580 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
44581 -- Prior Entry. Currently, the following code is always generated.
44582 ------------------------------------------------------------------------------------------------
44583 XLA_AE_LINES_PKG.ValidateCurrentLine;
44584
44585 ------------------------------------------------------------------------------------
44586 -- 4219869 Business Flow
44587 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
44588 ------------------------------------------------------------------------------------
44589 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44590
44591 ----------------------------------------------------------------------------------
44592 -- 4219869 Business Flow
44593 -- Update journal entry status -- Need to generate this within IF <condition>
44594 ----------------------------------------------------------------------------------
44595 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44596 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
44597 ,p_balance_type_code => l_balance_type_code
44598 );
44599
44600 -------------------------------------------------------------------------------------------
44601 -- 4262811 - Generate the Accrual Reversal lines
44602 -------------------------------------------------------------------------------------------
44603 BEGIN
44604 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
44605 (g_array_event(p_event_id).array_value_num('header_index'));
44606 IF l_acc_rev_flag IS NULL THEN
44607 l_acc_rev_flag := 'N';
44608 END IF;
44609 EXCEPTION
44610 WHEN OTHERS THEN
44611 l_acc_rev_flag := 'N';
44612 END;
44613 --
44614 IF (l_acc_rev_flag = 'Y') THEN
44615
44616 -- 4645092 ------------------------------------------------------------------------------
44617 -- To allow MPA report to determine if it should generate report process
44618 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
44619 ------------------------------------------------------------------------------------------
44620
44621 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
44622 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
44623 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
44624 -- call ADRs
44625 -- Bug 4922099
44626 --
44627 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
44628 (NVL(l_actual_upg_option, 'N') = 'O') OR
44629 (NVL(l_enc_upg_option, 'N') = 'O')
44630 )
44631 THEN
44632 NULL;
44633 --
44634 --
44635
44636 l_ccid := AcctDerRule_4(
44637 p_application_id => p_application_id
44638 , p_ae_header_id => l_ae_header_id
44639 , p_source_5 => p_source_5
44640 , x_transaction_coa_id => l_adr_transaction_coa_id
44641 , x_accounting_coa_id => l_adr_accounting_coa_id
44642 , x_value_type_code => l_adr_value_type_code
44643 , p_side => 'NA'
44644 );
44645
44646 xla_ae_lines_pkg.set_ccid(
44647 p_code_combination_id => l_ccid
44648 , p_value_type_code => l_adr_value_type_code
44649 , p_transaction_coa_id => l_adr_transaction_coa_id
44650 , p_accounting_coa_id => l_adr_accounting_coa_id
44651 , p_adr_code => 'DIST_CCID'
44652 , p_adr_type_code => 'S'
44653 , p_component_type => l_component_type
44654 , p_component_code => l_component_code
44655 , p_component_type_code => l_component_type_code
44656 , p_component_appl_id => l_component_appl_id
44657 , p_amb_context_code => l_amb_context_code
44658 , p_side => 'NA'
44659 );
44660
44661
44665
44662 --
44663 --
44664 END IF;
44666 --
44667 -- Update the line information that should be overwritten
44668 --
44669 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
44670 p_header_num => 1);
44671 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
44672
44673 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
44674
44675 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
44676 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
44677 END IF;
44678
44679 --
44680 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
44681 --
44682 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
44683 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
44684 ELSE
44685 ---------------------------------------------------------------------------------------------------
44686 -- 4262811a Switch Sign
44687 ---------------------------------------------------------------------------------------------------
44688 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
44689 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44690 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44691 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
44692 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44693 -- 5132302
44694 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
44695 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
44696
44697 END IF;
44698
44699 -- 4955764
44700 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44701 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
44702
44703
44704 XLA_AE_LINES_PKG.ValidateCurrentLine;
44705 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
44706
44707 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
44708 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
44709 ,p_balance_type_code => l_balance_type_code);
44710
44711 END IF;
44712
44713 -----------------------------------------------------------------------------------------
44714 -- 4262811 Multiperiod Accounting
44715 -----------------------------------------------------------------------------------------
44716 -- No MPA option is assigned.
44717
44718
44719 END IF;
44720 END IF;
44721 --
44722
44723 --
44724 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44725 trace
44726 (p_msg => 'END of AcctLineType_96'
44727 ,p_level => C_LEVEL_PROCEDURE
44728 ,p_module => l_log_module);
44729 END IF;
44730 --
44731 EXCEPTION
44732 WHEN xla_exceptions_pkg.application_exception THEN
44733 RAISE;
44734 WHEN OTHERS THEN
44735 xla_exceptions_pkg.raise_message
44736 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_96');
44737 END AcctLineType_96;
44738 --
44739
44740 ---------------------------------------
44741 --
44742 -- PRIVATE FUNCTION
44743 -- AcctLineType_97
44744 --
44745 ---------------------------------------
44746 PROCEDURE AcctLineType_97 (
44747 p_application_id IN NUMBER
44748 ,p_event_id IN NUMBER
44749 ,p_calculate_acctd_flag IN VARCHAR2
44750 ,p_calculate_g_l_flag IN VARCHAR2
44751 ,p_actual_flag IN OUT VARCHAR2
44752 ,p_balance_type_code OUT VARCHAR2
44753 ,p_gain_or_loss_ref OUT VARCHAR2
44754
44755 --Distribution GL Account
44756 , p_source_5 IN NUMBER
44757 --Distribution Source Type
44758 , p_source_20 IN VARCHAR2
44759 --Distribution Line Identifier
44760 , p_source_22 IN NUMBER
44761 --Distribution Type
44762 , p_source_23 IN VARCHAR2
44763 --Entered Amount
44764 , p_source_24 IN NUMBER
44765 --Currency Code
44766 , p_source_25 IN VARCHAR2
44767 --Exchange Rate
44768 , p_source_27 IN NUMBER
44769 --Exchange Rate Type
44770 , p_source_28 IN VARCHAR2
44771 --Applied To Document Accounting Amount
44772 , p_source_29 IN NUMBER
44773 --Applied To Document Exchange Date
44774 , p_source_57 IN DATE
44775 --Distribution Multi Fund Additional Entry
44776 , p_source_67 IN VARCHAR2
44777 )
44778 IS
44779
44780 l_component_type VARCHAR2(80);
44781 l_component_code VARCHAR2(30);
44782 l_component_type_code VARCHAR2(1);
44783 l_component_appl_id INTEGER;
44784 l_amb_context_code VARCHAR2(30);
44785 l_entity_code VARCHAR2(30);
44786 l_event_class_code VARCHAR2(30);
44787 l_ae_header_id NUMBER;
44788 l_event_type_code VARCHAR2(30);
44789 l_line_definition_code VARCHAR2(30);
44790 l_line_definition_owner_code VARCHAR2(1);
44791 --
44792 -- adr variables
44793 l_segment VARCHAR2(30);
44794 l_ccid NUMBER;
44795 l_adr_transaction_coa_id NUMBER;
44796 l_adr_accounting_coa_id NUMBER;
44797 l_adr_flexfield_segment_code VARCHAR2(30);
44798 l_adr_flex_value_set_id NUMBER;
44799 l_adr_value_type_code VARCHAR2(30);
44800 l_adr_value_combination_id NUMBER;
44801 l_adr_value_segment_code VARCHAR2(30);
44802
44803 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
44804 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
44805 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
44806 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
44807
44808 -- 4262811 Variables ------------------------------------------------------------------------------------------
44809 l_entered_amt_idx NUMBER;
44810 l_accted_amt_idx NUMBER;
44811 l_acc_rev_flag VARCHAR2(1);
44812 l_accrual_line_num NUMBER;
44813 l_tmp_amt NUMBER;
44814 l_acc_rev_natural_side_code VARCHAR2(1);
44815
44816 l_num_entries NUMBER;
44817 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
44818 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
44819 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
44820 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
44821 l_recog_line_1 NUMBER;
44822 l_recog_line_2 NUMBER;
44823
44824 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
44825 l_bflow_applied_to_amt NUMBER; -- 5132302
44826 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
44827
44828 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
44829
44830 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
44831 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
44832
44833 ---------------------------------------------------------------------------------------------------------------
44834
44835
44836 --
44837 -- bulk performance
44838 --
44839 l_balance_type_code VARCHAR2(1);
44840 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
44841 l_log_module VARCHAR2(240);
44842
44843 --
44844 -- Upgrade strategy
44845 --
44846 l_actual_upg_option VARCHAR2(1);
44847 l_enc_upg_option VARCHAR2(1);
44848
44849 --
44850 BEGIN
44851 --
44852 IF g_log_enabled THEN
44853 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_97';
44854 END IF;
44855 --
44856 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
44857
44858 trace
44859 (p_msg => 'BEGIN of AcctLineType_97'
44860 ,p_level => C_LEVEL_PROCEDURE
44861 ,p_module => l_log_module);
44862
44863 END IF;
44864 --
44865 l_component_type := 'AMB_JLT';
44866 l_component_code := 'MISC_RCT_CASH';
44867 l_component_type_code := 'S';
44868 l_component_appl_id := 222;
44869 l_amb_context_code := 'DEFAULT';
44870 l_entity_code := 'RECEIPTS';
44871 l_event_class_code := 'MISC_RECEIPT';
44872 l_event_type_code := 'MISC_RECEIPT_ALL';
44873 l_line_definition_owner_code := 'S';
44874 l_line_definition_code := 'AR_MISC_RECEIPTS';
44875 --
44876 l_balance_type_code := 'A';
44877 l_segment := NULL;
44878 l_ccid := NULL;
44879 l_adr_transaction_coa_id := NULL;
44880 l_adr_accounting_coa_id := NULL;
44881 l_adr_flexfield_segment_code := NULL;
44882 l_adr_flex_value_set_id := NULL;
44883 l_adr_value_type_code := NULL;
44884 l_adr_value_combination_id := NULL;
44885 l_adr_value_segment_code := NULL;
44886
44887 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
44888 l_bflow_class_code := ''; -- 4219869 Business Flow
44889 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
44890 l_budgetary_control_flag := 'N';
44891
44892 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44893 l_bflow_applied_to_amt := NULL; -- 5132302
44894 l_entered_amt_idx := NULL; -- 4262811
44895 l_accted_amt_idx := NULL; -- 4262811
44896 l_acc_rev_flag := NULL; -- 4262811
44897 l_accrual_line_num := NULL; -- 4262811
44898 l_tmp_amt := NULL; -- 4262811
44899 --
44900
44901 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
44902 l_balance_type_code <> 'B' THEN
44903 IF NVL(p_source_20,'
44904 ') = 'CASH' AND
44905 NVL(p_source_67,'
44906 ') = 'N'
44907 THEN
44908
44909 --
44910 XLA_AE_LINES_PKG.SetNewLine;
44911
44912 p_balance_type_code := l_balance_type_code;
44913 -- set the flag so later we will know whether the gain loss line needs to be created
44914
44915 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
44916 p_actual_flag :='A';
44917 END IF;
44918
44919 --
44920 -- bulk performance
44921 --
44922 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
44923 p_header_num => 0); -- 4262811
44924 --
44925 -- set accounting line options
44926 --
44927 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
44928 p_natural_side_code => 'C'
44929 , p_gain_or_loss_flag => 'N'
44930 , p_gl_transfer_mode_code => 'S'
44931 , p_acct_entry_type_code => 'A'
44932 , p_switch_side_flag => 'Y'
44933 , p_merge_duplicate_code => 'A'
44934 );
44935 --
44936 l_acc_rev_natural_side_code := 'D'; -- 4262811
44937 --
44938 --
44939 -- set accounting line type info
44940 --
44941 xla_ae_lines_pkg.SetAcctLineType
44942 (p_component_type => l_component_type
44943 ,p_event_type_code => l_event_type_code
44944 ,p_line_definition_owner_code => l_line_definition_owner_code
44945 ,p_line_definition_code => l_line_definition_code
44946 ,p_accounting_line_code => l_component_code
44947 ,p_accounting_line_type_code => l_component_type_code
44948 ,p_accounting_line_appl_id => l_component_appl_id
44949 ,p_amb_context_code => l_amb_context_code
44950 ,p_entity_code => l_entity_code
44951 ,p_event_class_code => l_event_class_code);
44952 --
44953 -- set accounting class
44954 --
44955 xla_ae_lines_pkg.SetAcctClass(
44956 p_accounting_class_code => 'CASH'
44957 , p_ae_header_id => l_ae_header_id
44958 );
44959
44960 --
44961 -- set rounding class
44962 --
44963 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
44964 'RECEIVABLE';
44965
44966 --
44967 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
44968 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
44969 --
44970 -- bulk performance
44971 --
44972 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
44973
44974 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
44975 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
44976
44977 -- 4955764
44978 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
44979 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
44980
44981 -- 4458381 Public Sector Enh
44982
44983 --
44984 -- set accounting attributes for the line type
44985 --
44986 l_entered_amt_idx := 3;
44987 l_accted_amt_idx := 8;
44988 l_bflow_applied_to_amt_idx := NULL; -- 5132302
44989 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
44990 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
44991 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
44992 l_rec_acct_attrs.array_char_value(2) := p_source_23;
44993 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
44994 l_rec_acct_attrs.array_num_value(3) := p_source_24;
44995 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
44996 l_rec_acct_attrs.array_char_value(4) := p_source_25;
44997 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
44998 l_rec_acct_attrs.array_date_value(5) := p_source_57;
44999 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
45000 l_rec_acct_attrs.array_num_value(6) := p_source_27;
45001 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
45002 l_rec_acct_attrs.array_char_value(7) := p_source_28;
45003 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
45004 l_rec_acct_attrs.array_num_value(8) := p_source_29;
45005
45006 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
45007 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
45008
45009 ---------------------------------------------------------------------------------------------------------------
45010 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
45011 ---------------------------------------------------------------------------------------------------------------
45012 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
45013
45014 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45015 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45016
45017 IF xla_accounting_cache_pkg.GetValueChar
45018 (p_source_code => 'LEDGER_CATEGORY_CODE'
45019 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
45020 AND l_bflow_method_code = 'PRIOR_ENTRY'
45021 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
45022 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
45023 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
45024 )
45025 THEN
45026 xla_ae_lines_pkg.BflowUpgEntry
45027 (p_business_method_code => l_bflow_method_code
45028 ,p_business_class_code => l_bflow_class_code
45029 ,p_balance_type => l_balance_type_code);
45030 ELSE
45031 NULL;
45032 -- No business flow processing for business flow method of NONE.
45033 END IF;
45034
45035 --
45036 -- call analytical criteria
45037 --
45038
45039 --
45040 -- call description
45041 --
45042 -- No description or it is inherited.
45043 --
45044 -- call ADRs
45045 -- Bug 4922099
45046 --
45047 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45048 (NVL(l_actual_upg_option, 'N') = 'O') OR
45049 (NVL(l_enc_upg_option, 'N') = 'O')
45050 )
45051 THEN
45052 NULL;
45053 --
45054 --
45055
45056 l_ccid := AcctDerRule_4(
45057 p_application_id => p_application_id
45058 , p_ae_header_id => l_ae_header_id
45059 , p_source_5 => p_source_5
45060 , x_transaction_coa_id => l_adr_transaction_coa_id
45061 , x_accounting_coa_id => l_adr_accounting_coa_id
45062 , x_value_type_code => l_adr_value_type_code
45063 , p_side => 'NA'
45064 );
45065
45066 xla_ae_lines_pkg.set_ccid(
45067 p_code_combination_id => l_ccid
45068 , p_value_type_code => l_adr_value_type_code
45069 , p_transaction_coa_id => l_adr_transaction_coa_id
45070 , p_accounting_coa_id => l_adr_accounting_coa_id
45071 , p_adr_code => 'DIST_CCID'
45072 , p_adr_type_code => 'S'
45073 , p_component_type => l_component_type
45074 , p_component_code => l_component_code
45075 , p_component_type_code => l_component_type_code
45076 , p_component_appl_id => l_component_appl_id
45077 , p_amb_context_code => l_amb_context_code
45078 , p_side => 'NA'
45079 );
45080
45081
45082 --
45083 --
45084 END IF;
45085 --
45086 -- Bug 4922099
45087 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
45088 (NVL(l_enc_upg_option, 'N') = 'O')
45089 ) AND
45090 (l_bflow_method_code = 'PRIOR_ENTRY')
45091 )
45092 THEN
45093 IF
45094 --
45095 1 = 2
45096 --
45097 THEN
45098 xla_accounting_err_pkg.build_message
45099 (p_appli_s_name => 'XLA'
45100 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45101 ,p_token_1 => 'LINE_NUMBER'
45102 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
45103 ,p_token_2 => 'LINE_TYPE_NAME'
45104 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
45105 l_component_type
45106 ,l_component_code
45107 ,l_component_type_code
45108 ,l_component_appl_id
45109 ,l_amb_context_code
45110 ,l_entity_code
45111 ,l_event_class_code
45112 )
45113 ,p_token_3 => 'OWNER'
45114 ,p_value_3 => xla_lookups_pkg.get_meaning(
45115 p_lookup_type => 'XLA_OWNER_TYPE'
45116 ,p_lookup_code => l_component_type_code
45117 )
45118 ,p_token_4 => 'PRODUCT_NAME'
45119 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
45120 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
45121 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
45122 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
45123 ,p_ae_header_id => NULL
45124 );
45125
45126 IF (C_LEVEL_ERROR>= g_log_level) THEN
45127 trace
45128 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45129 ,p_level => C_LEVEL_ERROR
45130 ,p_module => l_log_module);
45131 END IF;
45132 END IF;
45133 END IF;
45134 --
45135 --
45136 ------------------------------------------------------------------------------------------------
45137 -- 4219869 Business Flow
45138 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
45139 -- Prior Entry. Currently, the following code is always generated.
45140 ------------------------------------------------------------------------------------------------
45141 XLA_AE_LINES_PKG.ValidateCurrentLine;
45142
45143 ------------------------------------------------------------------------------------
45144 -- 4219869 Business Flow
45145 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
45146 ------------------------------------------------------------------------------------
45147 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45148
45149 ----------------------------------------------------------------------------------
45150 -- 4219869 Business Flow
45151 -- Update journal entry status -- Need to generate this within IF <condition>
45152 ----------------------------------------------------------------------------------
45153 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45154 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
45155 ,p_balance_type_code => l_balance_type_code
45156 );
45157
45158 -------------------------------------------------------------------------------------------
45159 -- 4262811 - Generate the Accrual Reversal lines
45160 -------------------------------------------------------------------------------------------
45161 BEGIN
45162 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
45163 (g_array_event(p_event_id).array_value_num('header_index'));
45164 IF l_acc_rev_flag IS NULL THEN
45165 l_acc_rev_flag := 'N';
45166 END IF;
45167 EXCEPTION
45168 WHEN OTHERS THEN
45169 l_acc_rev_flag := 'N';
45170 END;
45171 --
45172 IF (l_acc_rev_flag = 'Y') THEN
45173
45174 -- 4645092 ------------------------------------------------------------------------------
45175 -- To allow MPA report to determine if it should generate report process
45176 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
45177 ------------------------------------------------------------------------------------------
45178
45179 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
45180 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
45181 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
45182 -- call ADRs
45183 -- Bug 4922099
45184 --
45185 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45186 (NVL(l_actual_upg_option, 'N') = 'O') OR
45187 (NVL(l_enc_upg_option, 'N') = 'O')
45188 )
45189 THEN
45190 NULL;
45191 --
45192 --
45193
45194 l_ccid := AcctDerRule_4(
45195 p_application_id => p_application_id
45196 , p_ae_header_id => l_ae_header_id
45197 , p_source_5 => p_source_5
45198 , x_transaction_coa_id => l_adr_transaction_coa_id
45199 , x_accounting_coa_id => l_adr_accounting_coa_id
45200 , x_value_type_code => l_adr_value_type_code
45201 , p_side => 'NA'
45202 );
45203
45204 xla_ae_lines_pkg.set_ccid(
45205 p_code_combination_id => l_ccid
45206 , p_value_type_code => l_adr_value_type_code
45207 , p_transaction_coa_id => l_adr_transaction_coa_id
45208 , p_accounting_coa_id => l_adr_accounting_coa_id
45209 , p_adr_code => 'DIST_CCID'
45210 , p_adr_type_code => 'S'
45211 , p_component_type => l_component_type
45212 , p_component_code => l_component_code
45213 , p_component_type_code => l_component_type_code
45214 , p_component_appl_id => l_component_appl_id
45215 , p_amb_context_code => l_amb_context_code
45216 , p_side => 'NA'
45217 );
45218
45219
45220 --
45221 --
45222 END IF;
45223
45224 --
45225 -- Update the line information that should be overwritten
45226 --
45227 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
45228 p_header_num => 1);
45229 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
45230
45231 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
45232
45233 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
45234 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
45235 END IF;
45236
45237 --
45238 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
45239 --
45240 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
45241 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
45242 ELSE
45243 ---------------------------------------------------------------------------------------------------
45244 -- 4262811a Switch Sign
45245 ---------------------------------------------------------------------------------------------------
45246 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
45247 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45248 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45249 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45250 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45251 -- 5132302
45252 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
45253 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45254
45255 END IF;
45256
45257 -- 4955764
45258 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45259 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
45260
45261
45262 XLA_AE_LINES_PKG.ValidateCurrentLine;
45263 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45264
45265 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45266 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
45267 ,p_balance_type_code => l_balance_type_code);
45268
45269 END IF;
45270
45271 -----------------------------------------------------------------------------------------
45272 -- 4262811 Multiperiod Accounting
45273 -----------------------------------------------------------------------------------------
45274 -- No MPA option is assigned.
45275
45276
45277 END IF;
45278 END IF;
45279 --
45280
45281 --
45282 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45283 trace
45284 (p_msg => 'END of AcctLineType_97'
45285 ,p_level => C_LEVEL_PROCEDURE
45286 ,p_module => l_log_module);
45287 END IF;
45288 --
45289 EXCEPTION
45290 WHEN xla_exceptions_pkg.application_exception THEN
45291 RAISE;
45292 WHEN OTHERS THEN
45293 xla_exceptions_pkg.raise_message
45294 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_97');
45295 END AcctLineType_97;
45296 --
45297
45298 ---------------------------------------
45299 --
45300 -- PRIVATE FUNCTION
45301 -- AcctLineType_98
45302 --
45303 ---------------------------------------
45304 PROCEDURE AcctLineType_98 (
45305 p_application_id IN NUMBER
45306 ,p_event_id IN NUMBER
45307 ,p_calculate_acctd_flag IN VARCHAR2
45308 ,p_calculate_g_l_flag IN VARCHAR2
45309 ,p_actual_flag IN OUT VARCHAR2
45310 ,p_balance_type_code OUT VARCHAR2
45311 ,p_gain_or_loss_ref OUT VARCHAR2
45312
45313 --Distribution GL Account
45314 , p_source_5 IN NUMBER
45315 --Distribution Source Type
45316 , p_source_20 IN VARCHAR2
45317 --Distribution Line Identifier
45318 , p_source_22 IN NUMBER
45319 --Distribution Type
45320 , p_source_23 IN VARCHAR2
45321 --Entered Amount
45322 , p_source_24 IN NUMBER
45323 --Currency Code
45324 , p_source_25 IN VARCHAR2
45325 --Exchange Rate
45326 , p_source_27 IN NUMBER
45327 --Exchange Rate Type
45328 , p_source_28 IN VARCHAR2
45329 --Applied To Document Accounting Amount
45330 , p_source_29 IN NUMBER
45331 --Applied To Document Exchange Date
45332 , p_source_57 IN DATE
45333 --Distribution Multi Fund Additional Entry
45334 , p_source_67 IN VARCHAR2
45335 )
45336 IS
45337
45338 l_component_type VARCHAR2(80);
45339 l_component_code VARCHAR2(30);
45340 l_component_type_code VARCHAR2(1);
45341 l_component_appl_id INTEGER;
45342 l_amb_context_code VARCHAR2(30);
45343 l_entity_code VARCHAR2(30);
45344 l_event_class_code VARCHAR2(30);
45345 l_ae_header_id NUMBER;
45346 l_event_type_code VARCHAR2(30);
45347 l_line_definition_code VARCHAR2(30);
45348 l_line_definition_owner_code VARCHAR2(1);
45349 --
45350 -- adr variables
45351 l_segment VARCHAR2(30);
45352 l_ccid NUMBER;
45353 l_adr_transaction_coa_id NUMBER;
45354 l_adr_accounting_coa_id NUMBER;
45355 l_adr_flexfield_segment_code VARCHAR2(30);
45356 l_adr_flex_value_set_id NUMBER;
45357 l_adr_value_type_code VARCHAR2(30);
45358 l_adr_value_combination_id NUMBER;
45359 l_adr_value_segment_code VARCHAR2(30);
45360
45361 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
45362 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
45363 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
45364 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
45365
45366 -- 4262811 Variables ------------------------------------------------------------------------------------------
45367 l_entered_amt_idx NUMBER;
45368 l_accted_amt_idx NUMBER;
45369 l_acc_rev_flag VARCHAR2(1);
45370 l_accrual_line_num NUMBER;
45371 l_tmp_amt NUMBER;
45372 l_acc_rev_natural_side_code VARCHAR2(1);
45373
45374 l_num_entries NUMBER;
45375 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
45376 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
45377 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
45378 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
45379 l_recog_line_1 NUMBER;
45380 l_recog_line_2 NUMBER;
45381
45382 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
45383 l_bflow_applied_to_amt NUMBER; -- 5132302
45384 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
45385
45386 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
45387
45388 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
45389 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
45390
45391 ---------------------------------------------------------------------------------------------------------------
45392
45393
45394 --
45395 -- bulk performance
45396 --
45397 l_balance_type_code VARCHAR2(1);
45398 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
45399 l_log_module VARCHAR2(240);
45400
45401 --
45402 -- Upgrade strategy
45403 --
45404 l_actual_upg_option VARCHAR2(1);
45405 l_enc_upg_option VARCHAR2(1);
45406
45407 --
45408 BEGIN
45409 --
45410 IF g_log_enabled THEN
45411 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_98';
45412 END IF;
45413 --
45414 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45415
45416 trace
45417 (p_msg => 'BEGIN of AcctLineType_98'
45418 ,p_level => C_LEVEL_PROCEDURE
45419 ,p_module => l_log_module);
45420
45421 END IF;
45422 --
45423 l_component_type := 'AMB_JLT';
45424 l_component_code := 'MISC_RCT_CONFIRM';
45425 l_component_type_code := 'S';
45426 l_component_appl_id := 222;
45427 l_amb_context_code := 'DEFAULT';
45428 l_entity_code := 'RECEIPTS';
45429 l_event_class_code := 'MISC_RECEIPT';
45430 l_event_type_code := 'MISC_RECEIPT_ALL';
45431 l_line_definition_owner_code := 'S';
45432 l_line_definition_code := 'AR_MISC_RECEIPTS';
45433 --
45434 l_balance_type_code := 'A';
45435 l_segment := NULL;
45436 l_ccid := NULL;
45437 l_adr_transaction_coa_id := NULL;
45438 l_adr_accounting_coa_id := NULL;
45439 l_adr_flexfield_segment_code := NULL;
45440 l_adr_flex_value_set_id := NULL;
45441 l_adr_value_type_code := NULL;
45442 l_adr_value_combination_id := NULL;
45443 l_adr_value_segment_code := NULL;
45444
45445 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
45446 l_bflow_class_code := ''; -- 4219869 Business Flow
45447 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
45448 l_budgetary_control_flag := 'N';
45449
45450 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45451 l_bflow_applied_to_amt := NULL; -- 5132302
45452 l_entered_amt_idx := NULL; -- 4262811
45453 l_accted_amt_idx := NULL; -- 4262811
45454 l_acc_rev_flag := NULL; -- 4262811
45455 l_accrual_line_num := NULL; -- 4262811
45456 l_tmp_amt := NULL; -- 4262811
45457 --
45458
45459 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
45460 l_balance_type_code <> 'B' THEN
45461 IF NVL(p_source_20,'
45462 ') = 'CONFIRMATION' AND
45463 NVL(p_source_67,'
45464 ') = 'N'
45465 THEN
45466
45467 --
45468 XLA_AE_LINES_PKG.SetNewLine;
45469
45470 p_balance_type_code := l_balance_type_code;
45471 -- set the flag so later we will know whether the gain loss line needs to be created
45472
45473 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
45474 p_actual_flag :='A';
45475 END IF;
45476
45477 --
45478 -- bulk performance
45479 --
45480 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
45481 p_header_num => 0); -- 4262811
45482 --
45483 -- set accounting line options
45484 --
45485 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
45486 p_natural_side_code => 'C'
45487 , p_gain_or_loss_flag => 'N'
45488 , p_gl_transfer_mode_code => 'S'
45489 , p_acct_entry_type_code => 'A'
45490 , p_switch_side_flag => 'Y'
45491 , p_merge_duplicate_code => 'A'
45492 );
45493 --
45494 l_acc_rev_natural_side_code := 'D'; -- 4262811
45495 --
45496 --
45497 -- set accounting line type info
45498 --
45499 xla_ae_lines_pkg.SetAcctLineType
45500 (p_component_type => l_component_type
45501 ,p_event_type_code => l_event_type_code
45502 ,p_line_definition_owner_code => l_line_definition_owner_code
45503 ,p_line_definition_code => l_line_definition_code
45504 ,p_accounting_line_code => l_component_code
45505 ,p_accounting_line_type_code => l_component_type_code
45506 ,p_accounting_line_appl_id => l_component_appl_id
45507 ,p_amb_context_code => l_amb_context_code
45508 ,p_entity_code => l_entity_code
45509 ,p_event_class_code => l_event_class_code);
45510 --
45511 -- set accounting class
45512 --
45513 xla_ae_lines_pkg.SetAcctClass(
45514 p_accounting_class_code => 'CONFIRMATION'
45515 , p_ae_header_id => l_ae_header_id
45516 );
45517
45518 --
45519 -- set rounding class
45520 --
45521 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
45522 'RECEIVABLE';
45523
45524 --
45525 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
45526 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
45527 --
45528 -- bulk performance
45529 --
45530 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
45531
45532 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
45533 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
45534
45535 -- 4955764
45536 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45537 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
45538
45539 -- 4458381 Public Sector Enh
45540
45541 --
45542 -- set accounting attributes for the line type
45543 --
45544 l_entered_amt_idx := 3;
45545 l_accted_amt_idx := 8;
45546 l_bflow_applied_to_amt_idx := NULL; -- 5132302
45547 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
45548 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
45549 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
45550 l_rec_acct_attrs.array_char_value(2) := p_source_23;
45551 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
45552 l_rec_acct_attrs.array_num_value(3) := p_source_24;
45553 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
45554 l_rec_acct_attrs.array_char_value(4) := p_source_25;
45555 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
45556 l_rec_acct_attrs.array_date_value(5) := p_source_57;
45557 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
45558 l_rec_acct_attrs.array_num_value(6) := p_source_27;
45559 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
45560 l_rec_acct_attrs.array_char_value(7) := p_source_28;
45561 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
45562 l_rec_acct_attrs.array_num_value(8) := p_source_29;
45563
45564 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
45565 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
45566
45567 ---------------------------------------------------------------------------------------------------------------
45568 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
45569 ---------------------------------------------------------------------------------------------------------------
45570 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
45571
45572 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45573 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
45574
45575 IF xla_accounting_cache_pkg.GetValueChar
45576 (p_source_code => 'LEDGER_CATEGORY_CODE'
45577 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
45578 AND l_bflow_method_code = 'PRIOR_ENTRY'
45579 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
45580 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
45581 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
45582 )
45583 THEN
45584 xla_ae_lines_pkg.BflowUpgEntry
45585 (p_business_method_code => l_bflow_method_code
45586 ,p_business_class_code => l_bflow_class_code
45587 ,p_balance_type => l_balance_type_code);
45588 ELSE
45589 NULL;
45590 -- No business flow processing for business flow method of NONE.
45591 END IF;
45592
45593 --
45594 -- call analytical criteria
45595 --
45596
45597 --
45598 -- call description
45599 --
45600 -- No description or it is inherited.
45601 --
45602 -- call ADRs
45603 -- Bug 4922099
45604 --
45605 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45606 (NVL(l_actual_upg_option, 'N') = 'O') OR
45607 (NVL(l_enc_upg_option, 'N') = 'O')
45608 )
45609 THEN
45610 NULL;
45611 --
45612 --
45613
45614 l_ccid := AcctDerRule_4(
45615 p_application_id => p_application_id
45616 , p_ae_header_id => l_ae_header_id
45617 , p_source_5 => p_source_5
45618 , x_transaction_coa_id => l_adr_transaction_coa_id
45619 , x_accounting_coa_id => l_adr_accounting_coa_id
45620 , x_value_type_code => l_adr_value_type_code
45621 , p_side => 'NA'
45622 );
45623
45624 xla_ae_lines_pkg.set_ccid(
45625 p_code_combination_id => l_ccid
45626 , p_value_type_code => l_adr_value_type_code
45627 , p_transaction_coa_id => l_adr_transaction_coa_id
45631 , p_component_type => l_component_type
45628 , p_accounting_coa_id => l_adr_accounting_coa_id
45629 , p_adr_code => 'DIST_CCID'
45630 , p_adr_type_code => 'S'
45632 , p_component_code => l_component_code
45633 , p_component_type_code => l_component_type_code
45634 , p_component_appl_id => l_component_appl_id
45635 , p_amb_context_code => l_amb_context_code
45636 , p_side => 'NA'
45637 );
45638
45639
45640 --
45641 --
45642 END IF;
45643 --
45644 -- Bug 4922099
45645 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
45646 (NVL(l_enc_upg_option, 'N') = 'O')
45647 ) AND
45648 (l_bflow_method_code = 'PRIOR_ENTRY')
45649 )
45650 THEN
45651 IF
45652 --
45653 1 = 2
45654 --
45655 THEN
45656 xla_accounting_err_pkg.build_message
45657 (p_appli_s_name => 'XLA'
45658 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45659 ,p_token_1 => 'LINE_NUMBER'
45660 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
45661 ,p_token_2 => 'LINE_TYPE_NAME'
45662 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
45663 l_component_type
45664 ,l_component_code
45665 ,l_component_type_code
45666 ,l_component_appl_id
45667 ,l_amb_context_code
45668 ,l_entity_code
45669 ,l_event_class_code
45670 )
45671 ,p_token_3 => 'OWNER'
45672 ,p_value_3 => xla_lookups_pkg.get_meaning(
45673 p_lookup_type => 'XLA_OWNER_TYPE'
45674 ,p_lookup_code => l_component_type_code
45675 )
45676 ,p_token_4 => 'PRODUCT_NAME'
45677 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
45678 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
45679 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
45680 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
45681 ,p_ae_header_id => NULL
45682 );
45683
45684 IF (C_LEVEL_ERROR>= g_log_level) THEN
45685 trace
45686 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
45687 ,p_level => C_LEVEL_ERROR
45688 ,p_module => l_log_module);
45689 END IF;
45690 END IF;
45691 END IF;
45692 --
45693 --
45694 ------------------------------------------------------------------------------------------------
45695 -- 4219869 Business Flow
45696 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
45697 -- Prior Entry. Currently, the following code is always generated.
45698 ------------------------------------------------------------------------------------------------
45699 XLA_AE_LINES_PKG.ValidateCurrentLine;
45700
45701 ------------------------------------------------------------------------------------
45702 -- 4219869 Business Flow
45703 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
45704 ------------------------------------------------------------------------------------
45705 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45706
45707 ----------------------------------------------------------------------------------
45708 -- 4219869 Business Flow
45709 -- Update journal entry status -- Need to generate this within IF <condition>
45710 ----------------------------------------------------------------------------------
45711 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45712 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
45713 ,p_balance_type_code => l_balance_type_code
45714 );
45715
45716 -------------------------------------------------------------------------------------------
45717 -- 4262811 - Generate the Accrual Reversal lines
45718 -------------------------------------------------------------------------------------------
45719 BEGIN
45720 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
45721 (g_array_event(p_event_id).array_value_num('header_index'));
45722 IF l_acc_rev_flag IS NULL THEN
45723 l_acc_rev_flag := 'N';
45724 END IF;
45725 EXCEPTION
45726 WHEN OTHERS THEN
45727 l_acc_rev_flag := 'N';
45728 END;
45729 --
45730 IF (l_acc_rev_flag = 'Y') THEN
45731
45732 -- 4645092 ------------------------------------------------------------------------------
45733 -- To allow MPA report to determine if it should generate report process
45734 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
45735 ------------------------------------------------------------------------------------------
45736
45737 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
45738 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
45739 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
45740 -- call ADRs
45741 -- Bug 4922099
45742 --
45743 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
45744 (NVL(l_actual_upg_option, 'N') = 'O') OR
45745 (NVL(l_enc_upg_option, 'N') = 'O')
45746 )
45747 THEN
45748 NULL;
45749 --
45750 --
45751
45752 l_ccid := AcctDerRule_4(
45753 p_application_id => p_application_id
45754 , p_ae_header_id => l_ae_header_id
45755 , p_source_5 => p_source_5
45756 , x_transaction_coa_id => l_adr_transaction_coa_id
45757 , x_accounting_coa_id => l_adr_accounting_coa_id
45758 , x_value_type_code => l_adr_value_type_code
45759 , p_side => 'NA'
45760 );
45761
45762 xla_ae_lines_pkg.set_ccid(
45763 p_code_combination_id => l_ccid
45764 , p_value_type_code => l_adr_value_type_code
45765 , p_transaction_coa_id => l_adr_transaction_coa_id
45766 , p_accounting_coa_id => l_adr_accounting_coa_id
45767 , p_adr_code => 'DIST_CCID'
45768 , p_adr_type_code => 'S'
45769 , p_component_type => l_component_type
45770 , p_component_code => l_component_code
45771 , p_component_type_code => l_component_type_code
45772 , p_component_appl_id => l_component_appl_id
45773 , p_amb_context_code => l_amb_context_code
45774 , p_side => 'NA'
45775 );
45776
45777
45778 --
45779 --
45780 END IF;
45781
45782 --
45783 -- Update the line information that should be overwritten
45784 --
45785 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
45786 p_header_num => 1);
45787 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
45788
45789 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
45790
45791 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
45792 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
45793 END IF;
45794
45795 --
45796 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
45797 --
45798 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
45799 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
45800 ELSE
45801 ---------------------------------------------------------------------------------------------------
45802 -- 4262811a Switch Sign
45803 ---------------------------------------------------------------------------------------------------
45804 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
45805 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45806 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45807 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
45808 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45809 -- 5132302
45810 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
45811 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
45812
45813 END IF;
45814
45815 -- 4955764
45816 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
45817 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
45818
45819
45820 XLA_AE_LINES_PKG.ValidateCurrentLine;
45821 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
45822
45823 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
45827 END IF;
45824 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
45825 ,p_balance_type_code => l_balance_type_code);
45826
45828
45829 -----------------------------------------------------------------------------------------
45830 -- 4262811 Multiperiod Accounting
45831 -----------------------------------------------------------------------------------------
45832 -- No MPA option is assigned.
45833
45834
45835 END IF;
45836 END IF;
45837 --
45838
45839 --
45840 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45841 trace
45842 (p_msg => 'END of AcctLineType_98'
45843 ,p_level => C_LEVEL_PROCEDURE
45844 ,p_module => l_log_module);
45845 END IF;
45846 --
45847 EXCEPTION
45848 WHEN xla_exceptions_pkg.application_exception THEN
45849 RAISE;
45850 WHEN OTHERS THEN
45851 xla_exceptions_pkg.raise_message
45852 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_98');
45853 END AcctLineType_98;
45854 --
45855
45856 ---------------------------------------
45857 --
45858 -- PRIVATE FUNCTION
45859 -- AcctLineType_99
45860 --
45861 ---------------------------------------
45862 PROCEDURE AcctLineType_99 (
45863 p_application_id IN NUMBER
45864 ,p_event_id IN NUMBER
45865 ,p_calculate_acctd_flag IN VARCHAR2
45866 ,p_calculate_g_l_flag IN VARCHAR2
45867 ,p_actual_flag IN OUT VARCHAR2
45868 ,p_balance_type_code OUT VARCHAR2
45869 ,p_gain_or_loss_ref OUT VARCHAR2
45870
45871 --Distribution GL Account
45872 , p_source_5 IN NUMBER
45873 --Distribution Source Type
45874 , p_source_20 IN VARCHAR2
45875 --Distribution Line Identifier
45876 , p_source_22 IN NUMBER
45877 --Distribution Type
45878 , p_source_23 IN VARCHAR2
45879 --Entered Amount
45880 , p_source_24 IN NUMBER
45881 --Currency Code
45882 , p_source_25 IN VARCHAR2
45883 --Exchange Rate
45884 , p_source_27 IN NUMBER
45885 --Exchange Rate Type
45886 , p_source_28 IN VARCHAR2
45887 --Applied To Document Accounting Amount
45888 , p_source_29 IN NUMBER
45889 --Applied To Document Exchange Date
45890 , p_source_57 IN DATE
45891 --Distribution Multi Fund Additional Entry
45892 , p_source_67 IN VARCHAR2
45893 )
45894 IS
45895
45896 l_component_type VARCHAR2(80);
45897 l_component_code VARCHAR2(30);
45898 l_component_type_code VARCHAR2(1);
45899 l_component_appl_id INTEGER;
45900 l_amb_context_code VARCHAR2(30);
45901 l_entity_code VARCHAR2(30);
45902 l_event_class_code VARCHAR2(30);
45903 l_ae_header_id NUMBER;
45904 l_event_type_code VARCHAR2(30);
45905 l_line_definition_code VARCHAR2(30);
45906 l_line_definition_owner_code VARCHAR2(1);
45907 --
45908 -- adr variables
45909 l_segment VARCHAR2(30);
45910 l_ccid NUMBER;
45911 l_adr_transaction_coa_id NUMBER;
45912 l_adr_accounting_coa_id NUMBER;
45913 l_adr_flexfield_segment_code VARCHAR2(30);
45914 l_adr_flex_value_set_id NUMBER;
45915 l_adr_value_type_code VARCHAR2(30);
45916 l_adr_value_combination_id NUMBER;
45917 l_adr_value_segment_code VARCHAR2(30);
45918
45919 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
45920 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
45921 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
45922 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
45923
45924 -- 4262811 Variables ------------------------------------------------------------------------------------------
45925 l_entered_amt_idx NUMBER;
45926 l_accted_amt_idx NUMBER;
45927 l_acc_rev_flag VARCHAR2(1);
45928 l_accrual_line_num NUMBER;
45929 l_tmp_amt NUMBER;
45930 l_acc_rev_natural_side_code VARCHAR2(1);
45931
45932 l_num_entries NUMBER;
45933 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
45934 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
45935 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
45936 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
45937 l_recog_line_1 NUMBER;
45938 l_recog_line_2 NUMBER;
45939
45940 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
45941 l_bflow_applied_to_amt NUMBER; -- 5132302
45942 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
45943
45944 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
45945
45946 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
45947 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
45948
45949 ---------------------------------------------------------------------------------------------------------------
45950
45951
45952 --
45953 -- bulk performance
45954 --
45955 l_balance_type_code VARCHAR2(1);
45956 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
45957 l_log_module VARCHAR2(240);
45958
45959 --
45960 -- Upgrade strategy
45961 --
45962 l_actual_upg_option VARCHAR2(1);
45963 l_enc_upg_option VARCHAR2(1);
45964
45965 --
45966 BEGIN
45967 --
45968 IF g_log_enabled THEN
45969 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_99';
45970 END IF;
45971 --
45972 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
45973
45974 trace
45975 (p_msg => 'BEGIN of AcctLineType_99'
45976 ,p_level => C_LEVEL_PROCEDURE
45977 ,p_module => l_log_module);
45978
45979 END IF;
45980 --
45981 l_component_type := 'AMB_JLT';
45982 l_component_code := 'MISC_RCT_DEBT';
45983 l_component_type_code := 'S';
45984 l_component_appl_id := 222;
45985 l_amb_context_code := 'DEFAULT';
45986 l_entity_code := 'RECEIPTS';
45987 l_event_class_code := 'MISC_RECEIPT';
45988 l_event_type_code := 'MISC_RECEIPT_ALL';
45989 l_line_definition_owner_code := 'S';
45990 l_line_definition_code := 'AR_MISC_RECEIPTS';
45991 --
45992 l_balance_type_code := 'A';
45993 l_segment := NULL;
45994 l_ccid := NULL;
45995 l_adr_transaction_coa_id := NULL;
45996 l_adr_accounting_coa_id := NULL;
45997 l_adr_flexfield_segment_code := NULL;
45998 l_adr_flex_value_set_id := NULL;
45999 l_adr_value_type_code := NULL;
46000 l_adr_value_combination_id := NULL;
46001 l_adr_value_segment_code := NULL;
46002
46003 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
46004 l_bflow_class_code := ''; -- 4219869 Business Flow
46005 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
46006 l_budgetary_control_flag := 'N';
46007
46008 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46009 l_bflow_applied_to_amt := NULL; -- 5132302
46010 l_entered_amt_idx := NULL; -- 4262811
46011 l_accted_amt_idx := NULL; -- 4262811
46012 l_acc_rev_flag := NULL; -- 4262811
46013 l_accrual_line_num := NULL; -- 4262811
46014 l_tmp_amt := NULL; -- 4262811
46015 --
46016
46017 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
46018 l_balance_type_code <> 'B' THEN
46019 IF NVL(p_source_20,'
46020 ') = 'SHORT_TERM_DEBT' AND
46021 NVL(p_source_67,'
46022 ') = 'N'
46023 THEN
46024
46025 --
46026 XLA_AE_LINES_PKG.SetNewLine;
46027
46028 p_balance_type_code := l_balance_type_code;
46029 -- set the flag so later we will know whether the gain loss line needs to be created
46030
46031 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
46032 p_actual_flag :='A';
46033 END IF;
46034
46035 --
46036 -- bulk performance
46037 --
46038 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
46039 p_header_num => 0); -- 4262811
46040 --
46041 -- set accounting line options
46042 --
46043 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
46044 p_natural_side_code => 'C'
46045 , p_gain_or_loss_flag => 'N'
46046 , p_gl_transfer_mode_code => 'S'
46047 , p_acct_entry_type_code => 'A'
46048 , p_switch_side_flag => 'Y'
46049 , p_merge_duplicate_code => 'A'
46050 );
46051 --
46052 l_acc_rev_natural_side_code := 'D'; -- 4262811
46053 --
46054 --
46055 -- set accounting line type info
46056 --
46057 xla_ae_lines_pkg.SetAcctLineType
46058 (p_component_type => l_component_type
46059 ,p_event_type_code => l_event_type_code
46060 ,p_line_definition_owner_code => l_line_definition_owner_code
46061 ,p_line_definition_code => l_line_definition_code
46062 ,p_accounting_line_code => l_component_code
46063 ,p_accounting_line_type_code => l_component_type_code
46064 ,p_accounting_line_appl_id => l_component_appl_id
46065 ,p_amb_context_code => l_amb_context_code
46066 ,p_entity_code => l_entity_code
46067 ,p_event_class_code => l_event_class_code);
46068 --
46069 -- set accounting class
46070 --
46071 xla_ae_lines_pkg.SetAcctClass(
46072 p_accounting_class_code => 'SHORT_TERM_DEBT'
46073 , p_ae_header_id => l_ae_header_id
46074 );
46075
46076 --
46077 -- set rounding class
46078 --
46079 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
46080 'RECEIVABLE';
46081
46082 --
46083 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
46084 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
46085 --
46086 -- bulk performance
46087 --
46088 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
46089
46090 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
46091 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
46092
46093 -- 4955764
46094 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46095 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
46096
46097 -- 4458381 Public Sector Enh
46098
46099 --
46100 -- set accounting attributes for the line type
46101 --
46102 l_entered_amt_idx := 3;
46103 l_accted_amt_idx := 8;
46104 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46105 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
46106 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
46107 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
46108 l_rec_acct_attrs.array_char_value(2) := p_source_23;
46109 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
46110 l_rec_acct_attrs.array_num_value(3) := p_source_24;
46111 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
46112 l_rec_acct_attrs.array_char_value(4) := p_source_25;
46113 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
46114 l_rec_acct_attrs.array_date_value(5) := p_source_57;
46115 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
46116 l_rec_acct_attrs.array_num_value(6) := p_source_27;
46117 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
46118 l_rec_acct_attrs.array_char_value(7) := p_source_28;
46119 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
46120 l_rec_acct_attrs.array_num_value(8) := p_source_29;
46121
46122 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
46123 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
46124
46125 ---------------------------------------------------------------------------------------------------------------
46126 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
46127 ---------------------------------------------------------------------------------------------------------------
46128 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
46129
46130 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46131 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46132
46133 IF xla_accounting_cache_pkg.GetValueChar
46134 (p_source_code => 'LEDGER_CATEGORY_CODE'
46135 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
46136 AND l_bflow_method_code = 'PRIOR_ENTRY'
46137 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
46138 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
46139 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
46140 )
46141 THEN
46142 xla_ae_lines_pkg.BflowUpgEntry
46143 (p_business_method_code => l_bflow_method_code
46144 ,p_business_class_code => l_bflow_class_code
46145 ,p_balance_type => l_balance_type_code);
46146 ELSE
46147 NULL;
46148 -- No business flow processing for business flow method of NONE.
46149 END IF;
46150
46151 --
46152 -- call analytical criteria
46153 --
46154
46155 --
46156 -- call description
46157 --
46158 -- No description or it is inherited.
46159 --
46160 -- call ADRs
46161 -- Bug 4922099
46162 --
46163 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46164 (NVL(l_actual_upg_option, 'N') = 'O') OR
46165 (NVL(l_enc_upg_option, 'N') = 'O')
46166 )
46167 THEN
46168 NULL;
46169 --
46170 --
46171
46172 l_ccid := AcctDerRule_4(
46173 p_application_id => p_application_id
46174 , p_ae_header_id => l_ae_header_id
46175 , p_source_5 => p_source_5
46176 , x_transaction_coa_id => l_adr_transaction_coa_id
46177 , x_accounting_coa_id => l_adr_accounting_coa_id
46178 , x_value_type_code => l_adr_value_type_code
46179 , p_side => 'NA'
46180 );
46181
46182 xla_ae_lines_pkg.set_ccid(
46183 p_code_combination_id => l_ccid
46184 , p_value_type_code => l_adr_value_type_code
46185 , p_transaction_coa_id => l_adr_transaction_coa_id
46186 , p_accounting_coa_id => l_adr_accounting_coa_id
46187 , p_adr_code => 'DIST_CCID'
46188 , p_adr_type_code => 'S'
46189 , p_component_type => l_component_type
46190 , p_component_code => l_component_code
46191 , p_component_type_code => l_component_type_code
46192 , p_component_appl_id => l_component_appl_id
46193 , p_amb_context_code => l_amb_context_code
46194 , p_side => 'NA'
46195 );
46196
46197
46198 --
46199 --
46200 END IF;
46201 --
46202 -- Bug 4922099
46203 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
46204 (NVL(l_enc_upg_option, 'N') = 'O')
46205 ) AND
46206 (l_bflow_method_code = 'PRIOR_ENTRY')
46207 )
46208 THEN
46209 IF
46210 --
46211 1 = 2
46212 --
46213 THEN
46214 xla_accounting_err_pkg.build_message
46215 (p_appli_s_name => 'XLA'
46216 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46217 ,p_token_1 => 'LINE_NUMBER'
46218 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
46219 ,p_token_2 => 'LINE_TYPE_NAME'
46220 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
46221 l_component_type
46222 ,l_component_code
46223 ,l_component_type_code
46224 ,l_component_appl_id
46225 ,l_amb_context_code
46226 ,l_entity_code
46227 ,l_event_class_code
46228 )
46229 ,p_token_3 => 'OWNER'
46230 ,p_value_3 => xla_lookups_pkg.get_meaning(
46231 p_lookup_type => 'XLA_OWNER_TYPE'
46232 ,p_lookup_code => l_component_type_code
46233 )
46234 ,p_token_4 => 'PRODUCT_NAME'
46235 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
46236 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
46237 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
46238 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
46239 ,p_ae_header_id => NULL
46240 );
46241
46242 IF (C_LEVEL_ERROR>= g_log_level) THEN
46243 trace
46244 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46245 ,p_level => C_LEVEL_ERROR
46246 ,p_module => l_log_module);
46247 END IF;
46248 END IF;
46249 END IF;
46250 --
46251 --
46252 ------------------------------------------------------------------------------------------------
46253 -- 4219869 Business Flow
46254 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
46255 -- Prior Entry. Currently, the following code is always generated.
46256 ------------------------------------------------------------------------------------------------
46257 XLA_AE_LINES_PKG.ValidateCurrentLine;
46258
46259 ------------------------------------------------------------------------------------
46260 -- 4219869 Business Flow
46261 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
46262 ------------------------------------------------------------------------------------
46263 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46264
46265 ----------------------------------------------------------------------------------
46266 -- 4219869 Business Flow
46267 -- Update journal entry status -- Need to generate this within IF <condition>
46268 ----------------------------------------------------------------------------------
46269 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46270 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
46271 ,p_balance_type_code => l_balance_type_code
46272 );
46273
46274 -------------------------------------------------------------------------------------------
46275 -- 4262811 - Generate the Accrual Reversal lines
46276 -------------------------------------------------------------------------------------------
46277 BEGIN
46278 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
46279 (g_array_event(p_event_id).array_value_num('header_index'));
46280 IF l_acc_rev_flag IS NULL THEN
46281 l_acc_rev_flag := 'N';
46282 END IF;
46283 EXCEPTION
46284 WHEN OTHERS THEN
46285 l_acc_rev_flag := 'N';
46286 END;
46287 --
46288 IF (l_acc_rev_flag = 'Y') THEN
46289
46290 -- 4645092 ------------------------------------------------------------------------------
46291 -- To allow MPA report to determine if it should generate report process
46292 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
46293 ------------------------------------------------------------------------------------------
46294
46295 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
46296 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
46297 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
46298 -- call ADRs
46299 -- Bug 4922099
46300 --
46301 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46302 (NVL(l_actual_upg_option, 'N') = 'O') OR
46303 (NVL(l_enc_upg_option, 'N') = 'O')
46304 )
46305 THEN
46306 NULL;
46307 --
46308 --
46309
46310 l_ccid := AcctDerRule_4(
46311 p_application_id => p_application_id
46312 , p_ae_header_id => l_ae_header_id
46313 , p_source_5 => p_source_5
46314 , x_transaction_coa_id => l_adr_transaction_coa_id
46315 , x_accounting_coa_id => l_adr_accounting_coa_id
46316 , x_value_type_code => l_adr_value_type_code
46317 , p_side => 'NA'
46318 );
46319
46320 xla_ae_lines_pkg.set_ccid(
46321 p_code_combination_id => l_ccid
46322 , p_value_type_code => l_adr_value_type_code
46323 , p_transaction_coa_id => l_adr_transaction_coa_id
46324 , p_accounting_coa_id => l_adr_accounting_coa_id
46325 , p_adr_code => 'DIST_CCID'
46326 , p_adr_type_code => 'S'
46327 , p_component_type => l_component_type
46328 , p_component_code => l_component_code
46329 , p_component_type_code => l_component_type_code
46330 , p_component_appl_id => l_component_appl_id
46331 , p_amb_context_code => l_amb_context_code
46332 , p_side => 'NA'
46333 );
46334
46335
46336 --
46337 --
46338 END IF;
46339
46340 --
46341 -- Update the line information that should be overwritten
46342 --
46343 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
46344 p_header_num => 1);
46345 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
46346
46347 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
46348
46349 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
46350 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
46351 END IF;
46352
46353 --
46354 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
46355 --
46356 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
46357 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
46358 ELSE
46359 ---------------------------------------------------------------------------------------------------
46360 -- 4262811a Switch Sign
46361 ---------------------------------------------------------------------------------------------------
46362 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
46363 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46364 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46365 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46366 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46367 -- 5132302
46368 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
46369 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46370
46371 END IF;
46372
46373 -- 4955764
46374 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46375 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
46376
46377
46378 XLA_AE_LINES_PKG.ValidateCurrentLine;
46379 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46380
46381 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46382 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
46383 ,p_balance_type_code => l_balance_type_code);
46384
46385 END IF;
46386
46387 -----------------------------------------------------------------------------------------
46388 -- 4262811 Multiperiod Accounting
46389 -----------------------------------------------------------------------------------------
46390 -- No MPA option is assigned.
46391
46392
46393 END IF;
46394 END IF;
46395 --
46396
46397 --
46398 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46399 trace
46400 (p_msg => 'END of AcctLineType_99'
46401 ,p_level => C_LEVEL_PROCEDURE
46402 ,p_module => l_log_module);
46403 END IF;
46404 --
46405 EXCEPTION
46406 WHEN xla_exceptions_pkg.application_exception THEN
46407 RAISE;
46408 WHEN OTHERS THEN
46409 xla_exceptions_pkg.raise_message
46410 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_99');
46411 END AcctLineType_99;
46412 --
46413
46414 ---------------------------------------
46415 --
46416 -- PRIVATE FUNCTION
46417 -- AcctLineType_100
46418 --
46419 ---------------------------------------
46420 PROCEDURE AcctLineType_100 (
46421 p_application_id IN NUMBER
46422 ,p_event_id IN NUMBER
46423 ,p_calculate_acctd_flag IN VARCHAR2
46424 ,p_calculate_g_l_flag IN VARCHAR2
46425 ,p_actual_flag IN OUT VARCHAR2
46426 ,p_balance_type_code OUT VARCHAR2
46427 ,p_gain_or_loss_ref OUT VARCHAR2
46428
46429 --Distribution GL Account
46430 , p_source_5 IN NUMBER
46431 --Distribution Source Type
46432 , p_source_20 IN VARCHAR2
46433 --Distribution Line Identifier
46434 , p_source_22 IN NUMBER
46435 --Distribution Type
46436 , p_source_23 IN VARCHAR2
46437 --Entered Amount
46438 , p_source_24 IN NUMBER
46439 --Currency Code
46440 , p_source_25 IN VARCHAR2
46441 --Exchange Rate
46442 , p_source_27 IN NUMBER
46443 --Exchange Rate Type
46444 , p_source_28 IN VARCHAR2
46445 --Applied To Document Accounting Amount
46446 , p_source_29 IN NUMBER
46447 --Applied To Document Exchange Date
46448 , p_source_57 IN DATE
46449 --Distribution Multi Fund Additional Entry
46450 , p_source_67 IN VARCHAR2
46451 )
46452 IS
46453
46454 l_component_type VARCHAR2(80);
46455 l_component_code VARCHAR2(30);
46456 l_component_type_code VARCHAR2(1);
46457 l_component_appl_id INTEGER;
46458 l_amb_context_code VARCHAR2(30);
46459 l_entity_code VARCHAR2(30);
46460 l_event_class_code VARCHAR2(30);
46461 l_ae_header_id NUMBER;
46462 l_event_type_code VARCHAR2(30);
46466 -- adr variables
46463 l_line_definition_code VARCHAR2(30);
46464 l_line_definition_owner_code VARCHAR2(1);
46465 --
46467 l_segment VARCHAR2(30);
46468 l_ccid NUMBER;
46469 l_adr_transaction_coa_id NUMBER;
46470 l_adr_accounting_coa_id NUMBER;
46471 l_adr_flexfield_segment_code VARCHAR2(30);
46472 l_adr_flex_value_set_id NUMBER;
46473 l_adr_value_type_code VARCHAR2(30);
46474 l_adr_value_combination_id NUMBER;
46475 l_adr_value_segment_code VARCHAR2(30);
46476
46477 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
46478 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
46479 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
46480 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
46481
46482 -- 4262811 Variables ------------------------------------------------------------------------------------------
46483 l_entered_amt_idx NUMBER;
46484 l_accted_amt_idx NUMBER;
46485 l_acc_rev_flag VARCHAR2(1);
46486 l_accrual_line_num NUMBER;
46487 l_tmp_amt NUMBER;
46488 l_acc_rev_natural_side_code VARCHAR2(1);
46489
46490 l_num_entries NUMBER;
46491 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
46492 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
46493 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
46494 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
46495 l_recog_line_1 NUMBER;
46496 l_recog_line_2 NUMBER;
46497
46498 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
46499 l_bflow_applied_to_amt NUMBER; -- 5132302
46500 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
46501
46502 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
46503
46504 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
46505 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
46506
46507 ---------------------------------------------------------------------------------------------------------------
46508
46509
46510 --
46511 -- bulk performance
46512 --
46513 l_balance_type_code VARCHAR2(1);
46514 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
46515 l_log_module VARCHAR2(240);
46516
46517 --
46518 -- Upgrade strategy
46519 --
46520 l_actual_upg_option VARCHAR2(1);
46521 l_enc_upg_option VARCHAR2(1);
46522
46523 --
46524 BEGIN
46525 --
46526 IF g_log_enabled THEN
46527 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_100';
46528 END IF;
46529 --
46530 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46531
46532 trace
46533 (p_msg => 'BEGIN of AcctLineType_100'
46534 ,p_level => C_LEVEL_PROCEDURE
46535 ,p_module => l_log_module);
46536
46537 END IF;
46538 --
46539 l_component_type := 'AMB_JLT';
46540 l_component_code := 'MISC_RCT_FACTOR';
46541 l_component_type_code := 'S';
46542 l_component_appl_id := 222;
46543 l_amb_context_code := 'DEFAULT';
46544 l_entity_code := 'RECEIPTS';
46545 l_event_class_code := 'MISC_RECEIPT';
46546 l_event_type_code := 'MISC_RECEIPT_ALL';
46547 l_line_definition_owner_code := 'S';
46548 l_line_definition_code := 'AR_MISC_RECEIPTS';
46549 --
46550 l_balance_type_code := 'A';
46551 l_segment := NULL;
46552 l_ccid := NULL;
46553 l_adr_transaction_coa_id := NULL;
46554 l_adr_accounting_coa_id := NULL;
46555 l_adr_flexfield_segment_code := NULL;
46556 l_adr_flex_value_set_id := NULL;
46557 l_adr_value_type_code := NULL;
46558 l_adr_value_combination_id := NULL;
46559 l_adr_value_segment_code := NULL;
46560
46561 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
46562 l_bflow_class_code := ''; -- 4219869 Business Flow
46563 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
46564 l_budgetary_control_flag := 'N';
46565
46566 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46567 l_bflow_applied_to_amt := NULL; -- 5132302
46568 l_entered_amt_idx := NULL; -- 4262811
46569 l_accted_amt_idx := NULL; -- 4262811
46570 l_acc_rev_flag := NULL; -- 4262811
46571 l_accrual_line_num := NULL; -- 4262811
46572 l_tmp_amt := NULL; -- 4262811
46573 --
46574
46575 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
46576 l_balance_type_code <> 'B' THEN
46577 IF NVL(p_source_20,'
46578 ') = 'FACTOR' AND
46579 NVL(p_source_67,'
46580 ') = 'N'
46581 THEN
46582
46583 --
46584 XLA_AE_LINES_PKG.SetNewLine;
46585
46586 p_balance_type_code := l_balance_type_code;
46587 -- set the flag so later we will know whether the gain loss line needs to be created
46588
46589 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
46590 p_actual_flag :='A';
46591 END IF;
46592
46593 --
46594 -- bulk performance
46595 --
46596 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
46597 p_header_num => 0); -- 4262811
46598 --
46599 -- set accounting line options
46600 --
46601 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
46602 p_natural_side_code => 'C'
46603 , p_gain_or_loss_flag => 'N'
46604 , p_gl_transfer_mode_code => 'S'
46605 , p_acct_entry_type_code => 'A'
46606 , p_switch_side_flag => 'Y'
46607 , p_merge_duplicate_code => 'A'
46608 );
46609 --
46610 l_acc_rev_natural_side_code := 'D'; -- 4262811
46611 --
46612 --
46613 -- set accounting line type info
46614 --
46615 xla_ae_lines_pkg.SetAcctLineType
46616 (p_component_type => l_component_type
46617 ,p_event_type_code => l_event_type_code
46618 ,p_line_definition_owner_code => l_line_definition_owner_code
46619 ,p_line_definition_code => l_line_definition_code
46620 ,p_accounting_line_code => l_component_code
46621 ,p_accounting_line_type_code => l_component_type_code
46622 ,p_accounting_line_appl_id => l_component_appl_id
46623 ,p_amb_context_code => l_amb_context_code
46624 ,p_entity_code => l_entity_code
46625 ,p_event_class_code => l_event_class_code);
46626 --
46627 -- set accounting class
46628 --
46629 xla_ae_lines_pkg.SetAcctClass(
46630 p_accounting_class_code => 'FACTOR'
46631 , p_ae_header_id => l_ae_header_id
46632 );
46633
46634 --
46635 -- set rounding class
46636 --
46637 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
46638 'RECEIVABLE';
46639
46640 --
46641 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
46642 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
46643 --
46644 -- bulk performance
46645 --
46646 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
46647
46648 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
46649 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
46650
46651 -- 4955764
46652 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46653 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
46654
46655 -- 4458381 Public Sector Enh
46656
46657 --
46658 -- set accounting attributes for the line type
46659 --
46660 l_entered_amt_idx := 3;
46661 l_accted_amt_idx := 8;
46662 l_bflow_applied_to_amt_idx := NULL; -- 5132302
46663 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
46664 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
46665 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
46666 l_rec_acct_attrs.array_char_value(2) := p_source_23;
46667 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
46668 l_rec_acct_attrs.array_num_value(3) := p_source_24;
46669 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
46670 l_rec_acct_attrs.array_char_value(4) := p_source_25;
46671 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
46672 l_rec_acct_attrs.array_date_value(5) := p_source_57;
46673 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
46674 l_rec_acct_attrs.array_num_value(6) := p_source_27;
46675 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
46676 l_rec_acct_attrs.array_char_value(7) := p_source_28;
46677 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
46678 l_rec_acct_attrs.array_num_value(8) := p_source_29;
46679
46680 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
46681 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
46682
46683 ---------------------------------------------------------------------------------------------------------------
46684 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
46685 ---------------------------------------------------------------------------------------------------------------
46686 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
46687
46688 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46689 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
46690
46691 IF xla_accounting_cache_pkg.GetValueChar
46692 (p_source_code => 'LEDGER_CATEGORY_CODE'
46693 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
46694 AND l_bflow_method_code = 'PRIOR_ENTRY'
46695 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
46696 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
46697 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
46698 )
46699 THEN
46700 xla_ae_lines_pkg.BflowUpgEntry
46701 (p_business_method_code => l_bflow_method_code
46702 ,p_business_class_code => l_bflow_class_code
46703 ,p_balance_type => l_balance_type_code);
46704 ELSE
46705 NULL;
46706 -- No business flow processing for business flow method of NONE.
46707 END IF;
46708
46709 --
46710 -- call analytical criteria
46711 --
46712
46713 --
46714 -- call description
46715 --
46716 -- No description or it is inherited.
46717 --
46718 -- call ADRs
46719 -- Bug 4922099
46720 --
46721 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46722 (NVL(l_actual_upg_option, 'N') = 'O') OR
46723 (NVL(l_enc_upg_option, 'N') = 'O')
46724 )
46725 THEN
46726 NULL;
46727 --
46728 --
46729
46730 l_ccid := AcctDerRule_4(
46731 p_application_id => p_application_id
46732 , p_ae_header_id => l_ae_header_id
46733 , p_source_5 => p_source_5
46734 , x_transaction_coa_id => l_adr_transaction_coa_id
46735 , x_accounting_coa_id => l_adr_accounting_coa_id
46736 , x_value_type_code => l_adr_value_type_code
46737 , p_side => 'NA'
46738 );
46739
46740 xla_ae_lines_pkg.set_ccid(
46741 p_code_combination_id => l_ccid
46742 , p_value_type_code => l_adr_value_type_code
46743 , p_transaction_coa_id => l_adr_transaction_coa_id
46744 , p_accounting_coa_id => l_adr_accounting_coa_id
46745 , p_adr_code => 'DIST_CCID'
46746 , p_adr_type_code => 'S'
46747 , p_component_type => l_component_type
46748 , p_component_code => l_component_code
46749 , p_component_type_code => l_component_type_code
46750 , p_component_appl_id => l_component_appl_id
46751 , p_amb_context_code => l_amb_context_code
46752 , p_side => 'NA'
46753 );
46754
46755
46756 --
46757 --
46758 END IF;
46759 --
46760 -- Bug 4922099
46761 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
46762 (NVL(l_enc_upg_option, 'N') = 'O')
46763 ) AND
46764 (l_bflow_method_code = 'PRIOR_ENTRY')
46765 )
46766 THEN
46767 IF
46768 --
46769 1 = 2
46770 --
46771 THEN
46772 xla_accounting_err_pkg.build_message
46773 (p_appli_s_name => 'XLA'
46774 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46775 ,p_token_1 => 'LINE_NUMBER'
46776 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
46777 ,p_token_2 => 'LINE_TYPE_NAME'
46778 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
46779 l_component_type
46780 ,l_component_code
46781 ,l_component_type_code
46782 ,l_component_appl_id
46783 ,l_amb_context_code
46784 ,l_entity_code
46785 ,l_event_class_code
46786 )
46787 ,p_token_3 => 'OWNER'
46788 ,p_value_3 => xla_lookups_pkg.get_meaning(
46789 p_lookup_type => 'XLA_OWNER_TYPE'
46790 ,p_lookup_code => l_component_type_code
46791 )
46792 ,p_token_4 => 'PRODUCT_NAME'
46793 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
46794 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
46795 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
46796 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
46797 ,p_ae_header_id => NULL
46798 );
46799
46800 IF (C_LEVEL_ERROR>= g_log_level) THEN
46801 trace
46802 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
46803 ,p_level => C_LEVEL_ERROR
46804 ,p_module => l_log_module);
46805 END IF;
46806 END IF;
46807 END IF;
46808 --
46809 --
46810 ------------------------------------------------------------------------------------------------
46811 -- 4219869 Business Flow
46812 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
46813 -- Prior Entry. Currently, the following code is always generated.
46814 ------------------------------------------------------------------------------------------------
46815 XLA_AE_LINES_PKG.ValidateCurrentLine;
46816
46817 ------------------------------------------------------------------------------------
46818 -- 4219869 Business Flow
46819 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
46820 ------------------------------------------------------------------------------------
46821 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46822
46823 ----------------------------------------------------------------------------------
46824 -- 4219869 Business Flow
46825 -- Update journal entry status -- Need to generate this within IF <condition>
46826 ----------------------------------------------------------------------------------
46827 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46828 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
46829 ,p_balance_type_code => l_balance_type_code
46830 );
46831
46832 -------------------------------------------------------------------------------------------
46833 -- 4262811 - Generate the Accrual Reversal lines
46834 -------------------------------------------------------------------------------------------
46835 BEGIN
46836 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
46837 (g_array_event(p_event_id).array_value_num('header_index'));
46838 IF l_acc_rev_flag IS NULL THEN
46839 l_acc_rev_flag := 'N';
46840 END IF;
46841 EXCEPTION
46842 WHEN OTHERS THEN
46843 l_acc_rev_flag := 'N';
46844 END;
46845 --
46846 IF (l_acc_rev_flag = 'Y') THEN
46847
46848 -- 4645092 ------------------------------------------------------------------------------
46849 -- To allow MPA report to determine if it should generate report process
46850 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
46851 ------------------------------------------------------------------------------------------
46852
46853 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
46854 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
46855 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
46856 -- call ADRs
46857 -- Bug 4922099
46858 --
46859 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
46860 (NVL(l_actual_upg_option, 'N') = 'O') OR
46861 (NVL(l_enc_upg_option, 'N') = 'O')
46862 )
46863 THEN
46864 NULL;
46865 --
46866 --
46867
46868 l_ccid := AcctDerRule_4(
46869 p_application_id => p_application_id
46870 , p_ae_header_id => l_ae_header_id
46871 , p_source_5 => p_source_5
46872 , x_transaction_coa_id => l_adr_transaction_coa_id
46873 , x_accounting_coa_id => l_adr_accounting_coa_id
46874 , x_value_type_code => l_adr_value_type_code
46875 , p_side => 'NA'
46876 );
46877
46878 xla_ae_lines_pkg.set_ccid(
46879 p_code_combination_id => l_ccid
46880 , p_value_type_code => l_adr_value_type_code
46881 , p_transaction_coa_id => l_adr_transaction_coa_id
46882 , p_accounting_coa_id => l_adr_accounting_coa_id
46883 , p_adr_code => 'DIST_CCID'
46884 , p_adr_type_code => 'S'
46885 , p_component_type => l_component_type
46886 , p_component_code => l_component_code
46887 , p_component_type_code => l_component_type_code
46888 , p_component_appl_id => l_component_appl_id
46889 , p_amb_context_code => l_amb_context_code
46890 , p_side => 'NA'
46891 );
46892
46893
46894 --
46895 --
46896 END IF;
46897
46898 --
46899 -- Update the line information that should be overwritten
46900 --
46901 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
46902 p_header_num => 1);
46903 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
46904
46905 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
46906
46907 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
46908 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
46909 END IF;
46910
46911 --
46912 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
46913 --
46914 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
46915 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
46916 ELSE
46917 ---------------------------------------------------------------------------------------------------
46918 -- 4262811a Switch Sign
46919 ---------------------------------------------------------------------------------------------------
46920 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
46921 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46922 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46923 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
46924 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46925 -- 5132302
46926 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
46927 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
46928
46929 END IF;
46930
46931 -- 4955764
46932 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
46933 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
46934
46935
46936 XLA_AE_LINES_PKG.ValidateCurrentLine;
46937 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
46938
46939 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
46940 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
46941 ,p_balance_type_code => l_balance_type_code);
46942
46943 END IF;
46944
46945 -----------------------------------------------------------------------------------------
46946 -- 4262811 Multiperiod Accounting
46947 -----------------------------------------------------------------------------------------
46948 -- No MPA option is assigned.
46949
46950
46951 END IF;
46952 END IF;
46953 --
46954
46955 --
46956 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
46957 trace
46958 (p_msg => 'END of AcctLineType_100'
46959 ,p_level => C_LEVEL_PROCEDURE
46960 ,p_module => l_log_module);
46961 END IF;
46962 --
46963 EXCEPTION
46964 WHEN xla_exceptions_pkg.application_exception THEN
46965 RAISE;
46966 WHEN OTHERS THEN
46967 xla_exceptions_pkg.raise_message
46968 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_100');
46969 END AcctLineType_100;
46970 --
46971
46972 ---------------------------------------
46973 --
46974 -- PRIVATE FUNCTION
46975 -- AcctLineType_101
46976 --
46977 ---------------------------------------
46978 PROCEDURE AcctLineType_101 (
46979 p_application_id IN NUMBER
46980 ,p_event_id IN NUMBER
46981 ,p_calculate_acctd_flag IN VARCHAR2
46982 ,p_calculate_g_l_flag IN VARCHAR2
46983 ,p_actual_flag IN OUT VARCHAR2
46984 ,p_balance_type_code OUT VARCHAR2
46985 ,p_gain_or_loss_ref OUT VARCHAR2
46986
46987 --Distribution GL Account
46988 , p_source_5 IN NUMBER
46989 --Distribution Source Type
46990 , p_source_20 IN VARCHAR2
46991 --Distribution Line Identifier
46992 , p_source_22 IN NUMBER
46993 --Distribution Type
46994 , p_source_23 IN VARCHAR2
46995 --Entered Amount
46996 , p_source_24 IN NUMBER
46997 --Currency Code
46998 , p_source_25 IN VARCHAR2
46999 --Exchange Rate
47000 , p_source_27 IN NUMBER
47001 --Exchange Rate Type
47002 , p_source_28 IN VARCHAR2
47003 --Applied To Document Accounting Amount
47004 , p_source_29 IN NUMBER
47005 --Applied To Document Exchange Date
47006 , p_source_57 IN DATE
47007 --Distribution Multi Fund Additional Entry
47008 , p_source_67 IN VARCHAR2
47009 )
47010 IS
47011
47012 l_component_type VARCHAR2(80);
47013 l_component_code VARCHAR2(30);
47014 l_component_type_code VARCHAR2(1);
47015 l_component_appl_id INTEGER;
47016 l_amb_context_code VARCHAR2(30);
47017 l_entity_code VARCHAR2(30);
47018 l_event_class_code VARCHAR2(30);
47019 l_ae_header_id NUMBER;
47020 l_event_type_code VARCHAR2(30);
47021 l_line_definition_code VARCHAR2(30);
47022 l_line_definition_owner_code VARCHAR2(1);
47023 --
47024 -- adr variables
47025 l_segment VARCHAR2(30);
47026 l_ccid NUMBER;
47027 l_adr_transaction_coa_id NUMBER;
47028 l_adr_accounting_coa_id NUMBER;
47029 l_adr_flexfield_segment_code VARCHAR2(30);
47030 l_adr_flex_value_set_id NUMBER;
47031 l_adr_value_type_code VARCHAR2(30);
47032 l_adr_value_combination_id NUMBER;
47033 l_adr_value_segment_code VARCHAR2(30);
47034
47035 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
47036 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
47037 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
47038 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
47039
47040 -- 4262811 Variables ------------------------------------------------------------------------------------------
47041 l_entered_amt_idx NUMBER;
47042 l_accted_amt_idx NUMBER;
47043 l_acc_rev_flag VARCHAR2(1);
47044 l_accrual_line_num NUMBER;
47045 l_tmp_amt NUMBER;
47046 l_acc_rev_natural_side_code VARCHAR2(1);
47047
47048 l_num_entries NUMBER;
47049 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
47050 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
47051 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
47052 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
47053 l_recog_line_1 NUMBER;
47054 l_recog_line_2 NUMBER;
47055
47056 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
47057 l_bflow_applied_to_amt NUMBER; -- 5132302
47058 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
47059
47060 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
47061
47062 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
47066
47063 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
47064
47065 ---------------------------------------------------------------------------------------------------------------
47067
47068 --
47069 -- bulk performance
47070 --
47071 l_balance_type_code VARCHAR2(1);
47072 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
47073 l_log_module VARCHAR2(240);
47074
47075 --
47076 -- Upgrade strategy
47077 --
47078 l_actual_upg_option VARCHAR2(1);
47079 l_enc_upg_option VARCHAR2(1);
47080
47081 --
47082 BEGIN
47083 --
47084 IF g_log_enabled THEN
47085 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_101';
47086 END IF;
47087 --
47088 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
47089
47090 trace
47091 (p_msg => 'BEGIN of AcctLineType_101'
47092 ,p_level => C_LEVEL_PROCEDURE
47093 ,p_module => l_log_module);
47094
47095 END IF;
47096 --
47097 l_component_type := 'AMB_JLT';
47098 l_component_code := 'MISC_RCT_MISCCASH';
47099 l_component_type_code := 'S';
47100 l_component_appl_id := 222;
47101 l_amb_context_code := 'DEFAULT';
47102 l_entity_code := 'RECEIPTS';
47103 l_event_class_code := 'MISC_RECEIPT';
47104 l_event_type_code := 'MISC_RECEIPT_ALL';
47105 l_line_definition_owner_code := 'S';
47106 l_line_definition_code := 'AR_MISC_RECEIPTS';
47107 --
47108 l_balance_type_code := 'A';
47109 l_segment := NULL;
47110 l_ccid := NULL;
47111 l_adr_transaction_coa_id := NULL;
47112 l_adr_accounting_coa_id := NULL;
47113 l_adr_flexfield_segment_code := NULL;
47114 l_adr_flex_value_set_id := NULL;
47115 l_adr_value_type_code := NULL;
47116 l_adr_value_combination_id := NULL;
47117 l_adr_value_segment_code := NULL;
47118
47119 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
47120 l_bflow_class_code := ''; -- 4219869 Business Flow
47121 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
47122 l_budgetary_control_flag := 'N';
47123
47124 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47125 l_bflow_applied_to_amt := NULL; -- 5132302
47126 l_entered_amt_idx := NULL; -- 4262811
47127 l_accted_amt_idx := NULL; -- 4262811
47128 l_acc_rev_flag := NULL; -- 4262811
47129 l_accrual_line_num := NULL; -- 4262811
47130 l_tmp_amt := NULL; -- 4262811
47131 --
47132
47133 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
47134 l_balance_type_code <> 'B' THEN
47135 IF NVL(p_source_20,'
47136 ') = 'MISCCASH' AND
47137 NVL(p_source_67,'
47138 ') = 'N'
47139 THEN
47140
47141 --
47142 XLA_AE_LINES_PKG.SetNewLine;
47143
47144 p_balance_type_code := l_balance_type_code;
47145 -- set the flag so later we will know whether the gain loss line needs to be created
47146
47147 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
47148 p_actual_flag :='A';
47149 END IF;
47150
47151 --
47152 -- bulk performance
47153 --
47154 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
47155 p_header_num => 0); -- 4262811
47156 --
47157 -- set accounting line options
47158 --
47159 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
47160 p_natural_side_code => 'C'
47161 , p_gain_or_loss_flag => 'N'
47162 , p_gl_transfer_mode_code => 'S'
47163 , p_acct_entry_type_code => 'A'
47164 , p_switch_side_flag => 'Y'
47165 , p_merge_duplicate_code => 'A'
47166 );
47167 --
47168 l_acc_rev_natural_side_code := 'D'; -- 4262811
47169 --
47170 --
47171 -- set accounting line type info
47172 --
47173 xla_ae_lines_pkg.SetAcctLineType
47174 (p_component_type => l_component_type
47175 ,p_event_type_code => l_event_type_code
47176 ,p_line_definition_owner_code => l_line_definition_owner_code
47177 ,p_line_definition_code => l_line_definition_code
47178 ,p_accounting_line_code => l_component_code
47179 ,p_accounting_line_type_code => l_component_type_code
47180 ,p_accounting_line_appl_id => l_component_appl_id
47181 ,p_amb_context_code => l_amb_context_code
47182 ,p_entity_code => l_entity_code
47183 ,p_event_class_code => l_event_class_code);
47184 --
47185 -- set accounting class
47186 --
47187 xla_ae_lines_pkg.SetAcctClass(
47188 p_accounting_class_code => 'MISC_CASH'
47189 , p_ae_header_id => l_ae_header_id
47190 );
47191
47192 --
47193 -- set rounding class
47194 --
47195 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
47196 'RECEIVABLE';
47197
47198 --
47199 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
47200 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
47201 --
47202 -- bulk performance
47203 --
47204 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
47205
47206 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
47207 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
47208
47209 -- 4955764
47210 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47211 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
47212
47213 -- 4458381 Public Sector Enh
47214
47215 --
47216 -- set accounting attributes for the line type
47217 --
47218 l_entered_amt_idx := 3;
47219 l_accted_amt_idx := 8;
47220 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47221 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
47222 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
47223 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
47224 l_rec_acct_attrs.array_char_value(2) := p_source_23;
47225 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
47226 l_rec_acct_attrs.array_num_value(3) := p_source_24;
47227 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
47228 l_rec_acct_attrs.array_char_value(4) := p_source_25;
47229 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
47230 l_rec_acct_attrs.array_date_value(5) := p_source_57;
47231 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
47232 l_rec_acct_attrs.array_num_value(6) := p_source_27;
47233 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
47234 l_rec_acct_attrs.array_char_value(7) := p_source_28;
47235 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
47236 l_rec_acct_attrs.array_num_value(8) := p_source_29;
47237
47238 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
47239 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
47240
47241 ---------------------------------------------------------------------------------------------------------------
47242 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
47243 ---------------------------------------------------------------------------------------------------------------
47244 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
47245
47246 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47247 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47248
47249 IF xla_accounting_cache_pkg.GetValueChar
47250 (p_source_code => 'LEDGER_CATEGORY_CODE'
47251 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
47252 AND l_bflow_method_code = 'PRIOR_ENTRY'
47253 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
47254 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
47255 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
47256 )
47257 THEN
47258 xla_ae_lines_pkg.BflowUpgEntry
47259 (p_business_method_code => l_bflow_method_code
47260 ,p_business_class_code => l_bflow_class_code
47261 ,p_balance_type => l_balance_type_code);
47262 ELSE
47263 NULL;
47264 -- No business flow processing for business flow method of NONE.
47265 END IF;
47266
47267 --
47268 -- call analytical criteria
47269 --
47270
47271 --
47272 -- call description
47273 --
47274 -- No description or it is inherited.
47275 --
47276 -- call ADRs
47277 -- Bug 4922099
47278 --
47279 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47280 (NVL(l_actual_upg_option, 'N') = 'O') OR
47281 (NVL(l_enc_upg_option, 'N') = 'O')
47282 )
47283 THEN
47284 NULL;
47285 --
47286 --
47287
47288 l_ccid := AcctDerRule_4(
47289 p_application_id => p_application_id
47290 , p_ae_header_id => l_ae_header_id
47291 , p_source_5 => p_source_5
47292 , x_transaction_coa_id => l_adr_transaction_coa_id
47293 , x_accounting_coa_id => l_adr_accounting_coa_id
47294 , x_value_type_code => l_adr_value_type_code
47295 , p_side => 'NA'
47296 );
47297
47298 xla_ae_lines_pkg.set_ccid(
47299 p_code_combination_id => l_ccid
47300 , p_value_type_code => l_adr_value_type_code
47304 , p_adr_type_code => 'S'
47301 , p_transaction_coa_id => l_adr_transaction_coa_id
47302 , p_accounting_coa_id => l_adr_accounting_coa_id
47303 , p_adr_code => 'DIST_CCID'
47305 , p_component_type => l_component_type
47306 , p_component_code => l_component_code
47307 , p_component_type_code => l_component_type_code
47308 , p_component_appl_id => l_component_appl_id
47309 , p_amb_context_code => l_amb_context_code
47310 , p_side => 'NA'
47311 );
47312
47313
47314 --
47315 --
47316 END IF;
47317 --
47318 -- Bug 4922099
47319 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
47320 (NVL(l_enc_upg_option, 'N') = 'O')
47321 ) AND
47322 (l_bflow_method_code = 'PRIOR_ENTRY')
47323 )
47324 THEN
47325 IF
47326 --
47327 1 = 2
47328 --
47329 THEN
47330 xla_accounting_err_pkg.build_message
47331 (p_appli_s_name => 'XLA'
47332 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47333 ,p_token_1 => 'LINE_NUMBER'
47334 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
47335 ,p_token_2 => 'LINE_TYPE_NAME'
47336 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
47337 l_component_type
47338 ,l_component_code
47339 ,l_component_type_code
47340 ,l_component_appl_id
47341 ,l_amb_context_code
47342 ,l_entity_code
47343 ,l_event_class_code
47344 )
47345 ,p_token_3 => 'OWNER'
47346 ,p_value_3 => xla_lookups_pkg.get_meaning(
47347 p_lookup_type => 'XLA_OWNER_TYPE'
47348 ,p_lookup_code => l_component_type_code
47349 )
47350 ,p_token_4 => 'PRODUCT_NAME'
47351 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
47352 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
47353 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
47354 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
47355 ,p_ae_header_id => NULL
47356 );
47357
47358 IF (C_LEVEL_ERROR>= g_log_level) THEN
47359 trace
47360 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47361 ,p_level => C_LEVEL_ERROR
47362 ,p_module => l_log_module);
47363 END IF;
47364 END IF;
47365 END IF;
47366 --
47367 --
47368 ------------------------------------------------------------------------------------------------
47369 -- 4219869 Business Flow
47370 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
47371 -- Prior Entry. Currently, the following code is always generated.
47372 ------------------------------------------------------------------------------------------------
47373 XLA_AE_LINES_PKG.ValidateCurrentLine;
47374
47375 ------------------------------------------------------------------------------------
47376 -- 4219869 Business Flow
47377 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
47378 ------------------------------------------------------------------------------------
47379 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47380
47381 ----------------------------------------------------------------------------------
47382 -- 4219869 Business Flow
47383 -- Update journal entry status -- Need to generate this within IF <condition>
47384 ----------------------------------------------------------------------------------
47385 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47386 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
47387 ,p_balance_type_code => l_balance_type_code
47388 );
47389
47390 -------------------------------------------------------------------------------------------
47391 -- 4262811 - Generate the Accrual Reversal lines
47392 -------------------------------------------------------------------------------------------
47393 BEGIN
47394 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
47395 (g_array_event(p_event_id).array_value_num('header_index'));
47396 IF l_acc_rev_flag IS NULL THEN
47397 l_acc_rev_flag := 'N';
47398 END IF;
47399 EXCEPTION
47400 WHEN OTHERS THEN
47401 l_acc_rev_flag := 'N';
47402 END;
47403 --
47404 IF (l_acc_rev_flag = 'Y') THEN
47405
47409 ------------------------------------------------------------------------------------------
47406 -- 4645092 ------------------------------------------------------------------------------
47407 -- To allow MPA report to determine if it should generate report process
47408 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
47410
47411 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
47412 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
47413 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
47414 -- call ADRs
47415 -- Bug 4922099
47416 --
47417 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47418 (NVL(l_actual_upg_option, 'N') = 'O') OR
47419 (NVL(l_enc_upg_option, 'N') = 'O')
47420 )
47421 THEN
47422 NULL;
47423 --
47424 --
47425
47426 l_ccid := AcctDerRule_4(
47427 p_application_id => p_application_id
47428 , p_ae_header_id => l_ae_header_id
47429 , p_source_5 => p_source_5
47430 , x_transaction_coa_id => l_adr_transaction_coa_id
47431 , x_accounting_coa_id => l_adr_accounting_coa_id
47432 , x_value_type_code => l_adr_value_type_code
47433 , p_side => 'NA'
47434 );
47435
47436 xla_ae_lines_pkg.set_ccid(
47437 p_code_combination_id => l_ccid
47438 , p_value_type_code => l_adr_value_type_code
47439 , p_transaction_coa_id => l_adr_transaction_coa_id
47440 , p_accounting_coa_id => l_adr_accounting_coa_id
47441 , p_adr_code => 'DIST_CCID'
47442 , p_adr_type_code => 'S'
47443 , p_component_type => l_component_type
47444 , p_component_code => l_component_code
47445 , p_component_type_code => l_component_type_code
47446 , p_component_appl_id => l_component_appl_id
47447 , p_amb_context_code => l_amb_context_code
47448 , p_side => 'NA'
47449 );
47450
47451
47452 --
47453 --
47454 END IF;
47455
47456 --
47457 -- Update the line information that should be overwritten
47458 --
47459 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
47460 p_header_num => 1);
47461 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
47462
47463 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
47464
47465 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
47466 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
47467 END IF;
47468
47469 --
47470 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
47471 --
47472 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
47473 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
47474 ELSE
47475 ---------------------------------------------------------------------------------------------------
47476 -- 4262811a Switch Sign
47477 ---------------------------------------------------------------------------------------------------
47478 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
47479 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
47480 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47481 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
47482 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47483 -- 5132302
47484 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
47485 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
47486
47487 END IF;
47488
47489 -- 4955764
47490 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47491 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
47492
47493
47494 XLA_AE_LINES_PKG.ValidateCurrentLine;
47495 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47496
47497 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47498 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
47499 ,p_balance_type_code => l_balance_type_code);
47500
47501 END IF;
47502
47503 -----------------------------------------------------------------------------------------
47504 -- 4262811 Multiperiod Accounting
47505 -----------------------------------------------------------------------------------------
47506 -- No MPA option is assigned.
47507
47508
47509 END IF;
47510 END IF;
47511 --
47512
47513 --
47514 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
47515 trace
47516 (p_msg => 'END of AcctLineType_101'
47517 ,p_level => C_LEVEL_PROCEDURE
47518 ,p_module => l_log_module);
47519 END IF;
47520 --
47521 EXCEPTION
47522 WHEN xla_exceptions_pkg.application_exception THEN
47523 RAISE;
47524 WHEN OTHERS THEN
47525 xla_exceptions_pkg.raise_message
47526 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_101');
47527 END AcctLineType_101;
47528 --
47529
47533 -- AcctLineType_102
47530 ---------------------------------------
47531 --
47532 -- PRIVATE FUNCTION
47534 --
47535 ---------------------------------------
47536 PROCEDURE AcctLineType_102 (
47537 p_application_id IN NUMBER
47538 ,p_event_id IN NUMBER
47539 ,p_calculate_acctd_flag IN VARCHAR2
47540 ,p_calculate_g_l_flag IN VARCHAR2
47541 ,p_actual_flag IN OUT VARCHAR2
47542 ,p_balance_type_code OUT VARCHAR2
47543 ,p_gain_or_loss_ref OUT VARCHAR2
47544
47545 --Distribution GL Account
47546 , p_source_5 IN NUMBER
47547 --Distribution Source Type
47548 , p_source_20 IN VARCHAR2
47549 --Distribution Line Identifier
47550 , p_source_22 IN NUMBER
47551 --Distribution Type
47552 , p_source_23 IN VARCHAR2
47553 --Entered Amount
47554 , p_source_24 IN NUMBER
47555 --Currency Code
47556 , p_source_25 IN VARCHAR2
47557 --Exchange Rate
47558 , p_source_27 IN NUMBER
47559 --Exchange Rate Type
47560 , p_source_28 IN VARCHAR2
47561 --Applied To Document Accounting Amount
47562 , p_source_29 IN NUMBER
47563 --Applied To Document Exchange Date
47564 , p_source_57 IN DATE
47565 --Distribution Multi Fund Additional Entry
47566 , p_source_67 IN VARCHAR2
47567 )
47568 IS
47569
47570 l_component_type VARCHAR2(80);
47571 l_component_code VARCHAR2(30);
47572 l_component_type_code VARCHAR2(1);
47573 l_component_appl_id INTEGER;
47574 l_amb_context_code VARCHAR2(30);
47575 l_entity_code VARCHAR2(30);
47576 l_event_class_code VARCHAR2(30);
47577 l_ae_header_id NUMBER;
47578 l_event_type_code VARCHAR2(30);
47579 l_line_definition_code VARCHAR2(30);
47580 l_line_definition_owner_code VARCHAR2(1);
47581 --
47582 -- adr variables
47583 l_segment VARCHAR2(30);
47584 l_ccid NUMBER;
47585 l_adr_transaction_coa_id NUMBER;
47586 l_adr_accounting_coa_id NUMBER;
47587 l_adr_flexfield_segment_code VARCHAR2(30);
47588 l_adr_flex_value_set_id NUMBER;
47589 l_adr_value_type_code VARCHAR2(30);
47590 l_adr_value_combination_id NUMBER;
47591 l_adr_value_segment_code VARCHAR2(30);
47592
47593 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
47594 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
47595 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
47596 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
47597
47598 -- 4262811 Variables ------------------------------------------------------------------------------------------
47599 l_entered_amt_idx NUMBER;
47600 l_accted_amt_idx NUMBER;
47601 l_acc_rev_flag VARCHAR2(1);
47602 l_accrual_line_num NUMBER;
47603 l_tmp_amt NUMBER;
47604 l_acc_rev_natural_side_code VARCHAR2(1);
47605
47606 l_num_entries NUMBER;
47607 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
47608 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
47609 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
47610 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
47611 l_recog_line_1 NUMBER;
47612 l_recog_line_2 NUMBER;
47613
47614 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
47615 l_bflow_applied_to_amt NUMBER; -- 5132302
47616 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
47617
47618 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
47619
47620 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
47621 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
47622
47623 ---------------------------------------------------------------------------------------------------------------
47624
47625
47626 --
47627 -- bulk performance
47628 --
47629 l_balance_type_code VARCHAR2(1);
47630 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
47631 l_log_module VARCHAR2(240);
47632
47633 --
47634 -- Upgrade strategy
47635 --
47636 l_actual_upg_option VARCHAR2(1);
47637 l_enc_upg_option VARCHAR2(1);
47638
47639 --
47640 BEGIN
47641 --
47642 IF g_log_enabled THEN
47643 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_102';
47644 END IF;
47645 --
47646 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
47647
47648 trace
47649 (p_msg => 'BEGIN of AcctLineType_102'
47650 ,p_level => C_LEVEL_PROCEDURE
47651 ,p_module => l_log_module);
47652
47653 END IF;
47654 --
47655 l_component_type := 'AMB_JLT';
47656 l_component_code := 'MISC_RCT_REMIT';
47657 l_component_type_code := 'S';
47658 l_component_appl_id := 222;
47659 l_amb_context_code := 'DEFAULT';
47660 l_entity_code := 'RECEIPTS';
47661 l_event_class_code := 'MISC_RECEIPT';
47662 l_event_type_code := 'MISC_RECEIPT_ALL';
47663 l_line_definition_owner_code := 'S';
47664 l_line_definition_code := 'AR_MISC_RECEIPTS';
47665 --
47666 l_balance_type_code := 'A';
47667 l_segment := NULL;
47668 l_ccid := NULL;
47669 l_adr_transaction_coa_id := NULL;
47670 l_adr_accounting_coa_id := NULL;
47674 l_adr_value_combination_id := NULL;
47671 l_adr_flexfield_segment_code := NULL;
47672 l_adr_flex_value_set_id := NULL;
47673 l_adr_value_type_code := NULL;
47675 l_adr_value_segment_code := NULL;
47676
47677 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
47678 l_bflow_class_code := ''; -- 4219869 Business Flow
47679 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
47680 l_budgetary_control_flag := 'N';
47681
47682 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47683 l_bflow_applied_to_amt := NULL; -- 5132302
47684 l_entered_amt_idx := NULL; -- 4262811
47685 l_accted_amt_idx := NULL; -- 4262811
47686 l_acc_rev_flag := NULL; -- 4262811
47687 l_accrual_line_num := NULL; -- 4262811
47688 l_tmp_amt := NULL; -- 4262811
47689 --
47690
47691 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
47692 l_balance_type_code <> 'B' THEN
47693 IF NVL(p_source_20,'
47694 ') = 'REMITTANCE' AND
47695 NVL(p_source_67,'
47696 ') = 'N'
47697 THEN
47698
47699 --
47700 XLA_AE_LINES_PKG.SetNewLine;
47701
47702 p_balance_type_code := l_balance_type_code;
47703 -- set the flag so later we will know whether the gain loss line needs to be created
47704
47705 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
47706 p_actual_flag :='A';
47707 END IF;
47708
47709 --
47710 -- bulk performance
47711 --
47712 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
47713 p_header_num => 0); -- 4262811
47714 --
47715 -- set accounting line options
47716 --
47717 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
47718 p_natural_side_code => 'C'
47719 , p_gain_or_loss_flag => 'N'
47720 , p_gl_transfer_mode_code => 'S'
47721 , p_acct_entry_type_code => 'A'
47722 , p_switch_side_flag => 'Y'
47723 , p_merge_duplicate_code => 'A'
47724 );
47725 --
47726 l_acc_rev_natural_side_code := 'D'; -- 4262811
47727 --
47728 --
47729 -- set accounting line type info
47730 --
47731 xla_ae_lines_pkg.SetAcctLineType
47732 (p_component_type => l_component_type
47733 ,p_event_type_code => l_event_type_code
47734 ,p_line_definition_owner_code => l_line_definition_owner_code
47735 ,p_line_definition_code => l_line_definition_code
47736 ,p_accounting_line_code => l_component_code
47737 ,p_accounting_line_type_code => l_component_type_code
47738 ,p_accounting_line_appl_id => l_component_appl_id
47739 ,p_amb_context_code => l_amb_context_code
47740 ,p_entity_code => l_entity_code
47741 ,p_event_class_code => l_event_class_code);
47742 --
47743 -- set accounting class
47744 --
47745 xla_ae_lines_pkg.SetAcctClass(
47746 p_accounting_class_code => 'REMITTANCE'
47747 , p_ae_header_id => l_ae_header_id
47748 );
47749
47750 --
47751 -- set rounding class
47752 --
47753 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
47754 'RECEIVABLE';
47755
47756 --
47757 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
47758 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
47759 --
47760 -- bulk performance
47761 --
47762 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
47763
47764 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
47765 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
47766
47767 -- 4955764
47768 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
47769 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
47770
47771 -- 4458381 Public Sector Enh
47772
47773 --
47774 -- set accounting attributes for the line type
47775 --
47776 l_entered_amt_idx := 3;
47777 l_accted_amt_idx := 8;
47778 l_bflow_applied_to_amt_idx := NULL; -- 5132302
47779 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
47780 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
47781 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
47782 l_rec_acct_attrs.array_char_value(2) := p_source_23;
47783 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
47784 l_rec_acct_attrs.array_num_value(3) := p_source_24;
47785 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
47786 l_rec_acct_attrs.array_char_value(4) := p_source_25;
47787 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
47788 l_rec_acct_attrs.array_date_value(5) := p_source_57;
47789 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
47790 l_rec_acct_attrs.array_num_value(6) := p_source_27;
47791 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
47792 l_rec_acct_attrs.array_char_value(7) := p_source_28;
47793 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
47794 l_rec_acct_attrs.array_num_value(8) := p_source_29;
47795
47796 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
47797 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
47801 ---------------------------------------------------------------------------------------------------------------
47798
47799 ---------------------------------------------------------------------------------------------------------------
47800 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
47802 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
47803
47804 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47805 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
47806
47807 IF xla_accounting_cache_pkg.GetValueChar
47808 (p_source_code => 'LEDGER_CATEGORY_CODE'
47809 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
47810 AND l_bflow_method_code = 'PRIOR_ENTRY'
47811 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
47812 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
47813 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
47814 )
47815 THEN
47816 xla_ae_lines_pkg.BflowUpgEntry
47817 (p_business_method_code => l_bflow_method_code
47818 ,p_business_class_code => l_bflow_class_code
47819 ,p_balance_type => l_balance_type_code);
47820 ELSE
47821 NULL;
47822 -- No business flow processing for business flow method of NONE.
47823 END IF;
47824
47825 --
47826 -- call analytical criteria
47827 --
47828
47829 --
47830 -- call description
47831 --
47832 -- No description or it is inherited.
47833 --
47834 -- call ADRs
47835 -- Bug 4922099
47836 --
47837 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47838 (NVL(l_actual_upg_option, 'N') = 'O') OR
47839 (NVL(l_enc_upg_option, 'N') = 'O')
47840 )
47841 THEN
47842 NULL;
47843 --
47844 --
47845
47846 l_ccid := AcctDerRule_4(
47847 p_application_id => p_application_id
47848 , p_ae_header_id => l_ae_header_id
47849 , p_source_5 => p_source_5
47850 , x_transaction_coa_id => l_adr_transaction_coa_id
47851 , x_accounting_coa_id => l_adr_accounting_coa_id
47852 , x_value_type_code => l_adr_value_type_code
47853 , p_side => 'NA'
47854 );
47855
47856 xla_ae_lines_pkg.set_ccid(
47857 p_code_combination_id => l_ccid
47858 , p_value_type_code => l_adr_value_type_code
47859 , p_transaction_coa_id => l_adr_transaction_coa_id
47860 , p_accounting_coa_id => l_adr_accounting_coa_id
47861 , p_adr_code => 'DIST_CCID'
47862 , p_adr_type_code => 'S'
47863 , p_component_type => l_component_type
47864 , p_component_code => l_component_code
47865 , p_component_type_code => l_component_type_code
47866 , p_component_appl_id => l_component_appl_id
47867 , p_amb_context_code => l_amb_context_code
47868 , p_side => 'NA'
47869 );
47870
47871
47872 --
47873 --
47874 END IF;
47875 --
47876 -- Bug 4922099
47877 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
47878 (NVL(l_enc_upg_option, 'N') = 'O')
47879 ) AND
47880 (l_bflow_method_code = 'PRIOR_ENTRY')
47881 )
47882 THEN
47883 IF
47884 --
47885 1 = 2
47886 --
47887 THEN
47888 xla_accounting_err_pkg.build_message
47889 (p_appli_s_name => 'XLA'
47890 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47891 ,p_token_1 => 'LINE_NUMBER'
47892 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
47893 ,p_token_2 => 'LINE_TYPE_NAME'
47894 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
47895 l_component_type
47896 ,l_component_code
47897 ,l_component_type_code
47898 ,l_component_appl_id
47899 ,l_amb_context_code
47900 ,l_entity_code
47901 ,l_event_class_code
47902 )
47903 ,p_token_3 => 'OWNER'
47904 ,p_value_3 => xla_lookups_pkg.get_meaning(
47905 p_lookup_type => 'XLA_OWNER_TYPE'
47906 ,p_lookup_code => l_component_type_code
47907 )
47908 ,p_token_4 => 'PRODUCT_NAME'
47909 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
47910 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
47911 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
47912 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
47913 ,p_ae_header_id => NULL
47914 );
47915
47916 IF (C_LEVEL_ERROR>= g_log_level) THEN
47917 trace
47918 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
47919 ,p_level => C_LEVEL_ERROR
47920 ,p_module => l_log_module);
47921 END IF;
47922 END IF;
47923 END IF;
47924 --
47925 --
47926 ------------------------------------------------------------------------------------------------
47927 -- 4219869 Business Flow
47928 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
47929 -- Prior Entry. Currently, the following code is always generated.
47930 ------------------------------------------------------------------------------------------------
47931 XLA_AE_LINES_PKG.ValidateCurrentLine;
47932
47933 ------------------------------------------------------------------------------------
47934 -- 4219869 Business Flow
47935 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
47936 ------------------------------------------------------------------------------------
47937 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
47938
47939 ----------------------------------------------------------------------------------
47940 -- 4219869 Business Flow
47941 -- Update journal entry status -- Need to generate this within IF <condition>
47942 ----------------------------------------------------------------------------------
47943 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
47944 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
47945 ,p_balance_type_code => l_balance_type_code
47946 );
47947
47948 -------------------------------------------------------------------------------------------
47949 -- 4262811 - Generate the Accrual Reversal lines
47950 -------------------------------------------------------------------------------------------
47951 BEGIN
47952 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
47953 (g_array_event(p_event_id).array_value_num('header_index'));
47954 IF l_acc_rev_flag IS NULL THEN
47955 l_acc_rev_flag := 'N';
47956 END IF;
47957 EXCEPTION
47958 WHEN OTHERS THEN
47959 l_acc_rev_flag := 'N';
47960 END;
47961 --
47962 IF (l_acc_rev_flag = 'Y') THEN
47963
47964 -- 4645092 ------------------------------------------------------------------------------
47965 -- To allow MPA report to determine if it should generate report process
47966 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
47967 ------------------------------------------------------------------------------------------
47968
47969 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
47970 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
47971 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
47972 -- call ADRs
47973 -- Bug 4922099
47974 --
47975 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
47976 (NVL(l_actual_upg_option, 'N') = 'O') OR
47977 (NVL(l_enc_upg_option, 'N') = 'O')
47978 )
47979 THEN
47980 NULL;
47981 --
47982 --
47983
47984 l_ccid := AcctDerRule_4(
47985 p_application_id => p_application_id
47986 , p_ae_header_id => l_ae_header_id
47987 , p_source_5 => p_source_5
47988 , x_transaction_coa_id => l_adr_transaction_coa_id
47989 , x_accounting_coa_id => l_adr_accounting_coa_id
47990 , x_value_type_code => l_adr_value_type_code
47991 , p_side => 'NA'
47992 );
47993
47994 xla_ae_lines_pkg.set_ccid(
47995 p_code_combination_id => l_ccid
47996 , p_value_type_code => l_adr_value_type_code
47997 , p_transaction_coa_id => l_adr_transaction_coa_id
47998 , p_accounting_coa_id => l_adr_accounting_coa_id
47999 , p_adr_code => 'DIST_CCID'
48000 , p_adr_type_code => 'S'
48001 , p_component_type => l_component_type
48002 , p_component_code => l_component_code
48003 , p_component_type_code => l_component_type_code
48004 , p_component_appl_id => l_component_appl_id
48005 , p_amb_context_code => l_amb_context_code
48006 , p_side => 'NA'
48007 );
48008
48009
48010 --
48011 --
48012 END IF;
48013
48014 --
48015 -- Update the line information that should be overwritten
48016 --
48017 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
48018 p_header_num => 1);
48019 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
48020
48021 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
48022
48023 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
48024 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
48025 END IF;
48026
48027 --
48028 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
48029 --
48030 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
48031 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
48032 ELSE
48033 ---------------------------------------------------------------------------------------------------
48034 -- 4262811a Switch Sign
48035 ---------------------------------------------------------------------------------------------------
48036 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
48037 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48038 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48039 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48040 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48041 -- 5132302
48042 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
48043 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48044
48045 END IF;
48046
48047 -- 4955764
48048 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48049 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
48050
48051
48052 XLA_AE_LINES_PKG.ValidateCurrentLine;
48053 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
48054
48055 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48056 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
48057 ,p_balance_type_code => l_balance_type_code);
48058
48059 END IF;
48060
48061 -----------------------------------------------------------------------------------------
48062 -- 4262811 Multiperiod Accounting
48063 -----------------------------------------------------------------------------------------
48064 -- No MPA option is assigned.
48065
48066
48067 END IF;
48068 END IF;
48069 --
48070
48071 --
48072 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48073 trace
48074 (p_msg => 'END of AcctLineType_102'
48075 ,p_level => C_LEVEL_PROCEDURE
48076 ,p_module => l_log_module);
48077 END IF;
48078 --
48079 EXCEPTION
48080 WHEN xla_exceptions_pkg.application_exception THEN
48081 RAISE;
48082 WHEN OTHERS THEN
48083 xla_exceptions_pkg.raise_message
48084 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_102');
48085 END AcctLineType_102;
48086 --
48087
48088 ---------------------------------------
48089 --
48090 -- PRIVATE FUNCTION
48091 -- AcctLineType_103
48092 --
48093 ---------------------------------------
48094 PROCEDURE AcctLineType_103 (
48095 p_application_id IN NUMBER
48096 ,p_event_id IN NUMBER
48097 ,p_calculate_acctd_flag IN VARCHAR2
48098 ,p_calculate_g_l_flag IN VARCHAR2
48099 ,p_actual_flag IN OUT VARCHAR2
48100 ,p_balance_type_code OUT VARCHAR2
48101 ,p_gain_or_loss_ref OUT VARCHAR2
48102
48103 --Distribution GL Account
48104 , p_source_5 IN NUMBER
48105 --Distribution Source Type
48106 , p_source_20 IN VARCHAR2
48110 , p_source_23 IN VARCHAR2
48107 --Distribution Line Identifier
48108 , p_source_22 IN NUMBER
48109 --Distribution Type
48111 --Entered Amount
48112 , p_source_24 IN NUMBER
48113 --Currency Code
48114 , p_source_25 IN VARCHAR2
48115 --Exchange Rate
48116 , p_source_27 IN NUMBER
48117 --Exchange Rate Type
48118 , p_source_28 IN VARCHAR2
48119 --Applied To Document Accounting Amount
48120 , p_source_29 IN NUMBER
48121 --Applied To Document Exchange Date
48122 , p_source_57 IN DATE
48123 --Distribution Multi Fund Additional Entry
48124 , p_source_67 IN VARCHAR2
48125 )
48126 IS
48127
48128 l_component_type VARCHAR2(80);
48129 l_component_code VARCHAR2(30);
48130 l_component_type_code VARCHAR2(1);
48131 l_component_appl_id INTEGER;
48132 l_amb_context_code VARCHAR2(30);
48133 l_entity_code VARCHAR2(30);
48134 l_event_class_code VARCHAR2(30);
48135 l_ae_header_id NUMBER;
48136 l_event_type_code VARCHAR2(30);
48137 l_line_definition_code VARCHAR2(30);
48138 l_line_definition_owner_code VARCHAR2(1);
48139 --
48140 -- adr variables
48141 l_segment VARCHAR2(30);
48142 l_ccid NUMBER;
48143 l_adr_transaction_coa_id NUMBER;
48144 l_adr_accounting_coa_id NUMBER;
48145 l_adr_flexfield_segment_code VARCHAR2(30);
48146 l_adr_flex_value_set_id NUMBER;
48147 l_adr_value_type_code VARCHAR2(30);
48148 l_adr_value_combination_id NUMBER;
48149 l_adr_value_segment_code VARCHAR2(30);
48150
48151 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
48152 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
48153 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
48154 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
48155
48156 -- 4262811 Variables ------------------------------------------------------------------------------------------
48157 l_entered_amt_idx NUMBER;
48158 l_accted_amt_idx NUMBER;
48159 l_acc_rev_flag VARCHAR2(1);
48160 l_accrual_line_num NUMBER;
48161 l_tmp_amt NUMBER;
48162 l_acc_rev_natural_side_code VARCHAR2(1);
48163
48164 l_num_entries NUMBER;
48165 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
48166 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
48167 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
48168 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
48169 l_recog_line_1 NUMBER;
48170 l_recog_line_2 NUMBER;
48171
48172 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
48173 l_bflow_applied_to_amt NUMBER; -- 5132302
48174 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
48175
48176 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
48177
48178 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
48179 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
48180
48181 ---------------------------------------------------------------------------------------------------------------
48182
48183
48184 --
48185 -- bulk performance
48186 --
48187 l_balance_type_code VARCHAR2(1);
48188 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
48189 l_log_module VARCHAR2(240);
48190
48191 --
48192 -- Upgrade strategy
48193 --
48194 l_actual_upg_option VARCHAR2(1);
48195 l_enc_upg_option VARCHAR2(1);
48196
48197 --
48198 BEGIN
48199 --
48200 IF g_log_enabled THEN
48201 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_103';
48202 END IF;
48203 --
48204 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48205
48206 trace
48207 (p_msg => 'BEGIN of AcctLineType_103'
48208 ,p_level => C_LEVEL_PROCEDURE
48209 ,p_module => l_log_module);
48210
48211 END IF;
48212 --
48213 l_component_type := 'AMB_JLT';
48214 l_component_code := 'MISC_RCT_TAX';
48215 l_component_type_code := 'S';
48216 l_component_appl_id := 222;
48217 l_amb_context_code := 'DEFAULT';
48218 l_entity_code := 'RECEIPTS';
48219 l_event_class_code := 'MISC_RECEIPT';
48220 l_event_type_code := 'MISC_RECEIPT_ALL';
48221 l_line_definition_owner_code := 'S';
48222 l_line_definition_code := 'AR_MISC_RECEIPTS';
48223 --
48224 l_balance_type_code := 'A';
48225 l_segment := NULL;
48226 l_ccid := NULL;
48227 l_adr_transaction_coa_id := NULL;
48228 l_adr_accounting_coa_id := NULL;
48229 l_adr_flexfield_segment_code := NULL;
48230 l_adr_flex_value_set_id := NULL;
48231 l_adr_value_type_code := NULL;
48232 l_adr_value_combination_id := NULL;
48233 l_adr_value_segment_code := NULL;
48234
48235 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
48236 l_bflow_class_code := ''; -- 4219869 Business Flow
48237 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
48238 l_budgetary_control_flag := 'N';
48239
48240 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48241 l_bflow_applied_to_amt := NULL; -- 5132302
48242 l_entered_amt_idx := NULL; -- 4262811
48243 l_accted_amt_idx := NULL; -- 4262811
48244 l_acc_rev_flag := NULL; -- 4262811
48245 l_accrual_line_num := NULL; -- 4262811
48246 l_tmp_amt := NULL; -- 4262811
48247 --
48248
48249 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
48250 l_balance_type_code <> 'B' THEN
48251 IF NVL(p_source_20,'
48252 ') = 'TAX' AND
48253 NVL(p_source_67,'
48254 ') = 'N'
48255 THEN
48256
48257 --
48258 XLA_AE_LINES_PKG.SetNewLine;
48259
48260 p_balance_type_code := l_balance_type_code;
48261 -- set the flag so later we will know whether the gain loss line needs to be created
48262
48263 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
48264 p_actual_flag :='A';
48265 END IF;
48266
48267 --
48268 -- bulk performance
48269 --
48270 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
48271 p_header_num => 0); -- 4262811
48272 --
48273 -- set accounting line options
48274 --
48275 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
48276 p_natural_side_code => 'C'
48277 , p_gain_or_loss_flag => 'N'
48278 , p_gl_transfer_mode_code => 'S'
48279 , p_acct_entry_type_code => 'A'
48280 , p_switch_side_flag => 'Y'
48281 , p_merge_duplicate_code => 'A'
48282 );
48283 --
48284 l_acc_rev_natural_side_code := 'D'; -- 4262811
48285 --
48286 --
48287 -- set accounting line type info
48288 --
48289 xla_ae_lines_pkg.SetAcctLineType
48290 (p_component_type => l_component_type
48291 ,p_event_type_code => l_event_type_code
48292 ,p_line_definition_owner_code => l_line_definition_owner_code
48293 ,p_line_definition_code => l_line_definition_code
48294 ,p_accounting_line_code => l_component_code
48295 ,p_accounting_line_type_code => l_component_type_code
48296 ,p_accounting_line_appl_id => l_component_appl_id
48297 ,p_amb_context_code => l_amb_context_code
48298 ,p_entity_code => l_entity_code
48299 ,p_event_class_code => l_event_class_code);
48300 --
48301 -- set accounting class
48302 --
48303 xla_ae_lines_pkg.SetAcctClass(
48304 p_accounting_class_code => 'TAX'
48305 , p_ae_header_id => l_ae_header_id
48306 );
48307
48308 --
48309 -- set rounding class
48310 --
48311 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
48312 'RECEIVABLE';
48313
48314 --
48315 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
48316 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
48317 --
48318 -- bulk performance
48319 --
48320 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
48321
48322 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
48323 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
48324
48325 -- 4955764
48326 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48327 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
48328
48329 -- 4458381 Public Sector Enh
48330
48331 --
48332 -- set accounting attributes for the line type
48333 --
48334 l_entered_amt_idx := 3;
48335 l_accted_amt_idx := 8;
48336 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48337 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
48338 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
48339 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
48340 l_rec_acct_attrs.array_char_value(2) := p_source_23;
48341 l_rec_acct_attrs.array_acct_attr_code(3) := 'ENTERED_CURRENCY_AMOUNT';
48342 l_rec_acct_attrs.array_num_value(3) := p_source_24;
48343 l_rec_acct_attrs.array_acct_attr_code(4) := 'ENTERED_CURRENCY_CODE';
48344 l_rec_acct_attrs.array_char_value(4) := p_source_25;
48345 l_rec_acct_attrs.array_acct_attr_code(5) := 'EXCHANGE_DATE';
48346 l_rec_acct_attrs.array_date_value(5) := p_source_57;
48347 l_rec_acct_attrs.array_acct_attr_code(6) := 'EXCHANGE_RATE';
48348 l_rec_acct_attrs.array_num_value(6) := p_source_27;
48349 l_rec_acct_attrs.array_acct_attr_code(7) := 'EXCHANGE_RATE_TYPE';
48350 l_rec_acct_attrs.array_char_value(7) := p_source_28;
48351 l_rec_acct_attrs.array_acct_attr_code(8) := 'LEDGER_AMOUNT';
48352 l_rec_acct_attrs.array_num_value(8) := p_source_29;
48353
48354 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
48355 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
48356
48357 ---------------------------------------------------------------------------------------------------------------
48358 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
48359 ---------------------------------------------------------------------------------------------------------------
48360 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
48361
48362 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48363 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48364
48365 IF xla_accounting_cache_pkg.GetValueChar
48366 (p_source_code => 'LEDGER_CATEGORY_CODE'
48367 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
48368 AND l_bflow_method_code = 'PRIOR_ENTRY'
48369 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
48370 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
48371 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
48372 )
48373 THEN
48374 xla_ae_lines_pkg.BflowUpgEntry
48375 (p_business_method_code => l_bflow_method_code
48376 ,p_business_class_code => l_bflow_class_code
48377 ,p_balance_type => l_balance_type_code);
48378 ELSE
48379 NULL;
48380 -- No business flow processing for business flow method of NONE.
48381 END IF;
48382
48383 --
48384 -- call analytical criteria
48385 --
48386
48387 --
48388 -- call description
48389 --
48390 -- No description or it is inherited.
48391 --
48392 -- call ADRs
48393 -- Bug 4922099
48394 --
48395 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48396 (NVL(l_actual_upg_option, 'N') = 'O') OR
48397 (NVL(l_enc_upg_option, 'N') = 'O')
48398 )
48399 THEN
48400 NULL;
48401 --
48402 --
48403
48404 l_ccid := AcctDerRule_4(
48405 p_application_id => p_application_id
48406 , p_ae_header_id => l_ae_header_id
48407 , p_source_5 => p_source_5
48408 , x_transaction_coa_id => l_adr_transaction_coa_id
48409 , x_accounting_coa_id => l_adr_accounting_coa_id
48410 , x_value_type_code => l_adr_value_type_code
48411 , p_side => 'NA'
48412 );
48413
48414 xla_ae_lines_pkg.set_ccid(
48415 p_code_combination_id => l_ccid
48416 , p_value_type_code => l_adr_value_type_code
48417 , p_transaction_coa_id => l_adr_transaction_coa_id
48418 , p_accounting_coa_id => l_adr_accounting_coa_id
48419 , p_adr_code => 'DIST_CCID'
48420 , p_adr_type_code => 'S'
48421 , p_component_type => l_component_type
48422 , p_component_code => l_component_code
48423 , p_component_type_code => l_component_type_code
48424 , p_component_appl_id => l_component_appl_id
48425 , p_amb_context_code => l_amb_context_code
48426 , p_side => 'NA'
48427 );
48428
48429
48430 --
48431 --
48432 END IF;
48433 --
48434 -- Bug 4922099
48435 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
48436 (NVL(l_enc_upg_option, 'N') = 'O')
48437 ) AND
48438 (l_bflow_method_code = 'PRIOR_ENTRY')
48439 )
48440 THEN
48441 IF
48442 --
48443 1 = 2
48444 --
48445 THEN
48446 xla_accounting_err_pkg.build_message
48447 (p_appli_s_name => 'XLA'
48448 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
48449 ,p_token_1 => 'LINE_NUMBER'
48450 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
48451 ,p_token_2 => 'LINE_TYPE_NAME'
48452 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
48453 l_component_type
48454 ,l_component_code
48455 ,l_component_type_code
48456 ,l_component_appl_id
48457 ,l_amb_context_code
48458 ,l_entity_code
48459 ,l_event_class_code
48460 )
48461 ,p_token_3 => 'OWNER'
48462 ,p_value_3 => xla_lookups_pkg.get_meaning(
48463 p_lookup_type => 'XLA_OWNER_TYPE'
48464 ,p_lookup_code => l_component_type_code
48465 )
48466 ,p_token_4 => 'PRODUCT_NAME'
48467 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
48468 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
48469 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
48470 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
48471 ,p_ae_header_id => NULL
48472 );
48473
48474 IF (C_LEVEL_ERROR>= g_log_level) THEN
48475 trace
48476 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
48477 ,p_level => C_LEVEL_ERROR
48478 ,p_module => l_log_module);
48479 END IF;
48480 END IF;
48481 END IF;
48482 --
48483 --
48484 ------------------------------------------------------------------------------------------------
48485 -- 4219869 Business Flow
48486 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
48487 -- Prior Entry. Currently, the following code is always generated.
48488 ------------------------------------------------------------------------------------------------
48489 XLA_AE_LINES_PKG.ValidateCurrentLine;
48490
48491 ------------------------------------------------------------------------------------
48492 -- 4219869 Business Flow
48493 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
48494 ------------------------------------------------------------------------------------
48495 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
48496
48497 ----------------------------------------------------------------------------------
48498 -- 4219869 Business Flow
48499 -- Update journal entry status -- Need to generate this within IF <condition>
48500 ----------------------------------------------------------------------------------
48501 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48502 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
48503 ,p_balance_type_code => l_balance_type_code
48504 );
48505
48506 -------------------------------------------------------------------------------------------
48507 -- 4262811 - Generate the Accrual Reversal lines
48508 -------------------------------------------------------------------------------------------
48509 BEGIN
48510 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
48511 (g_array_event(p_event_id).array_value_num('header_index'));
48512 IF l_acc_rev_flag IS NULL THEN
48513 l_acc_rev_flag := 'N';
48514 END IF;
48515 EXCEPTION
48516 WHEN OTHERS THEN
48517 l_acc_rev_flag := 'N';
48518 END;
48519 --
48520 IF (l_acc_rev_flag = 'Y') THEN
48521
48522 -- 4645092 ------------------------------------------------------------------------------
48523 -- To allow MPA report to determine if it should generate report process
48524 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
48525 ------------------------------------------------------------------------------------------
48526
48527 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
48528 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
48529 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
48530 -- call ADRs
48531 -- Bug 4922099
48532 --
48533 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48534 (NVL(l_actual_upg_option, 'N') = 'O') OR
48535 (NVL(l_enc_upg_option, 'N') = 'O')
48536 )
48537 THEN
48538 NULL;
48539 --
48540 --
48541
48542 l_ccid := AcctDerRule_4(
48543 p_application_id => p_application_id
48544 , p_ae_header_id => l_ae_header_id
48545 , p_source_5 => p_source_5
48546 , x_transaction_coa_id => l_adr_transaction_coa_id
48547 , x_accounting_coa_id => l_adr_accounting_coa_id
48548 , x_value_type_code => l_adr_value_type_code
48549 , p_side => 'NA'
48550 );
48551
48552 xla_ae_lines_pkg.set_ccid(
48553 p_code_combination_id => l_ccid
48554 , p_value_type_code => l_adr_value_type_code
48555 , p_transaction_coa_id => l_adr_transaction_coa_id
48556 , p_accounting_coa_id => l_adr_accounting_coa_id
48557 , p_adr_code => 'DIST_CCID'
48558 , p_adr_type_code => 'S'
48559 , p_component_type => l_component_type
48560 , p_component_code => l_component_code
48561 , p_component_type_code => l_component_type_code
48562 , p_component_appl_id => l_component_appl_id
48563 , p_amb_context_code => l_amb_context_code
48564 , p_side => 'NA'
48565 );
48566
48567
48568 --
48569 --
48570 END IF;
48571
48572 --
48573 -- Update the line information that should be overwritten
48574 --
48575 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
48576 p_header_num => 1);
48577 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
48578
48579 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
48580
48581 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
48582 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
48583 END IF;
48584
48585 --
48586 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
48587 --
48588 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
48589 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
48590 ELSE
48591 ---------------------------------------------------------------------------------------------------
48592 -- 4262811a Switch Sign
48593 ---------------------------------------------------------------------------------------------------
48594 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
48595 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48596 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48597 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
48598 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48599 -- 5132302
48600 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
48601 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
48602
48603 END IF;
48604
48605 -- 4955764
48606 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48607 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
48608
48609
48610 XLA_AE_LINES_PKG.ValidateCurrentLine;
48611 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
48612
48613 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
48614 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
48615 ,p_balance_type_code => l_balance_type_code);
48616
48617 END IF;
48618
48619 -----------------------------------------------------------------------------------------
48620 -- 4262811 Multiperiod Accounting
48621 -----------------------------------------------------------------------------------------
48622 -- No MPA option is assigned.
48623
48624
48625 END IF;
48626 END IF;
48627 --
48628
48629 --
48630 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48631 trace
48632 (p_msg => 'END of AcctLineType_103'
48633 ,p_level => C_LEVEL_PROCEDURE
48634 ,p_module => l_log_module);
48635 END IF;
48636 --
48637 EXCEPTION
48638 WHEN xla_exceptions_pkg.application_exception THEN
48639 RAISE;
48640 WHEN OTHERS THEN
48641 xla_exceptions_pkg.raise_message
48642 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_103');
48643 END AcctLineType_103;
48644 --
48645
48646 ---------------------------------------
48647 --
48648 -- PRIVATE FUNCTION
48649 -- AcctLineType_104
48650 --
48651 ---------------------------------------
48652 PROCEDURE AcctLineType_104 (
48653 p_application_id IN NUMBER
48654 ,p_event_id IN NUMBER
48655 ,p_calculate_acctd_flag IN VARCHAR2
48656 ,p_calculate_g_l_flag IN VARCHAR2
48657 ,p_actual_flag IN OUT VARCHAR2
48658 ,p_balance_type_code OUT VARCHAR2
48659 ,p_gain_or_loss_ref OUT VARCHAR2
48660
48661 --Distribution GL Account
48662 , p_source_5 IN NUMBER
48663 --Distribution Source Type
48664 , p_source_20 IN VARCHAR2
48665 --Distribution Line Identifier
48666 , p_source_22 IN NUMBER
48667 --Distribution Type
48668 , p_source_23 IN VARCHAR2
48669 --Exchange Date
48670 , p_source_26 IN DATE
48671 --Exchange Rate
48672 , p_source_27 IN NUMBER
48673 --Exchange Rate Type
48674 , p_source_28 IN VARCHAR2
48675 --Transaction Distribution Identifier
48676 , p_source_34 IN NUMBER
48677 --Transaction Distribution Type
48678 , p_source_35 IN VARCHAR2
48679 --Receipt Applied To Application Identifier
48680 , p_source_58 IN NUMBER
48681 --Transaction Entity Code
48682 , p_source_59 IN VARCHAR2
48683 --Transaction Identifier
48684 , p_source_60 IN NUMBER
48685 --Applying Document Currency Code
48686 , p_source_61 IN VARCHAR2
48687 --Distribution Party Identifier
48688 , p_source_63 IN NUMBER
48689 --Distribution Party Site Id
48690 , p_source_64 IN NUMBER
48691 --Distribution Party Type
48692 , p_source_65 IN VARCHAR2
48693 --Distribution Multi Fund Additional Entry
48694 , p_source_67 IN VARCHAR2
48695 --DIST_ENT_AMT_FROM
48696 , p_source_68 IN NUMBER
48697 --Accounting Amount
48698 , p_source_69 IN NUMBER
48699 )
48700 IS
48701
48702 l_component_type VARCHAR2(80);
48703 l_component_code VARCHAR2(30);
48704 l_component_type_code VARCHAR2(1);
48705 l_component_appl_id INTEGER;
48706 l_amb_context_code VARCHAR2(30);
48707 l_entity_code VARCHAR2(30);
48708 l_event_class_code VARCHAR2(30);
48709 l_ae_header_id NUMBER;
48710 l_event_type_code VARCHAR2(30);
48711 l_line_definition_code VARCHAR2(30);
48712 l_line_definition_owner_code VARCHAR2(1);
48713 --
48714 -- adr variables
48715 l_segment VARCHAR2(30);
48716 l_ccid NUMBER;
48717 l_adr_transaction_coa_id NUMBER;
48718 l_adr_accounting_coa_id NUMBER;
48719 l_adr_flexfield_segment_code VARCHAR2(30);
48720 l_adr_flex_value_set_id NUMBER;
48721 l_adr_value_type_code VARCHAR2(30);
48722 l_adr_value_combination_id NUMBER;
48723 l_adr_value_segment_code VARCHAR2(30);
48724
48725 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
48726 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
48727 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
48728 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
48729
48730 -- 4262811 Variables ------------------------------------------------------------------------------------------
48731 l_entered_amt_idx NUMBER;
48732 l_accted_amt_idx NUMBER;
48733 l_acc_rev_flag VARCHAR2(1);
48734 l_accrual_line_num NUMBER;
48735 l_tmp_amt NUMBER;
48736 l_acc_rev_natural_side_code VARCHAR2(1);
48737
48738 l_num_entries NUMBER;
48739 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
48740 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
48741 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
48742 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
48743 l_recog_line_1 NUMBER;
48744 l_recog_line_2 NUMBER;
48745
48746 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
48747 l_bflow_applied_to_amt NUMBER; -- 5132302
48748 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
48749
48750 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
48751
48752 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
48753 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
48754
48755 ---------------------------------------------------------------------------------------------------------------
48756
48757
48758 --
48759 -- bulk performance
48760 --
48761 l_balance_type_code VARCHAR2(1);
48762 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
48763 l_log_module VARCHAR2(240);
48764
48765 --
48766 -- Upgrade strategy
48767 --
48768 l_actual_upg_option VARCHAR2(1);
48769 l_enc_upg_option VARCHAR2(1);
48770
48771 --
48772 BEGIN
48773 --
48774 IF g_log_enabled THEN
48775 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_104';
48776 END IF;
48777 --
48778 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
48779
48780 trace
48781 (p_msg => 'BEGIN of AcctLineType_104'
48782 ,p_level => C_LEVEL_PROCEDURE
48783 ,p_module => l_log_module);
48784
48785 END IF;
48786 --
48787 l_component_type := 'AMB_JLT';
48788 l_component_code := 'RCT_ACC';
48789 l_component_type_code := 'S';
48790 l_component_appl_id := 222;
48791 l_amb_context_code := 'DEFAULT';
48792 l_entity_code := 'RECEIPTS';
48793 l_event_class_code := 'RECEIPT';
48794 l_event_type_code := 'RECEIPT_ALL';
48795 l_line_definition_owner_code := 'S';
48796 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
48797 --
48798 l_balance_type_code := 'A';
48799 l_segment := NULL;
48800 l_ccid := NULL;
48801 l_adr_transaction_coa_id := NULL;
48802 l_adr_accounting_coa_id := NULL;
48803 l_adr_flexfield_segment_code := NULL;
48804 l_adr_flex_value_set_id := NULL;
48805 l_adr_value_type_code := NULL;
48806 l_adr_value_combination_id := NULL;
48807 l_adr_value_segment_code := NULL;
48808
48809 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
48810 l_bflow_class_code := ''; -- 4219869 Business Flow
48811 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
48812 l_budgetary_control_flag := 'N';
48813
48814 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48815 l_bflow_applied_to_amt := NULL; -- 5132302
48816 l_entered_amt_idx := NULL; -- 4262811
48817 l_accted_amt_idx := NULL; -- 4262811
48818 l_acc_rev_flag := NULL; -- 4262811
48819 l_accrual_line_num := NULL; -- 4262811
48820 l_tmp_amt := NULL; -- 4262811
48821 --
48822
48823 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
48824 l_balance_type_code <> 'B' THEN
48825 IF NVL(p_source_20,'
48826 ') = 'ACC' AND
48827 NVL(p_source_67,'
48828 ') = 'N'
48829 THEN
48830
48831 --
48832 XLA_AE_LINES_PKG.SetNewLine;
48833
48834 p_balance_type_code := l_balance_type_code;
48835 -- set the flag so later we will know whether the gain loss line needs to be created
48836
48837 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
48838 p_actual_flag :='A';
48839 END IF;
48840
48841 --
48842 -- bulk performance
48843 --
48844 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
48845 p_header_num => 0); -- 4262811
48846 --
48847 -- set accounting line options
48848 --
48849 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
48850 p_natural_side_code => 'C'
48851 , p_gain_or_loss_flag => 'N'
48852 , p_gl_transfer_mode_code => 'S'
48853 , p_acct_entry_type_code => 'A'
48854 , p_switch_side_flag => 'Y'
48855 , p_merge_duplicate_code => 'A'
48856 );
48857 --
48858 l_acc_rev_natural_side_code := 'D'; -- 4262811
48859 --
48860 --
48861 -- set accounting line type info
48862 --
48863 xla_ae_lines_pkg.SetAcctLineType
48864 (p_component_type => l_component_type
48865 ,p_event_type_code => l_event_type_code
48866 ,p_line_definition_owner_code => l_line_definition_owner_code
48867 ,p_line_definition_code => l_line_definition_code
48868 ,p_accounting_line_code => l_component_code
48869 ,p_accounting_line_type_code => l_component_type_code
48870 ,p_accounting_line_appl_id => l_component_appl_id
48871 ,p_amb_context_code => l_amb_context_code
48872 ,p_entity_code => l_entity_code
48873 ,p_event_class_code => l_event_class_code);
48874 --
48875 -- set accounting class
48876 --
48877 xla_ae_lines_pkg.SetAcctClass(
48878 p_accounting_class_code => 'ACC'
48879 , p_ae_header_id => l_ae_header_id
48880 );
48881
48882 --
48883 -- set rounding class
48884 --
48885 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
48886 'RECEIVABLE';
48887
48888 --
48889 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
48890 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
48891 --
48892 -- bulk performance
48893 --
48894 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
48895
48896 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
48897 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
48898
48899 -- 4955764
48900 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
48901 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
48902
48903 -- 4458381 Public Sector Enh
48904
48905 --
48906 -- set accounting attributes for the line type
48907 --
48908 l_entered_amt_idx := 8;
48909 l_accted_amt_idx := 13;
48910 l_bflow_applied_to_amt_idx := NULL; -- 5132302
48911 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
48912 l_rec_acct_attrs.array_num_value(1) := p_source_58;
48913 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
48914 l_rec_acct_attrs.array_char_value(2) := p_source_35;
48915 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
48916 l_rec_acct_attrs.array_char_value(3) := p_source_59;
48917 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
48918 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
48919 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
48920 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
48921 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
48922 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
48923 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
48924 l_rec_acct_attrs.array_char_value(7) := p_source_23;
48925 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
48926 l_rec_acct_attrs.array_num_value(8) := p_source_68;
48927 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
48928 l_rec_acct_attrs.array_char_value(9) := p_source_61;
48929 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
48930 l_rec_acct_attrs.array_date_value(10) := p_source_26;
48931 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
48932 l_rec_acct_attrs.array_num_value(11) := p_source_27;
48933 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
48934 l_rec_acct_attrs.array_char_value(12) := p_source_28;
48935 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
48936 l_rec_acct_attrs.array_num_value(13) := p_source_69;
48937 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
48938 l_rec_acct_attrs.array_num_value(14) := p_source_63;
48939 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
48940 l_rec_acct_attrs.array_num_value(15) := p_source_64;
48941 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
48942 l_rec_acct_attrs.array_char_value(16) := p_source_65;
48943
48944 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
48945 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
48946
48947 ---------------------------------------------------------------------------------------------------------------
48948 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
48949 ---------------------------------------------------------------------------------------------------------------
48950 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
48951
48952 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48953 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
48954
48955 IF xla_accounting_cache_pkg.GetValueChar
48956 (p_source_code => 'LEDGER_CATEGORY_CODE'
48957 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
48958 AND l_bflow_method_code = 'PRIOR_ENTRY'
48959 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
48960 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
48961 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
48962 )
48963 THEN
48964 xla_ae_lines_pkg.BflowUpgEntry
48965 (p_business_method_code => l_bflow_method_code
48966 ,p_business_class_code => l_bflow_class_code
48967 ,p_balance_type => l_balance_type_code);
48968 ELSE
48969 NULL;
48970 -- No business flow processing for business flow method of NONE.
48971 END IF;
48972
48973 --
48974 -- call analytical criteria
48975 --
48976
48977 --
48978 -- call description
48979 --
48980 -- No description or it is inherited.
48981 --
48982 -- call ADRs
48983 -- Bug 4922099
48984 --
48985 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
48986 (NVL(l_actual_upg_option, 'N') = 'O') OR
48987 (NVL(l_enc_upg_option, 'N') = 'O')
48988 )
48989 THEN
48990 NULL;
48991 --
48992 --
48993
48994 l_ccid := AcctDerRule_4(
48995 p_application_id => p_application_id
48996 , p_ae_header_id => l_ae_header_id
48997 , p_source_5 => p_source_5
48998 , x_transaction_coa_id => l_adr_transaction_coa_id
48999 , x_accounting_coa_id => l_adr_accounting_coa_id
49000 , x_value_type_code => l_adr_value_type_code
49001 , p_side => 'NA'
49002 );
49003
49004 xla_ae_lines_pkg.set_ccid(
49005 p_code_combination_id => l_ccid
49006 , p_value_type_code => l_adr_value_type_code
49007 , p_transaction_coa_id => l_adr_transaction_coa_id
49008 , p_accounting_coa_id => l_adr_accounting_coa_id
49009 , p_adr_code => 'DIST_CCID'
49010 , p_adr_type_code => 'S'
49011 , p_component_type => l_component_type
49012 , p_component_code => l_component_code
49013 , p_component_type_code => l_component_type_code
49014 , p_component_appl_id => l_component_appl_id
49015 , p_amb_context_code => l_amb_context_code
49016 , p_side => 'NA'
49017 );
49018
49019
49020 --
49021 --
49022 END IF;
49023 --
49024 -- Bug 4922099
49025 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
49026 (NVL(l_enc_upg_option, 'N') = 'O')
49027 ) AND
49028 (l_bflow_method_code = 'PRIOR_ENTRY')
49029 )
49030 THEN
49031 IF
49032 --
49033 1 = 2
49034 --
49035 THEN
49036 xla_accounting_err_pkg.build_message
49037 (p_appli_s_name => 'XLA'
49038 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49039 ,p_token_1 => 'LINE_NUMBER'
49040 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
49041 ,p_token_2 => 'LINE_TYPE_NAME'
49042 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
49043 l_component_type
49044 ,l_component_code
49045 ,l_component_type_code
49046 ,l_component_appl_id
49047 ,l_amb_context_code
49048 ,l_entity_code
49049 ,l_event_class_code
49050 )
49051 ,p_token_3 => 'OWNER'
49052 ,p_value_3 => xla_lookups_pkg.get_meaning(
49053 p_lookup_type => 'XLA_OWNER_TYPE'
49054 ,p_lookup_code => l_component_type_code
49055 )
49056 ,p_token_4 => 'PRODUCT_NAME'
49057 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
49058 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
49059 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
49060 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
49061 ,p_ae_header_id => NULL
49062 );
49063
49064 IF (C_LEVEL_ERROR>= g_log_level) THEN
49065 trace
49066 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49067 ,p_level => C_LEVEL_ERROR
49068 ,p_module => l_log_module);
49069 END IF;
49070 END IF;
49071 END IF;
49072 --
49073 --
49074 ------------------------------------------------------------------------------------------------
49075 -- 4219869 Business Flow
49076 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
49077 -- Prior Entry. Currently, the following code is always generated.
49078 ------------------------------------------------------------------------------------------------
49079 XLA_AE_LINES_PKG.ValidateCurrentLine;
49080
49081 ------------------------------------------------------------------------------------
49082 -- 4219869 Business Flow
49083 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
49084 ------------------------------------------------------------------------------------
49085 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49086
49087 ----------------------------------------------------------------------------------
49088 -- 4219869 Business Flow
49089 -- Update journal entry status -- Need to generate this within IF <condition>
49090 ----------------------------------------------------------------------------------
49091 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49092 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
49093 ,p_balance_type_code => l_balance_type_code
49094 );
49095
49096 -------------------------------------------------------------------------------------------
49097 -- 4262811 - Generate the Accrual Reversal lines
49098 -------------------------------------------------------------------------------------------
49099 BEGIN
49100 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
49101 (g_array_event(p_event_id).array_value_num('header_index'));
49102 IF l_acc_rev_flag IS NULL THEN
49103 l_acc_rev_flag := 'N';
49104 END IF;
49105 EXCEPTION
49106 WHEN OTHERS THEN
49107 l_acc_rev_flag := 'N';
49108 END;
49109 --
49110 IF (l_acc_rev_flag = 'Y') THEN
49111
49112 -- 4645092 ------------------------------------------------------------------------------
49113 -- To allow MPA report to determine if it should generate report process
49114 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
49115 ------------------------------------------------------------------------------------------
49116
49117 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
49118 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
49119 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
49120 -- call ADRs
49121 -- Bug 4922099
49122 --
49123 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49124 (NVL(l_actual_upg_option, 'N') = 'O') OR
49125 (NVL(l_enc_upg_option, 'N') = 'O')
49126 )
49127 THEN
49128 NULL;
49129 --
49130 --
49131
49132 l_ccid := AcctDerRule_4(
49133 p_application_id => p_application_id
49134 , p_ae_header_id => l_ae_header_id
49135 , p_source_5 => p_source_5
49136 , x_transaction_coa_id => l_adr_transaction_coa_id
49137 , x_accounting_coa_id => l_adr_accounting_coa_id
49138 , x_value_type_code => l_adr_value_type_code
49139 , p_side => 'NA'
49140 );
49141
49142 xla_ae_lines_pkg.set_ccid(
49143 p_code_combination_id => l_ccid
49144 , p_value_type_code => l_adr_value_type_code
49145 , p_transaction_coa_id => l_adr_transaction_coa_id
49146 , p_accounting_coa_id => l_adr_accounting_coa_id
49147 , p_adr_code => 'DIST_CCID'
49148 , p_adr_type_code => 'S'
49149 , p_component_type => l_component_type
49150 , p_component_code => l_component_code
49151 , p_component_type_code => l_component_type_code
49152 , p_component_appl_id => l_component_appl_id
49153 , p_amb_context_code => l_amb_context_code
49154 , p_side => 'NA'
49155 );
49156
49157
49158 --
49159 --
49160 END IF;
49161
49162 --
49163 -- Update the line information that should be overwritten
49164 --
49165 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
49166 p_header_num => 1);
49167 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
49168
49169 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
49170
49171 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
49172 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
49173 END IF;
49174
49175 --
49176 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
49177 --
49178 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
49179 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
49180 ELSE
49181 ---------------------------------------------------------------------------------------------------
49182 -- 4262811a Switch Sign
49183 ---------------------------------------------------------------------------------------------------
49184 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
49185 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49186 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49187 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49188 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49189 -- 5132302
49190 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
49191 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49192
49193 END IF;
49194
49195 -- 4955764
49196 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49197 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
49198
49199
49200 XLA_AE_LINES_PKG.ValidateCurrentLine;
49201 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49202
49203 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49204 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
49205 ,p_balance_type_code => l_balance_type_code);
49206
49207 END IF;
49208
49209 -----------------------------------------------------------------------------------------
49210 -- 4262811 Multiperiod Accounting
49211 -----------------------------------------------------------------------------------------
49212 -- No MPA option is assigned.
49213
49214
49215 END IF;
49216 END IF;
49217 --
49218
49219 --
49220 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49221 trace
49222 (p_msg => 'END of AcctLineType_104'
49223 ,p_level => C_LEVEL_PROCEDURE
49224 ,p_module => l_log_module);
49225 END IF;
49226 --
49227 EXCEPTION
49228 WHEN xla_exceptions_pkg.application_exception THEN
49229 RAISE;
49230 WHEN OTHERS THEN
49231 xla_exceptions_pkg.raise_message
49232 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_104');
49233 END AcctLineType_104;
49234 --
49235
49236 ---------------------------------------
49237 --
49238 -- PRIVATE FUNCTION
49239 -- AcctLineType_105
49240 --
49241 ---------------------------------------
49242 PROCEDURE AcctLineType_105 (
49243 p_application_id IN NUMBER
49244 ,p_event_id IN NUMBER
49245 ,p_calculate_acctd_flag IN VARCHAR2
49246 ,p_calculate_g_l_flag IN VARCHAR2
49247 ,p_actual_flag IN OUT VARCHAR2
49248 ,p_balance_type_code OUT VARCHAR2
49249 ,p_gain_or_loss_ref OUT VARCHAR2
49250
49251 --Distribution GL Account
49252 , p_source_5 IN NUMBER
49253 --Distribution Source Type
49254 , p_source_20 IN VARCHAR2
49255 --Distribution Line Identifier
49256 , p_source_22 IN NUMBER
49257 --Distribution Type
49258 , p_source_23 IN VARCHAR2
49259 --Exchange Date
49260 , p_source_26 IN DATE
49261 --Exchange Rate
49262 , p_source_27 IN NUMBER
49263 --Exchange Rate Type
49264 , p_source_28 IN VARCHAR2
49265 --Transaction Distribution Identifier
49266 , p_source_34 IN NUMBER
49267 --Transaction Distribution Type
49268 , p_source_35 IN VARCHAR2
49269 --Receipt Applied To Application Identifier
49270 , p_source_58 IN NUMBER
49271 --Transaction Entity Code
49272 , p_source_59 IN VARCHAR2
49273 --Transaction Identifier
49274 , p_source_60 IN NUMBER
49275 --Applying Document Currency Code
49276 , p_source_61 IN VARCHAR2
49277 --Distribution Party Identifier
49278 , p_source_63 IN NUMBER
49279 --Distribution Party Site Id
49280 , p_source_64 IN NUMBER
49281 --Distribution Party Type
49282 , p_source_65 IN VARCHAR2
49283 --Distribution Multi Fund Additional Entry
49284 , p_source_67 IN VARCHAR2
49285 --DIST_ENT_AMT_FROM
49286 , p_source_68 IN NUMBER
49287 --Accounting Amount
49288 , p_source_69 IN NUMBER
49289 )
49290 IS
49291
49292 l_component_type VARCHAR2(80);
49293 l_component_code VARCHAR2(30);
49294 l_component_type_code VARCHAR2(1);
49295 l_component_appl_id INTEGER;
49296 l_amb_context_code VARCHAR2(30);
49297 l_entity_code VARCHAR2(30);
49298 l_event_class_code VARCHAR2(30);
49299 l_ae_header_id NUMBER;
49300 l_event_type_code VARCHAR2(30);
49301 l_line_definition_code VARCHAR2(30);
49302 l_line_definition_owner_code VARCHAR2(1);
49303 --
49304 -- adr variables
49305 l_segment VARCHAR2(30);
49306 l_ccid NUMBER;
49307 l_adr_transaction_coa_id NUMBER;
49308 l_adr_accounting_coa_id NUMBER;
49309 l_adr_flexfield_segment_code VARCHAR2(30);
49310 l_adr_flex_value_set_id NUMBER;
49311 l_adr_value_type_code VARCHAR2(30);
49312 l_adr_value_combination_id NUMBER;
49313 l_adr_value_segment_code VARCHAR2(30);
49314
49315 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
49316 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
49317 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
49318 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
49319
49320 -- 4262811 Variables ------------------------------------------------------------------------------------------
49321 l_entered_amt_idx NUMBER;
49322 l_accted_amt_idx NUMBER;
49323 l_acc_rev_flag VARCHAR2(1);
49324 l_accrual_line_num NUMBER;
49325 l_tmp_amt NUMBER;
49326 l_acc_rev_natural_side_code VARCHAR2(1);
49327
49328 l_num_entries NUMBER;
49329 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
49330 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
49331 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
49332 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
49333 l_recog_line_1 NUMBER;
49334 l_recog_line_2 NUMBER;
49335
49336 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
49337 l_bflow_applied_to_amt NUMBER; -- 5132302
49338 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
49339
49340 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
49341
49342 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
49343 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
49344
49345 ---------------------------------------------------------------------------------------------------------------
49346
49347
49348 --
49349 -- bulk performance
49350 --
49351 l_balance_type_code VARCHAR2(1);
49352 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
49353 l_log_module VARCHAR2(240);
49354
49355 --
49356 -- Upgrade strategy
49357 --
49358 l_actual_upg_option VARCHAR2(1);
49359 l_enc_upg_option VARCHAR2(1);
49360
49361 --
49362 BEGIN
49363 --
49364 IF g_log_enabled THEN
49365 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_105';
49366 END IF;
49367 --
49368 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49369
49370 trace
49371 (p_msg => 'BEGIN of AcctLineType_105'
49372 ,p_level => C_LEVEL_PROCEDURE
49373 ,p_module => l_log_module);
49374
49375 END IF;
49376 --
49377 l_component_type := 'AMB_JLT';
49378 l_component_code := 'RCT_BNK_CHG';
49379 l_component_type_code := 'S';
49380 l_component_appl_id := 222;
49381 l_amb_context_code := 'DEFAULT';
49382 l_entity_code := 'RECEIPTS';
49383 l_event_class_code := 'RECEIPT';
49384 l_event_type_code := 'RECEIPT_ALL';
49385 l_line_definition_owner_code := 'S';
49386 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
49387 --
49388 l_balance_type_code := 'A';
49389 l_segment := NULL;
49390 l_ccid := NULL;
49391 l_adr_transaction_coa_id := NULL;
49392 l_adr_accounting_coa_id := NULL;
49393 l_adr_flexfield_segment_code := NULL;
49394 l_adr_flex_value_set_id := NULL;
49395 l_adr_value_type_code := NULL;
49396 l_adr_value_combination_id := NULL;
49397 l_adr_value_segment_code := NULL;
49398
49399 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
49400 l_bflow_class_code := ''; -- 4219869 Business Flow
49401 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
49402 l_budgetary_control_flag := 'N';
49403
49404 l_bflow_applied_to_amt_idx := NULL; -- 5132302
49405 l_bflow_applied_to_amt := NULL; -- 5132302
49406 l_entered_amt_idx := NULL; -- 4262811
49407 l_accted_amt_idx := NULL; -- 4262811
49408 l_acc_rev_flag := NULL; -- 4262811
49409 l_accrual_line_num := NULL; -- 4262811
49410 l_tmp_amt := NULL; -- 4262811
49411 --
49412
49413 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
49414 l_balance_type_code <> 'B' THEN
49415 IF NVL(p_source_20,'
49416 ') = 'BANK_CHARGES' AND
49417 NVL(p_source_67,'
49418 ') = 'N'
49419 THEN
49420
49421 --
49422 XLA_AE_LINES_PKG.SetNewLine;
49423
49424 p_balance_type_code := l_balance_type_code;
49425 -- set the flag so later we will know whether the gain loss line needs to be created
49426
49427 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
49428 p_actual_flag :='A';
49429 END IF;
49430
49431 --
49432 -- bulk performance
49433 --
49434 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
49435 p_header_num => 0); -- 4262811
49436 --
49437 -- set accounting line options
49438 --
49439 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
49440 p_natural_side_code => 'C'
49441 , p_gain_or_loss_flag => 'N'
49442 , p_gl_transfer_mode_code => 'S'
49443 , p_acct_entry_type_code => 'A'
49444 , p_switch_side_flag => 'Y'
49445 , p_merge_duplicate_code => 'A'
49446 );
49447 --
49448 l_acc_rev_natural_side_code := 'D'; -- 4262811
49449 --
49450 --
49451 -- set accounting line type info
49452 --
49453 xla_ae_lines_pkg.SetAcctLineType
49454 (p_component_type => l_component_type
49455 ,p_event_type_code => l_event_type_code
49456 ,p_line_definition_owner_code => l_line_definition_owner_code
49457 ,p_line_definition_code => l_line_definition_code
49458 ,p_accounting_line_code => l_component_code
49459 ,p_accounting_line_type_code => l_component_type_code
49460 ,p_accounting_line_appl_id => l_component_appl_id
49461 ,p_amb_context_code => l_amb_context_code
49462 ,p_entity_code => l_entity_code
49463 ,p_event_class_code => l_event_class_code);
49464 --
49465 -- set accounting class
49466 --
49467 xla_ae_lines_pkg.SetAcctClass(
49468 p_accounting_class_code => 'BANK_CHG'
49469 , p_ae_header_id => l_ae_header_id
49470 );
49471
49472 --
49473 -- set rounding class
49474 --
49475 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
49476 'RECEIVABLE';
49477
49478 --
49479 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
49480 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
49481 --
49482 -- bulk performance
49483 --
49484 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
49485
49486 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
49487 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
49488
49489 -- 4955764
49490 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49491 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
49492
49493 -- 4458381 Public Sector Enh
49494
49495 --
49496 -- set accounting attributes for the line type
49497 --
49498 l_entered_amt_idx := 8;
49499 l_accted_amt_idx := 13;
49500 l_bflow_applied_to_amt_idx := NULL; -- 5132302
49501 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
49502 l_rec_acct_attrs.array_num_value(1) := p_source_58;
49503 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
49504 l_rec_acct_attrs.array_char_value(2) := p_source_35;
49505 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
49506 l_rec_acct_attrs.array_char_value(3) := p_source_59;
49507 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
49508 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
49509 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
49510 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
49511 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
49512 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
49513 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
49514 l_rec_acct_attrs.array_char_value(7) := p_source_23;
49515 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
49516 l_rec_acct_attrs.array_num_value(8) := p_source_68;
49517 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
49518 l_rec_acct_attrs.array_char_value(9) := p_source_61;
49519 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
49520 l_rec_acct_attrs.array_date_value(10) := p_source_26;
49521 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
49522 l_rec_acct_attrs.array_num_value(11) := p_source_27;
49523 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
49524 l_rec_acct_attrs.array_char_value(12) := p_source_28;
49525 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
49526 l_rec_acct_attrs.array_num_value(13) := p_source_69;
49527 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
49528 l_rec_acct_attrs.array_num_value(14) := p_source_63;
49529 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
49530 l_rec_acct_attrs.array_num_value(15) := p_source_64;
49531 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
49532 l_rec_acct_attrs.array_char_value(16) := p_source_65;
49533
49534 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
49535 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
49536
49537 ---------------------------------------------------------------------------------------------------------------
49538 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
49539 ---------------------------------------------------------------------------------------------------------------
49540 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
49541
49542 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
49543 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
49544
49545 IF xla_accounting_cache_pkg.GetValueChar
49546 (p_source_code => 'LEDGER_CATEGORY_CODE'
49547 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
49548 AND l_bflow_method_code = 'PRIOR_ENTRY'
49549 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
49550 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
49551 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
49552 )
49553 THEN
49554 xla_ae_lines_pkg.BflowUpgEntry
49555 (p_business_method_code => l_bflow_method_code
49556 ,p_business_class_code => l_bflow_class_code
49557 ,p_balance_type => l_balance_type_code);
49558 ELSE
49559 NULL;
49560 -- No business flow processing for business flow method of NONE.
49561 END IF;
49562
49563 --
49564 -- call analytical criteria
49565 --
49566
49567 --
49568 -- call description
49569 --
49570 -- No description or it is inherited.
49571 --
49572 -- call ADRs
49573 -- Bug 4922099
49574 --
49575 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49576 (NVL(l_actual_upg_option, 'N') = 'O') OR
49577 (NVL(l_enc_upg_option, 'N') = 'O')
49578 )
49579 THEN
49580 NULL;
49581 --
49582 --
49583
49584 l_ccid := AcctDerRule_4(
49585 p_application_id => p_application_id
49586 , p_ae_header_id => l_ae_header_id
49587 , p_source_5 => p_source_5
49588 , x_transaction_coa_id => l_adr_transaction_coa_id
49589 , x_accounting_coa_id => l_adr_accounting_coa_id
49590 , x_value_type_code => l_adr_value_type_code
49591 , p_side => 'NA'
49592 );
49593
49594 xla_ae_lines_pkg.set_ccid(
49595 p_code_combination_id => l_ccid
49596 , p_value_type_code => l_adr_value_type_code
49597 , p_transaction_coa_id => l_adr_transaction_coa_id
49598 , p_accounting_coa_id => l_adr_accounting_coa_id
49599 , p_adr_code => 'DIST_CCID'
49600 , p_adr_type_code => 'S'
49601 , p_component_type => l_component_type
49602 , p_component_code => l_component_code
49603 , p_component_type_code => l_component_type_code
49604 , p_component_appl_id => l_component_appl_id
49605 , p_amb_context_code => l_amb_context_code
49606 , p_side => 'NA'
49607 );
49608
49609
49610 --
49611 --
49612 END IF;
49613 --
49614 -- Bug 4922099
49615 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
49616 (NVL(l_enc_upg_option, 'N') = 'O')
49617 ) AND
49618 (l_bflow_method_code = 'PRIOR_ENTRY')
49619 )
49620 THEN
49621 IF
49622 --
49623 1 = 2
49624 --
49625 THEN
49626 xla_accounting_err_pkg.build_message
49627 (p_appli_s_name => 'XLA'
49628 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49629 ,p_token_1 => 'LINE_NUMBER'
49630 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
49634 ,l_component_code
49631 ,p_token_2 => 'LINE_TYPE_NAME'
49632 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
49633 l_component_type
49635 ,l_component_type_code
49636 ,l_component_appl_id
49637 ,l_amb_context_code
49638 ,l_entity_code
49639 ,l_event_class_code
49640 )
49641 ,p_token_3 => 'OWNER'
49642 ,p_value_3 => xla_lookups_pkg.get_meaning(
49643 p_lookup_type => 'XLA_OWNER_TYPE'
49644 ,p_lookup_code => l_component_type_code
49645 )
49646 ,p_token_4 => 'PRODUCT_NAME'
49647 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
49648 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
49649 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
49650 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
49651 ,p_ae_header_id => NULL
49652 );
49653
49654 IF (C_LEVEL_ERROR>= g_log_level) THEN
49655 trace
49656 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
49657 ,p_level => C_LEVEL_ERROR
49658 ,p_module => l_log_module);
49659 END IF;
49660 END IF;
49661 END IF;
49662 --
49663 --
49664 ------------------------------------------------------------------------------------------------
49665 -- 4219869 Business Flow
49666 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
49667 -- Prior Entry. Currently, the following code is always generated.
49668 ------------------------------------------------------------------------------------------------
49669 XLA_AE_LINES_PKG.ValidateCurrentLine;
49670
49671 ------------------------------------------------------------------------------------
49672 -- 4219869 Business Flow
49673 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
49674 ------------------------------------------------------------------------------------
49675 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49676
49677 ----------------------------------------------------------------------------------
49678 -- 4219869 Business Flow
49679 -- Update journal entry status -- Need to generate this within IF <condition>
49680 ----------------------------------------------------------------------------------
49681 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49682 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
49683 ,p_balance_type_code => l_balance_type_code
49684 );
49685
49686 -------------------------------------------------------------------------------------------
49687 -- 4262811 - Generate the Accrual Reversal lines
49688 -------------------------------------------------------------------------------------------
49689 BEGIN
49690 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
49691 (g_array_event(p_event_id).array_value_num('header_index'));
49692 IF l_acc_rev_flag IS NULL THEN
49693 l_acc_rev_flag := 'N';
49694 END IF;
49695 EXCEPTION
49696 WHEN OTHERS THEN
49697 l_acc_rev_flag := 'N';
49698 END;
49699 --
49700 IF (l_acc_rev_flag = 'Y') THEN
49701
49702 -- 4645092 ------------------------------------------------------------------------------
49703 -- To allow MPA report to determine if it should generate report process
49704 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
49705 ------------------------------------------------------------------------------------------
49706
49707 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
49708 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
49709 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
49710 -- call ADRs
49711 -- Bug 4922099
49712 --
49713 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
49714 (NVL(l_actual_upg_option, 'N') = 'O') OR
49715 (NVL(l_enc_upg_option, 'N') = 'O')
49716 )
49717 THEN
49718 NULL;
49719 --
49720 --
49721
49722 l_ccid := AcctDerRule_4(
49723 p_application_id => p_application_id
49724 , p_ae_header_id => l_ae_header_id
49725 , p_source_5 => p_source_5
49726 , x_transaction_coa_id => l_adr_transaction_coa_id
49727 , x_accounting_coa_id => l_adr_accounting_coa_id
49728 , x_value_type_code => l_adr_value_type_code
49729 , p_side => 'NA'
49730 );
49731
49732 xla_ae_lines_pkg.set_ccid(
49733 p_code_combination_id => l_ccid
49734 , p_value_type_code => l_adr_value_type_code
49735 , p_transaction_coa_id => l_adr_transaction_coa_id
49736 , p_accounting_coa_id => l_adr_accounting_coa_id
49737 , p_adr_code => 'DIST_CCID'
49738 , p_adr_type_code => 'S'
49739 , p_component_type => l_component_type
49740 , p_component_code => l_component_code
49741 , p_component_type_code => l_component_type_code
49742 , p_component_appl_id => l_component_appl_id
49743 , p_amb_context_code => l_amb_context_code
49744 , p_side => 'NA'
49745 );
49746
49747
49748 --
49749 --
49750 END IF;
49751
49752 --
49753 -- Update the line information that should be overwritten
49754 --
49755 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
49756 p_header_num => 1);
49757 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
49758
49759 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
49760
49761 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
49762 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
49763 END IF;
49764
49765 --
49766 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
49767 --
49768 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
49769 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
49770 ELSE
49771 ---------------------------------------------------------------------------------------------------
49772 -- 4262811a Switch Sign
49773 ---------------------------------------------------------------------------------------------------
49774 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
49775 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49776 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49777 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
49778 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49779 -- 5132302
49780 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
49781 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
49782
49783 END IF;
49784
49785 -- 4955764
49786 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
49787 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
49788
49789
49790 XLA_AE_LINES_PKG.ValidateCurrentLine;
49791 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
49792
49793 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
49794 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
49795 ,p_balance_type_code => l_balance_type_code);
49796
49797 END IF;
49798
49799 -----------------------------------------------------------------------------------------
49800 -- 4262811 Multiperiod Accounting
49801 -----------------------------------------------------------------------------------------
49802 -- No MPA option is assigned.
49803
49804
49805 END IF;
49806 END IF;
49807 --
49808
49809 --
49810 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49811 trace
49812 (p_msg => 'END of AcctLineType_105'
49813 ,p_level => C_LEVEL_PROCEDURE
49814 ,p_module => l_log_module);
49815 END IF;
49816 --
49817 EXCEPTION
49818 WHEN xla_exceptions_pkg.application_exception THEN
49819 RAISE;
49820 WHEN OTHERS THEN
49821 xla_exceptions_pkg.raise_message
49822 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_105');
49823 END AcctLineType_105;
49824 --
49825
49826 ---------------------------------------
49827 --
49828 -- PRIVATE FUNCTION
49829 -- AcctLineType_106
49830 --
49831 ---------------------------------------
49832 PROCEDURE AcctLineType_106 (
49833 p_application_id IN NUMBER
49834 ,p_event_id IN NUMBER
49835 ,p_calculate_acctd_flag IN VARCHAR2
49836 ,p_calculate_g_l_flag IN VARCHAR2
49837 ,p_actual_flag IN OUT VARCHAR2
49838 ,p_balance_type_code OUT VARCHAR2
49839 ,p_gain_or_loss_ref OUT VARCHAR2
49840
49841 --Distribution GL Account
49842 , p_source_5 IN NUMBER
49843 --Distribution Source Type
49844 , p_source_20 IN VARCHAR2
49845 --Distribution Line Identifier
49846 , p_source_22 IN NUMBER
49847 --Distribution Type
49848 , p_source_23 IN VARCHAR2
49849 --Exchange Date
49850 , p_source_26 IN DATE
49851 --Exchange Rate
49852 , p_source_27 IN NUMBER
49853 --Exchange Rate Type
49854 , p_source_28 IN VARCHAR2
49855 --Transaction Distribution Identifier
49856 , p_source_34 IN NUMBER
49857 --Transaction Distribution Type
49858 , p_source_35 IN VARCHAR2
49859 --Receipt Applied To Application Identifier
49860 , p_source_58 IN NUMBER
49861 --Transaction Entity Code
49862 , p_source_59 IN VARCHAR2
49863 --Transaction Identifier
49864 , p_source_60 IN NUMBER
49865 --Applying Document Currency Code
49866 , p_source_61 IN VARCHAR2
49867 --Distribution Party Identifier
49868 , p_source_63 IN NUMBER
49869 --Distribution Party Site Id
49870 , p_source_64 IN NUMBER
49871 --Distribution Party Type
49872 , p_source_65 IN VARCHAR2
49873 --Distribution Multi Fund Additional Entry
49874 , p_source_67 IN VARCHAR2
49875 --DIST_ENT_AMT_FROM
49876 , p_source_68 IN NUMBER
49877 --Accounting Amount
49878 , p_source_69 IN NUMBER
49879 )
49880 IS
49881
49882 l_component_type VARCHAR2(80);
49883 l_component_code VARCHAR2(30);
49884 l_component_type_code VARCHAR2(1);
49885 l_component_appl_id INTEGER;
49886 l_amb_context_code VARCHAR2(30);
49887 l_entity_code VARCHAR2(30);
49888 l_event_class_code VARCHAR2(30);
49889 l_ae_header_id NUMBER;
49890 l_event_type_code VARCHAR2(30);
49891 l_line_definition_code VARCHAR2(30);
49892 l_line_definition_owner_code VARCHAR2(1);
49893 --
49894 -- adr variables
49895 l_segment VARCHAR2(30);
49896 l_ccid NUMBER;
49897 l_adr_transaction_coa_id NUMBER;
49898 l_adr_accounting_coa_id NUMBER;
49899 l_adr_flexfield_segment_code VARCHAR2(30);
49900 l_adr_flex_value_set_id NUMBER;
49901 l_adr_value_type_code VARCHAR2(30);
49902 l_adr_value_combination_id NUMBER;
49903 l_adr_value_segment_code VARCHAR2(30);
49904
49905 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
49906 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
49907 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
49908 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
49909
49910 -- 4262811 Variables ------------------------------------------------------------------------------------------
49911 l_entered_amt_idx NUMBER;
49912 l_accted_amt_idx NUMBER;
49913 l_acc_rev_flag VARCHAR2(1);
49914 l_accrual_line_num NUMBER;
49915 l_tmp_amt NUMBER;
49916 l_acc_rev_natural_side_code VARCHAR2(1);
49917
49918 l_num_entries NUMBER;
49919 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
49920 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
49921 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
49922 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
49923 l_recog_line_1 NUMBER;
49924 l_recog_line_2 NUMBER;
49925
49926 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
49927 l_bflow_applied_to_amt NUMBER; -- 5132302
49928 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
49929
49930 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
49931
49932 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
49933 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
49934
49935 ---------------------------------------------------------------------------------------------------------------
49936
49937
49938 --
49939 -- bulk performance
49940 --
49941 l_balance_type_code VARCHAR2(1);
49942 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
49943 l_log_module VARCHAR2(240);
49944
49945 --
49946 -- Upgrade strategy
49947 --
49948 l_actual_upg_option VARCHAR2(1);
49949 l_enc_upg_option VARCHAR2(1);
49950
49951 --
49952 BEGIN
49953 --
49954 IF g_log_enabled THEN
49955 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_106';
49956 END IF;
49957 --
49958 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
49959
49960 trace
49961 (p_msg => 'BEGIN of AcctLineType_106'
49962 ,p_level => C_LEVEL_PROCEDURE
49963 ,p_module => l_log_module);
49964
49965 END IF;
49966 --
49967 l_component_type := 'AMB_JLT';
49968 l_component_code := 'RCT_CASH';
49969 l_component_type_code := 'S';
49970 l_component_appl_id := 222;
49971 l_amb_context_code := 'DEFAULT';
49972 l_entity_code := 'RECEIPTS';
49973 l_event_class_code := 'RECEIPT';
49974 l_event_type_code := 'RECEIPT_ALL';
49975 l_line_definition_owner_code := 'S';
49976 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
49977 --
49978 l_balance_type_code := 'A';
49979 l_segment := NULL;
49980 l_ccid := NULL;
49981 l_adr_transaction_coa_id := NULL;
49982 l_adr_accounting_coa_id := NULL;
49983 l_adr_flexfield_segment_code := NULL;
49984 l_adr_flex_value_set_id := NULL;
49985 l_adr_value_type_code := NULL;
49986 l_adr_value_combination_id := NULL;
49987 l_adr_value_segment_code := NULL;
49988
49989 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
49990 l_bflow_class_code := ''; -- 4219869 Business Flow
49991 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
49992 l_budgetary_control_flag := 'N';
49993
49994 l_bflow_applied_to_amt_idx := NULL; -- 5132302
49995 l_bflow_applied_to_amt := NULL; -- 5132302
49996 l_entered_amt_idx := NULL; -- 4262811
49997 l_accted_amt_idx := NULL; -- 4262811
49998 l_acc_rev_flag := NULL; -- 4262811
49999 l_accrual_line_num := NULL; -- 4262811
50000 l_tmp_amt := NULL; -- 4262811
50001 --
50002
50003 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
50004 l_balance_type_code <> 'B' THEN
50005 IF NVL(p_source_20,'
50006 ') = 'CASH' AND
50007 NVL(p_source_67,'
50008 ') = 'N'
50009 THEN
50010
50011 --
50012 XLA_AE_LINES_PKG.SetNewLine;
50013
50014 p_balance_type_code := l_balance_type_code;
50015 -- set the flag so later we will know whether the gain loss line needs to be created
50016
50017 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
50018 p_actual_flag :='A';
50019 END IF;
50020
50021 --
50022 -- bulk performance
50023 --
50024 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
50025 p_header_num => 0); -- 4262811
50026 --
50027 -- set accounting line options
50028 --
50029 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
50030 p_natural_side_code => 'C'
50031 , p_gain_or_loss_flag => 'N'
50032 , p_gl_transfer_mode_code => 'S'
50033 , p_acct_entry_type_code => 'A'
50034 , p_switch_side_flag => 'Y'
50035 , p_merge_duplicate_code => 'A'
50036 );
50037 --
50038 l_acc_rev_natural_side_code := 'D'; -- 4262811
50039 --
50040 --
50041 -- set accounting line type info
50042 --
50043 xla_ae_lines_pkg.SetAcctLineType
50044 (p_component_type => l_component_type
50045 ,p_event_type_code => l_event_type_code
50046 ,p_line_definition_owner_code => l_line_definition_owner_code
50047 ,p_line_definition_code => l_line_definition_code
50048 ,p_accounting_line_code => l_component_code
50049 ,p_accounting_line_type_code => l_component_type_code
50050 ,p_accounting_line_appl_id => l_component_appl_id
50051 ,p_amb_context_code => l_amb_context_code
50052 ,p_entity_code => l_entity_code
50053 ,p_event_class_code => l_event_class_code);
50054 --
50055 -- set accounting class
50056 --
50057 xla_ae_lines_pkg.SetAcctClass(
50058 p_accounting_class_code => 'CASH'
50059 , p_ae_header_id => l_ae_header_id
50060 );
50061
50062 --
50063 -- set rounding class
50064 --
50065 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
50066 'RECEIVABLE';
50067
50068 --
50069 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
50070 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
50071 --
50072 -- bulk performance
50073 --
50074 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
50075
50076 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
50077 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
50078
50079 -- 4955764
50080 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50081 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
50082
50083 -- 4458381 Public Sector Enh
50084
50085 --
50086 -- set accounting attributes for the line type
50087 --
50088 l_entered_amt_idx := 8;
50089 l_accted_amt_idx := 13;
50090 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50091 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
50092 l_rec_acct_attrs.array_num_value(1) := p_source_58;
50093 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
50094 l_rec_acct_attrs.array_char_value(2) := p_source_35;
50095 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
50096 l_rec_acct_attrs.array_char_value(3) := p_source_59;
50097 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
50098 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
50099 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
50100 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
50101 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
50102 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
50103 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
50104 l_rec_acct_attrs.array_char_value(7) := p_source_23;
50105 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
50106 l_rec_acct_attrs.array_num_value(8) := p_source_68;
50107 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
50108 l_rec_acct_attrs.array_char_value(9) := p_source_61;
50109 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
50110 l_rec_acct_attrs.array_date_value(10) := p_source_26;
50111 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
50112 l_rec_acct_attrs.array_num_value(11) := p_source_27;
50113 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
50114 l_rec_acct_attrs.array_char_value(12) := p_source_28;
50115 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
50116 l_rec_acct_attrs.array_num_value(13) := p_source_69;
50117 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
50118 l_rec_acct_attrs.array_num_value(14) := p_source_63;
50119 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
50120 l_rec_acct_attrs.array_num_value(15) := p_source_64;
50121 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
50122 l_rec_acct_attrs.array_char_value(16) := p_source_65;
50123
50124 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
50125 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
50126
50127 ---------------------------------------------------------------------------------------------------------------
50128 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
50129 ---------------------------------------------------------------------------------------------------------------
50130 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
50131
50132 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50133 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50134
50135 IF xla_accounting_cache_pkg.GetValueChar
50136 (p_source_code => 'LEDGER_CATEGORY_CODE'
50137 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
50138 AND l_bflow_method_code = 'PRIOR_ENTRY'
50139 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
50140 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
50141 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
50142 )
50143 THEN
50144 xla_ae_lines_pkg.BflowUpgEntry
50145 (p_business_method_code => l_bflow_method_code
50146 ,p_business_class_code => l_bflow_class_code
50147 ,p_balance_type => l_balance_type_code);
50148 ELSE
50149 NULL;
50150 -- No business flow processing for business flow method of NONE.
50151 END IF;
50152
50153 --
50154 -- call analytical criteria
50155 --
50156
50157 --
50158 -- call description
50159 --
50160 -- No description or it is inherited.
50161 --
50162 -- call ADRs
50163 -- Bug 4922099
50164 --
50165 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50166 (NVL(l_actual_upg_option, 'N') = 'O') OR
50167 (NVL(l_enc_upg_option, 'N') = 'O')
50168 )
50169 THEN
50170 NULL;
50171 --
50172 --
50173
50174 l_ccid := AcctDerRule_4(
50175 p_application_id => p_application_id
50176 , p_ae_header_id => l_ae_header_id
50177 , p_source_5 => p_source_5
50178 , x_transaction_coa_id => l_adr_transaction_coa_id
50179 , x_accounting_coa_id => l_adr_accounting_coa_id
50180 , x_value_type_code => l_adr_value_type_code
50181 , p_side => 'NA'
50182 );
50183
50184 xla_ae_lines_pkg.set_ccid(
50185 p_code_combination_id => l_ccid
50186 , p_value_type_code => l_adr_value_type_code
50187 , p_transaction_coa_id => l_adr_transaction_coa_id
50188 , p_accounting_coa_id => l_adr_accounting_coa_id
50189 , p_adr_code => 'DIST_CCID'
50190 , p_adr_type_code => 'S'
50191 , p_component_type => l_component_type
50192 , p_component_code => l_component_code
50193 , p_component_type_code => l_component_type_code
50194 , p_component_appl_id => l_component_appl_id
50195 , p_amb_context_code => l_amb_context_code
50196 , p_side => 'NA'
50197 );
50198
50199
50200 --
50201 --
50202 END IF;
50203 --
50204 -- Bug 4922099
50205 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
50206 (NVL(l_enc_upg_option, 'N') = 'O')
50207 ) AND
50208 (l_bflow_method_code = 'PRIOR_ENTRY')
50209 )
50210 THEN
50211 IF
50212 --
50213 1 = 2
50214 --
50215 THEN
50216 xla_accounting_err_pkg.build_message
50217 (p_appli_s_name => 'XLA'
50218 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50219 ,p_token_1 => 'LINE_NUMBER'
50220 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
50221 ,p_token_2 => 'LINE_TYPE_NAME'
50222 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
50223 l_component_type
50224 ,l_component_code
50225 ,l_component_type_code
50226 ,l_component_appl_id
50227 ,l_amb_context_code
50228 ,l_entity_code
50229 ,l_event_class_code
50230 )
50231 ,p_token_3 => 'OWNER'
50232 ,p_value_3 => xla_lookups_pkg.get_meaning(
50233 p_lookup_type => 'XLA_OWNER_TYPE'
50234 ,p_lookup_code => l_component_type_code
50235 )
50236 ,p_token_4 => 'PRODUCT_NAME'
50240 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
50237 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
50238 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
50239 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
50241 ,p_ae_header_id => NULL
50242 );
50243
50244 IF (C_LEVEL_ERROR>= g_log_level) THEN
50245 trace
50246 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50247 ,p_level => C_LEVEL_ERROR
50248 ,p_module => l_log_module);
50249 END IF;
50250 END IF;
50251 END IF;
50252 --
50253 --
50254 ------------------------------------------------------------------------------------------------
50255 -- 4219869 Business Flow
50256 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
50257 -- Prior Entry. Currently, the following code is always generated.
50258 ------------------------------------------------------------------------------------------------
50259 XLA_AE_LINES_PKG.ValidateCurrentLine;
50260
50261 ------------------------------------------------------------------------------------
50262 -- 4219869 Business Flow
50263 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
50264 ------------------------------------------------------------------------------------
50265 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50266
50267 ----------------------------------------------------------------------------------
50268 -- 4219869 Business Flow
50269 -- Update journal entry status -- Need to generate this within IF <condition>
50270 ----------------------------------------------------------------------------------
50271 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50272 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
50273 ,p_balance_type_code => l_balance_type_code
50274 );
50275
50276 -------------------------------------------------------------------------------------------
50277 -- 4262811 - Generate the Accrual Reversal lines
50278 -------------------------------------------------------------------------------------------
50279 BEGIN
50280 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
50281 (g_array_event(p_event_id).array_value_num('header_index'));
50282 IF l_acc_rev_flag IS NULL THEN
50283 l_acc_rev_flag := 'N';
50284 END IF;
50285 EXCEPTION
50286 WHEN OTHERS THEN
50287 l_acc_rev_flag := 'N';
50288 END;
50289 --
50290 IF (l_acc_rev_flag = 'Y') THEN
50291
50292 -- 4645092 ------------------------------------------------------------------------------
50293 -- To allow MPA report to determine if it should generate report process
50294 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
50295 ------------------------------------------------------------------------------------------
50296
50297 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
50298 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
50299 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
50300 -- call ADRs
50301 -- Bug 4922099
50302 --
50303 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50304 (NVL(l_actual_upg_option, 'N') = 'O') OR
50305 (NVL(l_enc_upg_option, 'N') = 'O')
50306 )
50307 THEN
50308 NULL;
50309 --
50310 --
50311
50312 l_ccid := AcctDerRule_4(
50313 p_application_id => p_application_id
50314 , p_ae_header_id => l_ae_header_id
50315 , p_source_5 => p_source_5
50316 , x_transaction_coa_id => l_adr_transaction_coa_id
50317 , x_accounting_coa_id => l_adr_accounting_coa_id
50318 , x_value_type_code => l_adr_value_type_code
50319 , p_side => 'NA'
50320 );
50321
50322 xla_ae_lines_pkg.set_ccid(
50323 p_code_combination_id => l_ccid
50324 , p_value_type_code => l_adr_value_type_code
50325 , p_transaction_coa_id => l_adr_transaction_coa_id
50326 , p_accounting_coa_id => l_adr_accounting_coa_id
50327 , p_adr_code => 'DIST_CCID'
50328 , p_adr_type_code => 'S'
50329 , p_component_type => l_component_type
50330 , p_component_code => l_component_code
50331 , p_component_type_code => l_component_type_code
50332 , p_component_appl_id => l_component_appl_id
50333 , p_amb_context_code => l_amb_context_code
50334 , p_side => 'NA'
50335 );
50336
50337
50338 --
50339 --
50340 END IF;
50341
50342 --
50343 -- Update the line information that should be overwritten
50344 --
50345 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
50346 p_header_num => 1);
50347 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
50348
50349 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
50350
50351 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
50352 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
50353 END IF;
50354
50355 --
50356 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
50357 --
50358 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
50359 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
50360 ELSE
50361 ---------------------------------------------------------------------------------------------------
50362 -- 4262811a Switch Sign
50363 ---------------------------------------------------------------------------------------------------
50364 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
50365 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50366 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50367 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50368 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50369 -- 5132302
50370 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
50371 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50372
50373 END IF;
50374
50375 -- 4955764
50376 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50377 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
50378
50379
50380 XLA_AE_LINES_PKG.ValidateCurrentLine;
50381 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50382
50383 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50384 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
50385 ,p_balance_type_code => l_balance_type_code);
50386
50387 END IF;
50388
50389 -----------------------------------------------------------------------------------------
50390 -- 4262811 Multiperiod Accounting
50391 -----------------------------------------------------------------------------------------
50392 -- No MPA option is assigned.
50393
50394
50395 END IF;
50396 END IF;
50397 --
50398
50399 --
50400 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
50401 trace
50402 (p_msg => 'END of AcctLineType_106'
50403 ,p_level => C_LEVEL_PROCEDURE
50404 ,p_module => l_log_module);
50405 END IF;
50406 --
50407 EXCEPTION
50408 WHEN xla_exceptions_pkg.application_exception THEN
50409 RAISE;
50410 WHEN OTHERS THEN
50411 xla_exceptions_pkg.raise_message
50412 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_106');
50413 END AcctLineType_106;
50414 --
50415
50416 ---------------------------------------
50417 --
50418 -- PRIVATE FUNCTION
50419 -- AcctLineType_107
50420 --
50421 ---------------------------------------
50422 PROCEDURE AcctLineType_107 (
50423 p_application_id IN NUMBER
50424 ,p_event_id IN NUMBER
50425 ,p_calculate_acctd_flag IN VARCHAR2
50426 ,p_calculate_g_l_flag IN VARCHAR2
50427 ,p_actual_flag IN OUT VARCHAR2
50428 ,p_balance_type_code OUT VARCHAR2
50429 ,p_gain_or_loss_ref OUT VARCHAR2
50430
50431 --Distribution GL Account
50432 , p_source_5 IN NUMBER
50433 --Distribution Source Type
50434 , p_source_20 IN VARCHAR2
50435 --Receivable Activity Type
50436 , p_source_21 IN VARCHAR2
50437 --Distribution Line Identifier
50438 , p_source_22 IN NUMBER
50439 --Distribution Type
50440 , p_source_23 IN VARCHAR2
50441 --Exchange Date
50442 , p_source_26 IN DATE
50443 --Exchange Rate
50444 , p_source_27 IN NUMBER
50445 --Transaction Distribution Identifier
50446 , p_source_34 IN NUMBER
50447 --Transaction Distribution Type
50448 , p_source_35 IN VARCHAR2
50449 --Receipt Applied To Application Identifier
50450 , p_source_58 IN NUMBER
50451 --Transaction Entity Code
50452 , p_source_59 IN VARCHAR2
50453 --Transaction Identifier
50454 , p_source_60 IN NUMBER
50455 --Applying Document Currency Code
50456 , p_source_61 IN VARCHAR2
50457 --Distribution Party Identifier
50458 , p_source_63 IN NUMBER
50459 --Distribution Party Site Id
50460 , p_source_64 IN NUMBER
50461 --Distribution Party Type
50462 , p_source_65 IN VARCHAR2
50463 --Distribution Multi Fund Additional Entry
50464 , p_source_67 IN VARCHAR2
50465 --DIST_ENT_AMT_FROM
50466 , p_source_68 IN NUMBER
50467 --Accounting Amount
50468 , p_source_69 IN NUMBER
50469 --Applied To Document Exchange Rate Type
50470 , p_source_70 IN VARCHAR2
50471 )
50472 IS
50473
50474 l_component_type VARCHAR2(80);
50475 l_component_code VARCHAR2(30);
50476 l_component_type_code VARCHAR2(1);
50477 l_component_appl_id INTEGER;
50478 l_amb_context_code VARCHAR2(30);
50479 l_entity_code VARCHAR2(30);
50480 l_event_class_code VARCHAR2(30);
50481 l_ae_header_id NUMBER;
50482 l_event_type_code VARCHAR2(30);
50483 l_line_definition_code VARCHAR2(30);
50484 l_line_definition_owner_code VARCHAR2(1);
50485 --
50486 -- adr variables
50487 l_segment VARCHAR2(30);
50488 l_ccid NUMBER;
50489 l_adr_transaction_coa_id NUMBER;
50490 l_adr_accounting_coa_id NUMBER;
50491 l_adr_flexfield_segment_code VARCHAR2(30);
50492 l_adr_flex_value_set_id NUMBER;
50493 l_adr_value_type_code VARCHAR2(30);
50494 l_adr_value_combination_id NUMBER;
50495 l_adr_value_segment_code VARCHAR2(30);
50496
50497 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
50498 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
50499 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
50500 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
50501
50502 -- 4262811 Variables ------------------------------------------------------------------------------------------
50503 l_entered_amt_idx NUMBER;
50504 l_accted_amt_idx NUMBER;
50505 l_acc_rev_flag VARCHAR2(1);
50506 l_accrual_line_num NUMBER;
50507 l_tmp_amt NUMBER;
50508 l_acc_rev_natural_side_code VARCHAR2(1);
50509
50510 l_num_entries NUMBER;
50511 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
50512 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
50513 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
50514 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
50515 l_recog_line_1 NUMBER;
50516 l_recog_line_2 NUMBER;
50517
50518 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
50519 l_bflow_applied_to_amt NUMBER; -- 5132302
50520 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
50521
50522 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
50523
50524 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
50525 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
50526
50527 ---------------------------------------------------------------------------------------------------------------
50528
50529
50530 --
50531 -- bulk performance
50532 --
50533 l_balance_type_code VARCHAR2(1);
50534 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
50535 l_log_module VARCHAR2(240);
50536
50537 --
50538 -- Upgrade strategy
50539 --
50540 l_actual_upg_option VARCHAR2(1);
50541 l_enc_upg_option VARCHAR2(1);
50542
50543 --
50544 BEGIN
50545 --
50546 IF g_log_enabled THEN
50547 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_107';
50548 END IF;
50549 --
50550 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
50551
50552 trace
50553 (p_msg => 'BEGIN of AcctLineType_107'
50554 ,p_level => C_LEVEL_PROCEDURE
50555 ,p_module => l_log_module);
50556
50557 END IF;
50558 --
50559 l_component_type := 'AMB_JLT';
50560 l_component_code := 'RCT_CC_CHARGEBACK';
50561 l_component_type_code := 'S';
50562 l_component_appl_id := 222;
50563 l_amb_context_code := 'DEFAULT';
50564 l_entity_code := 'RECEIPTS';
50565 l_event_class_code := 'RECEIPT';
50566 l_event_type_code := 'RECEIPT_ALL';
50567 l_line_definition_owner_code := 'S';
50568 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
50569 --
50570 l_balance_type_code := 'A';
50571 l_segment := NULL;
50572 l_ccid := NULL;
50573 l_adr_transaction_coa_id := NULL;
50574 l_adr_accounting_coa_id := NULL;
50575 l_adr_flexfield_segment_code := NULL;
50576 l_adr_flex_value_set_id := NULL;
50577 l_adr_value_type_code := NULL;
50578 l_adr_value_combination_id := NULL;
50579 l_adr_value_segment_code := NULL;
50580
50581 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
50582 l_bflow_class_code := ''; -- 4219869 Business Flow
50583 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
50584 l_budgetary_control_flag := 'N';
50585
50586 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50587 l_bflow_applied_to_amt := NULL; -- 5132302
50588 l_entered_amt_idx := NULL; -- 4262811
50589 l_accted_amt_idx := NULL; -- 4262811
50590 l_acc_rev_flag := NULL; -- 4262811
50591 l_accrual_line_num := NULL; -- 4262811
50592 l_tmp_amt := NULL; -- 4262811
50593 --
50594
50595 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
50596 l_balance_type_code <> 'B' THEN
50597 IF NVL(p_source_20,'
50598 ') = 'ACTIVITY' AND
50599 NVL(p_source_21,'
50600 ') = 'CC_CHARGEBACK' AND
50601 NVL(p_source_67,'
50602 ') = 'N'
50603 THEN
50604
50605 --
50606 XLA_AE_LINES_PKG.SetNewLine;
50607
50608 p_balance_type_code := l_balance_type_code;
50609 -- set the flag so later we will know whether the gain loss line needs to be created
50610
50611 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
50612 p_actual_flag :='A';
50613 END IF;
50614
50615 --
50616 -- bulk performance
50617 --
50618 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
50619 p_header_num => 0); -- 4262811
50620 --
50621 -- set accounting line options
50622 --
50623 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
50624 p_natural_side_code => 'C'
50625 , p_gain_or_loss_flag => 'N'
50626 , p_gl_transfer_mode_code => 'S'
50627 , p_acct_entry_type_code => 'A'
50628 , p_switch_side_flag => 'Y'
50629 , p_merge_duplicate_code => 'A'
50630 );
50631 --
50632 l_acc_rev_natural_side_code := 'D'; -- 4262811
50633 --
50634 --
50635 -- set accounting line type info
50636 --
50637 xla_ae_lines_pkg.SetAcctLineType
50638 (p_component_type => l_component_type
50639 ,p_event_type_code => l_event_type_code
50640 ,p_line_definition_owner_code => l_line_definition_owner_code
50641 ,p_line_definition_code => l_line_definition_code
50642 ,p_accounting_line_code => l_component_code
50643 ,p_accounting_line_type_code => l_component_type_code
50644 ,p_accounting_line_appl_id => l_component_appl_id
50645 ,p_amb_context_code => l_amb_context_code
50646 ,p_entity_code => l_entity_code
50647 ,p_event_class_code => l_event_class_code);
50648 --
50649 -- set accounting class
50650 --
50651 xla_ae_lines_pkg.SetAcctClass(
50652 p_accounting_class_code => 'CLAIM'
50653 , p_ae_header_id => l_ae_header_id
50654 );
50655
50656 --
50657 -- set rounding class
50658 --
50659 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
50660 'RECEIVABLE';
50661
50662 --
50663 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
50664 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
50665 --
50666 -- bulk performance
50667 --
50668 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
50669
50670 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
50671 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
50672
50673 -- 4955764
50674 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50675 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
50676
50677 -- 4458381 Public Sector Enh
50678
50679 --
50680 -- set accounting attributes for the line type
50681 --
50682 l_entered_amt_idx := 8;
50683 l_accted_amt_idx := 13;
50684 l_bflow_applied_to_amt_idx := NULL; -- 5132302
50685 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
50686 l_rec_acct_attrs.array_num_value(1) := p_source_58;
50687 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
50688 l_rec_acct_attrs.array_char_value(2) := p_source_35;
50689 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
50690 l_rec_acct_attrs.array_char_value(3) := p_source_59;
50691 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
50692 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
50693 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
50694 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
50695 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
50696 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
50697 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
50698 l_rec_acct_attrs.array_char_value(7) := p_source_23;
50699 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
50700 l_rec_acct_attrs.array_num_value(8) := p_source_68;
50701 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
50702 l_rec_acct_attrs.array_char_value(9) := p_source_61;
50703 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
50704 l_rec_acct_attrs.array_date_value(10) := p_source_26;
50705 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
50706 l_rec_acct_attrs.array_num_value(11) := p_source_27;
50707 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
50708 l_rec_acct_attrs.array_char_value(12) := p_source_70;
50709 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
50710 l_rec_acct_attrs.array_num_value(13) := p_source_69;
50711 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
50712 l_rec_acct_attrs.array_num_value(14) := p_source_63;
50713 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
50714 l_rec_acct_attrs.array_num_value(15) := p_source_64;
50715 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
50716 l_rec_acct_attrs.array_char_value(16) := p_source_65;
50717
50718 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
50719 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
50720
50721 ---------------------------------------------------------------------------------------------------------------
50722 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
50723 ---------------------------------------------------------------------------------------------------------------
50724 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
50725
50726 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50727 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
50728
50729 IF xla_accounting_cache_pkg.GetValueChar
50730 (p_source_code => 'LEDGER_CATEGORY_CODE'
50731 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
50732 AND l_bflow_method_code = 'PRIOR_ENTRY'
50733 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
50734 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
50735 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
50736 )
50737 THEN
50738 xla_ae_lines_pkg.BflowUpgEntry
50739 (p_business_method_code => l_bflow_method_code
50740 ,p_business_class_code => l_bflow_class_code
50741 ,p_balance_type => l_balance_type_code);
50742 ELSE
50743 NULL;
50744 -- No business flow processing for business flow method of NONE.
50745 END IF;
50746
50747 --
50748 -- call analytical criteria
50749 --
50750
50751 --
50752 -- call description
50753 --
50754 -- No description or it is inherited.
50755 --
50756 -- call ADRs
50757 -- Bug 4922099
50758 --
50759 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50760 (NVL(l_actual_upg_option, 'N') = 'O') OR
50761 (NVL(l_enc_upg_option, 'N') = 'O')
50762 )
50763 THEN
50764 NULL;
50765 --
50766 --
50767
50768 l_ccid := AcctDerRule_4(
50769 p_application_id => p_application_id
50770 , p_ae_header_id => l_ae_header_id
50771 , p_source_5 => p_source_5
50772 , x_transaction_coa_id => l_adr_transaction_coa_id
50773 , x_accounting_coa_id => l_adr_accounting_coa_id
50774 , x_value_type_code => l_adr_value_type_code
50775 , p_side => 'NA'
50776 );
50777
50778 xla_ae_lines_pkg.set_ccid(
50779 p_code_combination_id => l_ccid
50780 , p_value_type_code => l_adr_value_type_code
50781 , p_transaction_coa_id => l_adr_transaction_coa_id
50782 , p_accounting_coa_id => l_adr_accounting_coa_id
50783 , p_adr_code => 'DIST_CCID'
50784 , p_adr_type_code => 'S'
50785 , p_component_type => l_component_type
50786 , p_component_code => l_component_code
50787 , p_component_type_code => l_component_type_code
50788 , p_component_appl_id => l_component_appl_id
50789 , p_amb_context_code => l_amb_context_code
50790 , p_side => 'NA'
50791 );
50792
50793
50794 --
50795 --
50796 END IF;
50797 --
50798 -- Bug 4922099
50799 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
50800 (NVL(l_enc_upg_option, 'N') = 'O')
50801 ) AND
50802 (l_bflow_method_code = 'PRIOR_ENTRY')
50803 )
50804 THEN
50805 IF
50806 --
50807 1 = 2
50808 --
50809 THEN
50810 xla_accounting_err_pkg.build_message
50811 (p_appli_s_name => 'XLA'
50812 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50813 ,p_token_1 => 'LINE_NUMBER'
50814 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
50815 ,p_token_2 => 'LINE_TYPE_NAME'
50816 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
50817 l_component_type
50818 ,l_component_code
50819 ,l_component_type_code
50820 ,l_component_appl_id
50821 ,l_amb_context_code
50822 ,l_entity_code
50823 ,l_event_class_code
50824 )
50825 ,p_token_3 => 'OWNER'
50826 ,p_value_3 => xla_lookups_pkg.get_meaning(
50827 p_lookup_type => 'XLA_OWNER_TYPE'
50828 ,p_lookup_code => l_component_type_code
50829 )
50830 ,p_token_4 => 'PRODUCT_NAME'
50831 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
50832 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
50833 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
50834 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
50835 ,p_ae_header_id => NULL
50836 );
50837
50838 IF (C_LEVEL_ERROR>= g_log_level) THEN
50839 trace
50840 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
50841 ,p_level => C_LEVEL_ERROR
50842 ,p_module => l_log_module);
50843 END IF;
50844 END IF;
50845 END IF;
50846 --
50847 --
50848 ------------------------------------------------------------------------------------------------
50849 -- 4219869 Business Flow
50850 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
50851 -- Prior Entry. Currently, the following code is always generated.
50852 ------------------------------------------------------------------------------------------------
50853 XLA_AE_LINES_PKG.ValidateCurrentLine;
50854
50855 ------------------------------------------------------------------------------------
50856 -- 4219869 Business Flow
50857 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
50858 ------------------------------------------------------------------------------------
50859 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50860
50861 ----------------------------------------------------------------------------------
50862 -- 4219869 Business Flow
50863 -- Update journal entry status -- Need to generate this within IF <condition>
50864 ----------------------------------------------------------------------------------
50865 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50866 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
50867 ,p_balance_type_code => l_balance_type_code
50868 );
50869
50870 -------------------------------------------------------------------------------------------
50871 -- 4262811 - Generate the Accrual Reversal lines
50872 -------------------------------------------------------------------------------------------
50873 BEGIN
50874 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
50875 (g_array_event(p_event_id).array_value_num('header_index'));
50876 IF l_acc_rev_flag IS NULL THEN
50877 l_acc_rev_flag := 'N';
50878 END IF;
50879 EXCEPTION
50880 WHEN OTHERS THEN
50881 l_acc_rev_flag := 'N';
50882 END;
50883 --
50884 IF (l_acc_rev_flag = 'Y') THEN
50885
50886 -- 4645092 ------------------------------------------------------------------------------
50887 -- To allow MPA report to determine if it should generate report process
50888 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
50889 ------------------------------------------------------------------------------------------
50890
50891 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
50892 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
50893 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
50894 -- call ADRs
50895 -- Bug 4922099
50896 --
50897 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
50898 (NVL(l_actual_upg_option, 'N') = 'O') OR
50899 (NVL(l_enc_upg_option, 'N') = 'O')
50900 )
50901 THEN
50902 NULL;
50903 --
50904 --
50905
50906 l_ccid := AcctDerRule_4(
50907 p_application_id => p_application_id
50908 , p_ae_header_id => l_ae_header_id
50909 , p_source_5 => p_source_5
50910 , x_transaction_coa_id => l_adr_transaction_coa_id
50911 , x_accounting_coa_id => l_adr_accounting_coa_id
50912 , x_value_type_code => l_adr_value_type_code
50913 , p_side => 'NA'
50914 );
50915
50916 xla_ae_lines_pkg.set_ccid(
50917 p_code_combination_id => l_ccid
50918 , p_value_type_code => l_adr_value_type_code
50919 , p_transaction_coa_id => l_adr_transaction_coa_id
50920 , p_accounting_coa_id => l_adr_accounting_coa_id
50921 , p_adr_code => 'DIST_CCID'
50922 , p_adr_type_code => 'S'
50923 , p_component_type => l_component_type
50927 , p_amb_context_code => l_amb_context_code
50924 , p_component_code => l_component_code
50925 , p_component_type_code => l_component_type_code
50926 , p_component_appl_id => l_component_appl_id
50928 , p_side => 'NA'
50929 );
50930
50931
50932 --
50933 --
50934 END IF;
50935
50936 --
50937 -- Update the line information that should be overwritten
50938 --
50939 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
50940 p_header_num => 1);
50941 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
50942
50943 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
50944
50945 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
50946 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
50947 END IF;
50948
50949 --
50950 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
50951 --
50952 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
50953 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
50954 ELSE
50955 ---------------------------------------------------------------------------------------------------
50956 -- 4262811a Switch Sign
50957 ---------------------------------------------------------------------------------------------------
50958 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
50959 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50960 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50961 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
50962 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50963 -- 5132302
50964 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
50965 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
50966
50967 END IF;
50968
50969 -- 4955764
50970 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
50971 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
50972
50973
50974 XLA_AE_LINES_PKG.ValidateCurrentLine;
50975 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
50976
50977 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
50978 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
50979 ,p_balance_type_code => l_balance_type_code);
50980
50981 END IF;
50982
50983 -----------------------------------------------------------------------------------------
50984 -- 4262811 Multiperiod Accounting
50985 -----------------------------------------------------------------------------------------
50986 -- No MPA option is assigned.
50987
50988
50989 END IF;
50990 END IF;
50991 --
50992
50993 --
50994 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
50995 trace
50996 (p_msg => 'END of AcctLineType_107'
50997 ,p_level => C_LEVEL_PROCEDURE
50998 ,p_module => l_log_module);
50999 END IF;
51000 --
51001 EXCEPTION
51002 WHEN xla_exceptions_pkg.application_exception THEN
51003 RAISE;
51004 WHEN OTHERS THEN
51005 xla_exceptions_pkg.raise_message
51006 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_107');
51007 END AcctLineType_107;
51008 --
51009
51010 ---------------------------------------
51011 --
51012 -- PRIVATE FUNCTION
51013 -- AcctLineType_108
51014 --
51015 ---------------------------------------
51016 PROCEDURE AcctLineType_108 (
51017 p_application_id IN NUMBER
51018 ,p_event_id IN NUMBER
51019 ,p_calculate_acctd_flag IN VARCHAR2
51020 ,p_calculate_g_l_flag IN VARCHAR2
51021 ,p_actual_flag IN OUT VARCHAR2
51022 ,p_balance_type_code OUT VARCHAR2
51023 ,p_gain_or_loss_ref OUT VARCHAR2
51024
51025 --Distribution GL Account
51026 , p_source_5 IN NUMBER
51027 --Distribution Source Type
51028 , p_source_20 IN VARCHAR2
51029 --Receivable Activity Type
51030 , p_source_21 IN VARCHAR2
51031 --Distribution Line Identifier
51032 , p_source_22 IN NUMBER
51033 --Distribution Type
51034 , p_source_23 IN VARCHAR2
51035 --Exchange Date
51036 , p_source_26 IN DATE
51037 --Exchange Rate
51038 , p_source_27 IN NUMBER
51039 --Transaction Distribution Identifier
51040 , p_source_34 IN NUMBER
51041 --Transaction Distribution Type
51042 , p_source_35 IN VARCHAR2
51043 --Receipt Applied To Application Identifier
51044 , p_source_58 IN NUMBER
51045 --Transaction Entity Code
51046 , p_source_59 IN VARCHAR2
51047 --Transaction Identifier
51048 , p_source_60 IN NUMBER
51049 --Applying Document Currency Code
51050 , p_source_61 IN VARCHAR2
51051 --Distribution Party Identifier
51052 , p_source_63 IN NUMBER
51053 --Distribution Party Site Id
51054 , p_source_64 IN NUMBER
51055 --Distribution Party Type
51056 , p_source_65 IN VARCHAR2
51057 --Distribution Multi Fund Additional Entry
51058 , p_source_67 IN VARCHAR2
51059 --DIST_ENT_AMT_FROM
51060 , p_source_68 IN NUMBER
51061 --Accounting Amount
51062 , p_source_69 IN NUMBER
51063 --Applied To Document Exchange Rate Type
51064 , p_source_70 IN VARCHAR2
51065 )
51066 IS
51067
51068 l_component_type VARCHAR2(80);
51069 l_component_code VARCHAR2(30);
51070 l_component_type_code VARCHAR2(1);
51071 l_component_appl_id INTEGER;
51072 l_amb_context_code VARCHAR2(30);
51073 l_entity_code VARCHAR2(30);
51074 l_event_class_code VARCHAR2(30);
51075 l_ae_header_id NUMBER;
51076 l_event_type_code VARCHAR2(30);
51077 l_line_definition_code VARCHAR2(30);
51078 l_line_definition_owner_code VARCHAR2(1);
51079 --
51080 -- adr variables
51081 l_segment VARCHAR2(30);
51082 l_ccid NUMBER;
51083 l_adr_transaction_coa_id NUMBER;
51084 l_adr_accounting_coa_id NUMBER;
51085 l_adr_flexfield_segment_code VARCHAR2(30);
51086 l_adr_flex_value_set_id NUMBER;
51087 l_adr_value_type_code VARCHAR2(30);
51088 l_adr_value_combination_id NUMBER;
51089 l_adr_value_segment_code VARCHAR2(30);
51090
51091 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
51092 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
51093 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
51094 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
51095
51096 -- 4262811 Variables ------------------------------------------------------------------------------------------
51097 l_entered_amt_idx NUMBER;
51098 l_accted_amt_idx NUMBER;
51099 l_acc_rev_flag VARCHAR2(1);
51100 l_accrual_line_num NUMBER;
51101 l_tmp_amt NUMBER;
51102 l_acc_rev_natural_side_code VARCHAR2(1);
51103
51104 l_num_entries NUMBER;
51105 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
51106 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
51107 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
51108 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
51109 l_recog_line_1 NUMBER;
51110 l_recog_line_2 NUMBER;
51111
51112 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
51113 l_bflow_applied_to_amt NUMBER; -- 5132302
51114 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
51115
51116 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
51117
51118 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
51119 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
51120
51121 ---------------------------------------------------------------------------------------------------------------
51122
51123
51124 --
51125 -- bulk performance
51126 --
51127 l_balance_type_code VARCHAR2(1);
51128 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
51129 l_log_module VARCHAR2(240);
51130
51131 --
51132 -- Upgrade strategy
51133 --
51134 l_actual_upg_option VARCHAR2(1);
51135 l_enc_upg_option VARCHAR2(1);
51136
51137 --
51138 BEGIN
51139 --
51140 IF g_log_enabled THEN
51141 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_108';
51142 END IF;
51143 --
51144 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51145
51146 trace
51147 (p_msg => 'BEGIN of AcctLineType_108'
51148 ,p_level => C_LEVEL_PROCEDURE
51149 ,p_module => l_log_module);
51150
51151 END IF;
51152 --
51153 l_component_type := 'AMB_JLT';
51154 l_component_code := 'RCT_CHARGEBACK';
51155 l_component_type_code := 'S';
51156 l_component_appl_id := 222;
51157 l_amb_context_code := 'DEFAULT';
51158 l_entity_code := 'RECEIPTS';
51159 l_event_class_code := 'RECEIPT';
51160 l_event_type_code := 'RECEIPT_ALL';
51161 l_line_definition_owner_code := 'S';
51162 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
51163 --
51164 l_balance_type_code := 'A';
51165 l_segment := NULL;
51166 l_ccid := NULL;
51167 l_adr_transaction_coa_id := NULL;
51168 l_adr_accounting_coa_id := NULL;
51169 l_adr_flexfield_segment_code := NULL;
51170 l_adr_flex_value_set_id := NULL;
51171 l_adr_value_type_code := NULL;
51172 l_adr_value_combination_id := NULL;
51173 l_adr_value_segment_code := NULL;
51174
51175 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
51176 l_bflow_class_code := ''; -- 4219869 Business Flow
51177 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
51178 l_budgetary_control_flag := 'N';
51179
51180 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51181 l_bflow_applied_to_amt := NULL; -- 5132302
51182 l_entered_amt_idx := NULL; -- 4262811
51183 l_accted_amt_idx := NULL; -- 4262811
51184 l_acc_rev_flag := NULL; -- 4262811
51185 l_accrual_line_num := NULL; -- 4262811
51186 l_tmp_amt := NULL; -- 4262811
51187 --
51188
51189 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
51190 l_balance_type_code <> 'B' THEN
51191 IF NVL(p_source_20,'
51192 ') = 'ACTIVITY' AND
51193 NVL(p_source_21,'
51194 ') = 'ADJUST' AND
51195 NVL(p_source_67,'
51196 ') = 'N'
51197 THEN
51198
51199 --
51200 XLA_AE_LINES_PKG.SetNewLine;
51201
51202 p_balance_type_code := l_balance_type_code;
51203 -- set the flag so later we will know whether the gain loss line needs to be created
51204
51205 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
51206 p_actual_flag :='A';
51207 END IF;
51208
51209 --
51210 -- bulk performance
51211 --
51212 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
51213 p_header_num => 0); -- 4262811
51214 --
51215 -- set accounting line options
51216 --
51217 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
51218 p_natural_side_code => 'C'
51219 , p_gain_or_loss_flag => 'N'
51220 , p_gl_transfer_mode_code => 'S'
51221 , p_acct_entry_type_code => 'A'
51222 , p_switch_side_flag => 'Y'
51223 , p_merge_duplicate_code => 'A'
51224 );
51225 --
51226 l_acc_rev_natural_side_code := 'D'; -- 4262811
51227 --
51228 --
51229 -- set accounting line type info
51230 --
51231 xla_ae_lines_pkg.SetAcctLineType
51232 (p_component_type => l_component_type
51233 ,p_event_type_code => l_event_type_code
51234 ,p_line_definition_owner_code => l_line_definition_owner_code
51235 ,p_line_definition_code => l_line_definition_code
51236 ,p_accounting_line_code => l_component_code
51237 ,p_accounting_line_type_code => l_component_type_code
51238 ,p_accounting_line_appl_id => l_component_appl_id
51239 ,p_amb_context_code => l_amb_context_code
51240 ,p_entity_code => l_entity_code
51241 ,p_event_class_code => l_event_class_code);
51242 --
51243 -- set accounting class
51244 --
51245 xla_ae_lines_pkg.SetAcctClass(
51246 p_accounting_class_code => 'CLAIM'
51247 , p_ae_header_id => l_ae_header_id
51248 );
51249
51250 --
51251 -- set rounding class
51252 --
51253 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
51254 'RECEIVABLE';
51255
51256 --
51257 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
51258 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
51259 --
51260 -- bulk performance
51261 --
51262 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
51263
51264 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
51265 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
51266
51267 -- 4955764
51268 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51269 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
51270
51271 -- 4458381 Public Sector Enh
51272
51273 --
51274 -- set accounting attributes for the line type
51275 --
51276 l_entered_amt_idx := 8;
51277 l_accted_amt_idx := 13;
51278 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51282 l_rec_acct_attrs.array_char_value(2) := p_source_35;
51279 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
51280 l_rec_acct_attrs.array_num_value(1) := p_source_58;
51281 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
51283 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
51284 l_rec_acct_attrs.array_char_value(3) := p_source_59;
51285 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
51286 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
51287 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
51288 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
51289 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
51290 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
51291 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
51292 l_rec_acct_attrs.array_char_value(7) := p_source_23;
51293 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
51294 l_rec_acct_attrs.array_num_value(8) := p_source_68;
51295 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
51296 l_rec_acct_attrs.array_char_value(9) := p_source_61;
51297 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
51298 l_rec_acct_attrs.array_date_value(10) := p_source_26;
51299 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
51300 l_rec_acct_attrs.array_num_value(11) := p_source_27;
51301 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
51302 l_rec_acct_attrs.array_char_value(12) := p_source_70;
51303 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
51304 l_rec_acct_attrs.array_num_value(13) := p_source_69;
51305 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
51306 l_rec_acct_attrs.array_num_value(14) := p_source_63;
51307 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
51308 l_rec_acct_attrs.array_num_value(15) := p_source_64;
51309 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
51310 l_rec_acct_attrs.array_char_value(16) := p_source_65;
51311
51312 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
51313 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
51314
51315 ---------------------------------------------------------------------------------------------------------------
51316 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
51317 ---------------------------------------------------------------------------------------------------------------
51318 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
51319
51320 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51321 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51322
51323 IF xla_accounting_cache_pkg.GetValueChar
51324 (p_source_code => 'LEDGER_CATEGORY_CODE'
51325 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
51326 AND l_bflow_method_code = 'PRIOR_ENTRY'
51327 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
51328 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
51329 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
51330 )
51331 THEN
51332 xla_ae_lines_pkg.BflowUpgEntry
51333 (p_business_method_code => l_bflow_method_code
51334 ,p_business_class_code => l_bflow_class_code
51335 ,p_balance_type => l_balance_type_code);
51336 ELSE
51337 NULL;
51338 -- No business flow processing for business flow method of NONE.
51339 END IF;
51340
51341 --
51342 -- call analytical criteria
51343 --
51344
51345 --
51346 -- call description
51347 --
51348 -- No description or it is inherited.
51349 --
51350 -- call ADRs
51351 -- Bug 4922099
51352 --
51353 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51354 (NVL(l_actual_upg_option, 'N') = 'O') OR
51355 (NVL(l_enc_upg_option, 'N') = 'O')
51356 )
51357 THEN
51358 NULL;
51359 --
51360 --
51361
51362 l_ccid := AcctDerRule_4(
51363 p_application_id => p_application_id
51364 , p_ae_header_id => l_ae_header_id
51365 , p_source_5 => p_source_5
51366 , x_transaction_coa_id => l_adr_transaction_coa_id
51367 , x_accounting_coa_id => l_adr_accounting_coa_id
51368 , x_value_type_code => l_adr_value_type_code
51369 , p_side => 'NA'
51370 );
51371
51372 xla_ae_lines_pkg.set_ccid(
51373 p_code_combination_id => l_ccid
51374 , p_value_type_code => l_adr_value_type_code
51375 , p_transaction_coa_id => l_adr_transaction_coa_id
51376 , p_accounting_coa_id => l_adr_accounting_coa_id
51377 , p_adr_code => 'DIST_CCID'
51378 , p_adr_type_code => 'S'
51379 , p_component_type => l_component_type
51380 , p_component_code => l_component_code
51381 , p_component_type_code => l_component_type_code
51382 , p_component_appl_id => l_component_appl_id
51383 , p_amb_context_code => l_amb_context_code
51384 , p_side => 'NA'
51385 );
51386
51387
51388 --
51389 --
51390 END IF;
51391 --
51392 -- Bug 4922099
51393 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
51394 (NVL(l_enc_upg_option, 'N') = 'O')
51395 ) AND
51396 (l_bflow_method_code = 'PRIOR_ENTRY')
51397 )
51398 THEN
51399 IF
51400 --
51401 1 = 2
51402 --
51403 THEN
51404 xla_accounting_err_pkg.build_message
51405 (p_appli_s_name => 'XLA'
51406 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
51407 ,p_token_1 => 'LINE_NUMBER'
51408 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
51409 ,p_token_2 => 'LINE_TYPE_NAME'
51410 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
51411 l_component_type
51412 ,l_component_code
51413 ,l_component_type_code
51414 ,l_component_appl_id
51415 ,l_amb_context_code
51416 ,l_entity_code
51417 ,l_event_class_code
51418 )
51419 ,p_token_3 => 'OWNER'
51420 ,p_value_3 => xla_lookups_pkg.get_meaning(
51421 p_lookup_type => 'XLA_OWNER_TYPE'
51422 ,p_lookup_code => l_component_type_code
51423 )
51424 ,p_token_4 => 'PRODUCT_NAME'
51425 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
51426 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
51427 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
51428 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
51429 ,p_ae_header_id => NULL
51430 );
51431
51432 IF (C_LEVEL_ERROR>= g_log_level) THEN
51433 trace
51434 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
51435 ,p_level => C_LEVEL_ERROR
51436 ,p_module => l_log_module);
51437 END IF;
51438 END IF;
51439 END IF;
51443 -- 4219869 Business Flow
51440 --
51441 --
51442 ------------------------------------------------------------------------------------------------
51444 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
51445 -- Prior Entry. Currently, the following code is always generated.
51446 ------------------------------------------------------------------------------------------------
51447 XLA_AE_LINES_PKG.ValidateCurrentLine;
51448
51449 ------------------------------------------------------------------------------------
51450 -- 4219869 Business Flow
51451 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
51452 ------------------------------------------------------------------------------------
51453 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
51454
51455 ----------------------------------------------------------------------------------
51456 -- 4219869 Business Flow
51457 -- Update journal entry status -- Need to generate this within IF <condition>
51458 ----------------------------------------------------------------------------------
51459 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
51460 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
51461 ,p_balance_type_code => l_balance_type_code
51462 );
51463
51464 -------------------------------------------------------------------------------------------
51465 -- 4262811 - Generate the Accrual Reversal lines
51466 -------------------------------------------------------------------------------------------
51467 BEGIN
51468 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
51469 (g_array_event(p_event_id).array_value_num('header_index'));
51470 IF l_acc_rev_flag IS NULL THEN
51471 l_acc_rev_flag := 'N';
51472 END IF;
51473 EXCEPTION
51474 WHEN OTHERS THEN
51475 l_acc_rev_flag := 'N';
51476 END;
51477 --
51478 IF (l_acc_rev_flag = 'Y') THEN
51479
51480 -- 4645092 ------------------------------------------------------------------------------
51481 -- To allow MPA report to determine if it should generate report process
51482 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
51483 ------------------------------------------------------------------------------------------
51484
51485 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
51486 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
51487 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
51488 -- call ADRs
51489 -- Bug 4922099
51490 --
51491 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51492 (NVL(l_actual_upg_option, 'N') = 'O') OR
51493 (NVL(l_enc_upg_option, 'N') = 'O')
51494 )
51495 THEN
51496 NULL;
51497 --
51498 --
51499
51500 l_ccid := AcctDerRule_4(
51501 p_application_id => p_application_id
51502 , p_ae_header_id => l_ae_header_id
51503 , p_source_5 => p_source_5
51504 , x_transaction_coa_id => l_adr_transaction_coa_id
51505 , x_accounting_coa_id => l_adr_accounting_coa_id
51506 , x_value_type_code => l_adr_value_type_code
51507 , p_side => 'NA'
51508 );
51509
51510 xla_ae_lines_pkg.set_ccid(
51511 p_code_combination_id => l_ccid
51512 , p_value_type_code => l_adr_value_type_code
51513 , p_transaction_coa_id => l_adr_transaction_coa_id
51514 , p_accounting_coa_id => l_adr_accounting_coa_id
51515 , p_adr_code => 'DIST_CCID'
51516 , p_adr_type_code => 'S'
51517 , p_component_type => l_component_type
51518 , p_component_code => l_component_code
51519 , p_component_type_code => l_component_type_code
51520 , p_component_appl_id => l_component_appl_id
51521 , p_amb_context_code => l_amb_context_code
51522 , p_side => 'NA'
51523 );
51524
51525
51526 --
51527 --
51528 END IF;
51529
51530 --
51531 -- Update the line information that should be overwritten
51532 --
51533 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
51534 p_header_num => 1);
51535 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
51536
51537 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
51538
51539 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
51540 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
51541 END IF;
51542
51543 --
51544 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
51545 --
51546 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
51547 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
51548 ELSE
51549 ---------------------------------------------------------------------------------------------------
51550 -- 4262811a Switch Sign
51551 ---------------------------------------------------------------------------------------------------
51552 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
51553 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51554 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51555 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
51556 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51557 -- 5132302
51558 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
51559 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
51560
51561 END IF;
51562
51563 -- 4955764
51564 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51565 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
51566
51567
51568 XLA_AE_LINES_PKG.ValidateCurrentLine;
51569 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
51570
51571 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
51572 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
51573 ,p_balance_type_code => l_balance_type_code);
51574
51575 END IF;
51576
51577 -----------------------------------------------------------------------------------------
51578 -- 4262811 Multiperiod Accounting
51579 -----------------------------------------------------------------------------------------
51580 -- No MPA option is assigned.
51581
51582
51583 END IF;
51584 END IF;
51585 --
51586
51587 --
51588 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51589 trace
51590 (p_msg => 'END of AcctLineType_108'
51591 ,p_level => C_LEVEL_PROCEDURE
51592 ,p_module => l_log_module);
51593 END IF;
51594 --
51595 EXCEPTION
51596 WHEN xla_exceptions_pkg.application_exception THEN
51597 RAISE;
51598 WHEN OTHERS THEN
51599 xla_exceptions_pkg.raise_message
51600 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_108');
51601 END AcctLineType_108;
51602 --
51603
51604 ---------------------------------------
51605 --
51606 -- PRIVATE FUNCTION
51607 -- AcctLineType_109
51608 --
51609 ---------------------------------------
51610 PROCEDURE AcctLineType_109 (
51611 p_application_id IN NUMBER
51612 ,p_event_id IN NUMBER
51613 ,p_calculate_acctd_flag IN VARCHAR2
51614 ,p_calculate_g_l_flag IN VARCHAR2
51615 ,p_actual_flag IN OUT VARCHAR2
51616 ,p_balance_type_code OUT VARCHAR2
51617 ,p_gain_or_loss_ref OUT VARCHAR2
51618
51619 --Distribution GL Account
51620 , p_source_5 IN NUMBER
51621 --Distribution Source Type
51622 , p_source_20 IN VARCHAR2
51623 --Receivable Activity Type
51624 , p_source_21 IN VARCHAR2
51625 --Distribution Line Identifier
51626 , p_source_22 IN NUMBER
51627 --Distribution Type
51628 , p_source_23 IN VARCHAR2
51629 --Exchange Date
51630 , p_source_26 IN DATE
51631 --Exchange Rate
51632 , p_source_27 IN NUMBER
51633 --Transaction Distribution Identifier
51634 , p_source_34 IN NUMBER
51635 --Transaction Distribution Type
51636 , p_source_35 IN VARCHAR2
51637 --Receipt Applied To Application Identifier
51638 , p_source_58 IN NUMBER
51639 --Transaction Entity Code
51640 , p_source_59 IN VARCHAR2
51641 --Transaction Identifier
51642 , p_source_60 IN NUMBER
51643 --Applying Document Currency Code
51644 , p_source_61 IN VARCHAR2
51645 --Distribution Party Identifier
51646 , p_source_63 IN NUMBER
51647 --Distribution Party Site Id
51648 , p_source_64 IN NUMBER
51649 --Distribution Party Type
51650 , p_source_65 IN VARCHAR2
51651 --Distribution Multi Fund Additional Entry
51652 , p_source_67 IN VARCHAR2
51653 --DIST_ENT_AMT_FROM
51654 , p_source_68 IN NUMBER
51655 --Accounting Amount
51656 , p_source_69 IN NUMBER
51657 --Applied To Document Exchange Rate Type
51658 , p_source_70 IN VARCHAR2
51659 )
51660 IS
51661
51662 l_component_type VARCHAR2(80);
51663 l_component_code VARCHAR2(30);
51664 l_component_type_code VARCHAR2(1);
51665 l_component_appl_id INTEGER;
51666 l_amb_context_code VARCHAR2(30);
51667 l_entity_code VARCHAR2(30);
51668 l_event_class_code VARCHAR2(30);
51669 l_ae_header_id NUMBER;
51670 l_event_type_code VARCHAR2(30);
51671 l_line_definition_code VARCHAR2(30);
51672 l_line_definition_owner_code VARCHAR2(1);
51673 --
51674 -- adr variables
51675 l_segment VARCHAR2(30);
51676 l_ccid NUMBER;
51677 l_adr_transaction_coa_id NUMBER;
51678 l_adr_accounting_coa_id NUMBER;
51679 l_adr_flexfield_segment_code VARCHAR2(30);
51680 l_adr_flex_value_set_id NUMBER;
51681 l_adr_value_type_code VARCHAR2(30);
51682 l_adr_value_combination_id NUMBER;
51683 l_adr_value_segment_code VARCHAR2(30);
51684
51685 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
51686 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
51687 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
51688 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
51689
51690 -- 4262811 Variables ------------------------------------------------------------------------------------------
51691 l_entered_amt_idx NUMBER;
51692 l_accted_amt_idx NUMBER;
51693 l_acc_rev_flag VARCHAR2(1);
51694 l_accrual_line_num NUMBER;
51695 l_tmp_amt NUMBER;
51696 l_acc_rev_natural_side_code VARCHAR2(1);
51697
51698 l_num_entries NUMBER;
51699 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
51700 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
51701 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
51702 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
51703 l_recog_line_1 NUMBER;
51704 l_recog_line_2 NUMBER;
51705
51706 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
51707 l_bflow_applied_to_amt NUMBER; -- 5132302
51708 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
51709
51710 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
51711
51712 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
51713 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
51714
51715 ---------------------------------------------------------------------------------------------------------------
51716
51717
51718 --
51719 -- bulk performance
51720 --
51721 l_balance_type_code VARCHAR2(1);
51722 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
51723 l_log_module VARCHAR2(240);
51724
51725 --
51726 -- Upgrade strategy
51727 --
51728 l_actual_upg_option VARCHAR2(1);
51729 l_enc_upg_option VARCHAR2(1);
51730
51731 --
51732 BEGIN
51733 --
51734 IF g_log_enabled THEN
51735 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_109';
51736 END IF;
51737 --
51738 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
51739
51740 trace
51741 (p_msg => 'BEGIN of AcctLineType_109'
51742 ,p_level => C_LEVEL_PROCEDURE
51743 ,p_module => l_log_module);
51744
51745 END IF;
51746 --
51747 l_component_type := 'AMB_JLT';
51748 l_component_code := 'RCT_CLAIM';
51749 l_component_type_code := 'S';
51750 l_component_appl_id := 222;
51751 l_amb_context_code := 'DEFAULT';
51752 l_entity_code := 'RECEIPTS';
51753 l_event_class_code := 'RECEIPT';
51754 l_event_type_code := 'RECEIPT_ALL';
51755 l_line_definition_owner_code := 'S';
51756 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
51757 --
51758 l_balance_type_code := 'A';
51759 l_segment := NULL;
51760 l_ccid := NULL;
51761 l_adr_transaction_coa_id := NULL;
51762 l_adr_accounting_coa_id := NULL;
51763 l_adr_flexfield_segment_code := NULL;
51764 l_adr_flex_value_set_id := NULL;
51765 l_adr_value_type_code := NULL;
51766 l_adr_value_combination_id := NULL;
51767 l_adr_value_segment_code := NULL;
51768
51769 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
51770 l_bflow_class_code := ''; -- 4219869 Business Flow
51771 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
51772 l_budgetary_control_flag := 'N';
51773
51774 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51775 l_bflow_applied_to_amt := NULL; -- 5132302
51776 l_entered_amt_idx := NULL; -- 4262811
51777 l_accted_amt_idx := NULL; -- 4262811
51778 l_acc_rev_flag := NULL; -- 4262811
51779 l_accrual_line_num := NULL; -- 4262811
51780 l_tmp_amt := NULL; -- 4262811
51781 --
51782
51783 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
51784 l_balance_type_code <> 'B' THEN
51785 IF NVL(p_source_20,'
51786 ') = 'OTHER ACC' AND
51787 NVL(p_source_21,'
51788 ') = 'CLAIM_INVESTIGATION' AND
51789 NVL(p_source_67,'
51790 ') = 'N'
51791 THEN
51792
51793 --
51794 XLA_AE_LINES_PKG.SetNewLine;
51795
51796 p_balance_type_code := l_balance_type_code;
51797 -- set the flag so later we will know whether the gain loss line needs to be created
51798
51799 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
51800 p_actual_flag :='A';
51801 END IF;
51802
51803 --
51804 -- bulk performance
51805 --
51806 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
51807 p_header_num => 0); -- 4262811
51808 --
51809 -- set accounting line options
51810 --
51811 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
51812 p_natural_side_code => 'C'
51813 , p_gain_or_loss_flag => 'N'
51814 , p_gl_transfer_mode_code => 'S'
51815 , p_acct_entry_type_code => 'A'
51816 , p_switch_side_flag => 'Y'
51817 , p_merge_duplicate_code => 'A'
51818 );
51819 --
51820 l_acc_rev_natural_side_code := 'D'; -- 4262811
51821 --
51822 --
51823 -- set accounting line type info
51824 --
51825 xla_ae_lines_pkg.SetAcctLineType
51826 (p_component_type => l_component_type
51827 ,p_event_type_code => l_event_type_code
51828 ,p_line_definition_owner_code => l_line_definition_owner_code
51829 ,p_line_definition_code => l_line_definition_code
51830 ,p_accounting_line_code => l_component_code
51831 ,p_accounting_line_type_code => l_component_type_code
51832 ,p_accounting_line_appl_id => l_component_appl_id
51833 ,p_amb_context_code => l_amb_context_code
51834 ,p_entity_code => l_entity_code
51835 ,p_event_class_code => l_event_class_code);
51836 --
51837 -- set accounting class
51838 --
51839 xla_ae_lines_pkg.SetAcctClass(
51840 p_accounting_class_code => 'CLAIM'
51841 , p_ae_header_id => l_ae_header_id
51842 );
51843
51844 --
51845 -- set rounding class
51846 --
51847 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
51848 'RECEIVABLE';
51849
51850 --
51851 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
51852 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
51853 --
51854 -- bulk performance
51855 --
51856 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
51857
51858 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
51859 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
51860
51861 -- 4955764
51862 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
51863 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
51864
51865 -- 4458381 Public Sector Enh
51866
51867 --
51868 -- set accounting attributes for the line type
51869 --
51870 l_entered_amt_idx := 8;
51871 l_accted_amt_idx := 13;
51872 l_bflow_applied_to_amt_idx := NULL; -- 5132302
51873 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
51874 l_rec_acct_attrs.array_num_value(1) := p_source_58;
51875 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
51876 l_rec_acct_attrs.array_char_value(2) := p_source_35;
51877 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
51878 l_rec_acct_attrs.array_char_value(3) := p_source_59;
51879 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
51880 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
51881 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
51882 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
51883 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
51884 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
51885 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
51886 l_rec_acct_attrs.array_char_value(7) := p_source_23;
51887 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
51888 l_rec_acct_attrs.array_num_value(8) := p_source_68;
51889 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
51890 l_rec_acct_attrs.array_char_value(9) := p_source_61;
51891 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
51892 l_rec_acct_attrs.array_date_value(10) := p_source_26;
51893 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
51894 l_rec_acct_attrs.array_num_value(11) := p_source_27;
51895 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
51896 l_rec_acct_attrs.array_char_value(12) := p_source_70;
51897 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
51898 l_rec_acct_attrs.array_num_value(13) := p_source_69;
51899 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
51900 l_rec_acct_attrs.array_num_value(14) := p_source_63;
51901 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
51902 l_rec_acct_attrs.array_num_value(15) := p_source_64;
51903 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
51904 l_rec_acct_attrs.array_char_value(16) := p_source_65;
51905
51906 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
51907 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
51908
51909 ---------------------------------------------------------------------------------------------------------------
51910 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
51911 ---------------------------------------------------------------------------------------------------------------
51912 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
51913
51914 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51915 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
51916
51917 IF xla_accounting_cache_pkg.GetValueChar
51918 (p_source_code => 'LEDGER_CATEGORY_CODE'
51919 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
51920 AND l_bflow_method_code = 'PRIOR_ENTRY'
51921 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
51922 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
51923 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
51924 )
51925 THEN
51926 xla_ae_lines_pkg.BflowUpgEntry
51927 (p_business_method_code => l_bflow_method_code
51928 ,p_business_class_code => l_bflow_class_code
51929 ,p_balance_type => l_balance_type_code);
51930 ELSE
51931 NULL;
51932 -- No business flow processing for business flow method of NONE.
51933 END IF;
51934
51935 --
51936 -- call analytical criteria
51937 --
51938
51939 --
51940 -- call description
51941 --
51942 -- No description or it is inherited.
51943 --
51944 -- call ADRs
51945 -- Bug 4922099
51946 --
51947 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
51948 (NVL(l_actual_upg_option, 'N') = 'O') OR
51949 (NVL(l_enc_upg_option, 'N') = 'O')
51950 )
51951 THEN
51952 NULL;
51953 --
51954 --
51955
51956 l_ccid := AcctDerRule_4(
51957 p_application_id => p_application_id
51958 , p_ae_header_id => l_ae_header_id
51959 , p_source_5 => p_source_5
51960 , x_transaction_coa_id => l_adr_transaction_coa_id
51961 , x_accounting_coa_id => l_adr_accounting_coa_id
51962 , x_value_type_code => l_adr_value_type_code
51963 , p_side => 'NA'
51964 );
51965
51966 xla_ae_lines_pkg.set_ccid(
51967 p_code_combination_id => l_ccid
51968 , p_value_type_code => l_adr_value_type_code
51969 , p_transaction_coa_id => l_adr_transaction_coa_id
51970 , p_accounting_coa_id => l_adr_accounting_coa_id
51971 , p_adr_code => 'DIST_CCID'
51972 , p_adr_type_code => 'S'
51973 , p_component_type => l_component_type
51974 , p_component_code => l_component_code
51975 , p_component_type_code => l_component_type_code
51976 , p_component_appl_id => l_component_appl_id
51977 , p_amb_context_code => l_amb_context_code
51978 , p_side => 'NA'
51979 );
51980
51981
51982 --
51983 --
51984 END IF;
51985 --
51986 -- Bug 4922099
51987 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
51988 (NVL(l_enc_upg_option, 'N') = 'O')
51989 ) AND
51990 (l_bflow_method_code = 'PRIOR_ENTRY')
51991 )
51992 THEN
51993 IF
51994 --
51995 1 = 2
51996 --
51997 THEN
51998 xla_accounting_err_pkg.build_message
51999 (p_appli_s_name => 'XLA'
52000 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52001 ,p_token_1 => 'LINE_NUMBER'
52002 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
52003 ,p_token_2 => 'LINE_TYPE_NAME'
52004 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
52005 l_component_type
52006 ,l_component_code
52007 ,l_component_type_code
52008 ,l_component_appl_id
52009 ,l_amb_context_code
52010 ,l_entity_code
52011 ,l_event_class_code
52012 )
52013 ,p_token_3 => 'OWNER'
52014 ,p_value_3 => xla_lookups_pkg.get_meaning(
52015 p_lookup_type => 'XLA_OWNER_TYPE'
52016 ,p_lookup_code => l_component_type_code
52017 )
52018 ,p_token_4 => 'PRODUCT_NAME'
52019 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
52020 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
52021 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
52022 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
52023 ,p_ae_header_id => NULL
52024 );
52025
52026 IF (C_LEVEL_ERROR>= g_log_level) THEN
52027 trace
52028 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52029 ,p_level => C_LEVEL_ERROR
52030 ,p_module => l_log_module);
52031 END IF;
52032 END IF;
52033 END IF;
52034 --
52035 --
52036 ------------------------------------------------------------------------------------------------
52037 -- 4219869 Business Flow
52038 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
52039 -- Prior Entry. Currently, the following code is always generated.
52040 ------------------------------------------------------------------------------------------------
52041 XLA_AE_LINES_PKG.ValidateCurrentLine;
52042
52043 ------------------------------------------------------------------------------------
52044 -- 4219869 Business Flow
52045 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
52046 ------------------------------------------------------------------------------------
52047 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52048
52049 ----------------------------------------------------------------------------------
52050 -- 4219869 Business Flow
52051 -- Update journal entry status -- Need to generate this within IF <condition>
52052 ----------------------------------------------------------------------------------
52053 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52054 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
52055 ,p_balance_type_code => l_balance_type_code
52056 );
52057
52058 -------------------------------------------------------------------------------------------
52059 -- 4262811 - Generate the Accrual Reversal lines
52060 -------------------------------------------------------------------------------------------
52061 BEGIN
52062 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
52063 (g_array_event(p_event_id).array_value_num('header_index'));
52064 IF l_acc_rev_flag IS NULL THEN
52065 l_acc_rev_flag := 'N';
52066 END IF;
52067 EXCEPTION
52068 WHEN OTHERS THEN
52069 l_acc_rev_flag := 'N';
52070 END;
52071 --
52072 IF (l_acc_rev_flag = 'Y') THEN
52073
52074 -- 4645092 ------------------------------------------------------------------------------
52075 -- To allow MPA report to determine if it should generate report process
52076 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
52080 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
52077 ------------------------------------------------------------------------------------------
52078
52079 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
52081 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
52082 -- call ADRs
52083 -- Bug 4922099
52084 --
52085 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52086 (NVL(l_actual_upg_option, 'N') = 'O') OR
52087 (NVL(l_enc_upg_option, 'N') = 'O')
52088 )
52089 THEN
52090 NULL;
52091 --
52092 --
52093
52094 l_ccid := AcctDerRule_4(
52095 p_application_id => p_application_id
52096 , p_ae_header_id => l_ae_header_id
52097 , p_source_5 => p_source_5
52098 , x_transaction_coa_id => l_adr_transaction_coa_id
52099 , x_accounting_coa_id => l_adr_accounting_coa_id
52100 , x_value_type_code => l_adr_value_type_code
52101 , p_side => 'NA'
52102 );
52103
52104 xla_ae_lines_pkg.set_ccid(
52105 p_code_combination_id => l_ccid
52106 , p_value_type_code => l_adr_value_type_code
52107 , p_transaction_coa_id => l_adr_transaction_coa_id
52108 , p_accounting_coa_id => l_adr_accounting_coa_id
52109 , p_adr_code => 'DIST_CCID'
52110 , p_adr_type_code => 'S'
52111 , p_component_type => l_component_type
52112 , p_component_code => l_component_code
52113 , p_component_type_code => l_component_type_code
52114 , p_component_appl_id => l_component_appl_id
52115 , p_amb_context_code => l_amb_context_code
52116 , p_side => 'NA'
52117 );
52118
52119
52120 --
52121 --
52122 END IF;
52123
52124 --
52125 -- Update the line information that should be overwritten
52126 --
52127 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
52128 p_header_num => 1);
52129 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
52130
52131 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
52132
52133 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
52134 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
52135 END IF;
52136
52137 --
52138 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
52139 --
52140 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
52141 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
52142 ELSE
52143 ---------------------------------------------------------------------------------------------------
52144 -- 4262811a Switch Sign
52145 ---------------------------------------------------------------------------------------------------
52146 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
52147 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52148 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52149 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52150 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52151 -- 5132302
52152 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
52153 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52154
52155 END IF;
52156
52157 -- 4955764
52158 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52159 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
52160
52161
52162 XLA_AE_LINES_PKG.ValidateCurrentLine;
52163 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52164
52165 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52166 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
52167 ,p_balance_type_code => l_balance_type_code);
52168
52169 END IF;
52170
52171 -----------------------------------------------------------------------------------------
52172 -- 4262811 Multiperiod Accounting
52173 -----------------------------------------------------------------------------------------
52174 -- No MPA option is assigned.
52175
52176
52177 END IF;
52178 END IF;
52179 --
52180
52181 --
52182 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52183 trace
52184 (p_msg => 'END of AcctLineType_109'
52185 ,p_level => C_LEVEL_PROCEDURE
52186 ,p_module => l_log_module);
52187 END IF;
52188 --
52189 EXCEPTION
52190 WHEN xla_exceptions_pkg.application_exception THEN
52191 RAISE;
52192 WHEN OTHERS THEN
52193 xla_exceptions_pkg.raise_message
52194 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_109');
52195 END AcctLineType_109;
52196 --
52197
52198 ---------------------------------------
52199 --
52200 -- PRIVATE FUNCTION
52201 -- AcctLineType_110
52202 --
52203 ---------------------------------------
52204 PROCEDURE AcctLineType_110 (
52205 p_application_id IN NUMBER
52206 ,p_event_id IN NUMBER
52207 ,p_calculate_acctd_flag IN VARCHAR2
52208 ,p_calculate_g_l_flag IN VARCHAR2
52209 ,p_actual_flag IN OUT VARCHAR2
52210 ,p_balance_type_code OUT VARCHAR2
52211 ,p_gain_or_loss_ref OUT VARCHAR2
52212
52213 --Distribution GL Account
52214 , p_source_5 IN NUMBER
52215 --Distribution Source Type
52216 , p_source_20 IN VARCHAR2
52217 --Distribution Line Identifier
52218 , p_source_22 IN NUMBER
52219 --Distribution Type
52220 , p_source_23 IN VARCHAR2
52221 --Exchange Date
52222 , p_source_26 IN DATE
52223 --Exchange Rate
52224 , p_source_27 IN NUMBER
52225 --Exchange Rate Type
52226 , p_source_28 IN VARCHAR2
52227 --Transaction Distribution Identifier
52228 , p_source_34 IN NUMBER
52229 --Transaction Distribution Type
52230 , p_source_35 IN VARCHAR2
52231 --Receipt Applied To Application Identifier
52232 , p_source_58 IN NUMBER
52233 --Transaction Entity Code
52234 , p_source_59 IN VARCHAR2
52235 --Transaction Identifier
52236 , p_source_60 IN NUMBER
52237 --Applying Document Currency Code
52238 , p_source_61 IN VARCHAR2
52239 --Distribution Party Identifier
52240 , p_source_63 IN NUMBER
52241 --Distribution Party Site Id
52242 , p_source_64 IN NUMBER
52243 --Distribution Party Type
52244 , p_source_65 IN VARCHAR2
52245 --Distribution Multi Fund Additional Entry
52246 , p_source_67 IN VARCHAR2
52247 --DIST_ENT_AMT_FROM
52248 , p_source_68 IN NUMBER
52249 --Accounting Amount
52250 , p_source_69 IN NUMBER
52251 )
52252 IS
52253
52254 l_component_type VARCHAR2(80);
52255 l_component_code VARCHAR2(30);
52256 l_component_type_code VARCHAR2(1);
52257 l_component_appl_id INTEGER;
52258 l_amb_context_code VARCHAR2(30);
52259 l_entity_code VARCHAR2(30);
52260 l_event_class_code VARCHAR2(30);
52261 l_ae_header_id NUMBER;
52262 l_event_type_code VARCHAR2(30);
52263 l_line_definition_code VARCHAR2(30);
52264 l_line_definition_owner_code VARCHAR2(1);
52265 --
52266 -- adr variables
52267 l_segment VARCHAR2(30);
52268 l_ccid NUMBER;
52269 l_adr_transaction_coa_id NUMBER;
52270 l_adr_accounting_coa_id NUMBER;
52271 l_adr_flexfield_segment_code VARCHAR2(30);
52272 l_adr_flex_value_set_id NUMBER;
52273 l_adr_value_type_code VARCHAR2(30);
52274 l_adr_value_combination_id NUMBER;
52275 l_adr_value_segment_code VARCHAR2(30);
52276
52277 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
52278 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
52279 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
52280 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
52281
52282 -- 4262811 Variables ------------------------------------------------------------------------------------------
52283 l_entered_amt_idx NUMBER;
52284 l_accted_amt_idx NUMBER;
52285 l_acc_rev_flag VARCHAR2(1);
52286 l_accrual_line_num NUMBER;
52287 l_tmp_amt NUMBER;
52288 l_acc_rev_natural_side_code VARCHAR2(1);
52289
52290 l_num_entries NUMBER;
52291 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
52292 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
52293 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
52294 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
52295 l_recog_line_1 NUMBER;
52296 l_recog_line_2 NUMBER;
52297
52298 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
52299 l_bflow_applied_to_amt NUMBER; -- 5132302
52300 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
52301
52302 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
52303
52304 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
52305 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
52306
52307 ---------------------------------------------------------------------------------------------------------------
52308
52309
52310 --
52311 -- bulk performance
52312 --
52313 l_balance_type_code VARCHAR2(1);
52314 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
52315 l_log_module VARCHAR2(240);
52316
52317 --
52318 -- Upgrade strategy
52319 --
52320 l_actual_upg_option VARCHAR2(1);
52321 l_enc_upg_option VARCHAR2(1);
52322
52323 --
52324 BEGIN
52325 --
52326 IF g_log_enabled THEN
52327 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_110';
52328 END IF;
52329 --
52330 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52331
52332 trace
52333 (p_msg => 'BEGIN of AcctLineType_110'
52334 ,p_level => C_LEVEL_PROCEDURE
52335 ,p_module => l_log_module);
52336
52337 END IF;
52338 --
52339 l_component_type := 'AMB_JLT';
52340 l_component_code := 'RCT_CONFIRM';
52341 l_component_type_code := 'S';
52342 l_component_appl_id := 222;
52343 l_amb_context_code := 'DEFAULT';
52344 l_entity_code := 'RECEIPTS';
52345 l_event_class_code := 'RECEIPT';
52346 l_event_type_code := 'RECEIPT_ALL';
52347 l_line_definition_owner_code := 'S';
52348 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
52349 --
52350 l_balance_type_code := 'A';
52351 l_segment := NULL;
52352 l_ccid := NULL;
52353 l_adr_transaction_coa_id := NULL;
52354 l_adr_accounting_coa_id := NULL;
52355 l_adr_flexfield_segment_code := NULL;
52356 l_adr_flex_value_set_id := NULL;
52357 l_adr_value_type_code := NULL;
52358 l_adr_value_combination_id := NULL;
52359 l_adr_value_segment_code := NULL;
52360
52361 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
52362 l_bflow_class_code := ''; -- 4219869 Business Flow
52363 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
52364 l_budgetary_control_flag := 'N';
52365
52366 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52367 l_bflow_applied_to_amt := NULL; -- 5132302
52368 l_entered_amt_idx := NULL; -- 4262811
52369 l_accted_amt_idx := NULL; -- 4262811
52370 l_acc_rev_flag := NULL; -- 4262811
52371 l_accrual_line_num := NULL; -- 4262811
52372 l_tmp_amt := NULL; -- 4262811
52373 --
52374
52375 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
52376 l_balance_type_code <> 'B' THEN
52377 IF NVL(p_source_20,'
52378 ') = 'CONFIRMATION' AND
52379 NVL(p_source_67,'
52380 ') = 'N'
52381 THEN
52382
52383 --
52384 XLA_AE_LINES_PKG.SetNewLine;
52385
52386 p_balance_type_code := l_balance_type_code;
52387 -- set the flag so later we will know whether the gain loss line needs to be created
52388
52389 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
52390 p_actual_flag :='A';
52391 END IF;
52392
52393 --
52394 -- bulk performance
52395 --
52396 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
52397 p_header_num => 0); -- 4262811
52398 --
52399 -- set accounting line options
52400 --
52401 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
52402 p_natural_side_code => 'C'
52403 , p_gain_or_loss_flag => 'N'
52404 , p_gl_transfer_mode_code => 'S'
52405 , p_acct_entry_type_code => 'A'
52406 , p_switch_side_flag => 'Y'
52407 , p_merge_duplicate_code => 'A'
52408 );
52409 --
52410 l_acc_rev_natural_side_code := 'D'; -- 4262811
52411 --
52412 --
52413 -- set accounting line type info
52414 --
52415 xla_ae_lines_pkg.SetAcctLineType
52416 (p_component_type => l_component_type
52417 ,p_event_type_code => l_event_type_code
52418 ,p_line_definition_owner_code => l_line_definition_owner_code
52419 ,p_line_definition_code => l_line_definition_code
52420 ,p_accounting_line_code => l_component_code
52421 ,p_accounting_line_type_code => l_component_type_code
52422 ,p_accounting_line_appl_id => l_component_appl_id
52423 ,p_amb_context_code => l_amb_context_code
52424 ,p_entity_code => l_entity_code
52425 ,p_event_class_code => l_event_class_code);
52426 --
52427 -- set accounting class
52428 --
52429 xla_ae_lines_pkg.SetAcctClass(
52430 p_accounting_class_code => 'CONFIRMATION'
52431 , p_ae_header_id => l_ae_header_id
52432 );
52433
52434 --
52438 'RECEIVABLE';
52435 -- set rounding class
52436 --
52437 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
52439
52440 --
52441 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
52442 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
52443 --
52444 -- bulk performance
52445 --
52446 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
52447
52448 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
52449 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
52450
52451 -- 4955764
52452 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52453 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
52454
52455 -- 4458381 Public Sector Enh
52456
52457 --
52458 -- set accounting attributes for the line type
52459 --
52460 l_entered_amt_idx := 8;
52461 l_accted_amt_idx := 13;
52462 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52463 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
52464 l_rec_acct_attrs.array_num_value(1) := p_source_58;
52465 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
52466 l_rec_acct_attrs.array_char_value(2) := p_source_35;
52467 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
52468 l_rec_acct_attrs.array_char_value(3) := p_source_59;
52469 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
52470 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
52471 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
52472 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
52473 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
52474 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
52475 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
52476 l_rec_acct_attrs.array_char_value(7) := p_source_23;
52477 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
52478 l_rec_acct_attrs.array_num_value(8) := p_source_68;
52479 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
52480 l_rec_acct_attrs.array_char_value(9) := p_source_61;
52481 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
52482 l_rec_acct_attrs.array_date_value(10) := p_source_26;
52483 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
52484 l_rec_acct_attrs.array_num_value(11) := p_source_27;
52485 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
52486 l_rec_acct_attrs.array_char_value(12) := p_source_28;
52487 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
52488 l_rec_acct_attrs.array_num_value(13) := p_source_69;
52489 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
52490 l_rec_acct_attrs.array_num_value(14) := p_source_63;
52491 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
52492 l_rec_acct_attrs.array_num_value(15) := p_source_64;
52493 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
52494 l_rec_acct_attrs.array_char_value(16) := p_source_65;
52495
52496 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
52497 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
52498
52499 ---------------------------------------------------------------------------------------------------------------
52500 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
52501 ---------------------------------------------------------------------------------------------------------------
52502 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
52503
52504 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52505 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
52506
52507 IF xla_accounting_cache_pkg.GetValueChar
52508 (p_source_code => 'LEDGER_CATEGORY_CODE'
52509 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
52510 AND l_bflow_method_code = 'PRIOR_ENTRY'
52511 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
52512 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
52513 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
52514 )
52515 THEN
52516 xla_ae_lines_pkg.BflowUpgEntry
52517 (p_business_method_code => l_bflow_method_code
52518 ,p_business_class_code => l_bflow_class_code
52519 ,p_balance_type => l_balance_type_code);
52520 ELSE
52521 NULL;
52522 -- No business flow processing for business flow method of NONE.
52523 END IF;
52524
52525 --
52526 -- call analytical criteria
52527 --
52528
52529 --
52530 -- call description
52531 --
52532 -- No description or it is inherited.
52533 --
52534 -- call ADRs
52535 -- Bug 4922099
52536 --
52537 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52538 (NVL(l_actual_upg_option, 'N') = 'O') OR
52539 (NVL(l_enc_upg_option, 'N') = 'O')
52540 )
52541 THEN
52542 NULL;
52543 --
52544 --
52545
52546 l_ccid := AcctDerRule_4(
52547 p_application_id => p_application_id
52548 , p_ae_header_id => l_ae_header_id
52549 , p_source_5 => p_source_5
52553 , p_side => 'NA'
52550 , x_transaction_coa_id => l_adr_transaction_coa_id
52551 , x_accounting_coa_id => l_adr_accounting_coa_id
52552 , x_value_type_code => l_adr_value_type_code
52554 );
52555
52556 xla_ae_lines_pkg.set_ccid(
52557 p_code_combination_id => l_ccid
52558 , p_value_type_code => l_adr_value_type_code
52559 , p_transaction_coa_id => l_adr_transaction_coa_id
52560 , p_accounting_coa_id => l_adr_accounting_coa_id
52561 , p_adr_code => 'DIST_CCID'
52562 , p_adr_type_code => 'S'
52563 , p_component_type => l_component_type
52564 , p_component_code => l_component_code
52565 , p_component_type_code => l_component_type_code
52566 , p_component_appl_id => l_component_appl_id
52567 , p_amb_context_code => l_amb_context_code
52568 , p_side => 'NA'
52569 );
52570
52571
52572 --
52573 --
52574 END IF;
52575 --
52576 -- Bug 4922099
52577 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
52578 (NVL(l_enc_upg_option, 'N') = 'O')
52579 ) AND
52580 (l_bflow_method_code = 'PRIOR_ENTRY')
52581 )
52582 THEN
52583 IF
52584 --
52585 1 = 2
52586 --
52587 THEN
52588 xla_accounting_err_pkg.build_message
52589 (p_appli_s_name => 'XLA'
52590 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52591 ,p_token_1 => 'LINE_NUMBER'
52592 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
52593 ,p_token_2 => 'LINE_TYPE_NAME'
52594 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
52595 l_component_type
52596 ,l_component_code
52597 ,l_component_type_code
52598 ,l_component_appl_id
52599 ,l_amb_context_code
52600 ,l_entity_code
52601 ,l_event_class_code
52602 )
52603 ,p_token_3 => 'OWNER'
52604 ,p_value_3 => xla_lookups_pkg.get_meaning(
52605 p_lookup_type => 'XLA_OWNER_TYPE'
52606 ,p_lookup_code => l_component_type_code
52607 )
52608 ,p_token_4 => 'PRODUCT_NAME'
52609 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
52610 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
52611 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
52612 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
52613 ,p_ae_header_id => NULL
52614 );
52615
52616 IF (C_LEVEL_ERROR>= g_log_level) THEN
52617 trace
52618 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
52619 ,p_level => C_LEVEL_ERROR
52620 ,p_module => l_log_module);
52621 END IF;
52622 END IF;
52623 END IF;
52624 --
52625 --
52626 ------------------------------------------------------------------------------------------------
52627 -- 4219869 Business Flow
52628 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
52629 -- Prior Entry. Currently, the following code is always generated.
52630 ------------------------------------------------------------------------------------------------
52631 XLA_AE_LINES_PKG.ValidateCurrentLine;
52632
52633 ------------------------------------------------------------------------------------
52634 -- 4219869 Business Flow
52635 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
52636 ------------------------------------------------------------------------------------
52637 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52638
52639 ----------------------------------------------------------------------------------
52640 -- 4219869 Business Flow
52641 -- Update journal entry status -- Need to generate this within IF <condition>
52642 ----------------------------------------------------------------------------------
52643 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52644 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
52645 ,p_balance_type_code => l_balance_type_code
52646 );
52647
52648 -------------------------------------------------------------------------------------------
52649 -- 4262811 - Generate the Accrual Reversal lines
52653 (g_array_event(p_event_id).array_value_num('header_index'));
52650 -------------------------------------------------------------------------------------------
52651 BEGIN
52652 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
52654 IF l_acc_rev_flag IS NULL THEN
52655 l_acc_rev_flag := 'N';
52656 END IF;
52657 EXCEPTION
52658 WHEN OTHERS THEN
52659 l_acc_rev_flag := 'N';
52660 END;
52661 --
52662 IF (l_acc_rev_flag = 'Y') THEN
52663
52664 -- 4645092 ------------------------------------------------------------------------------
52665 -- To allow MPA report to determine if it should generate report process
52666 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
52667 ------------------------------------------------------------------------------------------
52668
52669 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
52670 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
52671 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
52672 -- call ADRs
52673 -- Bug 4922099
52674 --
52675 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
52676 (NVL(l_actual_upg_option, 'N') = 'O') OR
52677 (NVL(l_enc_upg_option, 'N') = 'O')
52678 )
52679 THEN
52680 NULL;
52681 --
52682 --
52683
52684 l_ccid := AcctDerRule_4(
52685 p_application_id => p_application_id
52686 , p_ae_header_id => l_ae_header_id
52687 , p_source_5 => p_source_5
52688 , x_transaction_coa_id => l_adr_transaction_coa_id
52689 , x_accounting_coa_id => l_adr_accounting_coa_id
52690 , x_value_type_code => l_adr_value_type_code
52691 , p_side => 'NA'
52692 );
52693
52694 xla_ae_lines_pkg.set_ccid(
52695 p_code_combination_id => l_ccid
52696 , p_value_type_code => l_adr_value_type_code
52697 , p_transaction_coa_id => l_adr_transaction_coa_id
52698 , p_accounting_coa_id => l_adr_accounting_coa_id
52699 , p_adr_code => 'DIST_CCID'
52700 , p_adr_type_code => 'S'
52701 , p_component_type => l_component_type
52702 , p_component_code => l_component_code
52703 , p_component_type_code => l_component_type_code
52704 , p_component_appl_id => l_component_appl_id
52705 , p_amb_context_code => l_amb_context_code
52706 , p_side => 'NA'
52707 );
52708
52709
52710 --
52711 --
52712 END IF;
52713
52714 --
52715 -- Update the line information that should be overwritten
52716 --
52717 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
52718 p_header_num => 1);
52719 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
52720
52721 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
52722
52723 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
52724 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
52725 END IF;
52726
52727 --
52728 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
52729 --
52730 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
52731 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
52732 ELSE
52733 ---------------------------------------------------------------------------------------------------
52734 -- 4262811a Switch Sign
52735 ---------------------------------------------------------------------------------------------------
52736 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
52737 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52738 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52739 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
52740 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52741 -- 5132302
52742 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
52743 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
52744
52745 END IF;
52746
52747 -- 4955764
52748 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
52749 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
52750
52751
52752 XLA_AE_LINES_PKG.ValidateCurrentLine;
52753 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
52754
52755 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
52756 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
52757 ,p_balance_type_code => l_balance_type_code);
52758
52759 END IF;
52760
52761 -----------------------------------------------------------------------------------------
52762 -- 4262811 Multiperiod Accounting
52763 -----------------------------------------------------------------------------------------
52764 -- No MPA option is assigned.
52765
52766
52767 END IF;
52768 END IF;
52769 --
52770
52771 --
52772 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52773 trace
52774 (p_msg => 'END of AcctLineType_110'
52775 ,p_level => C_LEVEL_PROCEDURE
52776 ,p_module => l_log_module);
52777 END IF;
52778 --
52779 EXCEPTION
52780 WHEN xla_exceptions_pkg.application_exception THEN
52781 RAISE;
52782 WHEN OTHERS THEN
52783 xla_exceptions_pkg.raise_message
52784 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_110');
52785 END AcctLineType_110;
52786 --
52787
52788 ---------------------------------------
52789 --
52790 -- PRIVATE FUNCTION
52791 -- AcctLineType_111
52792 --
52793 ---------------------------------------
52794 PROCEDURE AcctLineType_111 (
52795 p_application_id IN NUMBER
52796 ,p_event_id IN NUMBER
52797 ,p_calculate_acctd_flag IN VARCHAR2
52798 ,p_calculate_g_l_flag IN VARCHAR2
52799 ,p_actual_flag IN OUT VARCHAR2
52800 ,p_balance_type_code OUT VARCHAR2
52801 ,p_gain_or_loss_ref OUT VARCHAR2
52802
52803 --Distribution GL Account
52804 , p_source_5 IN NUMBER
52805 --Distribution Source Type
52806 , p_source_20 IN VARCHAR2
52807 --Distribution Line Identifier
52808 , p_source_22 IN NUMBER
52809 --Distribution Type
52810 , p_source_23 IN VARCHAR2
52811 --Exchange Date
52812 , p_source_26 IN DATE
52813 --Exchange Rate
52814 , p_source_27 IN NUMBER
52815 --Exchange Rate Type
52816 , p_source_28 IN VARCHAR2
52817 --Transaction Distribution Identifier
52818 , p_source_34 IN NUMBER
52819 --Transaction Distribution Type
52820 , p_source_35 IN VARCHAR2
52821 --Receipt Applied To Application Identifier
52822 , p_source_58 IN NUMBER
52823 --Transaction Entity Code
52824 , p_source_59 IN VARCHAR2
52825 --Transaction Identifier
52826 , p_source_60 IN NUMBER
52827 --Applying Document Currency Code
52828 , p_source_61 IN VARCHAR2
52829 --Distribution Party Identifier
52830 , p_source_63 IN NUMBER
52831 --Distribution Party Site Id
52832 , p_source_64 IN NUMBER
52833 --Distribution Party Type
52834 , p_source_65 IN VARCHAR2
52835 --Distribution Multi Fund Additional Entry
52836 , p_source_67 IN VARCHAR2
52837 --DIST_ENT_AMT_FROM
52838 , p_source_68 IN NUMBER
52839 --Accounting Amount
52840 , p_source_69 IN NUMBER
52841 )
52842 IS
52843
52844 l_component_type VARCHAR2(80);
52845 l_component_code VARCHAR2(30);
52846 l_component_type_code VARCHAR2(1);
52847 l_component_appl_id INTEGER;
52848 l_amb_context_code VARCHAR2(30);
52849 l_entity_code VARCHAR2(30);
52850 l_event_class_code VARCHAR2(30);
52851 l_ae_header_id NUMBER;
52852 l_event_type_code VARCHAR2(30);
52853 l_line_definition_code VARCHAR2(30);
52854 l_line_definition_owner_code VARCHAR2(1);
52855 --
52856 -- adr variables
52857 l_segment VARCHAR2(30);
52858 l_ccid NUMBER;
52859 l_adr_transaction_coa_id NUMBER;
52860 l_adr_accounting_coa_id NUMBER;
52861 l_adr_flexfield_segment_code VARCHAR2(30);
52862 l_adr_flex_value_set_id NUMBER;
52863 l_adr_value_type_code VARCHAR2(30);
52864 l_adr_value_combination_id NUMBER;
52865 l_adr_value_segment_code VARCHAR2(30);
52866
52867 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
52868 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
52869 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
52870 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
52871
52872 -- 4262811 Variables ------------------------------------------------------------------------------------------
52873 l_entered_amt_idx NUMBER;
52874 l_accted_amt_idx NUMBER;
52875 l_acc_rev_flag VARCHAR2(1);
52876 l_accrual_line_num NUMBER;
52877 l_tmp_amt NUMBER;
52878 l_acc_rev_natural_side_code VARCHAR2(1);
52879
52880 l_num_entries NUMBER;
52881 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
52882 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
52883 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
52884 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
52885 l_recog_line_1 NUMBER;
52886 l_recog_line_2 NUMBER;
52887
52888 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
52889 l_bflow_applied_to_amt NUMBER; -- 5132302
52890 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
52891
52892 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
52893
52894 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
52895 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
52896
52897 ---------------------------------------------------------------------------------------------------------------
52898
52899
52900 --
52901 -- bulk performance
52902 --
52903 l_balance_type_code VARCHAR2(1);
52904 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
52905 l_log_module VARCHAR2(240);
52906
52907 --
52908 -- Upgrade strategy
52909 --
52910 l_actual_upg_option VARCHAR2(1);
52911 l_enc_upg_option VARCHAR2(1);
52912
52913 --
52914 BEGIN
52915 --
52916 IF g_log_enabled THEN
52917 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_111';
52918 END IF;
52919 --
52920 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
52921
52922 trace
52923 (p_msg => 'BEGIN of AcctLineType_111'
52924 ,p_level => C_LEVEL_PROCEDURE
52925 ,p_module => l_log_module);
52926
52927 END IF;
52928 --
52929 l_component_type := 'AMB_JLT';
52930 l_component_code := 'RCT_CURR_ROUND';
52931 l_component_type_code := 'S';
52932 l_component_appl_id := 222;
52933 l_amb_context_code := 'DEFAULT';
52934 l_entity_code := 'RECEIPTS';
52935 l_event_class_code := 'RECEIPT';
52936 l_event_type_code := 'RECEIPT_ALL';
52937 l_line_definition_owner_code := 'S';
52938 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
52939 --
52940 l_balance_type_code := 'A';
52941 l_segment := NULL;
52942 l_ccid := NULL;
52943 l_adr_transaction_coa_id := NULL;
52944 l_adr_accounting_coa_id := NULL;
52945 l_adr_flexfield_segment_code := NULL;
52946 l_adr_flex_value_set_id := NULL;
52947 l_adr_value_type_code := NULL;
52948 l_adr_value_combination_id := NULL;
52949 l_adr_value_segment_code := NULL;
52950
52951 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
52952 l_bflow_class_code := ''; -- 4219869 Business Flow
52953 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
52954 l_budgetary_control_flag := 'N';
52955
52956 l_bflow_applied_to_amt_idx := NULL; -- 5132302
52957 l_bflow_applied_to_amt := NULL; -- 5132302
52958 l_entered_amt_idx := NULL; -- 4262811
52959 l_accted_amt_idx := NULL; -- 4262811
52960 l_acc_rev_flag := NULL; -- 4262811
52961 l_accrual_line_num := NULL; -- 4262811
52962 l_tmp_amt := NULL; -- 4262811
52963 --
52964
52965 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
52966 l_balance_type_code <> 'B' THEN
52967 IF NVL(p_source_20,'
52968 ') = 'CURR_ROUND' AND
52969 NVL(p_source_67,'
52970 ') = 'N'
52971 THEN
52972
52973 --
52974 XLA_AE_LINES_PKG.SetNewLine;
52975
52976 p_balance_type_code := l_balance_type_code;
52977 -- set the flag so later we will know whether the gain loss line needs to be created
52978
52979 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
52980 p_actual_flag :='A';
52981 END IF;
52982
52983 --
52984 -- bulk performance
52985 --
52986 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
52987 p_header_num => 0); -- 4262811
52988 --
52989 -- set accounting line options
52990 --
52991 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
52992 p_natural_side_code => 'C'
52993 , p_gain_or_loss_flag => 'N'
52994 , p_gl_transfer_mode_code => 'S'
52995 , p_acct_entry_type_code => 'A'
52996 , p_switch_side_flag => 'Y'
52997 , p_merge_duplicate_code => 'A'
52998 );
52999 --
53000 l_acc_rev_natural_side_code := 'D'; -- 4262811
53001 --
53002 --
53003 -- set accounting line type info
53004 --
53005 xla_ae_lines_pkg.SetAcctLineType
53006 (p_component_type => l_component_type
53007 ,p_event_type_code => l_event_type_code
53008 ,p_line_definition_owner_code => l_line_definition_owner_code
53009 ,p_line_definition_code => l_line_definition_code
53010 ,p_accounting_line_code => l_component_code
53011 ,p_accounting_line_type_code => l_component_type_code
53012 ,p_accounting_line_appl_id => l_component_appl_id
53013 ,p_amb_context_code => l_amb_context_code
53014 ,p_entity_code => l_entity_code
53015 ,p_event_class_code => l_event_class_code);
53016 --
53017 -- set accounting class
53018 --
53019 xla_ae_lines_pkg.SetAcctClass(
53020 p_accounting_class_code => 'ROUNDING'
53021 , p_ae_header_id => l_ae_header_id
53022 );
53023
53024 --
53025 -- set rounding class
53026 --
53027 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
53028 'RECEIVABLE';
53029
53030 --
53031 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
53032 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
53033 --
53034 -- bulk performance
53035 --
53036 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
53037
53038 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
53039 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
53040
53041 -- 4955764
53042 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
53043 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
53044
53045 -- 4458381 Public Sector Enh
53046
53047 --
53048 -- set accounting attributes for the line type
53049 --
53050 l_entered_amt_idx := 8;
53051 l_accted_amt_idx := 13;
53052 l_bflow_applied_to_amt_idx := NULL; -- 5132302
53053 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
53054 l_rec_acct_attrs.array_num_value(1) := p_source_58;
53055 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
53056 l_rec_acct_attrs.array_char_value(2) := p_source_35;
53057 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
53058 l_rec_acct_attrs.array_char_value(3) := p_source_59;
53059 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
53060 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
53061 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
53062 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
53063 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
53064 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
53065 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
53066 l_rec_acct_attrs.array_char_value(7) := p_source_23;
53067 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
53068 l_rec_acct_attrs.array_num_value(8) := p_source_68;
53069 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
53070 l_rec_acct_attrs.array_char_value(9) := p_source_61;
53071 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
53072 l_rec_acct_attrs.array_date_value(10) := p_source_26;
53073 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
53074 l_rec_acct_attrs.array_num_value(11) := p_source_27;
53075 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
53076 l_rec_acct_attrs.array_char_value(12) := p_source_28;
53077 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
53078 l_rec_acct_attrs.array_num_value(13) := p_source_69;
53079 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
53080 l_rec_acct_attrs.array_num_value(14) := p_source_63;
53081 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
53082 l_rec_acct_attrs.array_num_value(15) := p_source_64;
53083 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
53084 l_rec_acct_attrs.array_char_value(16) := p_source_65;
53085
53086 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
53087 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
53088
53089 ---------------------------------------------------------------------------------------------------------------
53090 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
53091 ---------------------------------------------------------------------------------------------------------------
53092 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
53093
53094 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
53095 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
53096
53097 IF xla_accounting_cache_pkg.GetValueChar
53098 (p_source_code => 'LEDGER_CATEGORY_CODE'
53099 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
53100 AND l_bflow_method_code = 'PRIOR_ENTRY'
53101 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
53102 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
53103 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
53104 )
53105 THEN
53106 xla_ae_lines_pkg.BflowUpgEntry
53107 (p_business_method_code => l_bflow_method_code
53108 ,p_business_class_code => l_bflow_class_code
53109 ,p_balance_type => l_balance_type_code);
53110 ELSE
53111 NULL;
53112 -- No business flow processing for business flow method of NONE.
53113 END IF;
53114
53115 --
53116 -- call analytical criteria
53117 --
53118
53119 --
53120 -- call description
53121 --
53122 -- No description or it is inherited.
53123 --
53124 -- call ADRs
53125 -- Bug 4922099
53126 --
53127 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
53128 (NVL(l_actual_upg_option, 'N') = 'O') OR
53129 (NVL(l_enc_upg_option, 'N') = 'O')
53130 )
53131 THEN
53132 NULL;
53133 --
53134 --
53135
53136 l_ccid := AcctDerRule_4(
53137 p_application_id => p_application_id
53138 , p_ae_header_id => l_ae_header_id
53139 , p_source_5 => p_source_5
53140 , x_transaction_coa_id => l_adr_transaction_coa_id
53141 , x_accounting_coa_id => l_adr_accounting_coa_id
53142 , x_value_type_code => l_adr_value_type_code
53143 , p_side => 'NA'
53144 );
53145
53146 xla_ae_lines_pkg.set_ccid(
53147 p_code_combination_id => l_ccid
53148 , p_value_type_code => l_adr_value_type_code
53149 , p_transaction_coa_id => l_adr_transaction_coa_id
53150 , p_accounting_coa_id => l_adr_accounting_coa_id
53151 , p_adr_code => 'DIST_CCID'
53152 , p_adr_type_code => 'S'
53153 , p_component_type => l_component_type
53154 , p_component_code => l_component_code
53155 , p_component_type_code => l_component_type_code
53156 , p_component_appl_id => l_component_appl_id
53157 , p_amb_context_code => l_amb_context_code
53158 , p_side => 'NA'
53159 );
53160
53161
53162 --
53163 --
53164 END IF;
53165 --
53166 -- Bug 4922099
53167 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
53168 (NVL(l_enc_upg_option, 'N') = 'O')
53169 ) AND
53170 (l_bflow_method_code = 'PRIOR_ENTRY')
53171 )
53172 THEN
53173 IF
53174 --
53175 1 = 2
53176 --
53177 THEN
53178 xla_accounting_err_pkg.build_message
53179 (p_appli_s_name => 'XLA'
53180 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
53181 ,p_token_1 => 'LINE_NUMBER'
53182 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
53183 ,p_token_2 => 'LINE_TYPE_NAME'
53184 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
53185 l_component_type
53186 ,l_component_code
53187 ,l_component_type_code
53188 ,l_component_appl_id
53189 ,l_amb_context_code
53190 ,l_entity_code
53191 ,l_event_class_code
53192 )
53193 ,p_token_3 => 'OWNER'
53194 ,p_value_3 => xla_lookups_pkg.get_meaning(
53195 p_lookup_type => 'XLA_OWNER_TYPE'
53196 ,p_lookup_code => l_component_type_code
53197 )
53198 ,p_token_4 => 'PRODUCT_NAME'
53199 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
53200 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
53201 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
53202 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
53203 ,p_ae_header_id => NULL
53204 );
53205
53206 IF (C_LEVEL_ERROR>= g_log_level) THEN
53207 trace
53208 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
53209 ,p_level => C_LEVEL_ERROR
53210 ,p_module => l_log_module);
53211 END IF;
53212 END IF;
53213 END IF;
53214 --
53215 --
53216 ------------------------------------------------------------------------------------------------
53217 -- 4219869 Business Flow
53218 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
53219 -- Prior Entry. Currently, the following code is always generated.
53220 ------------------------------------------------------------------------------------------------
53221 XLA_AE_LINES_PKG.ValidateCurrentLine;
53222
53223 ------------------------------------------------------------------------------------
53224 -- 4219869 Business Flow
53225 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
53226 ------------------------------------------------------------------------------------
53227 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
53228
53229 ----------------------------------------------------------------------------------
53230 -- 4219869 Business Flow
53231 -- Update journal entry status -- Need to generate this within IF <condition>
53232 ----------------------------------------------------------------------------------
53233 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
53234 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
53235 ,p_balance_type_code => l_balance_type_code
53236 );
53237
53238 -------------------------------------------------------------------------------------------
53239 -- 4262811 - Generate the Accrual Reversal lines
53240 -------------------------------------------------------------------------------------------
53241 BEGIN
53242 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
53243 (g_array_event(p_event_id).array_value_num('header_index'));
53244 IF l_acc_rev_flag IS NULL THEN
53245 l_acc_rev_flag := 'N';
53246 END IF;
53247 EXCEPTION
53248 WHEN OTHERS THEN
53249 l_acc_rev_flag := 'N';
53250 END;
53251 --
53252 IF (l_acc_rev_flag = 'Y') THEN
53253
53254 -- 4645092 ------------------------------------------------------------------------------
53255 -- To allow MPA report to determine if it should generate report process
53256 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
53257 ------------------------------------------------------------------------------------------
53258
53259 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
53260 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
53261 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
53262 -- call ADRs
53263 -- Bug 4922099
53264 --
53265 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
53266 (NVL(l_actual_upg_option, 'N') = 'O') OR
53267 (NVL(l_enc_upg_option, 'N') = 'O')
53268 )
53269 THEN
53270 NULL;
53271 --
53272 --
53273
53274 l_ccid := AcctDerRule_4(
53275 p_application_id => p_application_id
53276 , p_ae_header_id => l_ae_header_id
53277 , p_source_5 => p_source_5
53278 , x_transaction_coa_id => l_adr_transaction_coa_id
53279 , x_accounting_coa_id => l_adr_accounting_coa_id
53280 , x_value_type_code => l_adr_value_type_code
53281 , p_side => 'NA'
53282 );
53283
53284 xla_ae_lines_pkg.set_ccid(
53285 p_code_combination_id => l_ccid
53286 , p_value_type_code => l_adr_value_type_code
53287 , p_transaction_coa_id => l_adr_transaction_coa_id
53288 , p_accounting_coa_id => l_adr_accounting_coa_id
53289 , p_adr_code => 'DIST_CCID'
53290 , p_adr_type_code => 'S'
53291 , p_component_type => l_component_type
53292 , p_component_code => l_component_code
53293 , p_component_type_code => l_component_type_code
53294 , p_component_appl_id => l_component_appl_id
53295 , p_amb_context_code => l_amb_context_code
53296 , p_side => 'NA'
53297 );
53298
53299
53300 --
53301 --
53302 END IF;
53303
53304 --
53305 -- Update the line information that should be overwritten
53306 --
53307 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
53308 p_header_num => 1);
53309 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
53310
53311 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
53312
53313 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
53314 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
53315 END IF;
53316
53317 --
53318 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
53319 --
53320 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
53321 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
53322 ELSE
53323 ---------------------------------------------------------------------------------------------------
53324 -- 4262811a Switch Sign
53325 ---------------------------------------------------------------------------------------------------
53326 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
53327 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53328 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53329 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53330 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53331 -- 5132302
53332 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
53333 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53334
53335 END IF;
53336
53337 -- 4955764
53338 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
53339 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
53340
53341
53342 XLA_AE_LINES_PKG.ValidateCurrentLine;
53343 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
53344
53345 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
53346 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
53347 ,p_balance_type_code => l_balance_type_code);
53348
53349 END IF;
53350
53351 -----------------------------------------------------------------------------------------
53352 -- 4262811 Multiperiod Accounting
53353 -----------------------------------------------------------------------------------------
53354 -- No MPA option is assigned.
53355
53356
53357 END IF;
53358 END IF;
53359 --
53360
53361 --
53362 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53363 trace
53364 (p_msg => 'END of AcctLineType_111'
53365 ,p_level => C_LEVEL_PROCEDURE
53366 ,p_module => l_log_module);
53367 END IF;
53368 --
53369 EXCEPTION
53370 WHEN xla_exceptions_pkg.application_exception THEN
53371 RAISE;
53372 WHEN OTHERS THEN
53373 xla_exceptions_pkg.raise_message
53374 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_111');
53375 END AcctLineType_111;
53376 --
53377
53378 ---------------------------------------
53379 --
53380 -- PRIVATE FUNCTION
53381 -- AcctLineType_112
53382 --
53383 ---------------------------------------
53384 PROCEDURE AcctLineType_112 (
53385 p_application_id IN NUMBER
53386 ,p_event_id IN NUMBER
53387 ,p_calculate_acctd_flag IN VARCHAR2
53388 ,p_calculate_g_l_flag IN VARCHAR2
53389 ,p_actual_flag IN OUT VARCHAR2
53390 ,p_balance_type_code OUT VARCHAR2
53391 ,p_gain_or_loss_ref OUT VARCHAR2
53392
53393 --Distribution GL Account
53394 , p_source_5 IN NUMBER
53395 --Distribution Source Type
53396 , p_source_20 IN VARCHAR2
53397 --Distribution Line Identifier
53398 , p_source_22 IN NUMBER
53399 --Distribution Type
53403 --Exchange Rate
53400 , p_source_23 IN VARCHAR2
53401 --Exchange Date
53402 , p_source_26 IN DATE
53404 , p_source_27 IN NUMBER
53405 --Exchange Rate Type
53406 , p_source_28 IN VARCHAR2
53407 --Transaction Distribution Identifier
53408 , p_source_34 IN NUMBER
53409 --Transaction Distribution Type
53410 , p_source_35 IN VARCHAR2
53411 --Receipt Applied To Application Identifier
53412 , p_source_58 IN NUMBER
53413 --Transaction Entity Code
53414 , p_source_59 IN VARCHAR2
53415 --Transaction Identifier
53416 , p_source_60 IN NUMBER
53417 --Applying Document Currency Code
53418 , p_source_61 IN VARCHAR2
53419 --Distribution Party Identifier
53420 , p_source_63 IN NUMBER
53421 --Distribution Party Site Id
53422 , p_source_64 IN NUMBER
53423 --Distribution Party Type
53424 , p_source_65 IN VARCHAR2
53425 --Distribution Multi Fund Additional Entry
53426 , p_source_67 IN VARCHAR2
53427 --DIST_ENT_AMT_FROM
53428 , p_source_68 IN NUMBER
53429 --Accounting Amount
53430 , p_source_69 IN NUMBER
53431 )
53432 IS
53433
53434 l_component_type VARCHAR2(80);
53435 l_component_code VARCHAR2(30);
53436 l_component_type_code VARCHAR2(1);
53437 l_component_appl_id INTEGER;
53438 l_amb_context_code VARCHAR2(30);
53439 l_entity_code VARCHAR2(30);
53440 l_event_class_code VARCHAR2(30);
53441 l_ae_header_id NUMBER;
53442 l_event_type_code VARCHAR2(30);
53443 l_line_definition_code VARCHAR2(30);
53444 l_line_definition_owner_code VARCHAR2(1);
53445 --
53446 -- adr variables
53447 l_segment VARCHAR2(30);
53448 l_ccid NUMBER;
53449 l_adr_transaction_coa_id NUMBER;
53450 l_adr_accounting_coa_id NUMBER;
53451 l_adr_flexfield_segment_code VARCHAR2(30);
53452 l_adr_flex_value_set_id NUMBER;
53453 l_adr_value_type_code VARCHAR2(30);
53454 l_adr_value_combination_id NUMBER;
53455 l_adr_value_segment_code VARCHAR2(30);
53456
53457 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
53458 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
53459 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
53460 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
53461
53462 -- 4262811 Variables ------------------------------------------------------------------------------------------
53463 l_entered_amt_idx NUMBER;
53464 l_accted_amt_idx NUMBER;
53465 l_acc_rev_flag VARCHAR2(1);
53466 l_accrual_line_num NUMBER;
53467 l_tmp_amt NUMBER;
53468 l_acc_rev_natural_side_code VARCHAR2(1);
53469
53470 l_num_entries NUMBER;
53471 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
53472 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
53473 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
53474 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
53475 l_recog_line_1 NUMBER;
53476 l_recog_line_2 NUMBER;
53477
53478 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
53479 l_bflow_applied_to_amt NUMBER; -- 5132302
53480 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
53481
53482 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
53483
53484 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
53485 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
53486
53487 ---------------------------------------------------------------------------------------------------------------
53488
53489
53490 --
53491 -- bulk performance
53492 --
53493 l_balance_type_code VARCHAR2(1);
53494 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
53495 l_log_module VARCHAR2(240);
53496
53497 --
53498 -- Upgrade strategy
53499 --
53500 l_actual_upg_option VARCHAR2(1);
53501 l_enc_upg_option VARCHAR2(1);
53502
53503 --
53504 BEGIN
53505 --
53506 IF g_log_enabled THEN
53507 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_112';
53508 END IF;
53509 --
53510 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53511
53512 trace
53513 (p_msg => 'BEGIN of AcctLineType_112'
53514 ,p_level => C_LEVEL_PROCEDURE
53515 ,p_module => l_log_module);
53516
53517 END IF;
53518 --
53519 l_component_type := 'AMB_JLT';
53520 l_component_code := 'RCT_DEBT';
53521 l_component_type_code := 'S';
53522 l_component_appl_id := 222;
53523 l_amb_context_code := 'DEFAULT';
53524 l_entity_code := 'RECEIPTS';
53525 l_event_class_code := 'RECEIPT';
53526 l_event_type_code := 'RECEIPT_ALL';
53527 l_line_definition_owner_code := 'S';
53528 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
53529 --
53530 l_balance_type_code := 'A';
53531 l_segment := NULL;
53532 l_ccid := NULL;
53533 l_adr_transaction_coa_id := NULL;
53534 l_adr_accounting_coa_id := NULL;
53538 l_adr_value_combination_id := NULL;
53535 l_adr_flexfield_segment_code := NULL;
53536 l_adr_flex_value_set_id := NULL;
53537 l_adr_value_type_code := NULL;
53539 l_adr_value_segment_code := NULL;
53540
53541 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
53542 l_bflow_class_code := ''; -- 4219869 Business Flow
53543 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
53544 l_budgetary_control_flag := 'N';
53545
53546 l_bflow_applied_to_amt_idx := NULL; -- 5132302
53547 l_bflow_applied_to_amt := NULL; -- 5132302
53548 l_entered_amt_idx := NULL; -- 4262811
53549 l_accted_amt_idx := NULL; -- 4262811
53550 l_acc_rev_flag := NULL; -- 4262811
53551 l_accrual_line_num := NULL; -- 4262811
53552 l_tmp_amt := NULL; -- 4262811
53553 --
53554
53555 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
53556 l_balance_type_code <> 'B' THEN
53557 IF NVL(p_source_20,'
53558 ') = 'SHORT_TERM_DEBT' AND
53559 NVL(p_source_67,'
53560 ') = 'N'
53561 THEN
53562
53563 --
53564 XLA_AE_LINES_PKG.SetNewLine;
53565
53566 p_balance_type_code := l_balance_type_code;
53567 -- set the flag so later we will know whether the gain loss line needs to be created
53568
53569 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
53570 p_actual_flag :='A';
53571 END IF;
53572
53573 --
53574 -- bulk performance
53575 --
53576 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
53577 p_header_num => 0); -- 4262811
53578 --
53579 -- set accounting line options
53580 --
53581 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
53582 p_natural_side_code => 'C'
53583 , p_gain_or_loss_flag => 'N'
53584 , p_gl_transfer_mode_code => 'S'
53585 , p_acct_entry_type_code => 'A'
53586 , p_switch_side_flag => 'Y'
53587 , p_merge_duplicate_code => 'A'
53588 );
53589 --
53590 l_acc_rev_natural_side_code := 'D'; -- 4262811
53591 --
53592 --
53593 -- set accounting line type info
53594 --
53595 xla_ae_lines_pkg.SetAcctLineType
53596 (p_component_type => l_component_type
53597 ,p_event_type_code => l_event_type_code
53598 ,p_line_definition_owner_code => l_line_definition_owner_code
53599 ,p_line_definition_code => l_line_definition_code
53600 ,p_accounting_line_code => l_component_code
53601 ,p_accounting_line_type_code => l_component_type_code
53602 ,p_accounting_line_appl_id => l_component_appl_id
53603 ,p_amb_context_code => l_amb_context_code
53604 ,p_entity_code => l_entity_code
53605 ,p_event_class_code => l_event_class_code);
53606 --
53607 -- set accounting class
53608 --
53609 xla_ae_lines_pkg.SetAcctClass(
53610 p_accounting_class_code => 'SHORT_TERM_DEBT'
53611 , p_ae_header_id => l_ae_header_id
53612 );
53613
53614 --
53615 -- set rounding class
53616 --
53617 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
53618 'RECEIVABLE';
53619
53620 --
53621 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
53622 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
53623 --
53624 -- bulk performance
53625 --
53626 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
53627
53628 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
53629 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
53630
53631 -- 4955764
53632 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
53633 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
53634
53635 -- 4458381 Public Sector Enh
53636
53637 --
53638 -- set accounting attributes for the line type
53639 --
53640 l_entered_amt_idx := 8;
53641 l_accted_amt_idx := 13;
53642 l_bflow_applied_to_amt_idx := NULL; -- 5132302
53643 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
53644 l_rec_acct_attrs.array_num_value(1) := p_source_58;
53645 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
53646 l_rec_acct_attrs.array_char_value(2) := p_source_35;
53647 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
53648 l_rec_acct_attrs.array_char_value(3) := p_source_59;
53649 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
53650 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
53651 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
53652 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
53653 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
53654 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
53655 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
53656 l_rec_acct_attrs.array_char_value(7) := p_source_23;
53657 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
53658 l_rec_acct_attrs.array_num_value(8) := p_source_68;
53659 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
53660 l_rec_acct_attrs.array_char_value(9) := p_source_61;
53661 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
53662 l_rec_acct_attrs.array_date_value(10) := p_source_26;
53663 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
53664 l_rec_acct_attrs.array_num_value(11) := p_source_27;
53665 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
53666 l_rec_acct_attrs.array_char_value(12) := p_source_28;
53667 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
53668 l_rec_acct_attrs.array_num_value(13) := p_source_69;
53669 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
53670 l_rec_acct_attrs.array_num_value(14) := p_source_63;
53671 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
53672 l_rec_acct_attrs.array_num_value(15) := p_source_64;
53673 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
53674 l_rec_acct_attrs.array_char_value(16) := p_source_65;
53675
53676 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
53677 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
53678
53679 ---------------------------------------------------------------------------------------------------------------
53680 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
53681 ---------------------------------------------------------------------------------------------------------------
53682 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
53683
53684 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
53685 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
53686
53687 IF xla_accounting_cache_pkg.GetValueChar
53688 (p_source_code => 'LEDGER_CATEGORY_CODE'
53689 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
53690 AND l_bflow_method_code = 'PRIOR_ENTRY'
53691 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
53692 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
53693 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
53694 )
53695 THEN
53696 xla_ae_lines_pkg.BflowUpgEntry
53697 (p_business_method_code => l_bflow_method_code
53698 ,p_business_class_code => l_bflow_class_code
53699 ,p_balance_type => l_balance_type_code);
53700 ELSE
53701 NULL;
53702 -- No business flow processing for business flow method of NONE.
53703 END IF;
53704
53705 --
53706 -- call analytical criteria
53707 --
53708
53709 --
53710 -- call description
53711 --
53712 -- No description or it is inherited.
53713 --
53714 -- call ADRs
53715 -- Bug 4922099
53716 --
53717 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
53718 (NVL(l_actual_upg_option, 'N') = 'O') OR
53719 (NVL(l_enc_upg_option, 'N') = 'O')
53720 )
53721 THEN
53722 NULL;
53723 --
53724 --
53725
53726 l_ccid := AcctDerRule_4(
53727 p_application_id => p_application_id
53728 , p_ae_header_id => l_ae_header_id
53729 , p_source_5 => p_source_5
53730 , x_transaction_coa_id => l_adr_transaction_coa_id
53731 , x_accounting_coa_id => l_adr_accounting_coa_id
53732 , x_value_type_code => l_adr_value_type_code
53733 , p_side => 'NA'
53734 );
53735
53736 xla_ae_lines_pkg.set_ccid(
53737 p_code_combination_id => l_ccid
53738 , p_value_type_code => l_adr_value_type_code
53739 , p_transaction_coa_id => l_adr_transaction_coa_id
53740 , p_accounting_coa_id => l_adr_accounting_coa_id
53741 , p_adr_code => 'DIST_CCID'
53742 , p_adr_type_code => 'S'
53743 , p_component_type => l_component_type
53744 , p_component_code => l_component_code
53745 , p_component_type_code => l_component_type_code
53746 , p_component_appl_id => l_component_appl_id
53747 , p_amb_context_code => l_amb_context_code
53748 , p_side => 'NA'
53749 );
53750
53751
53752 --
53753 --
53754 END IF;
53755 --
53756 -- Bug 4922099
53757 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
53758 (NVL(l_enc_upg_option, 'N') = 'O')
53759 ) AND
53760 (l_bflow_method_code = 'PRIOR_ENTRY')
53761 )
53762 THEN
53763 IF
53764 --
53765 1 = 2
53766 --
53767 THEN
53768 xla_accounting_err_pkg.build_message
53769 (p_appli_s_name => 'XLA'
53770 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
53771 ,p_token_1 => 'LINE_NUMBER'
53772 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
53773 ,p_token_2 => 'LINE_TYPE_NAME'
53774 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
53775 l_component_type
53776 ,l_component_code
53777 ,l_component_type_code
53778 ,l_component_appl_id
53779 ,l_amb_context_code
53780 ,l_entity_code
53781 ,l_event_class_code
53782 )
53783 ,p_token_3 => 'OWNER'
53784 ,p_value_3 => xla_lookups_pkg.get_meaning(
53785 p_lookup_type => 'XLA_OWNER_TYPE'
53786 ,p_lookup_code => l_component_type_code
53787 )
53788 ,p_token_4 => 'PRODUCT_NAME'
53789 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
53790 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
53791 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
53792 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
53793 ,p_ae_header_id => NULL
53794 );
53795
53796 IF (C_LEVEL_ERROR>= g_log_level) THEN
53797 trace
53798 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
53799 ,p_level => C_LEVEL_ERROR
53800 ,p_module => l_log_module);
53801 END IF;
53802 END IF;
53803 END IF;
53804 --
53805 --
53806 ------------------------------------------------------------------------------------------------
53807 -- 4219869 Business Flow
53808 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
53809 -- Prior Entry. Currently, the following code is always generated.
53810 ------------------------------------------------------------------------------------------------
53811 XLA_AE_LINES_PKG.ValidateCurrentLine;
53812
53813 ------------------------------------------------------------------------------------
53814 -- 4219869 Business Flow
53815 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
53816 ------------------------------------------------------------------------------------
53817 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
53818
53819 ----------------------------------------------------------------------------------
53820 -- 4219869 Business Flow
53821 -- Update journal entry status -- Need to generate this within IF <condition>
53825 ,p_balance_type_code => l_balance_type_code
53822 ----------------------------------------------------------------------------------
53823 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
53824 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
53826 );
53827
53828 -------------------------------------------------------------------------------------------
53829 -- 4262811 - Generate the Accrual Reversal lines
53830 -------------------------------------------------------------------------------------------
53831 BEGIN
53832 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
53833 (g_array_event(p_event_id).array_value_num('header_index'));
53834 IF l_acc_rev_flag IS NULL THEN
53835 l_acc_rev_flag := 'N';
53836 END IF;
53837 EXCEPTION
53838 WHEN OTHERS THEN
53839 l_acc_rev_flag := 'N';
53840 END;
53841 --
53842 IF (l_acc_rev_flag = 'Y') THEN
53843
53844 -- 4645092 ------------------------------------------------------------------------------
53845 -- To allow MPA report to determine if it should generate report process
53846 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
53847 ------------------------------------------------------------------------------------------
53848
53849 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
53850 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
53851 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
53852 -- call ADRs
53853 -- Bug 4922099
53854 --
53855 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
53856 (NVL(l_actual_upg_option, 'N') = 'O') OR
53857 (NVL(l_enc_upg_option, 'N') = 'O')
53858 )
53859 THEN
53860 NULL;
53861 --
53862 --
53863
53864 l_ccid := AcctDerRule_4(
53865 p_application_id => p_application_id
53866 , p_ae_header_id => l_ae_header_id
53867 , p_source_5 => p_source_5
53868 , x_transaction_coa_id => l_adr_transaction_coa_id
53869 , x_accounting_coa_id => l_adr_accounting_coa_id
53870 , x_value_type_code => l_adr_value_type_code
53871 , p_side => 'NA'
53872 );
53873
53874 xla_ae_lines_pkg.set_ccid(
53875 p_code_combination_id => l_ccid
53876 , p_value_type_code => l_adr_value_type_code
53877 , p_transaction_coa_id => l_adr_transaction_coa_id
53878 , p_accounting_coa_id => l_adr_accounting_coa_id
53879 , p_adr_code => 'DIST_CCID'
53880 , p_adr_type_code => 'S'
53881 , p_component_type => l_component_type
53882 , p_component_code => l_component_code
53883 , p_component_type_code => l_component_type_code
53884 , p_component_appl_id => l_component_appl_id
53885 , p_amb_context_code => l_amb_context_code
53886 , p_side => 'NA'
53887 );
53888
53889
53890 --
53891 --
53892 END IF;
53893
53894 --
53895 -- Update the line information that should be overwritten
53896 --
53897 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
53898 p_header_num => 1);
53899 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
53900
53901 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
53902
53903 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
53904 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
53905 END IF;
53906
53907 --
53908 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
53909 --
53910 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
53911 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
53912 ELSE
53913 ---------------------------------------------------------------------------------------------------
53914 -- 4262811a Switch Sign
53915 ---------------------------------------------------------------------------------------------------
53916 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
53917 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53918 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53919 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
53920 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53921 -- 5132302
53922 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
53923 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
53924
53925 END IF;
53926
53927 -- 4955764
53928 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
53929 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
53930
53931
53932 XLA_AE_LINES_PKG.ValidateCurrentLine;
53933 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
53934
53935 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
53936 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
53940
53937 ,p_balance_type_code => l_balance_type_code);
53938
53939 END IF;
53941 -----------------------------------------------------------------------------------------
53942 -- 4262811 Multiperiod Accounting
53943 -----------------------------------------------------------------------------------------
53944 -- No MPA option is assigned.
53945
53946
53947 END IF;
53948 END IF;
53949 --
53950
53951 --
53952 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
53953 trace
53954 (p_msg => 'END of AcctLineType_112'
53955 ,p_level => C_LEVEL_PROCEDURE
53956 ,p_module => l_log_module);
53957 END IF;
53958 --
53959 EXCEPTION
53960 WHEN xla_exceptions_pkg.application_exception THEN
53961 RAISE;
53962 WHEN OTHERS THEN
53963 xla_exceptions_pkg.raise_message
53964 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_112');
53965 END AcctLineType_112;
53966 --
53967
53968 ---------------------------------------
53969 --
53970 -- PRIVATE FUNCTION
53971 -- AcctLineType_113
53972 --
53973 ---------------------------------------
53974 PROCEDURE AcctLineType_113 (
53975 p_application_id IN NUMBER
53976 ,p_event_id IN NUMBER
53977 ,p_calculate_acctd_flag IN VARCHAR2
53978 ,p_calculate_g_l_flag IN VARCHAR2
53979 ,p_actual_flag IN OUT VARCHAR2
53980 ,p_balance_type_code OUT VARCHAR2
53981 ,p_gain_or_loss_ref OUT VARCHAR2
53982
53983 --Transaction Type Name
53984 , p_source_1 IN VARCHAR2
53985 --Transaction Number
53986 , p_source_2 IN VARCHAR2
53987 --Transaction Document Sequence Number
53988 , p_source_3 IN NUMBER
53989 --Distribution GL Account
53990 , p_source_5 IN NUMBER
53991 --Distribution Source Type
53992 , p_source_20 IN VARCHAR2
53993 --Distribution Line Identifier
53994 , p_source_22 IN NUMBER
53995 --Distribution Type
53996 , p_source_23 IN VARCHAR2
53997 --Entered Amount
53998 , p_source_24 IN NUMBER
53999 --Currency Code
54000 , p_source_25 IN VARCHAR2
54001 --Applied To Document Accounting Amount
54002 , p_source_29 IN NUMBER
54003 --Transaction Distribution Identifier
54004 , p_source_34 IN NUMBER
54005 --Transaction Distribution Type
54006 , p_source_35 IN VARCHAR2
54007 --Applied To Document Exchange Date
54008 , p_source_57 IN DATE
54009 --Receipt Applied To Application Identifier
54010 , p_source_58 IN NUMBER
54011 --Transaction Entity Code
54012 , p_source_59 IN VARCHAR2
54013 --Transaction Identifier
54014 , p_source_60 IN NUMBER
54015 --Applied To Document Exchange Rate
54016 , p_source_62 IN NUMBER
54017 --Distribution Party Identifier
54018 , p_source_63 IN NUMBER
54019 --Distribution Party Site Id
54020 , p_source_64 IN NUMBER
54021 --Distribution Party Type
54022 , p_source_65 IN VARCHAR2
54023 --Distribution Multi Fund Additional Entry
54024 , p_source_67 IN VARCHAR2
54025 --Applied To Document Exchange Rate Type
54026 , p_source_70 IN VARCHAR2
54027 )
54028 IS
54029
54030 l_component_type VARCHAR2(80);
54031 l_component_code VARCHAR2(30);
54032 l_component_type_code VARCHAR2(1);
54033 l_component_appl_id INTEGER;
54034 l_amb_context_code VARCHAR2(30);
54035 l_entity_code VARCHAR2(30);
54036 l_event_class_code VARCHAR2(30);
54037 l_ae_header_id NUMBER;
54038 l_event_type_code VARCHAR2(30);
54039 l_line_definition_code VARCHAR2(30);
54040 l_line_definition_owner_code VARCHAR2(1);
54041 --
54042 -- adr variables
54043 l_segment VARCHAR2(30);
54044 l_ccid NUMBER;
54045 l_adr_transaction_coa_id NUMBER;
54046 l_adr_accounting_coa_id NUMBER;
54047 l_adr_flexfield_segment_code VARCHAR2(30);
54048 l_adr_flex_value_set_id NUMBER;
54049 l_adr_value_type_code VARCHAR2(30);
54050 l_adr_value_combination_id NUMBER;
54051 l_adr_value_segment_code VARCHAR2(30);
54052
54053 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
54054 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
54055 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
54056 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
54057
54058 -- 4262811 Variables ------------------------------------------------------------------------------------------
54059 l_entered_amt_idx NUMBER;
54060 l_accted_amt_idx NUMBER;
54061 l_acc_rev_flag VARCHAR2(1);
54062 l_accrual_line_num NUMBER;
54063 l_tmp_amt NUMBER;
54064 l_acc_rev_natural_side_code VARCHAR2(1);
54065
54066 l_num_entries NUMBER;
54067 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
54068 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
54069 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
54070 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
54071 l_recog_line_1 NUMBER;
54072 l_recog_line_2 NUMBER;
54073
54074 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
54075 l_bflow_applied_to_amt NUMBER; -- 5132302
54076 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
54077
54081 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
54078 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
54079
54080 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
54082
54083 ---------------------------------------------------------------------------------------------------------------
54084
54085
54086 --
54087 -- bulk performance
54088 --
54089 l_balance_type_code VARCHAR2(1);
54090 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
54091 l_log_module VARCHAR2(240);
54092
54093 --
54094 -- Upgrade strategy
54095 --
54096 l_actual_upg_option VARCHAR2(1);
54097 l_enc_upg_option VARCHAR2(1);
54098
54099 --
54100 BEGIN
54101 --
54102 IF g_log_enabled THEN
54103 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_113';
54104 END IF;
54105 --
54106 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54107
54108 trace
54109 (p_msg => 'BEGIN of AcctLineType_113'
54110 ,p_level => C_LEVEL_PROCEDURE
54111 ,p_module => l_log_module);
54112
54113 END IF;
54114 --
54115 l_component_type := 'AMB_JLT';
54116 l_component_code := 'RCT_DEFAULT_APP';
54117 l_component_type_code := 'S';
54118 l_component_appl_id := 222;
54119 l_amb_context_code := 'DEFAULT';
54120 l_entity_code := 'RECEIPTS';
54121 l_event_class_code := 'RECEIPT';
54122 l_event_type_code := 'RECEIPT_ALL';
54123 l_line_definition_owner_code := 'S';
54124 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
54125 --
54126 l_balance_type_code := 'A';
54127 l_segment := NULL;
54128 l_ccid := NULL;
54129 l_adr_transaction_coa_id := NULL;
54130 l_adr_accounting_coa_id := NULL;
54131 l_adr_flexfield_segment_code := NULL;
54132 l_adr_flex_value_set_id := NULL;
54133 l_adr_value_type_code := NULL;
54134 l_adr_value_combination_id := NULL;
54135 l_adr_value_segment_code := NULL;
54136
54137 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
54138 l_bflow_class_code := ''; -- 4219869 Business Flow
54139 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
54140 l_budgetary_control_flag := 'N';
54141
54142 l_bflow_applied_to_amt_idx := NULL; -- 5132302
54143 l_bflow_applied_to_amt := NULL; -- 5132302
54144 l_entered_amt_idx := NULL; -- 4262811
54145 l_accted_amt_idx := NULL; -- 4262811
54146 l_acc_rev_flag := NULL; -- 4262811
54147 l_accrual_line_num := NULL; -- 4262811
54148 l_tmp_amt := NULL; -- 4262811
54149 --
54150
54151 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
54152 l_balance_type_code <> 'B' THEN
54153 IF NVL(p_source_20,'
54154 ') = 'REC' AND
54155 NVL(p_source_67,'
54156 ') = 'N'
54157 THEN
54158
54159 --
54160 XLA_AE_LINES_PKG.SetNewLine;
54161
54162 p_balance_type_code := l_balance_type_code;
54163 -- set the flag so later we will know whether the gain loss line needs to be created
54164
54165 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
54166 p_actual_flag :='A';
54167 END IF;
54168
54169 --
54170 -- bulk performance
54171 --
54172 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
54173 p_header_num => 0); -- 4262811
54174 --
54175 -- set accounting line options
54176 --
54177 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
54178 p_natural_side_code => 'C'
54179 , p_gain_or_loss_flag => 'N'
54180 , p_gl_transfer_mode_code => 'S'
54181 , p_acct_entry_type_code => 'A'
54182 , p_switch_side_flag => 'Y'
54183 , p_merge_duplicate_code => 'A'
54184 );
54185 --
54186 l_acc_rev_natural_side_code := 'D'; -- 4262811
54187 --
54188 --
54189 -- set accounting line type info
54190 --
54191 xla_ae_lines_pkg.SetAcctLineType
54192 (p_component_type => l_component_type
54193 ,p_event_type_code => l_event_type_code
54194 ,p_line_definition_owner_code => l_line_definition_owner_code
54195 ,p_line_definition_code => l_line_definition_code
54196 ,p_accounting_line_code => l_component_code
54197 ,p_accounting_line_type_code => l_component_type_code
54198 ,p_accounting_line_appl_id => l_component_appl_id
54199 ,p_amb_context_code => l_amb_context_code
54200 ,p_entity_code => l_entity_code
54201 ,p_event_class_code => l_event_class_code);
54202 --
54203 -- set accounting class
54204 --
54205 xla_ae_lines_pkg.SetAcctClass(
54206 p_accounting_class_code => 'RECEIVABLE'
54207 , p_ae_header_id => l_ae_header_id
54208 );
54209
54210 --
54211 -- set rounding class
54212 --
54213 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
54214 'RECEIVABLE';
54215
54216 --
54217 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
54218 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
54222 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
54219 --
54220 -- bulk performance
54221 --
54223
54224 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
54225 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
54226
54227 -- 4955764
54228 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
54229 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
54230
54231 -- 4458381 Public Sector Enh
54232
54233 --
54234 -- set accounting attributes for the line type
54235 --
54236 l_entered_amt_idx := 8;
54237 l_accted_amt_idx := 13;
54238 l_bflow_applied_to_amt_idx := NULL; -- 5132302
54239 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
54240 l_rec_acct_attrs.array_num_value(1) := p_source_58;
54241 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
54242 l_rec_acct_attrs.array_char_value(2) := p_source_35;
54243 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
54244 l_rec_acct_attrs.array_char_value(3) := p_source_59;
54245 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
54246 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
54247 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
54248 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
54249 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
54250 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
54251 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
54252 l_rec_acct_attrs.array_char_value(7) := p_source_23;
54253 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
54254 l_rec_acct_attrs.array_num_value(8) := p_source_24;
54255 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
54256 l_rec_acct_attrs.array_char_value(9) := p_source_25;
54257 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
54258 l_rec_acct_attrs.array_date_value(10) := p_source_57;
54259 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
54260 l_rec_acct_attrs.array_num_value(11) := p_source_62;
54261 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
54262 l_rec_acct_attrs.array_char_value(12) := p_source_70;
54263 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
54264 l_rec_acct_attrs.array_num_value(13) := p_source_29;
54265 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
54266 l_rec_acct_attrs.array_num_value(14) := p_source_63;
54267 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
54268 l_rec_acct_attrs.array_num_value(15) := p_source_64;
54269 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
54270 l_rec_acct_attrs.array_char_value(16) := p_source_65;
54271
54272 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
54273 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
54274
54275 ---------------------------------------------------------------------------------------------------------------
54276 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
54277 ---------------------------------------------------------------------------------------------------------------
54278 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
54279
54280 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
54281 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
54282
54283 IF xla_accounting_cache_pkg.GetValueChar
54284 (p_source_code => 'LEDGER_CATEGORY_CODE'
54285 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
54286 AND l_bflow_method_code = 'PRIOR_ENTRY'
54287 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
54288 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
54289 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
54290 )
54291 THEN
54292 xla_ae_lines_pkg.BflowUpgEntry
54293 (p_business_method_code => l_bflow_method_code
54294 ,p_business_class_code => l_bflow_class_code
54295 ,p_balance_type => l_balance_type_code);
54296 ELSE
54297 NULL;
54298 -- No business flow processing for business flow method of NONE.
54299 END IF;
54300
54301 --
54302 -- call analytical criteria
54303 --
54304
54305 --
54306 -- call description
54307 --
54308
54309 xla_ae_lines_pkg.SetLineDescription(
54310 p_ae_header_id => l_ae_header_id
54311 ,p_description => Description_2 (
54312 p_application_id => p_application_id
54313 , p_ae_header_id => l_ae_header_id
54314 , p_source_1 => p_source_1
54315 , p_source_2 => p_source_2
54316 , p_source_3 => p_source_3
54317 )
54318 );
54319
54320
54321 --
54322 -- call ADRs
54323 -- Bug 4922099
54324 --
54325 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
54326 (NVL(l_actual_upg_option, 'N') = 'O') OR
54327 (NVL(l_enc_upg_option, 'N') = 'O')
54328 )
54329 THEN
54330 NULL;
54331 --
54332 --
54333
54334 l_ccid := AcctDerRule_4(
54335 p_application_id => p_application_id
54336 , p_ae_header_id => l_ae_header_id
54337 , p_source_5 => p_source_5
54338 , x_transaction_coa_id => l_adr_transaction_coa_id
54339 , x_accounting_coa_id => l_adr_accounting_coa_id
54340 , x_value_type_code => l_adr_value_type_code
54341 , p_side => 'NA'
54342 );
54343
54344 xla_ae_lines_pkg.set_ccid(
54345 p_code_combination_id => l_ccid
54346 , p_value_type_code => l_adr_value_type_code
54347 , p_transaction_coa_id => l_adr_transaction_coa_id
54348 , p_accounting_coa_id => l_adr_accounting_coa_id
54349 , p_adr_code => 'DIST_CCID'
54350 , p_adr_type_code => 'S'
54351 , p_component_type => l_component_type
54352 , p_component_code => l_component_code
54353 , p_component_type_code => l_component_type_code
54354 , p_component_appl_id => l_component_appl_id
54355 , p_amb_context_code => l_amb_context_code
54356 , p_side => 'NA'
54357 );
54358
54359
54360 --
54361 --
54362 END IF;
54363 --
54364 -- Bug 4922099
54365 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
54366 (NVL(l_enc_upg_option, 'N') = 'O')
54367 ) AND
54368 (l_bflow_method_code = 'PRIOR_ENTRY')
54369 )
54370 THEN
54371 IF
54372 --
54373 1 = 2
54374 --
54375 THEN
54376 xla_accounting_err_pkg.build_message
54377 (p_appli_s_name => 'XLA'
54378 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54379 ,p_token_1 => 'LINE_NUMBER'
54380 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
54381 ,p_token_2 => 'LINE_TYPE_NAME'
54382 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
54383 l_component_type
54384 ,l_component_code
54385 ,l_component_type_code
54386 ,l_component_appl_id
54387 ,l_amb_context_code
54388 ,l_entity_code
54389 ,l_event_class_code
54390 )
54391 ,p_token_3 => 'OWNER'
54392 ,p_value_3 => xla_lookups_pkg.get_meaning(
54393 p_lookup_type => 'XLA_OWNER_TYPE'
54394 ,p_lookup_code => l_component_type_code
54395 )
54396 ,p_token_4 => 'PRODUCT_NAME'
54397 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
54398 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
54399 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
54400 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
54401 ,p_ae_header_id => NULL
54402 );
54403
54404 IF (C_LEVEL_ERROR>= g_log_level) THEN
54405 trace
54406 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54407 ,p_level => C_LEVEL_ERROR
54408 ,p_module => l_log_module);
54409 END IF;
54410 END IF;
54411 END IF;
54412 --
54413 --
54414 ------------------------------------------------------------------------------------------------
54415 -- 4219869 Business Flow
54416 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
54417 -- Prior Entry. Currently, the following code is always generated.
54418 ------------------------------------------------------------------------------------------------
54419 XLA_AE_LINES_PKG.ValidateCurrentLine;
54420
54421 ------------------------------------------------------------------------------------
54422 -- 4219869 Business Flow
54423 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
54424 ------------------------------------------------------------------------------------
54425 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
54426
54427 ----------------------------------------------------------------------------------
54428 -- 4219869 Business Flow
54429 -- Update journal entry status -- Need to generate this within IF <condition>
54430 ----------------------------------------------------------------------------------
54431 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
54432 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
54433 ,p_balance_type_code => l_balance_type_code
54434 );
54435
54436 -------------------------------------------------------------------------------------------
54437 -- 4262811 - Generate the Accrual Reversal lines
54438 -------------------------------------------------------------------------------------------
54439 BEGIN
54440 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
54441 (g_array_event(p_event_id).array_value_num('header_index'));
54442 IF l_acc_rev_flag IS NULL THEN
54443 l_acc_rev_flag := 'N';
54444 END IF;
54445 EXCEPTION
54446 WHEN OTHERS THEN
54447 l_acc_rev_flag := 'N';
54448 END;
54449 --
54450 IF (l_acc_rev_flag = 'Y') THEN
54451
54452 -- 4645092 ------------------------------------------------------------------------------
54453 -- To allow MPA report to determine if it should generate report process
54454 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
54455 ------------------------------------------------------------------------------------------
54456
54457 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
54458 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
54459 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
54460 -- call ADRs
54461 -- Bug 4922099
54462 --
54463 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
54464 (NVL(l_actual_upg_option, 'N') = 'O') OR
54465 (NVL(l_enc_upg_option, 'N') = 'O')
54466 )
54467 THEN
54468 NULL;
54469 --
54470 --
54471
54472 l_ccid := AcctDerRule_4(
54473 p_application_id => p_application_id
54474 , p_ae_header_id => l_ae_header_id
54475 , p_source_5 => p_source_5
54476 , x_transaction_coa_id => l_adr_transaction_coa_id
54477 , x_accounting_coa_id => l_adr_accounting_coa_id
54478 , x_value_type_code => l_adr_value_type_code
54479 , p_side => 'NA'
54480 );
54481
54482 xla_ae_lines_pkg.set_ccid(
54483 p_code_combination_id => l_ccid
54484 , p_value_type_code => l_adr_value_type_code
54485 , p_transaction_coa_id => l_adr_transaction_coa_id
54486 , p_accounting_coa_id => l_adr_accounting_coa_id
54487 , p_adr_code => 'DIST_CCID'
54488 , p_adr_type_code => 'S'
54489 , p_component_type => l_component_type
54490 , p_component_code => l_component_code
54491 , p_component_type_code => l_component_type_code
54492 , p_component_appl_id => l_component_appl_id
54493 , p_amb_context_code => l_amb_context_code
54494 , p_side => 'NA'
54495 );
54496
54497
54498 --
54499 --
54500 END IF;
54501
54502 --
54503 -- Update the line information that should be overwritten
54504 --
54505 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
54506 p_header_num => 1);
54507 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
54508
54509 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
54510
54511 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
54512 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
54513 END IF;
54514
54515 --
54516 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
54517 --
54518 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
54522 -- 4262811a Switch Sign
54519 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
54520 ELSE
54521 ---------------------------------------------------------------------------------------------------
54523 ---------------------------------------------------------------------------------------------------
54524 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
54525 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
54526 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54527 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
54528 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54529 -- 5132302
54530 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
54531 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
54532
54533 END IF;
54534
54535 -- 4955764
54536 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
54537 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
54538
54539
54540 XLA_AE_LINES_PKG.ValidateCurrentLine;
54541 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
54542
54543 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
54544 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
54545 ,p_balance_type_code => l_balance_type_code);
54546
54547 END IF;
54548
54549 -----------------------------------------------------------------------------------------
54550 -- 4262811 Multiperiod Accounting
54551 -----------------------------------------------------------------------------------------
54552 -- No MPA option is assigned.
54553
54554
54555 END IF;
54556 END IF;
54557 --
54558
54559 --
54560 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54561 trace
54562 (p_msg => 'END of AcctLineType_113'
54563 ,p_level => C_LEVEL_PROCEDURE
54564 ,p_module => l_log_module);
54565 END IF;
54566 --
54567 EXCEPTION
54568 WHEN xla_exceptions_pkg.application_exception THEN
54569 RAISE;
54570 WHEN OTHERS THEN
54571 xla_exceptions_pkg.raise_message
54572 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_113');
54573 END AcctLineType_113;
54574 --
54575
54576 ---------------------------------------
54577 --
54578 -- PRIVATE FUNCTION
54579 -- AcctLineType_114
54580 --
54581 ---------------------------------------
54582 PROCEDURE AcctLineType_114 (
54583 p_application_id IN NUMBER
54584 ,p_event_id IN NUMBER
54585 ,p_calculate_acctd_flag IN VARCHAR2
54586 ,p_calculate_g_l_flag IN VARCHAR2
54587 ,p_actual_flag IN OUT VARCHAR2
54588 ,p_balance_type_code OUT VARCHAR2
54589 ,p_gain_or_loss_ref OUT VARCHAR2
54590
54591 --Distribution GL Account
54592 , p_source_5 IN NUMBER
54593 --Distribution Source Type
54594 , p_source_20 IN VARCHAR2
54595 --Distribution Line Identifier
54596 , p_source_22 IN NUMBER
54597 --Distribution Type
54598 , p_source_23 IN VARCHAR2
54599 --Entered Amount
54600 , p_source_24 IN NUMBER
54601 --Currency Code
54602 , p_source_25 IN VARCHAR2
54603 --Applied To Document Accounting Amount
54604 , p_source_29 IN NUMBER
54605 --Transaction Distribution Identifier
54606 , p_source_34 IN NUMBER
54607 --Transaction Distribution Type
54608 , p_source_35 IN VARCHAR2
54609 --Applied To Document Exchange Date
54610 , p_source_57 IN DATE
54611 --Receipt Applied To Application Identifier
54612 , p_source_58 IN NUMBER
54613 --Transaction Entity Code
54614 , p_source_59 IN VARCHAR2
54615 --Transaction Identifier
54616 , p_source_60 IN NUMBER
54617 --Applied To Document Exchange Rate
54618 , p_source_62 IN NUMBER
54619 --Distribution Party Identifier
54620 , p_source_63 IN NUMBER
54621 --Distribution Party Site Id
54622 , p_source_64 IN NUMBER
54623 --Distribution Party Type
54624 , p_source_65 IN VARCHAR2
54625 --Distribution Multi Fund Additional Entry
54626 , p_source_67 IN VARCHAR2
54627 --Applied To Document Exchange Rate Type
54628 , p_source_70 IN VARCHAR2
54629 )
54630 IS
54631
54632 l_component_type VARCHAR2(80);
54633 l_component_code VARCHAR2(30);
54634 l_component_type_code VARCHAR2(1);
54635 l_component_appl_id INTEGER;
54636 l_amb_context_code VARCHAR2(30);
54637 l_entity_code VARCHAR2(30);
54638 l_event_class_code VARCHAR2(30);
54639 l_ae_header_id NUMBER;
54640 l_event_type_code VARCHAR2(30);
54641 l_line_definition_code VARCHAR2(30);
54642 l_line_definition_owner_code VARCHAR2(1);
54643 --
54644 -- adr variables
54645 l_segment VARCHAR2(30);
54646 l_ccid NUMBER;
54647 l_adr_transaction_coa_id NUMBER;
54648 l_adr_accounting_coa_id NUMBER;
54649 l_adr_flexfield_segment_code VARCHAR2(30);
54650 l_adr_flex_value_set_id NUMBER;
54651 l_adr_value_type_code VARCHAR2(30);
54652 l_adr_value_combination_id NUMBER;
54653 l_adr_value_segment_code VARCHAR2(30);
54657 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
54654
54655 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
54656 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
54658 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
54659
54660 -- 4262811 Variables ------------------------------------------------------------------------------------------
54661 l_entered_amt_idx NUMBER;
54662 l_accted_amt_idx NUMBER;
54663 l_acc_rev_flag VARCHAR2(1);
54664 l_accrual_line_num NUMBER;
54665 l_tmp_amt NUMBER;
54666 l_acc_rev_natural_side_code VARCHAR2(1);
54667
54668 l_num_entries NUMBER;
54669 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
54673 l_recog_line_1 NUMBER;
54670 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
54671 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
54672 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
54674 l_recog_line_2 NUMBER;
54675
54676 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
54677 l_bflow_applied_to_amt NUMBER; -- 5132302
54678 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
54679
54680 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
54681
54682 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
54683 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
54684
54685 ---------------------------------------------------------------------------------------------------------------
54686
54687
54688 --
54689 -- bulk performance
54690 --
54691 l_balance_type_code VARCHAR2(1);
54692 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
54693 l_log_module VARCHAR2(240);
54694
54695 --
54696 -- Upgrade strategy
54697 --
54698 l_actual_upg_option VARCHAR2(1);
54699 l_enc_upg_option VARCHAR2(1);
54700
54701 --
54702 BEGIN
54703 --
54704 IF g_log_enabled THEN
54705 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_114';
54706 END IF;
54707 --
54708 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
54709
54710 trace
54711 (p_msg => 'BEGIN of AcctLineType_114'
54712 ,p_level => C_LEVEL_PROCEDURE
54713 ,p_module => l_log_module);
54714
54715 END IF;
54716 --
54717 l_component_type := 'AMB_JLT';
54718 l_component_code := 'RCT_DEFERRED_TAX';
54719 l_component_type_code := 'S';
54720 l_component_appl_id := 222;
54721 l_amb_context_code := 'DEFAULT';
54722 l_entity_code := 'RECEIPTS';
54723 l_event_class_code := 'RECEIPT';
54724 l_event_type_code := 'RECEIPT_ALL';
54725 l_line_definition_owner_code := 'S';
54726 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
54727 --
54728 l_balance_type_code := 'A';
54729 l_segment := NULL;
54730 l_ccid := NULL;
54731 l_adr_transaction_coa_id := NULL;
54732 l_adr_accounting_coa_id := NULL;
54733 l_adr_flexfield_segment_code := NULL;
54734 l_adr_flex_value_set_id := NULL;
54735 l_adr_value_type_code := NULL;
54736 l_adr_value_combination_id := NULL;
54737 l_adr_value_segment_code := NULL;
54738
54739 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
54740 l_bflow_class_code := ''; -- 4219869 Business Flow
54741 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
54742 l_budgetary_control_flag := 'N';
54743
54744 l_bflow_applied_to_amt_idx := NULL; -- 5132302
54745 l_bflow_applied_to_amt := NULL; -- 5132302
54746 l_entered_amt_idx := NULL; -- 4262811
54747 l_accted_amt_idx := NULL; -- 4262811
54748 l_acc_rev_flag := NULL; -- 4262811
54749 l_accrual_line_num := NULL; -- 4262811
54750 l_tmp_amt := NULL; -- 4262811
54751 --
54752
54753 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
54754 l_balance_type_code <> 'B' THEN
54755 IF NVL(p_source_20,'
54756 ') = 'DEFERRED_TAX' AND
54757 NVL(p_source_67,'
54758 ') = 'N'
54759 THEN
54760
54761 --
54762 XLA_AE_LINES_PKG.SetNewLine;
54763
54764 p_balance_type_code := l_balance_type_code;
54765 -- set the flag so later we will know whether the gain loss line needs to be created
54766
54767 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
54768 p_actual_flag :='A';
54769 END IF;
54770
54771 --
54772 -- bulk performance
54773 --
54774 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
54775 p_header_num => 0); -- 4262811
54776 --
54777 -- set accounting line options
54778 --
54779 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
54780 p_natural_side_code => 'C'
54781 , p_gain_or_loss_flag => 'N'
54782 , p_gl_transfer_mode_code => 'S'
54783 , p_acct_entry_type_code => 'A'
54784 , p_switch_side_flag => 'Y'
54785 , p_merge_duplicate_code => 'A'
54786 );
54787 --
54788 l_acc_rev_natural_side_code := 'D'; -- 4262811
54789 --
54790 --
54791 -- set accounting line type info
54792 --
54793 xla_ae_lines_pkg.SetAcctLineType
54794 (p_component_type => l_component_type
54795 ,p_event_type_code => l_event_type_code
54796 ,p_line_definition_owner_code => l_line_definition_owner_code
54797 ,p_line_definition_code => l_line_definition_code
54798 ,p_accounting_line_code => l_component_code
54799 ,p_accounting_line_type_code => l_component_type_code
54800 ,p_accounting_line_appl_id => l_component_appl_id
54801 ,p_amb_context_code => l_amb_context_code
54802 ,p_entity_code => l_entity_code
54803 ,p_event_class_code => l_event_class_code);
54804 --
54805 -- set accounting class
54806 --
54807 xla_ae_lines_pkg.SetAcctClass(
54808 p_accounting_class_code => 'DEFERRED_TAX'
54809 , p_ae_header_id => l_ae_header_id
54810 );
54811
54812 --
54813 -- set rounding class
54814 --
54815 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
54816 'RECEIVABLE';
54817
54818 --
54819 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
54820 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
54821 --
54822 -- bulk performance
54823 --
54824 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
54825
54826 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
54827 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
54828
54829 -- 4955764
54833 -- 4458381 Public Sector Enh
54830 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
54831 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
54832
54834
54835 --
54836 -- set accounting attributes for the line type
54837 --
54838 l_entered_amt_idx := 8;
54839 l_accted_amt_idx := 13;
54840 l_bflow_applied_to_amt_idx := NULL; -- 5132302
54841 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
54842 l_rec_acct_attrs.array_num_value(1) := p_source_58;
54843 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
54844 l_rec_acct_attrs.array_char_value(2) := p_source_35;
54845 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
54846 l_rec_acct_attrs.array_char_value(3) := p_source_59;
54847 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
54848 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
54849 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
54850 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
54851 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
54852 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
54853 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
54854 l_rec_acct_attrs.array_char_value(7) := p_source_23;
54855 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
54856 l_rec_acct_attrs.array_num_value(8) := p_source_24;
54857 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
54858 l_rec_acct_attrs.array_char_value(9) := p_source_25;
54859 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
54860 l_rec_acct_attrs.array_date_value(10) := p_source_57;
54861 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
54862 l_rec_acct_attrs.array_num_value(11) := p_source_62;
54863 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
54864 l_rec_acct_attrs.array_char_value(12) := p_source_70;
54865 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
54866 l_rec_acct_attrs.array_num_value(13) := p_source_29;
54867 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
54868 l_rec_acct_attrs.array_num_value(14) := p_source_63;
54869 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
54873
54870 l_rec_acct_attrs.array_num_value(15) := p_source_64;
54871 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
54872 l_rec_acct_attrs.array_char_value(16) := p_source_65;
54874 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
54875 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
54876
54877 ---------------------------------------------------------------------------------------------------------------
54878 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
54879 ---------------------------------------------------------------------------------------------------------------
54880 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
54881
54882 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
54883 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
54884
54885 IF xla_accounting_cache_pkg.GetValueChar
54886 (p_source_code => 'LEDGER_CATEGORY_CODE'
54887 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
54888 AND l_bflow_method_code = 'PRIOR_ENTRY'
54889 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
54890 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
54891 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
54892 )
54893 THEN
54894 xla_ae_lines_pkg.BflowUpgEntry
54895 (p_business_method_code => l_bflow_method_code
54896 ,p_business_class_code => l_bflow_class_code
54897 ,p_balance_type => l_balance_type_code);
54898 ELSE
54899 NULL;
54900 -- No business flow processing for business flow method of NONE.
54901 END IF;
54902
54903 --
54904 -- call analytical criteria
54905 --
54906
54907 --
54908 -- call description
54909 --
54910 -- No description or it is inherited.
54911 --
54912 -- call ADRs
54913 -- Bug 4922099
54914 --
54915 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
54916 (NVL(l_actual_upg_option, 'N') = 'O') OR
54917 (NVL(l_enc_upg_option, 'N') = 'O')
54918 )
54919 THEN
54920 NULL;
54921 --
54922 --
54923
54924 l_ccid := AcctDerRule_4(
54925 p_application_id => p_application_id
54926 , p_ae_header_id => l_ae_header_id
54927 , p_source_5 => p_source_5
54928 , x_transaction_coa_id => l_adr_transaction_coa_id
54929 , x_accounting_coa_id => l_adr_accounting_coa_id
54930 , x_value_type_code => l_adr_value_type_code
54931 , p_side => 'NA'
54932 );
54933
54934 xla_ae_lines_pkg.set_ccid(
54935 p_code_combination_id => l_ccid
54936 , p_value_type_code => l_adr_value_type_code
54937 , p_transaction_coa_id => l_adr_transaction_coa_id
54938 , p_accounting_coa_id => l_adr_accounting_coa_id
54939 , p_adr_code => 'DIST_CCID'
54940 , p_adr_type_code => 'S'
54941 , p_component_type => l_component_type
54942 , p_component_code => l_component_code
54943 , p_component_type_code => l_component_type_code
54944 , p_component_appl_id => l_component_appl_id
54945 , p_amb_context_code => l_amb_context_code
54946 , p_side => 'NA'
54947 );
54948
54949
54950 --
54951 --
54952 END IF;
54953 --
54954 -- Bug 4922099
54955 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
54956 (NVL(l_enc_upg_option, 'N') = 'O')
54957 ) AND
54958 (l_bflow_method_code = 'PRIOR_ENTRY')
54959 )
54960 THEN
54961 IF
54962 --
54963 1 = 2
54964 --
54965 THEN
54966 xla_accounting_err_pkg.build_message
54967 (p_appli_s_name => 'XLA'
54968 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54974 ,l_component_code
54969 ,p_token_1 => 'LINE_NUMBER'
54970 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
54971 ,p_token_2 => 'LINE_TYPE_NAME'
54972 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
54973 l_component_type
54975 ,l_component_type_code
54976 ,l_component_appl_id
54977 ,l_amb_context_code
54978 ,l_entity_code
54979 ,l_event_class_code
54980 )
54981 ,p_token_3 => 'OWNER'
54982 ,p_value_3 => xla_lookups_pkg.get_meaning(
54983 p_lookup_type => 'XLA_OWNER_TYPE'
54984 ,p_lookup_code => l_component_type_code
54985 )
54986 ,p_token_4 => 'PRODUCT_NAME'
54987 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
54988 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
54989 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
54990 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
54991 ,p_ae_header_id => NULL
54992 );
54993
54994 IF (C_LEVEL_ERROR>= g_log_level) THEN
54995 trace
54996 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
54997 ,p_level => C_LEVEL_ERROR
54998 ,p_module => l_log_module);
54999 END IF;
55000 END IF;
55001 END IF;
55002 --
55003 --
55004 ------------------------------------------------------------------------------------------------
55005 -- 4219869 Business Flow
55006 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
55007 -- Prior Entry. Currently, the following code is always generated.
55008 ------------------------------------------------------------------------------------------------
55009 XLA_AE_LINES_PKG.ValidateCurrentLine;
55010
55011 ------------------------------------------------------------------------------------
55012 -- 4219869 Business Flow
55013 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
55014 ------------------------------------------------------------------------------------
55015 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
55016
55017 ----------------------------------------------------------------------------------
55018 -- 4219869 Business Flow
55019 -- Update journal entry status -- Need to generate this within IF <condition>
55020 ----------------------------------------------------------------------------------
55021 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
55022 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
55023 ,p_balance_type_code => l_balance_type_code
55024 );
55025
55026 -------------------------------------------------------------------------------------------
55027 -- 4262811 - Generate the Accrual Reversal lines
55028 -------------------------------------------------------------------------------------------
55029 BEGIN
55030 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
55031 (g_array_event(p_event_id).array_value_num('header_index'));
55032 IF l_acc_rev_flag IS NULL THEN
55033 l_acc_rev_flag := 'N';
55034 END IF;
55035 EXCEPTION
55036 WHEN OTHERS THEN
55037 l_acc_rev_flag := 'N';
55038 END;
55039 --
55040 IF (l_acc_rev_flag = 'Y') THEN
55041
55042 -- 4645092 ------------------------------------------------------------------------------
55043 -- To allow MPA report to determine if it should generate report process
55044 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
55045 ------------------------------------------------------------------------------------------
55046
55047 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
55048 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
55049 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
55050 -- call ADRs
55051 -- Bug 4922099
55052 --
55053 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
55054 (NVL(l_actual_upg_option, 'N') = 'O') OR
55055 (NVL(l_enc_upg_option, 'N') = 'O')
55056 )
55057 THEN
55058 NULL;
55059 --
55060 --
55061
55062 l_ccid := AcctDerRule_4(
55063 p_application_id => p_application_id
55064 , p_ae_header_id => l_ae_header_id
55065 , p_source_5 => p_source_5
55066 , x_transaction_coa_id => l_adr_transaction_coa_id
55067 , x_accounting_coa_id => l_adr_accounting_coa_id
55068 , x_value_type_code => l_adr_value_type_code
55069 , p_side => 'NA'
55070 );
55071
55072 xla_ae_lines_pkg.set_ccid(
55073 p_code_combination_id => l_ccid
55074 , p_value_type_code => l_adr_value_type_code
55078 , p_adr_type_code => 'S'
55075 , p_transaction_coa_id => l_adr_transaction_coa_id
55076 , p_accounting_coa_id => l_adr_accounting_coa_id
55077 , p_adr_code => 'DIST_CCID'
55079 , p_component_type => l_component_type
55080 , p_component_code => l_component_code
55081 , p_component_type_code => l_component_type_code
55082 , p_component_appl_id => l_component_appl_id
55083 , p_amb_context_code => l_amb_context_code
55084 , p_side => 'NA'
55085 );
55086
55087
55088 --
55089 --
55090 END IF;
55091
55092 --
55093 -- Update the line information that should be overwritten
55094 --
55095 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
55096 p_header_num => 1);
55097 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
55098
55099 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
55100
55101 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
55102 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
55103 END IF;
55104
55105 --
55106 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
55107 --
55108 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
55109 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
55110 ELSE
55111 ---------------------------------------------------------------------------------------------------
55112 -- 4262811a Switch Sign
55113 ---------------------------------------------------------------------------------------------------
55114 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
55115 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
55116 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55117 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
55118 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55119 -- 5132302
55120 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
55121 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55122
55123 END IF;
55124
55125 -- 4955764
55126 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
55127 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
55128
55129
55130 XLA_AE_LINES_PKG.ValidateCurrentLine;
55131 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
55132
55133 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
55134 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
55135 ,p_balance_type_code => l_balance_type_code);
55136
55137 END IF;
55138
55139 -----------------------------------------------------------------------------------------
55140 -- 4262811 Multiperiod Accounting
55141 -----------------------------------------------------------------------------------------
55142 -- No MPA option is assigned.
55143
55144
55145 END IF;
55146 END IF;
55147 --
55148
55149 --
55150 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55151 trace
55152 (p_msg => 'END of AcctLineType_114'
55153 ,p_level => C_LEVEL_PROCEDURE
55157 EXCEPTION
55154 ,p_module => l_log_module);
55155 END IF;
55156 --
55158 WHEN xla_exceptions_pkg.application_exception THEN
55159 RAISE;
55160 WHEN OTHERS THEN
55161 xla_exceptions_pkg.raise_message
55162 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_114');
55163 END AcctLineType_114;
55164 --
55165
55166 ---------------------------------------
55167 --
55168 -- PRIVATE FUNCTION
55169 -- AcctLineType_115
55170 --
55171 ---------------------------------------
55172 PROCEDURE AcctLineType_115 (
55173 p_application_id IN NUMBER
55174 ,p_event_id IN NUMBER
55175 ,p_calculate_acctd_flag IN VARCHAR2
55176 ,p_calculate_g_l_flag IN VARCHAR2
55177 ,p_actual_flag IN OUT VARCHAR2
55178 ,p_balance_type_code OUT VARCHAR2
55179 ,p_gain_or_loss_ref OUT VARCHAR2
55180
55181 --Distribution GL Account
55182 , p_source_5 IN NUMBER
55183 --Distribution Source Type
55184 , p_source_20 IN VARCHAR2
55185 --Distribution Line Identifier
55186 , p_source_22 IN NUMBER
55187 --Distribution Type
55188 , p_source_23 IN VARCHAR2
55189 --Entered Amount
55190 , p_source_24 IN NUMBER
55191 --Currency Code
55192 , p_source_25 IN VARCHAR2
55193 --Applied To Document Accounting Amount
55194 , p_source_29 IN NUMBER
55195 --Transaction Distribution Identifier
55196 , p_source_34 IN NUMBER
55197 --Transaction Distribution Type
55198 , p_source_35 IN VARCHAR2
55199 --Applied To Document Exchange Date
55200 , p_source_57 IN DATE
55201 --Receipt Applied To Application Identifier
55202 , p_source_58 IN NUMBER
55203 --Transaction Entity Code
55204 , p_source_59 IN VARCHAR2
55205 --Transaction Identifier
55206 , p_source_60 IN NUMBER
55207 --Applied To Document Exchange Rate
55208 , p_source_62 IN NUMBER
55209 --Distribution Party Identifier
55210 , p_source_63 IN NUMBER
55211 --Distribution Party Site Id
55212 , p_source_64 IN NUMBER
55213 --Distribution Party Type
55214 , p_source_65 IN VARCHAR2
55215 --Distribution Multi Fund Additional Entry
55216 , p_source_67 IN VARCHAR2
55217 --Applied To Document Exchange Rate Type
55218 , p_source_70 IN VARCHAR2
55219 )
55220 IS
55221
55222 l_component_type VARCHAR2(80);
55223 l_component_code VARCHAR2(30);
55224 l_component_type_code VARCHAR2(1);
55225 l_component_appl_id INTEGER;
55226 l_amb_context_code VARCHAR2(30);
55227 l_entity_code VARCHAR2(30);
55228 l_event_class_code VARCHAR2(30);
55229 l_ae_header_id NUMBER;
55230 l_event_type_code VARCHAR2(30);
55231 l_line_definition_code VARCHAR2(30);
55232 l_line_definition_owner_code VARCHAR2(1);
55233 --
55234 -- adr variables
55235 l_segment VARCHAR2(30);
55236 l_ccid NUMBER;
55237 l_adr_transaction_coa_id NUMBER;
55238 l_adr_accounting_coa_id NUMBER;
55239 l_adr_flexfield_segment_code VARCHAR2(30);
55240 l_adr_flex_value_set_id NUMBER;
55241 l_adr_value_type_code VARCHAR2(30);
55242 l_adr_value_combination_id NUMBER;
55243 l_adr_value_segment_code VARCHAR2(30);
55244
55245 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
55246 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
55247 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
55248 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
55249
55250 -- 4262811 Variables ------------------------------------------------------------------------------------------
55251 l_entered_amt_idx NUMBER;
55252 l_accted_amt_idx NUMBER;
55253 l_acc_rev_flag VARCHAR2(1);
55254 l_accrual_line_num NUMBER;
55255 l_tmp_amt NUMBER;
55256 l_acc_rev_natural_side_code VARCHAR2(1);
55257
55258 l_num_entries NUMBER;
55259 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
55260 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
55261 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
55262 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
55263 l_recog_line_1 NUMBER;
55264 l_recog_line_2 NUMBER;
55265
55266 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
55267 l_bflow_applied_to_amt NUMBER; -- 5132302
55268 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
55269
55270 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
55271
55272 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
55273 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
55274
55275 ---------------------------------------------------------------------------------------------------------------
55276
55277
55278 --
55279 -- bulk performance
55280 --
55281 l_balance_type_code VARCHAR2(1);
55282 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
55283 l_log_module VARCHAR2(240);
55284
55285 --
55286 -- Upgrade strategy
55287 --
55288 l_actual_upg_option VARCHAR2(1);
55289 l_enc_upg_option VARCHAR2(1);
55290
55291 --
55292 BEGIN
55293 --
55294 IF g_log_enabled THEN
55298 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55295 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_115';
55296 END IF;
55297 --
55299
55300 trace
55301 (p_msg => 'BEGIN of AcctLineType_115'
55302 ,p_level => C_LEVEL_PROCEDURE
55303 ,p_module => l_log_module);
55304
55305 END IF;
55306 --
55307 l_component_type := 'AMB_JLT';
55308 l_component_code := 'RCT_EDISC';
55309 l_component_type_code := 'S';
55310 l_component_appl_id := 222;
55311 l_amb_context_code := 'DEFAULT';
55312 l_entity_code := 'RECEIPTS';
55313 l_event_class_code := 'RECEIPT';
55314 l_event_type_code := 'RECEIPT_ALL';
55315 l_line_definition_owner_code := 'S';
55316 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
55317 --
55318 l_balance_type_code := 'A';
55319 l_segment := NULL;
55320 l_ccid := NULL;
55321 l_adr_transaction_coa_id := NULL;
55322 l_adr_accounting_coa_id := NULL;
55323 l_adr_flexfield_segment_code := NULL;
55324 l_adr_flex_value_set_id := NULL;
55325 l_adr_value_type_code := NULL;
55326 l_adr_value_combination_id := NULL;
55327 l_adr_value_segment_code := NULL;
55328
55329 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
55330 l_bflow_class_code := ''; -- 4219869 Business Flow
55331 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
55332 l_budgetary_control_flag := 'N';
55333
55334 l_bflow_applied_to_amt_idx := NULL; -- 5132302
55335 l_bflow_applied_to_amt := NULL; -- 5132302
55336 l_entered_amt_idx := NULL; -- 4262811
55337 l_accted_amt_idx := NULL; -- 4262811
55338 l_acc_rev_flag := NULL; -- 4262811
55339 l_accrual_line_num := NULL; -- 4262811
55340 l_tmp_amt := NULL; -- 4262811
55341 --
55342
55343 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
55344 l_balance_type_code <> 'B' THEN
55345 IF NVL(p_source_20,'
55346 ') = 'EDISC' AND
55347 NVL(p_source_67,'
55348 ') = 'N'
55349 THEN
55350
55351 --
55352 XLA_AE_LINES_PKG.SetNewLine;
55353
55354 p_balance_type_code := l_balance_type_code;
55355 -- set the flag so later we will know whether the gain loss line needs to be created
55356
55357 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
55358 p_actual_flag :='A';
55359 END IF;
55360
55361 --
55362 -- bulk performance
55363 --
55364 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
55365 p_header_num => 0); -- 4262811
55366 --
55367 -- set accounting line options
55368 --
55369 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
55370 p_natural_side_code => 'C'
55371 , p_gain_or_loss_flag => 'N'
55372 , p_gl_transfer_mode_code => 'S'
55373 , p_acct_entry_type_code => 'A'
55374 , p_switch_side_flag => 'Y'
55375 , p_merge_duplicate_code => 'A'
55376 );
55377 --
55378 l_acc_rev_natural_side_code := 'D'; -- 4262811
55379 --
55380 --
55381 -- set accounting line type info
55382 --
55383 xla_ae_lines_pkg.SetAcctLineType
55384 (p_component_type => l_component_type
55385 ,p_event_type_code => l_event_type_code
55386 ,p_line_definition_owner_code => l_line_definition_owner_code
55387 ,p_line_definition_code => l_line_definition_code
55388 ,p_accounting_line_code => l_component_code
55389 ,p_accounting_line_type_code => l_component_type_code
55390 ,p_accounting_line_appl_id => l_component_appl_id
55391 ,p_amb_context_code => l_amb_context_code
55392 ,p_entity_code => l_entity_code
55393 ,p_event_class_code => l_event_class_code);
55394 --
55395 -- set accounting class
55396 --
55397 xla_ae_lines_pkg.SetAcctClass(
55398 p_accounting_class_code => 'EDISC'
55399 , p_ae_header_id => l_ae_header_id
55400 );
55401
55402 --
55403 -- set rounding class
55404 --
55405 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
55406 'RECEIVABLE';
55407
55408 --
55409 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
55410 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
55411 --
55412 -- bulk performance
55413 --
55414 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
55415
55416 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
55417 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
55418
55419 -- 4955764
55420 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
55421 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
55422
55423 -- 4458381 Public Sector Enh
55424
55425 --
55426 -- set accounting attributes for the line type
55427 --
55428 l_entered_amt_idx := 8;
55429 l_accted_amt_idx := 13;
55430 l_bflow_applied_to_amt_idx := NULL; -- 5132302
55431 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
55432 l_rec_acct_attrs.array_num_value(1) := p_source_58;
55433 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
55434 l_rec_acct_attrs.array_char_value(2) := p_source_35;
55435 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
55436 l_rec_acct_attrs.array_char_value(3) := p_source_59;
55437 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
55438 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
55439 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
55440 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
55441 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
55442 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
55443 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
55444 l_rec_acct_attrs.array_char_value(7) := p_source_23;
55445 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
55446 l_rec_acct_attrs.array_num_value(8) := p_source_24;
55447 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
55448 l_rec_acct_attrs.array_char_value(9) := p_source_25;
55449 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
55450 l_rec_acct_attrs.array_date_value(10) := p_source_57;
55451 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
55452 l_rec_acct_attrs.array_num_value(11) := p_source_62;
55453 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
55454 l_rec_acct_attrs.array_char_value(12) := p_source_70;
55455 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
55456 l_rec_acct_attrs.array_num_value(13) := p_source_29;
55457 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
55458 l_rec_acct_attrs.array_num_value(14) := p_source_63;
55459 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
55460 l_rec_acct_attrs.array_num_value(15) := p_source_64;
55461 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
55462 l_rec_acct_attrs.array_char_value(16) := p_source_65;
55463
55464 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
55465 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
55466
55467 ---------------------------------------------------------------------------------------------------------------
55468 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
55469 ---------------------------------------------------------------------------------------------------------------
55470 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
55471
55472 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
55473 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
55474
55475 IF xla_accounting_cache_pkg.GetValueChar
55476 (p_source_code => 'LEDGER_CATEGORY_CODE'
55477 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
55478 AND l_bflow_method_code = 'PRIOR_ENTRY'
55479 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
55480 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
55481 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
55482 )
55483 THEN
55484 xla_ae_lines_pkg.BflowUpgEntry
55485 (p_business_method_code => l_bflow_method_code
55486 ,p_business_class_code => l_bflow_class_code
55487 ,p_balance_type => l_balance_type_code);
55488 ELSE
55489 NULL;
55490 -- No business flow processing for business flow method of NONE.
55491 END IF;
55492
55493 --
55494 -- call analytical criteria
55495 --
55496
55497 --
55498 -- call description
55499 --
55500 -- No description or it is inherited.
55501 --
55502 -- call ADRs
55503 -- Bug 4922099
55504 --
55505 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
55506 (NVL(l_actual_upg_option, 'N') = 'O') OR
55507 (NVL(l_enc_upg_option, 'N') = 'O')
55508 )
55509 THEN
55510 NULL;
55511 --
55512 --
55513
55514 l_ccid := AcctDerRule_4(
55515 p_application_id => p_application_id
55516 , p_ae_header_id => l_ae_header_id
55517 , p_source_5 => p_source_5
55518 , x_transaction_coa_id => l_adr_transaction_coa_id
55519 , x_accounting_coa_id => l_adr_accounting_coa_id
55520 , x_value_type_code => l_adr_value_type_code
55521 , p_side => 'NA'
55522 );
55523
55524 xla_ae_lines_pkg.set_ccid(
55525 p_code_combination_id => l_ccid
55526 , p_value_type_code => l_adr_value_type_code
55527 , p_transaction_coa_id => l_adr_transaction_coa_id
55528 , p_accounting_coa_id => l_adr_accounting_coa_id
55529 , p_adr_code => 'DIST_CCID'
55530 , p_adr_type_code => 'S'
55531 , p_component_type => l_component_type
55532 , p_component_code => l_component_code
55533 , p_component_type_code => l_component_type_code
55534 , p_component_appl_id => l_component_appl_id
55535 , p_amb_context_code => l_amb_context_code
55536 , p_side => 'NA'
55537 );
55538
55539
55540 --
55541 --
55542 END IF;
55543 --
55544 -- Bug 4922099
55545 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
55546 (NVL(l_enc_upg_option, 'N') = 'O')
55547 ) AND
55548 (l_bflow_method_code = 'PRIOR_ENTRY')
55549 )
55550 THEN
55551 IF
55552 --
55553 1 = 2
55554 --
55555 THEN
55556 xla_accounting_err_pkg.build_message
55557 (p_appli_s_name => 'XLA'
55558 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
55559 ,p_token_1 => 'LINE_NUMBER'
55560 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
55561 ,p_token_2 => 'LINE_TYPE_NAME'
55562 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
55563 l_component_type
55564 ,l_component_code
55565 ,l_component_type_code
55566 ,l_component_appl_id
55567 ,l_amb_context_code
55568 ,l_entity_code
55569 ,l_event_class_code
55570 )
55571 ,p_token_3 => 'OWNER'
55572 ,p_value_3 => xla_lookups_pkg.get_meaning(
55573 p_lookup_type => 'XLA_OWNER_TYPE'
55574 ,p_lookup_code => l_component_type_code
55575 )
55576 ,p_token_4 => 'PRODUCT_NAME'
55577 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
55578 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
55579 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
55580 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
55581 ,p_ae_header_id => NULL
55582 );
55583
55584 IF (C_LEVEL_ERROR>= g_log_level) THEN
55585 trace
55586 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
55587 ,p_level => C_LEVEL_ERROR
55588 ,p_module => l_log_module);
55589 END IF;
55590 END IF;
55591 END IF;
55592 --
55593 --
55594 ------------------------------------------------------------------------------------------------
55595 -- 4219869 Business Flow
55596 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
55597 -- Prior Entry. Currently, the following code is always generated.
55598 ------------------------------------------------------------------------------------------------
55599 XLA_AE_LINES_PKG.ValidateCurrentLine;
55600
55601 ------------------------------------------------------------------------------------
55602 -- 4219869 Business Flow
55603 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
55604 ------------------------------------------------------------------------------------
55605 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
55606
55607 ----------------------------------------------------------------------------------
55608 -- 4219869 Business Flow
55609 -- Update journal entry status -- Need to generate this within IF <condition>
55610 ----------------------------------------------------------------------------------
55611 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
55612 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
55613 ,p_balance_type_code => l_balance_type_code
55614 );
55615
55616 -------------------------------------------------------------------------------------------
55617 -- 4262811 - Generate the Accrual Reversal lines
55618 -------------------------------------------------------------------------------------------
55619 BEGIN
55620 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
55621 (g_array_event(p_event_id).array_value_num('header_index'));
55622 IF l_acc_rev_flag IS NULL THEN
55623 l_acc_rev_flag := 'N';
55624 END IF;
55625 EXCEPTION
55626 WHEN OTHERS THEN
55627 l_acc_rev_flag := 'N';
55628 END;
55629 --
55630 IF (l_acc_rev_flag = 'Y') THEN
55631
55632 -- 4645092 ------------------------------------------------------------------------------
55633 -- To allow MPA report to determine if it should generate report process
55634 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
55635 ------------------------------------------------------------------------------------------
55636
55637 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
55638 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
55639 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
55640 -- call ADRs
55641 -- Bug 4922099
55642 --
55643 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
55644 (NVL(l_actual_upg_option, 'N') = 'O') OR
55645 (NVL(l_enc_upg_option, 'N') = 'O')
55646 )
55647 THEN
55648 NULL;
55649 --
55650 --
55651
55652 l_ccid := AcctDerRule_4(
55653 p_application_id => p_application_id
55654 , p_ae_header_id => l_ae_header_id
55655 , p_source_5 => p_source_5
55656 , x_transaction_coa_id => l_adr_transaction_coa_id
55657 , x_accounting_coa_id => l_adr_accounting_coa_id
55658 , x_value_type_code => l_adr_value_type_code
55659 , p_side => 'NA'
55660 );
55661
55662 xla_ae_lines_pkg.set_ccid(
55663 p_code_combination_id => l_ccid
55667 , p_adr_code => 'DIST_CCID'
55664 , p_value_type_code => l_adr_value_type_code
55665 , p_transaction_coa_id => l_adr_transaction_coa_id
55666 , p_accounting_coa_id => l_adr_accounting_coa_id
55668 , p_adr_type_code => 'S'
55669 , p_component_type => l_component_type
55670 , p_component_code => l_component_code
55671 , p_component_type_code => l_component_type_code
55672 , p_component_appl_id => l_component_appl_id
55673 , p_amb_context_code => l_amb_context_code
55674 , p_side => 'NA'
55675 );
55676
55677
55678 --
55679 --
55680 END IF;
55681
55682 --
55683 -- Update the line information that should be overwritten
55684 --
55685 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
55689 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
55686 p_header_num => 1);
55687 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
55688
55690
55691 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
55692 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
55693 END IF;
55694
55695 --
55696 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
55697 --
55698 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
55699 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
55700 ELSE
55701 ---------------------------------------------------------------------------------------------------
55702 -- 4262811a Switch Sign
55703 ---------------------------------------------------------------------------------------------------
55704 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
55705 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
55706 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55707 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
55708 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55709 -- 5132302
55710 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
55711 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
55712
55713 END IF;
55714
55715 -- 4955764
55716 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
55717 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
55718
55719
55720 XLA_AE_LINES_PKG.ValidateCurrentLine;
55721 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
55722
55723 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
55724 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
55725 ,p_balance_type_code => l_balance_type_code);
55726
55727 END IF;
55728
55729 -----------------------------------------------------------------------------------------
55730 -- 4262811 Multiperiod Accounting
55731 -----------------------------------------------------------------------------------------
55732 -- No MPA option is assigned.
55733
55734
55735 END IF;
55736 END IF;
55737 --
55738
55739 --
55740 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55741 trace
55742 (p_msg => 'END of AcctLineType_115'
55743 ,p_level => C_LEVEL_PROCEDURE
55744 ,p_module => l_log_module);
55745 END IF;
55746 --
55747 EXCEPTION
55748 WHEN xla_exceptions_pkg.application_exception THEN
55749 RAISE;
55750 WHEN OTHERS THEN
55751 xla_exceptions_pkg.raise_message
55752 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_115');
55753 END AcctLineType_115;
55754 --
55755
55756 ---------------------------------------
55757 --
55758 -- PRIVATE FUNCTION
55759 -- AcctLineType_116
55760 --
55761 ---------------------------------------
55762 PROCEDURE AcctLineType_116 (
55763 p_application_id IN NUMBER
55764 ,p_event_id IN NUMBER
55765 ,p_calculate_acctd_flag IN VARCHAR2
55766 ,p_calculate_g_l_flag IN VARCHAR2
55767 ,p_actual_flag IN OUT VARCHAR2
55768 ,p_balance_type_code OUT VARCHAR2
55769 ,p_gain_or_loss_ref OUT VARCHAR2
55770
55771 --Distribution GL Account
55772 , p_source_5 IN NUMBER
55773 --Distribution Source Type
55774 , p_source_20 IN VARCHAR2
55775 --Distribution Line Identifier
55776 , p_source_22 IN NUMBER
55777 --Distribution Type
55778 , p_source_23 IN VARCHAR2
55779 --Entered Amount
55780 , p_source_24 IN NUMBER
55781 --Currency Code
55782 , p_source_25 IN VARCHAR2
55783 --Applied To Document Accounting Amount
55784 , p_source_29 IN NUMBER
55785 --Transaction Distribution Identifier
55786 , p_source_34 IN NUMBER
55787 --Transaction Distribution Type
55788 , p_source_35 IN VARCHAR2
55789 --Applied To Document Exchange Date
55790 , p_source_57 IN DATE
55791 --Receipt Applied To Application Identifier
55792 , p_source_58 IN NUMBER
55793 --Transaction Entity Code
55794 , p_source_59 IN VARCHAR2
55795 --Transaction Identifier
55796 , p_source_60 IN NUMBER
55797 --Applied To Document Exchange Rate
55798 , p_source_62 IN NUMBER
55799 --Distribution Party Identifier
55800 , p_source_63 IN NUMBER
55801 --Distribution Party Site Id
55802 , p_source_64 IN NUMBER
55803 --Distribution Party Type
55804 , p_source_65 IN VARCHAR2
55805 --Distribution Multi Fund Additional Entry
55806 , p_source_67 IN VARCHAR2
55807 --Applied To Document Exchange Rate Type
55808 , p_source_70 IN VARCHAR2
55809 )
55810 IS
55811
55812 l_component_type VARCHAR2(80);
55813 l_component_code VARCHAR2(30);
55814 l_component_type_code VARCHAR2(1);
55815 l_component_appl_id INTEGER;
55816 l_amb_context_code VARCHAR2(30);
55820 l_event_type_code VARCHAR2(30);
55817 l_entity_code VARCHAR2(30);
55818 l_event_class_code VARCHAR2(30);
55819 l_ae_header_id NUMBER;
55821 l_line_definition_code VARCHAR2(30);
55822 l_line_definition_owner_code VARCHAR2(1);
55823 --
55824 -- adr variables
55825 l_segment VARCHAR2(30);
55826 l_ccid NUMBER;
55827 l_adr_transaction_coa_id NUMBER;
55828 l_adr_accounting_coa_id NUMBER;
55829 l_adr_flexfield_segment_code VARCHAR2(30);
55830 l_adr_flex_value_set_id NUMBER;
55831 l_adr_value_type_code VARCHAR2(30);
55832 l_adr_value_combination_id NUMBER;
55833 l_adr_value_segment_code VARCHAR2(30);
55834
55835 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
55836 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
55837 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
55838 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
55839
55840 -- 4262811 Variables ------------------------------------------------------------------------------------------
55841 l_entered_amt_idx NUMBER;
55842 l_accted_amt_idx NUMBER;
55843 l_acc_rev_flag VARCHAR2(1);
55844 l_accrual_line_num NUMBER;
55845 l_tmp_amt NUMBER;
55846 l_acc_rev_natural_side_code VARCHAR2(1);
55847
55848 l_num_entries NUMBER;
55849 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
55850 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
55851 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
55852 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
55853 l_recog_line_1 NUMBER;
55854 l_recog_line_2 NUMBER;
55855
55856 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
55857 l_bflow_applied_to_amt NUMBER; -- 5132302
55858 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
55859
55860 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
55861
55862 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
55863 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
55864
55865 ---------------------------------------------------------------------------------------------------------------
55866
55867
55868 --
55869 -- bulk performance
55870 --
55871 l_balance_type_code VARCHAR2(1);
55872 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
55873 l_log_module VARCHAR2(240);
55874
55875 --
55876 -- Upgrade strategy
55877 --
55878 l_actual_upg_option VARCHAR2(1);
55879 l_enc_upg_option VARCHAR2(1);
55880
55881 --
55882 BEGIN
55883 --
55884 IF g_log_enabled THEN
55885 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_116';
55886 END IF;
55887 --
55888 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
55889
55890 trace
55891 (p_msg => 'BEGIN of AcctLineType_116'
55892 ,p_level => C_LEVEL_PROCEDURE
55893 ,p_module => l_log_module);
55894
55895 END IF;
55896 --
55897 l_component_type := 'AMB_JLT';
55898 l_component_code := 'RCT_EDISC_NON_REC_TAX';
55899 l_component_type_code := 'S';
55900 l_component_appl_id := 222;
55901 l_amb_context_code := 'DEFAULT';
55902 l_entity_code := 'RECEIPTS';
55903 l_event_class_code := 'RECEIPT';
55904 l_event_type_code := 'RECEIPT_ALL';
55905 l_line_definition_owner_code := 'S';
55909 l_segment := NULL;
55906 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
55907 --
55908 l_balance_type_code := 'A';
55910 l_ccid := NULL;
55911 l_adr_transaction_coa_id := NULL;
55912 l_adr_accounting_coa_id := NULL;
55913 l_adr_flexfield_segment_code := NULL;
55914 l_adr_flex_value_set_id := NULL;
55915 l_adr_value_type_code := NULL;
55916 l_adr_value_combination_id := NULL;
55917 l_adr_value_segment_code := NULL;
55918
55919 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
55920 l_bflow_class_code := ''; -- 4219869 Business Flow
55921 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
55922 l_budgetary_control_flag := 'N';
55923
55924 l_bflow_applied_to_amt_idx := NULL; -- 5132302
55925 l_bflow_applied_to_amt := NULL; -- 5132302
55926 l_entered_amt_idx := NULL; -- 4262811
55927 l_accted_amt_idx := NULL; -- 4262811
55928 l_acc_rev_flag := NULL; -- 4262811
55929 l_accrual_line_num := NULL; -- 4262811
55930 l_tmp_amt := NULL; -- 4262811
55931 --
55932
55933 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
55934 l_balance_type_code <> 'B' THEN
55935 IF NVL(p_source_20,'
55936 ') = 'EDISC_NON_REC_TAX' AND
55937 NVL(p_source_67,'
55938 ') = 'N'
55939 THEN
55940
55941 --
55942 XLA_AE_LINES_PKG.SetNewLine;
55943
55944 p_balance_type_code := l_balance_type_code;
55945 -- set the flag so later we will know whether the gain loss line needs to be created
55946
55947 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
55948 p_actual_flag :='A';
55949 END IF;
55950
55951 --
55952 -- bulk performance
55953 --
55954 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
55955 p_header_num => 0); -- 4262811
55956 --
55957 -- set accounting line options
55958 --
55959 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
55960 p_natural_side_code => 'C'
55961 , p_gain_or_loss_flag => 'N'
55962 , p_gl_transfer_mode_code => 'S'
55963 , p_acct_entry_type_code => 'A'
55964 , p_switch_side_flag => 'Y'
55965 , p_merge_duplicate_code => 'A'
55966 );
55967 --
55968 l_acc_rev_natural_side_code := 'D'; -- 4262811
55969 --
55970 --
55971 -- set accounting line type info
55972 --
55973 xla_ae_lines_pkg.SetAcctLineType
55974 (p_component_type => l_component_type
55975 ,p_event_type_code => l_event_type_code
55976 ,p_line_definition_owner_code => l_line_definition_owner_code
55977 ,p_line_definition_code => l_line_definition_code
55978 ,p_accounting_line_code => l_component_code
55979 ,p_accounting_line_type_code => l_component_type_code
55980 ,p_accounting_line_appl_id => l_component_appl_id
55981 ,p_amb_context_code => l_amb_context_code
55982 ,p_entity_code => l_entity_code
55983 ,p_event_class_code => l_event_class_code);
55984 --
55985 -- set accounting class
55986 --
55987 xla_ae_lines_pkg.SetAcctClass(
55988 p_accounting_class_code => 'EDISC_NON_REC_TAX'
55989 , p_ae_header_id => l_ae_header_id
55990 );
55991
55992 --
55993 -- set rounding class
55994 --
55995 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
55996 'RECEIVABLE';
55997
55998 --
55999 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
56000 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
56001 --
56002 -- bulk performance
56003 --
56004 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
56005
56006 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
56007 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
56008
56009 -- 4955764
56010 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
56011 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
56012
56013 -- 4458381 Public Sector Enh
56014
56015 --
56016 -- set accounting attributes for the line type
56017 --
56018 l_entered_amt_idx := 8;
56019 l_accted_amt_idx := 13;
56020 l_bflow_applied_to_amt_idx := NULL; -- 5132302
56021 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
56022 l_rec_acct_attrs.array_num_value(1) := p_source_58;
56023 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
56024 l_rec_acct_attrs.array_char_value(2) := p_source_35;
56025 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
56026 l_rec_acct_attrs.array_char_value(3) := p_source_59;
56027 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
56028 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
56029 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
56030 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
56031 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
56032 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
56033 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
56037 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
56034 l_rec_acct_attrs.array_char_value(7) := p_source_23;
56035 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
56036 l_rec_acct_attrs.array_num_value(8) := p_source_24;
56038 l_rec_acct_attrs.array_char_value(9) := p_source_25;
56039 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
56040 l_rec_acct_attrs.array_date_value(10) := p_source_57;
56041 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
56042 l_rec_acct_attrs.array_num_value(11) := p_source_62;
56043 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
56044 l_rec_acct_attrs.array_char_value(12) := p_source_70;
56045 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
56046 l_rec_acct_attrs.array_num_value(13) := p_source_29;
56047 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
56048 l_rec_acct_attrs.array_num_value(14) := p_source_63;
56049 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
56050 l_rec_acct_attrs.array_num_value(15) := p_source_64;
56051 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
56052 l_rec_acct_attrs.array_char_value(16) := p_source_65;
56053
56054 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
56055 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
56056
56057 ---------------------------------------------------------------------------------------------------------------
56058 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
56059 ---------------------------------------------------------------------------------------------------------------
56060 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
56061
56062 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56063 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56064
56065 IF xla_accounting_cache_pkg.GetValueChar
56066 (p_source_code => 'LEDGER_CATEGORY_CODE'
56067 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
56068 AND l_bflow_method_code = 'PRIOR_ENTRY'
56069 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
56070 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
56071 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
56072 )
56073 THEN
56074 xla_ae_lines_pkg.BflowUpgEntry
56075 (p_business_method_code => l_bflow_method_code
56076 ,p_business_class_code => l_bflow_class_code
56077 ,p_balance_type => l_balance_type_code);
56078 ELSE
56079 NULL;
56080 -- No business flow processing for business flow method of NONE.
56081 END IF;
56082
56083 --
56084 -- call analytical criteria
56085 --
56086
56087 --
56088 -- call description
56089 --
56090 -- No description or it is inherited.
56091 --
56092 -- call ADRs
56093 -- Bug 4922099
56094 --
56095 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
56096 (NVL(l_actual_upg_option, 'N') = 'O') OR
56097 (NVL(l_enc_upg_option, 'N') = 'O')
56098 )
56099 THEN
56100 NULL;
56101 --
56102 --
56103
56104 l_ccid := AcctDerRule_4(
56105 p_application_id => p_application_id
56106 , p_ae_header_id => l_ae_header_id
56107 , p_source_5 => p_source_5
56108 , x_transaction_coa_id => l_adr_transaction_coa_id
56109 , x_accounting_coa_id => l_adr_accounting_coa_id
56110 , x_value_type_code => l_adr_value_type_code
56111 , p_side => 'NA'
56112 );
56113
56114 xla_ae_lines_pkg.set_ccid(
56115 p_code_combination_id => l_ccid
56116 , p_value_type_code => l_adr_value_type_code
56117 , p_transaction_coa_id => l_adr_transaction_coa_id
56118 , p_accounting_coa_id => l_adr_accounting_coa_id
56119 , p_adr_code => 'DIST_CCID'
56120 , p_adr_type_code => 'S'
56121 , p_component_type => l_component_type
56122 , p_component_code => l_component_code
56123 , p_component_type_code => l_component_type_code
56124 , p_component_appl_id => l_component_appl_id
56125 , p_amb_context_code => l_amb_context_code
56126 , p_side => 'NA'
56127 );
56128
56129
56130 --
56131 --
56132 END IF;
56133 --
56134 -- Bug 4922099
56135 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
56136 (NVL(l_enc_upg_option, 'N') = 'O')
56137 ) AND
56138 (l_bflow_method_code = 'PRIOR_ENTRY')
56139 )
56140 THEN
56141 IF
56142 --
56143 1 = 2
56144 --
56145 THEN
56146 xla_accounting_err_pkg.build_message
56147 (p_appli_s_name => 'XLA'
56148 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
56149 ,p_token_1 => 'LINE_NUMBER'
56150 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
56151 ,p_token_2 => 'LINE_TYPE_NAME'
56152 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
56153 l_component_type
56157 ,l_amb_context_code
56154 ,l_component_code
56155 ,l_component_type_code
56156 ,l_component_appl_id
56158 ,l_entity_code
56159 ,l_event_class_code
56160 )
56161 ,p_token_3 => 'OWNER'
56162 ,p_value_3 => xla_lookups_pkg.get_meaning(
56163 p_lookup_type => 'XLA_OWNER_TYPE'
56164 ,p_lookup_code => l_component_type_code
56165 )
56166 ,p_token_4 => 'PRODUCT_NAME'
56167 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
56168 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
56169 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
56170 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
56171 ,p_ae_header_id => NULL
56172 );
56173
56174 IF (C_LEVEL_ERROR>= g_log_level) THEN
56175 trace
56176 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
56177 ,p_level => C_LEVEL_ERROR
56178 ,p_module => l_log_module);
56179 END IF;
56180 END IF;
56181 END IF;
56182 --
56183 --
56184 ------------------------------------------------------------------------------------------------
56185 -- 4219869 Business Flow
56186 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
56187 -- Prior Entry. Currently, the following code is always generated.
56188 ------------------------------------------------------------------------------------------------
56189 XLA_AE_LINES_PKG.ValidateCurrentLine;
56190
56191 ------------------------------------------------------------------------------------
56192 -- 4219869 Business Flow
56193 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
56194 ------------------------------------------------------------------------------------
56195 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
56196
56197 ----------------------------------------------------------------------------------
56198 -- 4219869 Business Flow
56199 -- Update journal entry status -- Need to generate this within IF <condition>
56200 ----------------------------------------------------------------------------------
56201 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
56202 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
56203 ,p_balance_type_code => l_balance_type_code
56204 );
56205
56206 -------------------------------------------------------------------------------------------
56207 -- 4262811 - Generate the Accrual Reversal lines
56208 -------------------------------------------------------------------------------------------
56209 BEGIN
56210 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
56211 (g_array_event(p_event_id).array_value_num('header_index'));
56212 IF l_acc_rev_flag IS NULL THEN
56213 l_acc_rev_flag := 'N';
56214 END IF;
56215 EXCEPTION
56216 WHEN OTHERS THEN
56217 l_acc_rev_flag := 'N';
56218 END;
56219 --
56220 IF (l_acc_rev_flag = 'Y') THEN
56221
56222 -- 4645092 ------------------------------------------------------------------------------
56223 -- To allow MPA report to determine if it should generate report process
56224 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
56225 ------------------------------------------------------------------------------------------
56226
56227 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
56228 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
56229 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
56230 -- call ADRs
56231 -- Bug 4922099
56232 --
56233 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
56234 (NVL(l_actual_upg_option, 'N') = 'O') OR
56235 (NVL(l_enc_upg_option, 'N') = 'O')
56236 )
56237 THEN
56238 NULL;
56239 --
56240 --
56241
56242 l_ccid := AcctDerRule_4(
56243 p_application_id => p_application_id
56244 , p_ae_header_id => l_ae_header_id
56245 , p_source_5 => p_source_5
56246 , x_transaction_coa_id => l_adr_transaction_coa_id
56247 , x_accounting_coa_id => l_adr_accounting_coa_id
56248 , x_value_type_code => l_adr_value_type_code
56249 , p_side => 'NA'
56250 );
56251
56252 xla_ae_lines_pkg.set_ccid(
56253 p_code_combination_id => l_ccid
56254 , p_value_type_code => l_adr_value_type_code
56255 , p_transaction_coa_id => l_adr_transaction_coa_id
56256 , p_accounting_coa_id => l_adr_accounting_coa_id
56257 , p_adr_code => 'DIST_CCID'
56261 , p_component_type_code => l_component_type_code
56258 , p_adr_type_code => 'S'
56259 , p_component_type => l_component_type
56260 , p_component_code => l_component_code
56262 , p_component_appl_id => l_component_appl_id
56263 , p_amb_context_code => l_amb_context_code
56264 , p_side => 'NA'
56265 );
56266
56267
56268 --
56269 --
56270 END IF;
56271
56272 --
56273 -- Update the line information that should be overwritten
56274 --
56275 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
56276 p_header_num => 1);
56277 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
56278
56279 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
56280
56281 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
56282 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
56283 END IF;
56284
56285 --
56286 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
56287 --
56288 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
56289 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
56290 ELSE
56291 ---------------------------------------------------------------------------------------------------
56292 -- 4262811a Switch Sign
56293 ---------------------------------------------------------------------------------------------------
56294 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
56295 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
56296 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56297 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
56298 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56299 -- 5132302
56300 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
56301 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56302
56303 END IF;
56304
56305 -- 4955764
56306 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
56307 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
56308
56309
56310 XLA_AE_LINES_PKG.ValidateCurrentLine;
56311 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
56312
56313 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
56314 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
56315 ,p_balance_type_code => l_balance_type_code);
56316
56317 END IF;
56318
56319 -----------------------------------------------------------------------------------------
56320 -- 4262811 Multiperiod Accounting
56321 -----------------------------------------------------------------------------------------
56322 -- No MPA option is assigned.
56323
56324
56325 END IF;
56326 END IF;
56327 --
56328
56329 --
56330 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56331 trace
56332 (p_msg => 'END of AcctLineType_116'
56333 ,p_level => C_LEVEL_PROCEDURE
56334 ,p_module => l_log_module);
56335 END IF;
56336 --
56337 EXCEPTION
56338 WHEN xla_exceptions_pkg.application_exception THEN
56339 RAISE;
56340 WHEN OTHERS THEN
56341 xla_exceptions_pkg.raise_message
56342 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_116');
56343 END AcctLineType_116;
56344 --
56345
56346 ---------------------------------------
56347 --
56348 -- PRIVATE FUNCTION
56349 -- AcctLineType_117
56350 --
56351 ---------------------------------------
56352 PROCEDURE AcctLineType_117 (
56353 p_application_id IN NUMBER
56354 ,p_event_id IN NUMBER
56355 ,p_calculate_acctd_flag IN VARCHAR2
56356 ,p_calculate_g_l_flag IN VARCHAR2
56357 ,p_actual_flag IN OUT VARCHAR2
56358 ,p_balance_type_code OUT VARCHAR2
56359 ,p_gain_or_loss_ref OUT VARCHAR2
56360
56361 --Distribution Gain Loss Account
56362 , p_source_6 IN NUMBER
56363 --System Gain Account
56364 , p_source_7 IN NUMBER
56365 --System Loss Account
56366 , p_source_8 IN NUMBER
56367 --Distribution Line Identifier
56368 , p_source_22 IN NUMBER
56369 --Distribution Type
56370 , p_source_23 IN VARCHAR2
56371 --Distribution Party Identifier
56372 , p_source_63 IN NUMBER
56373 --Distribution Party Site Id
56374 , p_source_64 IN NUMBER
56375 --Distribution Party Type
56376 , p_source_65 IN VARCHAR2
56377 --Accounting Amount
56378 , p_source_69 IN NUMBER
56379 )
56380 IS
56381
56382 l_component_type VARCHAR2(80);
56383 l_component_code VARCHAR2(30);
56384 l_component_type_code VARCHAR2(1);
56385 l_component_appl_id INTEGER;
56386 l_amb_context_code VARCHAR2(30);
56390 l_event_type_code VARCHAR2(30);
56387 l_entity_code VARCHAR2(30);
56388 l_event_class_code VARCHAR2(30);
56389 l_ae_header_id NUMBER;
56391 l_line_definition_code VARCHAR2(30);
56392 l_line_definition_owner_code VARCHAR2(1);
56393 --
56394 -- adr variables
56395 l_segment VARCHAR2(30);
56396 l_ccid NUMBER;
56397 l_adr_transaction_coa_id NUMBER;
56398 l_adr_accounting_coa_id NUMBER;
56399 l_adr_flexfield_segment_code VARCHAR2(30);
56400 l_adr_flex_value_set_id NUMBER;
56401 l_adr_value_type_code VARCHAR2(30);
56402 l_adr_value_combination_id NUMBER;
56403 l_adr_value_segment_code VARCHAR2(30);
56404
56405 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
56406 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
56407 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
56408 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
56409
56410 -- 4262811 Variables ------------------------------------------------------------------------------------------
56411 l_entered_amt_idx NUMBER;
56412 l_accted_amt_idx NUMBER;
56413 l_acc_rev_flag VARCHAR2(1);
56414 l_accrual_line_num NUMBER;
56415 l_tmp_amt NUMBER;
56416 l_acc_rev_natural_side_code VARCHAR2(1);
56417
56418 l_num_entries NUMBER;
56419 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
56420 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
56421 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
56422 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
56423 l_recog_line_1 NUMBER;
56424 l_recog_line_2 NUMBER;
56425
56426 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
56427 l_bflow_applied_to_amt NUMBER; -- 5132302
56428 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
56429
56430 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
56431
56432 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
56433 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
56434
56435 ---------------------------------------------------------------------------------------------------------------
56436
56437
56438 --
56439 -- bulk performance
56440 --
56441 l_balance_type_code VARCHAR2(1);
56442 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
56443 l_log_module VARCHAR2(240);
56444
56445 --
56446 -- Upgrade strategy
56447 --
56448 l_actual_upg_option VARCHAR2(1);
56449 l_enc_upg_option VARCHAR2(1);
56450
56451 --
56452 BEGIN
56453 --
56454 IF g_log_enabled THEN
56455 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_117';
56456 END IF;
56457 --
56458 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56459
56460 trace
56461 (p_msg => 'BEGIN of AcctLineType_117'
56462 ,p_level => C_LEVEL_PROCEDURE
56463 ,p_module => l_log_module);
56464
56465 END IF;
56466 --
56467 l_component_type := 'AMB_JLT';
56468 l_component_code := 'RCT_EXCH_GAIN_LOSS';
56469 l_component_type_code := 'S';
56470 l_component_appl_id := 222;
56471 l_amb_context_code := 'DEFAULT';
56472 l_entity_code := 'RECEIPTS';
56473 l_event_class_code := 'RECEIPT';
56474 l_event_type_code := 'RECEIPT_ALL';
56475 l_line_definition_owner_code := 'S';
56476 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
56477 --
56478 l_balance_type_code := 'A';
56479 l_segment := NULL;
56480 l_ccid := NULL;
56481 l_adr_transaction_coa_id := NULL;
56482 l_adr_accounting_coa_id := NULL;
56483 l_adr_flexfield_segment_code := NULL;
56484 l_adr_flex_value_set_id := NULL;
56485 l_adr_value_type_code := NULL;
56486 l_adr_value_combination_id := NULL;
56487 l_adr_value_segment_code := NULL;
56488
56489 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
56490 l_bflow_class_code := ''; -- 4219869 Business Flow
56491 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
56492 l_budgetary_control_flag := 'N';
56493
56494 l_bflow_applied_to_amt_idx := NULL; -- 5132302
56495 l_bflow_applied_to_amt := NULL; -- 5132302
56496 l_entered_amt_idx := NULL; -- 4262811
56497 l_accted_amt_idx := NULL; -- 4262811
56498 l_acc_rev_flag := NULL; -- 4262811
56499 l_accrual_line_num := NULL; -- 4262811
56500 l_tmp_amt := NULL; -- 4262811
56501 --
56502 IF NOT ((p_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
56503 (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
56504 return;
56505 END IF;
56506
56507 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
56508 l_balance_type_code <> 'B' THEN
56509
56510 --
56511 XLA_AE_LINES_PKG.SetNewLine;
56512
56513 p_balance_type_code := l_balance_type_code;
56514 -- set the flag so later we will know whether the gain loss line needs to be created
56515
56516 IF(l_balance_type_code = 'A' ) THEN
56520 --
56517 p_actual_flag :='G';
56518 END IF;
56519
56521 -- bulk performance
56522 --
56523 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
56524 p_header_num => 0); -- 4262811
56525 --
56526 -- set accounting line options
56527 --
56528 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
56529 p_natural_side_code => 'G'
56530 , p_gain_or_loss_flag => 'N'
56531 , p_gl_transfer_mode_code => 'S'
56532 , p_acct_entry_type_code => 'A'
56533 , p_switch_side_flag => ''
56534 , p_merge_duplicate_code => 'A'
56535 );
56536 --
56537 l_acc_rev_natural_side_code := 'C'; -- 4262811
56538 --
56539 --
56540 -- set accounting line type info
56541 --
56542 xla_ae_lines_pkg.SetAcctLineType
56543 (p_component_type => l_component_type
56544 ,p_event_type_code => l_event_type_code
56545 ,p_line_definition_owner_code => l_line_definition_owner_code
56546 ,p_line_definition_code => l_line_definition_code
56547 ,p_accounting_line_code => l_component_code
56548 ,p_accounting_line_type_code => l_component_type_code
56549 ,p_accounting_line_appl_id => l_component_appl_id
56550 ,p_amb_context_code => l_amb_context_code
56551 ,p_entity_code => l_entity_code
56552 ,p_event_class_code => l_event_class_code);
56553 --
56554 -- set accounting class
56555 --
56556 xla_ae_lines_pkg.SetAcctClass(
56557 p_accounting_class_code => 'EXCHANGE_GAIN_LOSS'
56558 , p_ae_header_id => l_ae_header_id
56559 );
56560
56561 --
56562 -- set rounding class
56563 --
56564 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
56565 'EXCHANGE_GAIN_LOSS';
56566
56567 --
56568 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
56569 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
56570 --
56571 -- bulk performance
56572 --
56573 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
56574
56575 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
56576 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
56577
56578 -- 4955764
56579 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
56580 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
56581
56582 -- 4458381 Public Sector Enh
56583
56584 --
56585 -- set accounting attributes for the line type
56586 --
56587 l_entered_amt_idx := NULL;
56588 l_accted_amt_idx := 3;
56589 l_bflow_applied_to_amt_idx := NULL; -- 5132302
56590 l_rec_acct_attrs.array_acct_attr_code(1) := 'DISTRIBUTION_IDENTIFIER_1';
56591 l_rec_acct_attrs.array_num_value(1) := to_char(p_source_22);
56592 l_rec_acct_attrs.array_acct_attr_code(2) := 'DISTRIBUTION_TYPE';
56593 l_rec_acct_attrs.array_char_value(2) := p_source_23;
56594 l_rec_acct_attrs.array_acct_attr_code(3) := 'LEDGER_AMOUNT';
56595 l_rec_acct_attrs.array_num_value(3) := p_source_69;
56596 l_rec_acct_attrs.array_acct_attr_code(4) := 'PARTY_ID';
56597 l_rec_acct_attrs.array_num_value(4) := p_source_63;
56598 l_rec_acct_attrs.array_acct_attr_code(5) := 'PARTY_SITE_ID';
56599 l_rec_acct_attrs.array_num_value(5) := p_source_64;
56600 l_rec_acct_attrs.array_acct_attr_code(6) := 'PARTY_TYPE';
56601 l_rec_acct_attrs.array_char_value(6) := p_source_65;
56602
56603 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
56604 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
56605
56606 ---------------------------------------------------------------------------------------------------------------
56607 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
56608 ---------------------------------------------------------------------------------------------------------------
56609 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
56610
56611 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56612 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
56613
56614 IF xla_accounting_cache_pkg.GetValueChar
56615 (p_source_code => 'LEDGER_CATEGORY_CODE'
56616 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
56617 AND l_bflow_method_code = 'PRIOR_ENTRY'
56618 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
56619 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
56620 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
56621 )
56622 THEN
56623 xla_ae_lines_pkg.BflowUpgEntry
56624 (p_business_method_code => l_bflow_method_code
56625 ,p_business_class_code => l_bflow_class_code
56626 ,p_balance_type => l_balance_type_code);
56627 ELSE
56628 NULL;
56629 -- No business flow processing for business flow method of NONE.
56630 END IF;
56631
56632 --
56633 -- call analytical criteria
56634 --
56635
56636 --
56637 -- call description
56638 --
56639 -- No description or it is inherited.
56640 --
56641 -- call ADRs
56645 (NVL(l_actual_upg_option, 'N') = 'O') OR
56642 -- Bug 4922099
56643 --
56644 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
56646 (NVL(l_enc_upg_option, 'N') = 'O')
56647 )
56648 THEN
56649 NULL;
56650 --
56651 --
56652
56653 l_ccid := AcctDerRule_5(
56654 p_application_id => p_application_id
56655 , p_ae_header_id => l_ae_header_id
56656 , p_source_6 => p_source_6
56657 , p_source_7 => p_source_7
56658 , x_transaction_coa_id => l_adr_transaction_coa_id
56659 , x_accounting_coa_id => l_adr_accounting_coa_id
56660 , x_value_type_code => l_adr_value_type_code
56661 , p_side => 'CREDIT'
56662 );
56663
56664 xla_ae_lines_pkg.set_ccid(
56665 p_code_combination_id => l_ccid
56666 , p_value_type_code => l_adr_value_type_code
56667 , p_transaction_coa_id => l_adr_transaction_coa_id
56668 , p_accounting_coa_id => l_adr_accounting_coa_id
56669 , p_adr_code => 'DIST_GAIN_GL_ACCOUNT'
56670 , p_adr_type_code => 'S'
56671 , p_component_type => l_component_type
56672 , p_component_code => l_component_code
56673 , p_component_type_code => l_component_type_code
56674 , p_component_appl_id => l_component_appl_id
56675 , p_amb_context_code => l_amb_context_code
56676 , p_side => 'CREDIT'
56677 );
56678
56679
56680 l_ccid := AcctDerRule_6(
56681 p_application_id => p_application_id
56682 , p_ae_header_id => l_ae_header_id
56683 , p_source_6 => p_source_6
56684 , p_source_8 => p_source_8
56685 , x_transaction_coa_id => l_adr_transaction_coa_id
56686 , x_accounting_coa_id => l_adr_accounting_coa_id
56687 , x_value_type_code => l_adr_value_type_code
56688 , p_side => 'DEBIT'
56689 );
56690
56691 xla_ae_lines_pkg.set_ccid(
56692 p_code_combination_id => l_ccid
56693 , p_value_type_code => l_adr_value_type_code
56694 , p_transaction_coa_id => l_adr_transaction_coa_id
56695 , p_accounting_coa_id => l_adr_accounting_coa_id
56696 , p_adr_code => 'DIST_LOSS_GL_ACCOUNT'
56697 , p_adr_type_code => 'S'
56698 , p_component_type => l_component_type
56699 , p_component_code => l_component_code
56700 , p_component_type_code => l_component_type_code
56701 , p_component_appl_id => l_component_appl_id
56702 , p_amb_context_code => l_amb_context_code
56703 , p_side => 'DEBIT'
56704 );
56705
56706
56707 --
56708 --
56709 END IF;
56710 --
56711 -- Bug 4922099
56712 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
56713 (NVL(l_enc_upg_option, 'N') = 'O')
56714 ) AND
56715 (l_bflow_method_code = 'PRIOR_ENTRY')
56716 )
56717 THEN
56718 IF
56719 --
56720 1 = 2
56721 --
56722 THEN
56723 xla_accounting_err_pkg.build_message
56724 (p_appli_s_name => 'XLA'
56725 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
56726 ,p_token_1 => 'LINE_NUMBER'
56727 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
56728 ,p_token_2 => 'LINE_TYPE_NAME'
56729 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
56730 l_component_type
56731 ,l_component_code
56732 ,l_component_type_code
56733 ,l_component_appl_id
56734 ,l_amb_context_code
56735 ,l_entity_code
56736 ,l_event_class_code
56737 )
56738 ,p_token_3 => 'OWNER'
56739 ,p_value_3 => xla_lookups_pkg.get_meaning(
56740 p_lookup_type => 'XLA_OWNER_TYPE'
56741 ,p_lookup_code => l_component_type_code
56742 )
56743 ,p_token_4 => 'PRODUCT_NAME'
56744 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
56745 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
56746 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
56747 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
56748 ,p_ae_header_id => NULL
56749 );
56750
56751 IF (C_LEVEL_ERROR>= g_log_level) THEN
56752 trace
56753 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
56757 END IF;
56754 ,p_level => C_LEVEL_ERROR
56755 ,p_module => l_log_module);
56756 END IF;
56758 END IF;
56759 --
56760 --
56761 ------------------------------------------------------------------------------------------------
56762 -- 4219869 Business Flow
56763 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
56764 -- Prior Entry. Currently, the following code is always generated.
56765 ------------------------------------------------------------------------------------------------
56766 XLA_AE_LINES_PKG.ValidateCurrentLine;
56767
56768 ------------------------------------------------------------------------------------
56769 -- 4219869 Business Flow
56770 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
56771 ------------------------------------------------------------------------------------
56772 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
56773
56774 ----------------------------------------------------------------------------------
56775 -- 4219869 Business Flow
56776 -- Update journal entry status -- Need to generate this within IF <condition>
56777 ----------------------------------------------------------------------------------
56778 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
56779 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
56780 ,p_balance_type_code => l_balance_type_code
56781 );
56782
56783 -------------------------------------------------------------------------------------------
56784 -- 4262811 - Generate the Accrual Reversal lines
56785 -------------------------------------------------------------------------------------------
56786 BEGIN
56787 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
56788 (g_array_event(p_event_id).array_value_num('header_index'));
56789 IF l_acc_rev_flag IS NULL THEN
56790 l_acc_rev_flag := 'N';
56791 END IF;
56792 EXCEPTION
56793 WHEN OTHERS THEN
56794 l_acc_rev_flag := 'N';
56795 END;
56796 --
56797 IF (l_acc_rev_flag = 'Y') THEN
56798
56799 -- 4645092 ------------------------------------------------------------------------------
56800 -- To allow MPA report to determine if it should generate report process
56801 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
56802 ------------------------------------------------------------------------------------------
56803
56804 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
56805 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
56806 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
56807 -- call ADRs
56808 -- Bug 4922099
56809 --
56810 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
56811 (NVL(l_actual_upg_option, 'N') = 'O') OR
56812 (NVL(l_enc_upg_option, 'N') = 'O')
56813 )
56814 THEN
56815 NULL;
56816 --
56817 --
56818
56819 l_ccid := AcctDerRule_5(
56820 p_application_id => p_application_id
56821 , p_ae_header_id => l_ae_header_id
56822 , p_source_6 => p_source_6
56823 , p_source_7 => p_source_7
56824 , x_transaction_coa_id => l_adr_transaction_coa_id
56825 , x_accounting_coa_id => l_adr_accounting_coa_id
56826 , x_value_type_code => l_adr_value_type_code
56827 , p_side => 'CREDIT'
56828 );
56829
56830 xla_ae_lines_pkg.set_ccid(
56831 p_code_combination_id => l_ccid
56832 , p_value_type_code => l_adr_value_type_code
56833 , p_transaction_coa_id => l_adr_transaction_coa_id
56834 , p_accounting_coa_id => l_adr_accounting_coa_id
56835 , p_adr_code => 'DIST_GAIN_GL_ACCOUNT'
56836 , p_adr_type_code => 'S'
56837 , p_component_type => l_component_type
56838 , p_component_code => l_component_code
56839 , p_component_type_code => l_component_type_code
56840 , p_component_appl_id => l_component_appl_id
56841 , p_amb_context_code => l_amb_context_code
56842 , p_side => 'CREDIT'
56843 );
56844
56845
56846 l_ccid := AcctDerRule_6(
56847 p_application_id => p_application_id
56848 , p_ae_header_id => l_ae_header_id
56849 , p_source_6 => p_source_6
56850 , p_source_8 => p_source_8
56851 , x_transaction_coa_id => l_adr_transaction_coa_id
56852 , x_accounting_coa_id => l_adr_accounting_coa_id
56853 , x_value_type_code => l_adr_value_type_code
56854 , p_side => 'DEBIT'
56855 );
56856
56857 xla_ae_lines_pkg.set_ccid(
56858 p_code_combination_id => l_ccid
56859 , p_value_type_code => l_adr_value_type_code
56860 , p_transaction_coa_id => l_adr_transaction_coa_id
56861 , p_accounting_coa_id => l_adr_accounting_coa_id
56862 , p_adr_code => 'DIST_LOSS_GL_ACCOUNT'
56863 , p_adr_type_code => 'S'
56864 , p_component_type => l_component_type
56865 , p_component_code => l_component_code
56866 , p_component_type_code => l_component_type_code
56867 , p_component_appl_id => l_component_appl_id
56868 , p_amb_context_code => l_amb_context_code
56869 , p_side => 'DEBIT'
56870 );
56871
56872
56873 --
56874 --
56875 END IF;
56876
56877 --
56878 -- Update the line information that should be overwritten
56879 --
56880 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
56881 p_header_num => 1);
56882 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
56883
56884 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
56885
56886 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
56887 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
56888 END IF;
56889
56890 --
56891 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
56892 --
56893 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
56894 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
56895 ELSE
56896 ---------------------------------------------------------------------------------------------------
56897 -- 4262811a Switch Sign
56898 ---------------------------------------------------------------------------------------------------
56899 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
56900 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
56901 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56902 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
56903 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56904 -- 5132302
56905 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
56906 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
56907
56908 END IF;
56909
56910 -- 4955764
56911 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
56912 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
56913
56914
56915 XLA_AE_LINES_PKG.ValidateCurrentLine;
56916 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
56917
56918 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
56919 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
56920 ,p_balance_type_code => l_balance_type_code);
56921
56922 END IF;
56923
56924 -----------------------------------------------------------------------------------------
56925 -- 4262811 Multiperiod Accounting
56926 -----------------------------------------------------------------------------------------
56927 -- No MPA option is assigned.
56928
56929
56930 END IF;
56931 --
56932
56933 --
56934 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
56935 trace
56936 (p_msg => 'END of AcctLineType_117'
56937 ,p_level => C_LEVEL_PROCEDURE
56938 ,p_module => l_log_module);
56939 END IF;
56940 --
56941 EXCEPTION
56942 WHEN xla_exceptions_pkg.application_exception THEN
56943 RAISE;
56944 WHEN OTHERS THEN
56945 xla_exceptions_pkg.raise_message
56946 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_117');
56947 END AcctLineType_117;
56948 --
56949
56950 ---------------------------------------
56951 --
56952 -- PRIVATE FUNCTION
56953 -- AcctLineType_118
56954 --
56955 ---------------------------------------
56956 PROCEDURE AcctLineType_118 (
56957 p_application_id IN NUMBER
56958 ,p_event_id IN NUMBER
56959 ,p_calculate_acctd_flag IN VARCHAR2
56960 ,p_calculate_g_l_flag IN VARCHAR2
56961 ,p_actual_flag IN OUT VARCHAR2
56962 ,p_balance_type_code OUT VARCHAR2
56963 ,p_gain_or_loss_ref OUT VARCHAR2
56964
56965 --Distribution GL Account
56966 , p_source_5 IN NUMBER
56967 --Distribution Source Type
56968 , p_source_20 IN VARCHAR2
56969 --Distribution Line Identifier
56970 , p_source_22 IN NUMBER
56971 --Distribution Type
56972 , p_source_23 IN VARCHAR2
56973 --Exchange Date
56974 , p_source_26 IN DATE
56975 --Exchange Rate
56976 , p_source_27 IN NUMBER
56977 --Exchange Rate Type
56978 , p_source_28 IN VARCHAR2
56982 , p_source_35 IN VARCHAR2
56979 --Transaction Distribution Identifier
56980 , p_source_34 IN NUMBER
56981 --Transaction Distribution Type
56983 --Receipt Applied To Application Identifier
56984 , p_source_58 IN NUMBER
56985 --Transaction Entity Code
56986 , p_source_59 IN VARCHAR2
56987 --Transaction Identifier
56988 , p_source_60 IN NUMBER
56989 --Applying Document Currency Code
56990 , p_source_61 IN VARCHAR2
56991 --Distribution Party Identifier
56992 , p_source_63 IN NUMBER
56993 --Distribution Party Site Id
56994 , p_source_64 IN NUMBER
56995 --Distribution Party Type
56996 , p_source_65 IN VARCHAR2
56997 --Distribution Multi Fund Additional Entry
56998 , p_source_67 IN VARCHAR2
56999 --DIST_ENT_AMT_FROM
57000 , p_source_68 IN NUMBER
57001 --Accounting Amount
57002 , p_source_69 IN NUMBER
57003 --Distribution Source Table
57004 , p_source_71 IN VARCHAR2
57005 )
57006 IS
57007
57008 l_component_type VARCHAR2(80);
57009 l_component_code VARCHAR2(30);
57010 l_component_type_code VARCHAR2(1);
57011 l_component_appl_id INTEGER;
57012 l_amb_context_code VARCHAR2(30);
57013 l_entity_code VARCHAR2(30);
57014 l_event_class_code VARCHAR2(30);
57015 l_ae_header_id NUMBER;
57016 l_event_type_code VARCHAR2(30);
57017 l_line_definition_code VARCHAR2(30);
57018 l_line_definition_owner_code VARCHAR2(1);
57019 --
57020 -- adr variables
57021 l_segment VARCHAR2(30);
57022 l_ccid NUMBER;
57023 l_adr_transaction_coa_id NUMBER;
57024 l_adr_accounting_coa_id NUMBER;
57025 l_adr_flexfield_segment_code VARCHAR2(30);
57026 l_adr_flex_value_set_id NUMBER;
57027 l_adr_value_type_code VARCHAR2(30);
57028 l_adr_value_combination_id NUMBER;
57029 l_adr_value_segment_code VARCHAR2(30);
57030
57031 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
57032 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
57033 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
57034 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
57035
57036 -- 4262811 Variables ------------------------------------------------------------------------------------------
57037 l_entered_amt_idx NUMBER;
57038 l_accted_amt_idx NUMBER;
57039 l_acc_rev_flag VARCHAR2(1);
57040 l_accrual_line_num NUMBER;
57041 l_tmp_amt NUMBER;
57042 l_acc_rev_natural_side_code VARCHAR2(1);
57043
57044 l_num_entries NUMBER;
57045 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
57046 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
57047 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
57048 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
57049 l_recog_line_1 NUMBER;
57050 l_recog_line_2 NUMBER;
57051
57052 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
57053 l_bflow_applied_to_amt NUMBER; -- 5132302
57054 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
57055
57056 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
57057
57058 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
57059 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
57060
57061 ---------------------------------------------------------------------------------------------------------------
57062
57063
57064 --
57065 -- bulk performance
57066 --
57067 l_balance_type_code VARCHAR2(1);
57068 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
57069 l_log_module VARCHAR2(240);
57070
57071 --
57072 -- Upgrade strategy
57073 --
57074 l_actual_upg_option VARCHAR2(1);
57075 l_enc_upg_option VARCHAR2(1);
57076
57077 --
57078 BEGIN
57079 --
57080 IF g_log_enabled THEN
57081 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_118';
57082 END IF;
57083 --
57084 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57085
57086 trace
57087 (p_msg => 'BEGIN of AcctLineType_118'
57088 ,p_level => C_LEVEL_PROCEDURE
57089 ,p_module => l_log_module);
57090
57091 END IF;
57092 --
57093 l_component_type := 'AMB_JLT';
57094 l_component_code := 'RCT_FACTOR';
57095 l_component_type_code := 'S';
57096 l_component_appl_id := 222;
57097 l_amb_context_code := 'DEFAULT';
57098 l_entity_code := 'RECEIPTS';
57099 l_event_class_code := 'RECEIPT';
57100 l_event_type_code := 'RECEIPT_ALL';
57101 l_line_definition_owner_code := 'S';
57102 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
57103 --
57104 l_balance_type_code := 'A';
57105 l_segment := NULL;
57106 l_ccid := NULL;
57107 l_adr_transaction_coa_id := NULL;
57108 l_adr_accounting_coa_id := NULL;
57109 l_adr_flexfield_segment_code := NULL;
57110 l_adr_flex_value_set_id := NULL;
57111 l_adr_value_type_code := NULL;
57112 l_adr_value_combination_id := NULL;
57113 l_adr_value_segment_code := NULL;
57114
57115 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
57116 l_bflow_class_code := ''; -- 4219869 Business Flow
57117 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
57118 l_budgetary_control_flag := 'N';
57119
57120 l_bflow_applied_to_amt_idx := NULL; -- 5132302
57121 l_bflow_applied_to_amt := NULL; -- 5132302
57122 l_entered_amt_idx := NULL; -- 4262811
57123 l_accted_amt_idx := NULL; -- 4262811
57124 l_acc_rev_flag := NULL; -- 4262811
57125 l_accrual_line_num := NULL; -- 4262811
57126 l_tmp_amt := NULL; -- 4262811
57127 --
57128
57129 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
57130 l_balance_type_code <> 'B' THEN
57131 IF NVL(p_source_20,'
57132 ') = 'FACTOR' AND
57133 NVL(p_source_71,'
57134 ') = 'CRH' AND
57135 NVL(p_source_67,'
57136 ') = 'N'
57137 THEN
57138
57139 --
57140 XLA_AE_LINES_PKG.SetNewLine;
57141
57142 p_balance_type_code := l_balance_type_code;
57143 -- set the flag so later we will know whether the gain loss line needs to be created
57144
57145 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
57146 p_actual_flag :='A';
57147 END IF;
57148
57149 --
57150 -- bulk performance
57151 --
57152 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
57153 p_header_num => 0); -- 4262811
57154 --
57155 -- set accounting line options
57156 --
57157 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
57158 p_natural_side_code => 'C'
57159 , p_gain_or_loss_flag => 'N'
57160 , p_gl_transfer_mode_code => 'S'
57161 , p_acct_entry_type_code => 'A'
57162 , p_switch_side_flag => 'Y'
57163 , p_merge_duplicate_code => 'A'
57164 );
57165 --
57166 l_acc_rev_natural_side_code := 'D'; -- 4262811
57167 --
57168 --
57169 -- set accounting line type info
57170 --
57171 xla_ae_lines_pkg.SetAcctLineType
57172 (p_component_type => l_component_type
57173 ,p_event_type_code => l_event_type_code
57174 ,p_line_definition_owner_code => l_line_definition_owner_code
57175 ,p_line_definition_code => l_line_definition_code
57176 ,p_accounting_line_code => l_component_code
57177 ,p_accounting_line_type_code => l_component_type_code
57178 ,p_accounting_line_appl_id => l_component_appl_id
57179 ,p_amb_context_code => l_amb_context_code
57180 ,p_entity_code => l_entity_code
57181 ,p_event_class_code => l_event_class_code);
57182 --
57183 -- set accounting class
57184 --
57185 xla_ae_lines_pkg.SetAcctClass(
57186 p_accounting_class_code => 'FACTOR'
57187 , p_ae_header_id => l_ae_header_id
57188 );
57189
57190 --
57191 -- set rounding class
57192 --
57193 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
57194 'RECEIVABLE';
57195
57196 --
57197 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
57198 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
57199 --
57200 -- bulk performance
57201 --
57202 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
57203
57207 -- 4955764
57204 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
57205 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
57206
57208 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
57209 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
57210
57211 -- 4458381 Public Sector Enh
57212
57213 --
57214 -- set accounting attributes for the line type
57215 --
57216 l_entered_amt_idx := 8;
57217 l_accted_amt_idx := 13;
57218 l_bflow_applied_to_amt_idx := NULL; -- 5132302
57219 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
57220 l_rec_acct_attrs.array_num_value(1) := p_source_58;
57221 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
57222 l_rec_acct_attrs.array_char_value(2) := p_source_35;
57223 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
57224 l_rec_acct_attrs.array_char_value(3) := p_source_59;
57225 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
57226 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
57227 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
57228 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
57229 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
57230 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
57231 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
57232 l_rec_acct_attrs.array_char_value(7) := p_source_23;
57233 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
57234 l_rec_acct_attrs.array_num_value(8) := p_source_68;
57235 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
57236 l_rec_acct_attrs.array_char_value(9) := p_source_61;
57237 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
57238 l_rec_acct_attrs.array_date_value(10) := p_source_26;
57239 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
57240 l_rec_acct_attrs.array_num_value(11) := p_source_27;
57241 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
57242 l_rec_acct_attrs.array_char_value(12) := p_source_28;
57243 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
57244 l_rec_acct_attrs.array_num_value(13) := p_source_69;
57245 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
57246 l_rec_acct_attrs.array_num_value(14) := p_source_63;
57247 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
57248 l_rec_acct_attrs.array_num_value(15) := p_source_64;
57249 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
57250 l_rec_acct_attrs.array_char_value(16) := p_source_65;
57251
57252 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
57253 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
57254
57255 ---------------------------------------------------------------------------------------------------------------
57256 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
57257 ---------------------------------------------------------------------------------------------------------------
57258 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
57259
57260 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
57261 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
57262
57263 IF xla_accounting_cache_pkg.GetValueChar
57264 (p_source_code => 'LEDGER_CATEGORY_CODE'
57265 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
57266 AND l_bflow_method_code = 'PRIOR_ENTRY'
57267 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
57268 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
57269 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
57270 )
57271 THEN
57272 xla_ae_lines_pkg.BflowUpgEntry
57273 (p_business_method_code => l_bflow_method_code
57274 ,p_business_class_code => l_bflow_class_code
57275 ,p_balance_type => l_balance_type_code);
57276 ELSE
57277 NULL;
57278 -- No business flow processing for business flow method of NONE.
57279 END IF;
57280
57281 --
57282 -- call analytical criteria
57283 --
57284
57285 --
57286 -- call description
57287 --
57288 -- No description or it is inherited.
57289 --
57290 -- call ADRs
57291 -- Bug 4922099
57292 --
57293 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
57294 (NVL(l_actual_upg_option, 'N') = 'O') OR
57295 (NVL(l_enc_upg_option, 'N') = 'O')
57296 )
57297 THEN
57298 NULL;
57299 --
57300 --
57301
57302 l_ccid := AcctDerRule_4(
57303 p_application_id => p_application_id
57304 , p_ae_header_id => l_ae_header_id
57305 , p_source_5 => p_source_5
57306 , x_transaction_coa_id => l_adr_transaction_coa_id
57307 , x_accounting_coa_id => l_adr_accounting_coa_id
57308 , x_value_type_code => l_adr_value_type_code
57309 , p_side => 'NA'
57310 );
57311
57312 xla_ae_lines_pkg.set_ccid(
57313 p_code_combination_id => l_ccid
57314 , p_value_type_code => l_adr_value_type_code
57315 , p_transaction_coa_id => l_adr_transaction_coa_id
57316 , p_accounting_coa_id => l_adr_accounting_coa_id
57317 , p_adr_code => 'DIST_CCID'
57318 , p_adr_type_code => 'S'
57319 , p_component_type => l_component_type
57320 , p_component_code => l_component_code
57321 , p_component_type_code => l_component_type_code
57322 , p_component_appl_id => l_component_appl_id
57323 , p_amb_context_code => l_amb_context_code
57324 , p_side => 'NA'
57325 );
57326
57327
57328 --
57329 --
57330 END IF;
57331 --
57332 -- Bug 4922099
57333 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
57334 (NVL(l_enc_upg_option, 'N') = 'O')
57335 ) AND
57336 (l_bflow_method_code = 'PRIOR_ENTRY')
57337 )
57338 THEN
57339 IF
57340 --
57341 1 = 2
57342 --
57343 THEN
57344 xla_accounting_err_pkg.build_message
57345 (p_appli_s_name => 'XLA'
57346 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57347 ,p_token_1 => 'LINE_NUMBER'
57348 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
57349 ,p_token_2 => 'LINE_TYPE_NAME'
57350 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
57351 l_component_type
57352 ,l_component_code
57353 ,l_component_type_code
57354 ,l_component_appl_id
57355 ,l_amb_context_code
57356 ,l_entity_code
57357 ,l_event_class_code
57358 )
57359 ,p_token_3 => 'OWNER'
57360 ,p_value_3 => xla_lookups_pkg.get_meaning(
57361 p_lookup_type => 'XLA_OWNER_TYPE'
57362 ,p_lookup_code => l_component_type_code
57363 )
57364 ,p_token_4 => 'PRODUCT_NAME'
57365 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
57366 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
57367 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
57368 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
57369 ,p_ae_header_id => NULL
57370 );
57371
57372 IF (C_LEVEL_ERROR>= g_log_level) THEN
57373 trace
57374 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57375 ,p_level => C_LEVEL_ERROR
57376 ,p_module => l_log_module);
57377 END IF;
57378 END IF;
57379 END IF;
57380 --
57381 --
57382 ------------------------------------------------------------------------------------------------
57383 -- 4219869 Business Flow
57384 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
57385 -- Prior Entry. Currently, the following code is always generated.
57386 ------------------------------------------------------------------------------------------------
57387 XLA_AE_LINES_PKG.ValidateCurrentLine;
57388
57389 ------------------------------------------------------------------------------------
57390 -- 4219869 Business Flow
57391 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
57392 ------------------------------------------------------------------------------------
57393 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
57394
57395 ----------------------------------------------------------------------------------
57396 -- 4219869 Business Flow
57397 -- Update journal entry status -- Need to generate this within IF <condition>
57398 ----------------------------------------------------------------------------------
57399 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
57400 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
57404 -------------------------------------------------------------------------------------------
57401 ,p_balance_type_code => l_balance_type_code
57402 );
57403
57405 -- 4262811 - Generate the Accrual Reversal lines
57406 -------------------------------------------------------------------------------------------
57407 BEGIN
57408 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
57409 (g_array_event(p_event_id).array_value_num('header_index'));
57410 IF l_acc_rev_flag IS NULL THEN
57411 l_acc_rev_flag := 'N';
57412 END IF;
57413 EXCEPTION
57414 WHEN OTHERS THEN
57415 l_acc_rev_flag := 'N';
57416 END;
57417 --
57418 IF (l_acc_rev_flag = 'Y') THEN
57419
57420 -- 4645092 ------------------------------------------------------------------------------
57421 -- To allow MPA report to determine if it should generate report process
57422 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
57423 ------------------------------------------------------------------------------------------
57424
57425 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
57426 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
57427 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
57428 -- call ADRs
57429 -- Bug 4922099
57430 --
57431 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
57432 (NVL(l_actual_upg_option, 'N') = 'O') OR
57433 (NVL(l_enc_upg_option, 'N') = 'O')
57434 )
57435 THEN
57436 NULL;
57437 --
57438 --
57439
57440 l_ccid := AcctDerRule_4(
57441 p_application_id => p_application_id
57442 , p_ae_header_id => l_ae_header_id
57443 , p_source_5 => p_source_5
57444 , x_transaction_coa_id => l_adr_transaction_coa_id
57445 , x_accounting_coa_id => l_adr_accounting_coa_id
57446 , x_value_type_code => l_adr_value_type_code
57447 , p_side => 'NA'
57448 );
57449
57450 xla_ae_lines_pkg.set_ccid(
57451 p_code_combination_id => l_ccid
57452 , p_value_type_code => l_adr_value_type_code
57453 , p_transaction_coa_id => l_adr_transaction_coa_id
57454 , p_accounting_coa_id => l_adr_accounting_coa_id
57455 , p_adr_code => 'DIST_CCID'
57456 , p_adr_type_code => 'S'
57457 , p_component_type => l_component_type
57458 , p_component_code => l_component_code
57459 , p_component_type_code => l_component_type_code
57460 , p_component_appl_id => l_component_appl_id
57461 , p_amb_context_code => l_amb_context_code
57462 , p_side => 'NA'
57463 );
57464
57465
57466 --
57467 --
57468 END IF;
57469
57470 --
57471 -- Update the line information that should be overwritten
57472 --
57473 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
57474 p_header_num => 1);
57475 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
57476
57477 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
57478
57479 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
57480 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
57481 END IF;
57482
57483 --
57484 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
57485 --
57486 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
57487 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
57488 ELSE
57489 ---------------------------------------------------------------------------------------------------
57490 -- 4262811a Switch Sign
57491 ---------------------------------------------------------------------------------------------------
57492 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
57493 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
57494 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57495 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
57496 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57497 -- 5132302
57498 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
57499 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
57500
57501 END IF;
57502
57503 -- 4955764
57504 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
57505 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
57506
57507
57508 XLA_AE_LINES_PKG.ValidateCurrentLine;
57509 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
57510
57511 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
57512 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
57513 ,p_balance_type_code => l_balance_type_code);
57514
57515 END IF;
57516
57517 -----------------------------------------------------------------------------------------
57518 -- 4262811 Multiperiod Accounting
57519 -----------------------------------------------------------------------------------------
57520 -- No MPA option is assigned.
57521
57522
57523 END IF;
57524 END IF;
57525 --
57526
57527 --
57528 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57529 trace
57530 (p_msg => 'END of AcctLineType_118'
57531 ,p_level => C_LEVEL_PROCEDURE
57532 ,p_module => l_log_module);
57533 END IF;
57534 --
57535 EXCEPTION
57536 WHEN xla_exceptions_pkg.application_exception THEN
57537 RAISE;
57538 WHEN OTHERS THEN
57539 xla_exceptions_pkg.raise_message
57540 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_118');
57541 END AcctLineType_118;
57542 --
57543
57544 ---------------------------------------
57545 --
57546 -- PRIVATE FUNCTION
57547 -- AcctLineType_119
57548 --
57549 ---------------------------------------
57550 PROCEDURE AcctLineType_119 (
57551 p_application_id IN NUMBER
57552 ,p_event_id IN NUMBER
57553 ,p_calculate_acctd_flag IN VARCHAR2
57554 ,p_calculate_g_l_flag IN VARCHAR2
57555 ,p_actual_flag IN OUT VARCHAR2
57556 ,p_balance_type_code OUT VARCHAR2
57557 ,p_gain_or_loss_ref OUT VARCHAR2
57558
57559 --Distribution GL Account
57560 , p_source_5 IN NUMBER
57561 --Distribution Source Type
57562 , p_source_20 IN VARCHAR2
57563 --Distribution Line Identifier
57564 , p_source_22 IN NUMBER
57565 --Distribution Type
57566 , p_source_23 IN VARCHAR2
57567 --Exchange Date
57568 , p_source_26 IN DATE
57569 --Exchange Rate
57570 , p_source_27 IN NUMBER
57571 --Exchange Rate Type
57572 , p_source_28 IN VARCHAR2
57573 --Transaction Distribution Identifier
57574 , p_source_34 IN NUMBER
57575 --Transaction Distribution Type
57576 , p_source_35 IN VARCHAR2
57577 --Receipt Applied To Application Identifier
57578 , p_source_58 IN NUMBER
57579 --Transaction Entity Code
57580 , p_source_59 IN VARCHAR2
57581 --Transaction Identifier
57582 , p_source_60 IN NUMBER
57583 --Applying Document Currency Code
57584 , p_source_61 IN VARCHAR2
57585 --Distribution Party Identifier
57586 , p_source_63 IN NUMBER
57587 --Distribution Party Site Id
57588 , p_source_64 IN NUMBER
57589 --Distribution Party Type
57590 , p_source_65 IN VARCHAR2
57591 --Distribution Multi Fund Additional Entry
57592 , p_source_67 IN VARCHAR2
57593 --DIST_ENT_AMT_FROM
57594 , p_source_68 IN NUMBER
57595 --Accounting Amount
57596 , p_source_69 IN NUMBER
57597 --Distribution Source Table
57598 , p_source_71 IN VARCHAR2
57599 )
57600 IS
57601
57602 l_component_type VARCHAR2(80);
57603 l_component_code VARCHAR2(30);
57604 l_component_type_code VARCHAR2(1);
57605 l_component_appl_id INTEGER;
57606 l_amb_context_code VARCHAR2(30);
57607 l_entity_code VARCHAR2(30);
57608 l_event_class_code VARCHAR2(30);
57609 l_ae_header_id NUMBER;
57610 l_event_type_code VARCHAR2(30);
57611 l_line_definition_code VARCHAR2(30);
57612 l_line_definition_owner_code VARCHAR2(1);
57613 --
57614 -- adr variables
57615 l_segment VARCHAR2(30);
57616 l_ccid NUMBER;
57617 l_adr_transaction_coa_id NUMBER;
57618 l_adr_accounting_coa_id NUMBER;
57619 l_adr_flexfield_segment_code VARCHAR2(30);
57620 l_adr_flex_value_set_id NUMBER;
57621 l_adr_value_type_code VARCHAR2(30);
57622 l_adr_value_combination_id NUMBER;
57623 l_adr_value_segment_code VARCHAR2(30);
57624
57625 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
57626 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
57627 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
57628 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
57629
57630 -- 4262811 Variables ------------------------------------------------------------------------------------------
57631 l_entered_amt_idx NUMBER;
57632 l_accted_amt_idx NUMBER;
57633 l_acc_rev_flag VARCHAR2(1);
57634 l_accrual_line_num NUMBER;
57635 l_tmp_amt NUMBER;
57636 l_acc_rev_natural_side_code VARCHAR2(1);
57637
57638 l_num_entries NUMBER;
57639 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
57640 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
57641 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
57642 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
57643 l_recog_line_1 NUMBER;
57644 l_recog_line_2 NUMBER;
57645
57646 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
57647 l_bflow_applied_to_amt NUMBER; -- 5132302
57648 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
57649
57650 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
57651
57652 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
57653 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
57654
57655 ---------------------------------------------------------------------------------------------------------------
57656
57657
57658 --
57659 -- bulk performance
57660 --
57661 l_balance_type_code VARCHAR2(1);
57662 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
57663 l_log_module VARCHAR2(240);
57664
57665 --
57666 -- Upgrade strategy
57667 --
57668 l_actual_upg_option VARCHAR2(1);
57669 l_enc_upg_option VARCHAR2(1);
57670
57671 --
57672 BEGIN
57673 --
57674 IF g_log_enabled THEN
57675 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_119';
57676 END IF;
57677 --
57678 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
57679
57680 trace
57681 (p_msg => 'BEGIN of AcctLineType_119'
57682 ,p_level => C_LEVEL_PROCEDURE
57683 ,p_module => l_log_module);
57684
57685 END IF;
57686 --
57687 l_component_type := 'AMB_JLT';
57688 l_component_code := 'RCT_FACTOR_BR';
57689 l_component_type_code := 'S';
57690 l_component_appl_id := 222;
57691 l_amb_context_code := 'DEFAULT';
57692 l_entity_code := 'RECEIPTS';
57693 l_event_class_code := 'RECEIPT';
57694 l_event_type_code := 'RECEIPT_ALL';
57695 l_line_definition_owner_code := 'S';
57696 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
57697 --
57698 l_balance_type_code := 'A';
57699 l_segment := NULL;
57700 l_ccid := NULL;
57701 l_adr_transaction_coa_id := NULL;
57702 l_adr_accounting_coa_id := NULL;
57703 l_adr_flexfield_segment_code := NULL;
57704 l_adr_flex_value_set_id := NULL;
57705 l_adr_value_type_code := NULL;
57709 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
57706 l_adr_value_combination_id := NULL;
57707 l_adr_value_segment_code := NULL;
57708
57710 l_bflow_class_code := ''; -- 4219869 Business Flow
57711 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
57712 l_budgetary_control_flag := 'N';
57713
57714 l_bflow_applied_to_amt_idx := NULL; -- 5132302
57715 l_bflow_applied_to_amt := NULL; -- 5132302
57716 l_entered_amt_idx := NULL; -- 4262811
57717 l_accted_amt_idx := NULL; -- 4262811
57718 l_acc_rev_flag := NULL; -- 4262811
57719 l_accrual_line_num := NULL; -- 4262811
57720 l_tmp_amt := NULL; -- 4262811
57721 --
57722
57723 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
57724 l_balance_type_code <> 'B' THEN
57725 IF NVL(p_source_20,'
57726 ') = 'FACTOR' AND
57727 NVL(p_source_71,'
57728 ') = 'RA' AND
57729 NVL(p_source_67,'
57730 ') = 'N'
57731 THEN
57732
57733 --
57734 XLA_AE_LINES_PKG.SetNewLine;
57735
57736 p_balance_type_code := l_balance_type_code;
57737 -- set the flag so later we will know whether the gain loss line needs to be created
57738
57739 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
57740 p_actual_flag :='A';
57741 END IF;
57742
57743 --
57744 -- bulk performance
57745 --
57746 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
57747 p_header_num => 0); -- 4262811
57748 --
57749 -- set accounting line options
57750 --
57751 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
57752 p_natural_side_code => 'C'
57753 , p_gain_or_loss_flag => 'N'
57754 , p_gl_transfer_mode_code => 'S'
57755 , p_acct_entry_type_code => 'A'
57756 , p_switch_side_flag => 'Y'
57757 , p_merge_duplicate_code => 'A'
57758 );
57759 --
57760 l_acc_rev_natural_side_code := 'D'; -- 4262811
57761 --
57762 --
57763 -- set accounting line type info
57764 --
57765 xla_ae_lines_pkg.SetAcctLineType
57766 (p_component_type => l_component_type
57767 ,p_event_type_code => l_event_type_code
57768 ,p_line_definition_owner_code => l_line_definition_owner_code
57769 ,p_line_definition_code => l_line_definition_code
57770 ,p_accounting_line_code => l_component_code
57771 ,p_accounting_line_type_code => l_component_type_code
57772 ,p_accounting_line_appl_id => l_component_appl_id
57773 ,p_amb_context_code => l_amb_context_code
57774 ,p_entity_code => l_entity_code
57775 ,p_event_class_code => l_event_class_code);
57776 --
57777 -- set accounting class
57778 --
57779 xla_ae_lines_pkg.SetAcctClass(
57780 p_accounting_class_code => 'FAC_BR'
57781 , p_ae_header_id => l_ae_header_id
57782 );
57783
57784 --
57785 -- set rounding class
57786 --
57787 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
57788 'RECEIVABLE';
57789
57790 --
57791 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
57792 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
57793 --
57794 -- bulk performance
57795 --
57796 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
57797
57798 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
57799 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
57800
57801 -- 4955764
57802 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
57803 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
57804
57805 -- 4458381 Public Sector Enh
57806
57807 --
57808 -- set accounting attributes for the line type
57809 --
57810 l_entered_amt_idx := 8;
57811 l_accted_amt_idx := 13;
57812 l_bflow_applied_to_amt_idx := NULL; -- 5132302
57813 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
57814 l_rec_acct_attrs.array_num_value(1) := p_source_58;
57815 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
57816 l_rec_acct_attrs.array_char_value(2) := p_source_35;
57817 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
57818 l_rec_acct_attrs.array_char_value(3) := p_source_59;
57819 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
57820 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
57821 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
57822 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
57823 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
57824 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
57825 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
57826 l_rec_acct_attrs.array_char_value(7) := p_source_23;
57827 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
57828 l_rec_acct_attrs.array_num_value(8) := p_source_68;
57829 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
57830 l_rec_acct_attrs.array_char_value(9) := p_source_61;
57831 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
57832 l_rec_acct_attrs.array_date_value(10) := p_source_26;
57833 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
57834 l_rec_acct_attrs.array_num_value(11) := p_source_27;
57835 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
57836 l_rec_acct_attrs.array_char_value(12) := p_source_28;
57837 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
57838 l_rec_acct_attrs.array_num_value(13) := p_source_69;
57839 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
57840 l_rec_acct_attrs.array_num_value(14) := p_source_63;
57841 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
57842 l_rec_acct_attrs.array_num_value(15) := p_source_64;
57843 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
57844 l_rec_acct_attrs.array_char_value(16) := p_source_65;
57845
57846 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
57847 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
57848
57849 ---------------------------------------------------------------------------------------------------------------
57850 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
57851 ---------------------------------------------------------------------------------------------------------------
57852 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
57853
57854 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
57855 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
57856
57857 IF xla_accounting_cache_pkg.GetValueChar
57858 (p_source_code => 'LEDGER_CATEGORY_CODE'
57859 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
57860 AND l_bflow_method_code = 'PRIOR_ENTRY'
57861 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
57862 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
57863 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
57864 )
57865 THEN
57866 xla_ae_lines_pkg.BflowUpgEntry
57867 (p_business_method_code => l_bflow_method_code
57868 ,p_business_class_code => l_bflow_class_code
57869 ,p_balance_type => l_balance_type_code);
57870 ELSE
57871 NULL;
57872 -- No business flow processing for business flow method of NONE.
57873 END IF;
57874
57875 --
57876 -- call analytical criteria
57877 --
57878
57879 --
57880 -- call description
57881 --
57882 -- No description or it is inherited.
57883 --
57884 -- call ADRs
57885 -- Bug 4922099
57886 --
57887 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
57888 (NVL(l_actual_upg_option, 'N') = 'O') OR
57889 (NVL(l_enc_upg_option, 'N') = 'O')
57890 )
57891 THEN
57892 NULL;
57893 --
57894 --
57895
57896 l_ccid := AcctDerRule_4(
57897 p_application_id => p_application_id
57898 , p_ae_header_id => l_ae_header_id
57899 , p_source_5 => p_source_5
57900 , x_transaction_coa_id => l_adr_transaction_coa_id
57901 , x_accounting_coa_id => l_adr_accounting_coa_id
57902 , x_value_type_code => l_adr_value_type_code
57903 , p_side => 'NA'
57904 );
57905
57906 xla_ae_lines_pkg.set_ccid(
57907 p_code_combination_id => l_ccid
57908 , p_value_type_code => l_adr_value_type_code
57909 , p_transaction_coa_id => l_adr_transaction_coa_id
57910 , p_accounting_coa_id => l_adr_accounting_coa_id
57911 , p_adr_code => 'DIST_CCID'
57912 , p_adr_type_code => 'S'
57913 , p_component_type => l_component_type
57914 , p_component_code => l_component_code
57915 , p_component_type_code => l_component_type_code
57916 , p_component_appl_id => l_component_appl_id
57917 , p_amb_context_code => l_amb_context_code
57918 , p_side => 'NA'
57919 );
57920
57921
57922 --
57923 --
57924 END IF;
57925 --
57926 -- Bug 4922099
57927 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
57928 (NVL(l_enc_upg_option, 'N') = 'O')
57929 ) AND
57930 (l_bflow_method_code = 'PRIOR_ENTRY')
57931 )
57932 THEN
57933 IF
57934 --
57935 1 = 2
57936 --
57937 THEN
57938 xla_accounting_err_pkg.build_message
57939 (p_appli_s_name => 'XLA'
57940 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57944 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
57941 ,p_token_1 => 'LINE_NUMBER'
57942 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
57943 ,p_token_2 => 'LINE_TYPE_NAME'
57945 l_component_type
57946 ,l_component_code
57947 ,l_component_type_code
57948 ,l_component_appl_id
57949 ,l_amb_context_code
57950 ,l_entity_code
57951 ,l_event_class_code
57952 )
57953 ,p_token_3 => 'OWNER'
57954 ,p_value_3 => xla_lookups_pkg.get_meaning(
57955 p_lookup_type => 'XLA_OWNER_TYPE'
57956 ,p_lookup_code => l_component_type_code
57957 )
57958 ,p_token_4 => 'PRODUCT_NAME'
57959 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
57960 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
57961 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
57962 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
57963 ,p_ae_header_id => NULL
57964 );
57965
57966 IF (C_LEVEL_ERROR>= g_log_level) THEN
57967 trace
57968 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
57969 ,p_level => C_LEVEL_ERROR
57970 ,p_module => l_log_module);
57971 END IF;
57972 END IF;
57973 END IF;
57974 --
57975 --
57976 ------------------------------------------------------------------------------------------------
57977 -- 4219869 Business Flow
57978 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
57979 -- Prior Entry. Currently, the following code is always generated.
57980 ------------------------------------------------------------------------------------------------
57981 XLA_AE_LINES_PKG.ValidateCurrentLine;
57982
57983 ------------------------------------------------------------------------------------
57984 -- 4219869 Business Flow
57985 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
57986 ------------------------------------------------------------------------------------
57987 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
57988
57989 ----------------------------------------------------------------------------------
57990 -- 4219869 Business Flow
57991 -- Update journal entry status -- Need to generate this within IF <condition>
57992 ----------------------------------------------------------------------------------
57993 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
57994 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
57995 ,p_balance_type_code => l_balance_type_code
57996 );
57997
57998 -------------------------------------------------------------------------------------------
57999 -- 4262811 - Generate the Accrual Reversal lines
58000 -------------------------------------------------------------------------------------------
58001 BEGIN
58002 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
58003 (g_array_event(p_event_id).array_value_num('header_index'));
58004 IF l_acc_rev_flag IS NULL THEN
58005 l_acc_rev_flag := 'N';
58006 END IF;
58007 EXCEPTION
58008 WHEN OTHERS THEN
58009 l_acc_rev_flag := 'N';
58010 END;
58011 --
58012 IF (l_acc_rev_flag = 'Y') THEN
58013
58014 -- 4645092 ------------------------------------------------------------------------------
58015 -- To allow MPA report to determine if it should generate report process
58016 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
58017 ------------------------------------------------------------------------------------------
58018
58019 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
58020 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
58021 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
58022 -- call ADRs
58023 -- Bug 4922099
58024 --
58025 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
58026 (NVL(l_actual_upg_option, 'N') = 'O') OR
58027 (NVL(l_enc_upg_option, 'N') = 'O')
58028 )
58029 THEN
58030 NULL;
58031 --
58032 --
58033
58034 l_ccid := AcctDerRule_4(
58035 p_application_id => p_application_id
58036 , p_ae_header_id => l_ae_header_id
58037 , p_source_5 => p_source_5
58038 , x_transaction_coa_id => l_adr_transaction_coa_id
58039 , x_accounting_coa_id => l_adr_accounting_coa_id
58040 , x_value_type_code => l_adr_value_type_code
58044 xla_ae_lines_pkg.set_ccid(
58041 , p_side => 'NA'
58042 );
58043
58045 p_code_combination_id => l_ccid
58046 , p_value_type_code => l_adr_value_type_code
58047 , p_transaction_coa_id => l_adr_transaction_coa_id
58048 , p_accounting_coa_id => l_adr_accounting_coa_id
58049 , p_adr_code => 'DIST_CCID'
58050 , p_adr_type_code => 'S'
58051 , p_component_type => l_component_type
58052 , p_component_code => l_component_code
58053 , p_component_type_code => l_component_type_code
58054 , p_component_appl_id => l_component_appl_id
58055 , p_amb_context_code => l_amb_context_code
58056 , p_side => 'NA'
58057 );
58058
58059
58060 --
58061 --
58062 END IF;
58063
58064 --
58065 -- Update the line information that should be overwritten
58066 --
58067 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
58068 p_header_num => 1);
58069 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
58070
58071 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
58072
58073 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
58074 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
58075 END IF;
58076
58077 --
58078 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
58079 --
58080 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
58081 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
58082 ELSE
58083 ---------------------------------------------------------------------------------------------------
58084 -- 4262811a Switch Sign
58085 ---------------------------------------------------------------------------------------------------
58086 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
58087 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
58088 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58089 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
58090 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58091 -- 5132302
58092 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
58093 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58094
58095 END IF;
58096
58097 -- 4955764
58098 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
58099 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
58100
58101
58102 XLA_AE_LINES_PKG.ValidateCurrentLine;
58103 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
58104
58105 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
58106 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
58107 ,p_balance_type_code => l_balance_type_code);
58108
58109 END IF;
58110
58111 -----------------------------------------------------------------------------------------
58112 -- 4262811 Multiperiod Accounting
58113 -----------------------------------------------------------------------------------------
58114 -- No MPA option is assigned.
58115
58116
58117 END IF;
58118 END IF;
58119 --
58120
58121 --
58122 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58123 trace
58124 (p_msg => 'END of AcctLineType_119'
58125 ,p_level => C_LEVEL_PROCEDURE
58126 ,p_module => l_log_module);
58127 END IF;
58128 --
58129 EXCEPTION
58130 WHEN xla_exceptions_pkg.application_exception THEN
58131 RAISE;
58132 WHEN OTHERS THEN
58133 xla_exceptions_pkg.raise_message
58134 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_119');
58135 END AcctLineType_119;
58136 --
58137
58138 ---------------------------------------
58139 --
58140 -- PRIVATE FUNCTION
58141 -- AcctLineType_120
58142 --
58143 ---------------------------------------
58144 PROCEDURE AcctLineType_120 (
58145 p_application_id IN NUMBER
58146 ,p_event_id IN NUMBER
58147 ,p_calculate_acctd_flag IN VARCHAR2
58148 ,p_calculate_g_l_flag IN VARCHAR2
58149 ,p_actual_flag IN OUT VARCHAR2
58150 ,p_balance_type_code OUT VARCHAR2
58151 ,p_gain_or_loss_ref OUT VARCHAR2
58152
58153 --Distribution GL Account
58154 , p_source_5 IN NUMBER
58155 --Distribution Source Type
58156 , p_source_20 IN VARCHAR2
58157 --Receivable Activity Type
58158 , p_source_21 IN VARCHAR2
58159 --Distribution Line Identifier
58160 , p_source_22 IN NUMBER
58161 --Distribution Type
58162 , p_source_23 IN VARCHAR2
58163 --Exchange Date
58164 , p_source_26 IN DATE
58165 --Exchange Rate
58166 , p_source_27 IN NUMBER
58167 --Exchange Rate Type
58168 , p_source_28 IN VARCHAR2
58169 --Applied To Document Accounting Amount
58170 , p_source_29 IN NUMBER
58171 --Transaction Distribution Identifier
58172 , p_source_34 IN NUMBER
58173 --Transaction Distribution Type
58174 , p_source_35 IN VARCHAR2
58175 --Receipt Applied To Application Identifier
58176 , p_source_58 IN NUMBER
58177 --Transaction Entity Code
58178 , p_source_59 IN VARCHAR2
58179 --Transaction Identifier
58180 , p_source_60 IN NUMBER
58181 --Applying Document Currency Code
58182 , p_source_61 IN VARCHAR2
58183 --Distribution Party Identifier
58184 , p_source_63 IN NUMBER
58185 --Distribution Party Site Id
58186 , p_source_64 IN NUMBER
58187 --Distribution Party Type
58188 , p_source_65 IN VARCHAR2
58189 --Distribution Multi Fund Additional Entry
58190 , p_source_67 IN VARCHAR2
58191 --DIST_ENT_AMT_FROM
58192 , p_source_68 IN NUMBER
58193 )
58194 IS
58195
58196 l_component_type VARCHAR2(80);
58197 l_component_code VARCHAR2(30);
58198 l_component_type_code VARCHAR2(1);
58199 l_component_appl_id INTEGER;
58200 l_amb_context_code VARCHAR2(30);
58201 l_entity_code VARCHAR2(30);
58202 l_event_class_code VARCHAR2(30);
58203 l_ae_header_id NUMBER;
58204 l_event_type_code VARCHAR2(30);
58205 l_line_definition_code VARCHAR2(30);
58206 l_line_definition_owner_code VARCHAR2(1);
58207 --
58208 -- adr variables
58209 l_segment VARCHAR2(30);
58210 l_ccid NUMBER;
58211 l_adr_transaction_coa_id NUMBER;
58212 l_adr_accounting_coa_id NUMBER;
58213 l_adr_flexfield_segment_code VARCHAR2(30);
58214 l_adr_flex_value_set_id NUMBER;
58215 l_adr_value_type_code VARCHAR2(30);
58216 l_adr_value_combination_id NUMBER;
58217 l_adr_value_segment_code VARCHAR2(30);
58218
58219 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
58220 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
58221 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
58222 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
58223
58224 -- 4262811 Variables ------------------------------------------------------------------------------------------
58225 l_entered_amt_idx NUMBER;
58226 l_accted_amt_idx NUMBER;
58227 l_acc_rev_flag VARCHAR2(1);
58228 l_accrual_line_num NUMBER;
58229 l_tmp_amt NUMBER;
58230 l_acc_rev_natural_side_code VARCHAR2(1);
58231
58232 l_num_entries NUMBER;
58233 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
58234 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
58235 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
58236 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
58237 l_recog_line_1 NUMBER;
58238 l_recog_line_2 NUMBER;
58239
58240 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
58241 l_bflow_applied_to_amt NUMBER; -- 5132302
58242 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
58243
58244 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
58245
58246 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
58247 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
58248
58249 ---------------------------------------------------------------------------------------------------------------
58250
58251
58252 --
58253 -- bulk performance
58254 --
58255 l_balance_type_code VARCHAR2(1);
58256 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
58257 l_log_module VARCHAR2(240);
58258
58259 --
58260 -- Upgrade strategy
58261 --
58262 l_actual_upg_option VARCHAR2(1);
58263 l_enc_upg_option VARCHAR2(1);
58264
58265 --
58266 BEGIN
58267 --
58268 IF g_log_enabled THEN
58269 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_120';
58270 END IF;
58271 --
58272 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58273
58274 trace
58275 (p_msg => 'BEGIN of AcctLineType_120'
58276 ,p_level => C_LEVEL_PROCEDURE
58277 ,p_module => l_log_module);
58278
58279 END IF;
58280 --
58281 l_component_type := 'AMB_JLT';
58285 l_amb_context_code := 'DEFAULT';
58282 l_component_code := 'RCT_PMT_NET';
58283 l_component_type_code := 'S';
58284 l_component_appl_id := 222;
58286 l_entity_code := 'RECEIPTS';
58287 l_event_class_code := 'RECEIPT';
58288 l_event_type_code := 'RECEIPT_ALL';
58289 l_line_definition_owner_code := 'S';
58290 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
58291 --
58292 l_balance_type_code := 'A';
58293 l_segment := NULL;
58294 l_ccid := NULL;
58295 l_adr_transaction_coa_id := NULL;
58296 l_adr_accounting_coa_id := NULL;
58297 l_adr_flexfield_segment_code := NULL;
58298 l_adr_flex_value_set_id := NULL;
58299 l_adr_value_type_code := NULL;
58300 l_adr_value_combination_id := NULL;
58301 l_adr_value_segment_code := NULL;
58302
58303 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
58304 l_bflow_class_code := ''; -- 4219869 Business Flow
58305 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
58306 l_budgetary_control_flag := 'N';
58307
58308 l_bflow_applied_to_amt_idx := NULL; -- 5132302
58309 l_bflow_applied_to_amt := NULL; -- 5132302
58310 l_entered_amt_idx := NULL; -- 4262811
58311 l_accted_amt_idx := NULL; -- 4262811
58312 l_acc_rev_flag := NULL; -- 4262811
58313 l_accrual_line_num := NULL; -- 4262811
58314 l_tmp_amt := NULL; -- 4262811
58315 --
58316
58317 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
58318 l_balance_type_code <> 'B' THEN
58319 IF (NVL(p_source_20,'
58320 ') = 'OTHER_ACC' OR
58321 NVL(p_source_20,'
58322 ') = 'ACTIVITY') AND
58323 NVL(p_source_21,'
58324 ') = 'NETTING' AND
58325 NVL(p_source_67,'
58326 ') = 'N'
58327 THEN
58328
58329 --
58330 XLA_AE_LINES_PKG.SetNewLine;
58331
58332 p_balance_type_code := l_balance_type_code;
58333 -- set the flag so later we will know whether the gain loss line needs to be created
58334
58335 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
58336 p_actual_flag :='A';
58337 END IF;
58338
58339 --
58340 -- bulk performance
58341 --
58342 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
58343 p_header_num => 0); -- 4262811
58344 --
58345 -- set accounting line options
58346 --
58347 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
58348 p_natural_side_code => 'C'
58349 , p_gain_or_loss_flag => 'N'
58350 , p_gl_transfer_mode_code => 'S'
58351 , p_acct_entry_type_code => 'A'
58352 , p_switch_side_flag => 'Y'
58353 , p_merge_duplicate_code => 'A'
58354 );
58355 --
58356 l_acc_rev_natural_side_code := 'D'; -- 4262811
58357 --
58358 --
58359 -- set accounting line type info
58360 --
58361 xla_ae_lines_pkg.SetAcctLineType
58362 (p_component_type => l_component_type
58363 ,p_event_type_code => l_event_type_code
58364 ,p_line_definition_owner_code => l_line_definition_owner_code
58365 ,p_line_definition_code => l_line_definition_code
58366 ,p_accounting_line_code => l_component_code
58367 ,p_accounting_line_type_code => l_component_type_code
58368 ,p_accounting_line_appl_id => l_component_appl_id
58369 ,p_amb_context_code => l_amb_context_code
58370 ,p_entity_code => l_entity_code
58371 ,p_event_class_code => l_event_class_code);
58372 --
58373 -- set accounting class
58374 --
58375 xla_ae_lines_pkg.SetAcctClass(
58376 p_accounting_class_code => 'PMT_NET'
58377 , p_ae_header_id => l_ae_header_id
58378 );
58379
58380 --
58381 -- set rounding class
58382 --
58383 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
58384 'RECEIVABLE';
58385
58386 --
58387 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
58388 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
58389 --
58390 -- bulk performance
58391 --
58392 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
58393
58394 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
58395 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
58396
58397 -- 4955764
58398 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
58399 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
58400
58401 -- 4458381 Public Sector Enh
58402
58403 --
58404 -- set accounting attributes for the line type
58405 --
58406 l_entered_amt_idx := 8;
58407 l_accted_amt_idx := 13;
58408 l_bflow_applied_to_amt_idx := NULL; -- 5132302
58409 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
58410 l_rec_acct_attrs.array_num_value(1) := p_source_58;
58411 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
58412 l_rec_acct_attrs.array_char_value(2) := p_source_35;
58413 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
58414 l_rec_acct_attrs.array_char_value(3) := p_source_59;
58415 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
58416 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
58417 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
58418 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
58419 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
58420 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
58421 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
58422 l_rec_acct_attrs.array_char_value(7) := p_source_23;
58423 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
58424 l_rec_acct_attrs.array_num_value(8) := p_source_68;
58425 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
58426 l_rec_acct_attrs.array_char_value(9) := p_source_61;
58427 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
58428 l_rec_acct_attrs.array_date_value(10) := p_source_26;
58429 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
58430 l_rec_acct_attrs.array_num_value(11) := p_source_27;
58431 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
58432 l_rec_acct_attrs.array_char_value(12) := p_source_28;
58433 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
58434 l_rec_acct_attrs.array_num_value(13) := p_source_29;
58435 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
58436 l_rec_acct_attrs.array_num_value(14) := p_source_63;
58437 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
58438 l_rec_acct_attrs.array_num_value(15) := p_source_64;
58439 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
58440 l_rec_acct_attrs.array_char_value(16) := p_source_65;
58441
58442 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
58443 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
58444
58445 ---------------------------------------------------------------------------------------------------------------
58446 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
58447 ---------------------------------------------------------------------------------------------------------------
58448 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
58449
58450 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
58451 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
58452
58453 IF xla_accounting_cache_pkg.GetValueChar
58454 (p_source_code => 'LEDGER_CATEGORY_CODE'
58455 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
58456 AND l_bflow_method_code = 'PRIOR_ENTRY'
58457 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
58458 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
58459 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
58460 )
58461 THEN
58462 xla_ae_lines_pkg.BflowUpgEntry
58463 (p_business_method_code => l_bflow_method_code
58464 ,p_business_class_code => l_bflow_class_code
58465 ,p_balance_type => l_balance_type_code);
58466 ELSE
58467 NULL;
58471 --
58468 -- No business flow processing for business flow method of NONE.
58469 END IF;
58470
58472 -- call analytical criteria
58473 --
58474
58475 --
58476 -- call description
58477 --
58478 -- No description or it is inherited.
58479 --
58480 -- call ADRs
58481 -- Bug 4922099
58482 --
58483 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
58484 (NVL(l_actual_upg_option, 'N') = 'O') OR
58485 (NVL(l_enc_upg_option, 'N') = 'O')
58486 )
58487 THEN
58488 NULL;
58489 --
58490 --
58491
58492 l_ccid := AcctDerRule_4(
58493 p_application_id => p_application_id
58494 , p_ae_header_id => l_ae_header_id
58495 , p_source_5 => p_source_5
58496 , x_transaction_coa_id => l_adr_transaction_coa_id
58497 , x_accounting_coa_id => l_adr_accounting_coa_id
58498 , x_value_type_code => l_adr_value_type_code
58499 , p_side => 'NA'
58500 );
58501
58502 xla_ae_lines_pkg.set_ccid(
58503 p_code_combination_id => l_ccid
58504 , p_value_type_code => l_adr_value_type_code
58505 , p_transaction_coa_id => l_adr_transaction_coa_id
58506 , p_accounting_coa_id => l_adr_accounting_coa_id
58507 , p_adr_code => 'DIST_CCID'
58508 , p_adr_type_code => 'S'
58509 , p_component_type => l_component_type
58510 , p_component_code => l_component_code
58511 , p_component_type_code => l_component_type_code
58512 , p_component_appl_id => l_component_appl_id
58513 , p_amb_context_code => l_amb_context_code
58514 , p_side => 'NA'
58515 );
58516
58517
58518 --
58519 --
58520 END IF;
58521 --
58522 -- Bug 4922099
58523 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
58524 (NVL(l_enc_upg_option, 'N') = 'O')
58525 ) AND
58526 (l_bflow_method_code = 'PRIOR_ENTRY')
58527 )
58528 THEN
58529 IF
58530 --
58531 1 = 2
58532 --
58533 THEN
58534 xla_accounting_err_pkg.build_message
58535 (p_appli_s_name => 'XLA'
58536 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
58537 ,p_token_1 => 'LINE_NUMBER'
58538 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
58539 ,p_token_2 => 'LINE_TYPE_NAME'
58540 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
58541 l_component_type
58542 ,l_component_code
58543 ,l_component_type_code
58544 ,l_component_appl_id
58545 ,l_amb_context_code
58546 ,l_entity_code
58547 ,l_event_class_code
58548 )
58549 ,p_token_3 => 'OWNER'
58550 ,p_value_3 => xla_lookups_pkg.get_meaning(
58551 p_lookup_type => 'XLA_OWNER_TYPE'
58552 ,p_lookup_code => l_component_type_code
58553 )
58554 ,p_token_4 => 'PRODUCT_NAME'
58555 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
58556 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
58557 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
58558 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
58559 ,p_ae_header_id => NULL
58560 );
58561
58562 IF (C_LEVEL_ERROR>= g_log_level) THEN
58563 trace
58564 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
58565 ,p_level => C_LEVEL_ERROR
58566 ,p_module => l_log_module);
58567 END IF;
58568 END IF;
58569 END IF;
58570 --
58571 --
58572 ------------------------------------------------------------------------------------------------
58573 -- 4219869 Business Flow
58574 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
58575 -- Prior Entry. Currently, the following code is always generated.
58576 ------------------------------------------------------------------------------------------------
58577 XLA_AE_LINES_PKG.ValidateCurrentLine;
58578
58579 ------------------------------------------------------------------------------------
58580 -- 4219869 Business Flow
58581 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
58582 ------------------------------------------------------------------------------------
58586 -- 4219869 Business Flow
58583 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
58584
58585 ----------------------------------------------------------------------------------
58587 -- Update journal entry status -- Need to generate this within IF <condition>
58588 ----------------------------------------------------------------------------------
58589 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
58590 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
58591 ,p_balance_type_code => l_balance_type_code
58592 );
58593
58594 -------------------------------------------------------------------------------------------
58595 -- 4262811 - Generate the Accrual Reversal lines
58596 -------------------------------------------------------------------------------------------
58597 BEGIN
58598 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
58599 (g_array_event(p_event_id).array_value_num('header_index'));
58600 IF l_acc_rev_flag IS NULL THEN
58601 l_acc_rev_flag := 'N';
58602 END IF;
58603 EXCEPTION
58604 WHEN OTHERS THEN
58605 l_acc_rev_flag := 'N';
58606 END;
58607 --
58608 IF (l_acc_rev_flag = 'Y') THEN
58609
58610 -- 4645092 ------------------------------------------------------------------------------
58611 -- To allow MPA report to determine if it should generate report process
58612 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
58613 ------------------------------------------------------------------------------------------
58614
58615 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
58616 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
58617 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
58618 -- call ADRs
58619 -- Bug 4922099
58620 --
58621 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
58622 (NVL(l_actual_upg_option, 'N') = 'O') OR
58623 (NVL(l_enc_upg_option, 'N') = 'O')
58624 )
58625 THEN
58626 NULL;
58627 --
58628 --
58629
58630 l_ccid := AcctDerRule_4(
58631 p_application_id => p_application_id
58632 , p_ae_header_id => l_ae_header_id
58633 , p_source_5 => p_source_5
58634 , x_transaction_coa_id => l_adr_transaction_coa_id
58635 , x_accounting_coa_id => l_adr_accounting_coa_id
58636 , x_value_type_code => l_adr_value_type_code
58637 , p_side => 'NA'
58638 );
58639
58640 xla_ae_lines_pkg.set_ccid(
58641 p_code_combination_id => l_ccid
58642 , p_value_type_code => l_adr_value_type_code
58643 , p_transaction_coa_id => l_adr_transaction_coa_id
58644 , p_accounting_coa_id => l_adr_accounting_coa_id
58645 , p_adr_code => 'DIST_CCID'
58646 , p_adr_type_code => 'S'
58647 , p_component_type => l_component_type
58648 , p_component_code => l_component_code
58649 , p_component_type_code => l_component_type_code
58650 , p_component_appl_id => l_component_appl_id
58651 , p_amb_context_code => l_amb_context_code
58652 , p_side => 'NA'
58653 );
58654
58655
58656 --
58657 --
58658 END IF;
58659
58660 --
58661 -- Update the line information that should be overwritten
58662 --
58663 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
58664 p_header_num => 1);
58665 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
58666
58667 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
58668
58669 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
58670 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
58671 END IF;
58672
58673 --
58674 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
58675 --
58676 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
58677 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
58678 ELSE
58679 ---------------------------------------------------------------------------------------------------
58680 -- 4262811a Switch Sign
58681 ---------------------------------------------------------------------------------------------------
58682 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
58683 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
58684 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58685 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
58686 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58687 -- 5132302
58688 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
58689 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
58690
58691 END IF;
58692
58693 -- 4955764
58694 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
58698 XLA_AE_LINES_PKG.ValidateCurrentLine;
58695 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
58696
58697
58699 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
58700
58701 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
58702 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
58703 ,p_balance_type_code => l_balance_type_code);
58704
58705 END IF;
58706
58707 -----------------------------------------------------------------------------------------
58708 -- 4262811 Multiperiod Accounting
58709 -----------------------------------------------------------------------------------------
58710 -- No MPA option is assigned.
58711
58712
58713 END IF;
58714 END IF;
58715 --
58716
58717 --
58718 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58719 trace
58720 (p_msg => 'END of AcctLineType_120'
58721 ,p_level => C_LEVEL_PROCEDURE
58722 ,p_module => l_log_module);
58723 END IF;
58724 --
58725 EXCEPTION
58726 WHEN xla_exceptions_pkg.application_exception THEN
58727 RAISE;
58728 WHEN OTHERS THEN
58729 xla_exceptions_pkg.raise_message
58730 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_120');
58731 END AcctLineType_120;
58732 --
58733
58734 ---------------------------------------
58735 --
58736 -- PRIVATE FUNCTION
58737 -- AcctLineType_121
58738 --
58739 ---------------------------------------
58740 PROCEDURE AcctLineType_121 (
58741 p_application_id IN NUMBER
58742 ,p_event_id IN NUMBER
58743 ,p_calculate_acctd_flag IN VARCHAR2
58744 ,p_calculate_g_l_flag IN VARCHAR2
58745 ,p_actual_flag IN OUT VARCHAR2
58746 ,p_balance_type_code OUT VARCHAR2
58747 ,p_gain_or_loss_ref OUT VARCHAR2
58748
58749 --Distribution GL Account
58750 , p_source_5 IN NUMBER
58751 --Distribution Source Type
58752 , p_source_20 IN VARCHAR2
58753 --Receivable Activity Type
58754 , p_source_21 IN VARCHAR2
58755 --Distribution Line Identifier
58756 , p_source_22 IN NUMBER
58757 --Distribution Type
58758 , p_source_23 IN VARCHAR2
58759 --Exchange Date
58760 , p_source_26 IN DATE
58761 --Exchange Rate
58762 , p_source_27 IN NUMBER
58763 --Exchange Rate Type
58764 , p_source_28 IN VARCHAR2
58765 --Transaction Distribution Identifier
58766 , p_source_34 IN NUMBER
58767 --Transaction Distribution Type
58768 , p_source_35 IN VARCHAR2
58769 --Receipt Applied To Application Identifier
58770 , p_source_58 IN NUMBER
58771 --Transaction Entity Code
58772 , p_source_59 IN VARCHAR2
58773 --Transaction Identifier
58774 , p_source_60 IN NUMBER
58775 --Applying Document Currency Code
58776 , p_source_61 IN VARCHAR2
58777 --Distribution Party Identifier
58778 , p_source_63 IN NUMBER
58779 --Distribution Party Site Id
58780 , p_source_64 IN NUMBER
58781 --Distribution Party Type
58782 , p_source_65 IN VARCHAR2
58783 --Distribution Multi Fund Additional Entry
58784 , p_source_67 IN VARCHAR2
58785 --DIST_ENT_AMT_FROM
58786 , p_source_68 IN NUMBER
58787 --Accounting Amount
58788 , p_source_69 IN NUMBER
58789 )
58790 IS
58791
58792 l_component_type VARCHAR2(80);
58793 l_component_code VARCHAR2(30);
58794 l_component_type_code VARCHAR2(1);
58795 l_component_appl_id INTEGER;
58796 l_amb_context_code VARCHAR2(30);
58797 l_entity_code VARCHAR2(30);
58798 l_event_class_code VARCHAR2(30);
58799 l_ae_header_id NUMBER;
58800 l_event_type_code VARCHAR2(30);
58801 l_line_definition_code VARCHAR2(30);
58802 l_line_definition_owner_code VARCHAR2(1);
58803 --
58804 -- adr variables
58805 l_segment VARCHAR2(30);
58806 l_ccid NUMBER;
58807 l_adr_transaction_coa_id NUMBER;
58808 l_adr_accounting_coa_id NUMBER;
58809 l_adr_flexfield_segment_code VARCHAR2(30);
58810 l_adr_flex_value_set_id NUMBER;
58811 l_adr_value_type_code VARCHAR2(30);
58812 l_adr_value_combination_id NUMBER;
58813 l_adr_value_segment_code VARCHAR2(30);
58814
58815 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
58816 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
58817 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
58818 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
58819
58820 -- 4262811 Variables ------------------------------------------------------------------------------------------
58821 l_entered_amt_idx NUMBER;
58822 l_accted_amt_idx NUMBER;
58823 l_acc_rev_flag VARCHAR2(1);
58824 l_accrual_line_num NUMBER;
58825 l_tmp_amt NUMBER;
58826 l_acc_rev_natural_side_code VARCHAR2(1);
58827
58828 l_num_entries NUMBER;
58829 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
58830 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
58831 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
58832 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
58833 l_recog_line_1 NUMBER;
58834 l_recog_line_2 NUMBER;
58835
58836 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
58840 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
58837 l_bflow_applied_to_amt NUMBER; -- 5132302
58838 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
58839
58841
58842 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
58843 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
58844
58845 ---------------------------------------------------------------------------------------------------------------
58846
58847
58848 --
58849 -- bulk performance
58850 --
58851 l_balance_type_code VARCHAR2(1);
58852 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
58853 l_log_module VARCHAR2(240);
58854
58855 --
58856 -- Upgrade strategy
58857 --
58858 l_actual_upg_option VARCHAR2(1);
58859 l_enc_upg_option VARCHAR2(1);
58860
58861 --
58862 BEGIN
58863 --
58864 IF g_log_enabled THEN
58865 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_121';
58866 END IF;
58867 --
58868 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
58869
58870 trace
58871 (p_msg => 'BEGIN of AcctLineType_121'
58872 ,p_level => C_LEVEL_PROCEDURE
58873 ,p_module => l_log_module);
58874
58875 END IF;
58876 --
58877 l_component_type := 'AMB_JLT';
58878 l_component_code := 'RCT_PREPAYMENT';
58879 l_component_type_code := 'S';
58880 l_component_appl_id := 222;
58881 l_amb_context_code := 'DEFAULT';
58882 l_entity_code := 'RECEIPTS';
58883 l_event_class_code := 'RECEIPT';
58884 l_event_type_code := 'RECEIPT_ALL';
58885 l_line_definition_owner_code := 'S';
58886 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
58887 --
58888 l_balance_type_code := 'A';
58889 l_segment := NULL;
58890 l_ccid := NULL;
58891 l_adr_transaction_coa_id := NULL;
58892 l_adr_accounting_coa_id := NULL;
58893 l_adr_flexfield_segment_code := NULL;
58894 l_adr_flex_value_set_id := NULL;
58895 l_adr_value_type_code := NULL;
58896 l_adr_value_combination_id := NULL;
58897 l_adr_value_segment_code := NULL;
58898
58899 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
58900 l_bflow_class_code := ''; -- 4219869 Business Flow
58901 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
58902 l_budgetary_control_flag := 'N';
58903
58904 l_bflow_applied_to_amt_idx := NULL; -- 5132302
58905 l_bflow_applied_to_amt := NULL; -- 5132302
58906 l_entered_amt_idx := NULL; -- 4262811
58907 l_accted_amt_idx := NULL; -- 4262811
58908 l_acc_rev_flag := NULL; -- 4262811
58909 l_accrual_line_num := NULL; -- 4262811
58910 l_tmp_amt := NULL; -- 4262811
58911 --
58912
58913 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
58914 l_balance_type_code <> 'B' THEN
58915 IF NVL(p_source_20,'
58916 ') = 'OTHER ACC' AND
58917 NVL(p_source_21,'
58918 ') = 'PREPAYMENT' AND
58919 NVL(p_source_67,'
58920 ') = 'N'
58921 THEN
58922
58923 --
58924 XLA_AE_LINES_PKG.SetNewLine;
58925
58926 p_balance_type_code := l_balance_type_code;
58927 -- set the flag so later we will know whether the gain loss line needs to be created
58928
58929 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
58930 p_actual_flag :='A';
58931 END IF;
58932
58933 --
58934 -- bulk performance
58935 --
58936 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
58937 p_header_num => 0); -- 4262811
58938 --
58939 -- set accounting line options
58940 --
58941 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
58942 p_natural_side_code => 'C'
58943 , p_gain_or_loss_flag => 'N'
58944 , p_gl_transfer_mode_code => 'S'
58945 , p_acct_entry_type_code => 'A'
58946 , p_switch_side_flag => 'Y'
58947 , p_merge_duplicate_code => 'A'
58948 );
58949 --
58950 l_acc_rev_natural_side_code := 'D'; -- 4262811
58951 --
58952 --
58953 -- set accounting line type info
58954 --
58955 xla_ae_lines_pkg.SetAcctLineType
58956 (p_component_type => l_component_type
58957 ,p_event_type_code => l_event_type_code
58958 ,p_line_definition_owner_code => l_line_definition_owner_code
58959 ,p_line_definition_code => l_line_definition_code
58960 ,p_accounting_line_code => l_component_code
58961 ,p_accounting_line_type_code => l_component_type_code
58962 ,p_accounting_line_appl_id => l_component_appl_id
58963 ,p_amb_context_code => l_amb_context_code
58964 ,p_entity_code => l_entity_code
58965 ,p_event_class_code => l_event_class_code);
58966 --
58967 -- set accounting class
58968 --
58969 xla_ae_lines_pkg.SetAcctClass(
58970 p_accounting_class_code => 'PREPAY'
58971 , p_ae_header_id => l_ae_header_id
58972 );
58973
58974 --
58975 -- set rounding class
58976 --
58977 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
58978 'RECEIVABLE';
58979
58980 --
58984 -- bulk performance
58981 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
58982 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
58983 --
58985 --
58986 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
58987
58988 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
58989 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
58990
58991 -- 4955764
58992 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
58993 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
58994
58995 -- 4458381 Public Sector Enh
58996
58997 --
58998 -- set accounting attributes for the line type
58999 --
59000 l_entered_amt_idx := 8;
59001 l_accted_amt_idx := 13;
59002 l_bflow_applied_to_amt_idx := NULL; -- 5132302
59003 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
59004 l_rec_acct_attrs.array_num_value(1) := p_source_58;
59005 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
59006 l_rec_acct_attrs.array_char_value(2) := p_source_35;
59007 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
59008 l_rec_acct_attrs.array_char_value(3) := p_source_59;
59009 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
59010 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
59011 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
59012 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
59013 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
59014 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
59015 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
59016 l_rec_acct_attrs.array_char_value(7) := p_source_23;
59017 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
59018 l_rec_acct_attrs.array_num_value(8) := p_source_68;
59019 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
59020 l_rec_acct_attrs.array_char_value(9) := p_source_61;
59021 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
59022 l_rec_acct_attrs.array_date_value(10) := p_source_26;
59023 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
59024 l_rec_acct_attrs.array_num_value(11) := p_source_27;
59025 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
59026 l_rec_acct_attrs.array_char_value(12) := p_source_28;
59027 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
59028 l_rec_acct_attrs.array_num_value(13) := p_source_69;
59029 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
59030 l_rec_acct_attrs.array_num_value(14) := p_source_63;
59031 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
59032 l_rec_acct_attrs.array_num_value(15) := p_source_64;
59033 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
59034 l_rec_acct_attrs.array_char_value(16) := p_source_65;
59035
59036 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
59037 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
59038
59039 ---------------------------------------------------------------------------------------------------------------
59040 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
59041 ---------------------------------------------------------------------------------------------------------------
59042 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
59043
59044 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59045 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59046
59047 IF xla_accounting_cache_pkg.GetValueChar
59048 (p_source_code => 'LEDGER_CATEGORY_CODE'
59049 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
59050 AND l_bflow_method_code = 'PRIOR_ENTRY'
59051 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
59052 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
59053 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
59054 )
59055 THEN
59056 xla_ae_lines_pkg.BflowUpgEntry
59057 (p_business_method_code => l_bflow_method_code
59058 ,p_business_class_code => l_bflow_class_code
59059 ,p_balance_type => l_balance_type_code);
59060 ELSE
59061 NULL;
59062 -- No business flow processing for business flow method of NONE.
59063 END IF;
59064
59065 --
59066 -- call analytical criteria
59067 --
59068
59069 --
59070 -- call description
59071 --
59072 -- No description or it is inherited.
59073 --
59074 -- call ADRs
59075 -- Bug 4922099
59076 --
59077 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
59078 (NVL(l_actual_upg_option, 'N') = 'O') OR
59079 (NVL(l_enc_upg_option, 'N') = 'O')
59080 )
59081 THEN
59082 NULL;
59083 --
59084 --
59085
59086 l_ccid := AcctDerRule_4(
59087 p_application_id => p_application_id
59088 , p_ae_header_id => l_ae_header_id
59089 , p_source_5 => p_source_5
59090 , x_transaction_coa_id => l_adr_transaction_coa_id
59091 , x_accounting_coa_id => l_adr_accounting_coa_id
59092 , x_value_type_code => l_adr_value_type_code
59096 xla_ae_lines_pkg.set_ccid(
59093 , p_side => 'NA'
59094 );
59095
59097 p_code_combination_id => l_ccid
59098 , p_value_type_code => l_adr_value_type_code
59099 , p_transaction_coa_id => l_adr_transaction_coa_id
59100 , p_accounting_coa_id => l_adr_accounting_coa_id
59101 , p_adr_code => 'DIST_CCID'
59102 , p_adr_type_code => 'S'
59103 , p_component_type => l_component_type
59104 , p_component_code => l_component_code
59105 , p_component_type_code => l_component_type_code
59106 , p_component_appl_id => l_component_appl_id
59107 , p_amb_context_code => l_amb_context_code
59108 , p_side => 'NA'
59109 );
59110
59111
59112 --
59113 --
59114 END IF;
59115 --
59116 -- Bug 4922099
59117 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
59118 (NVL(l_enc_upg_option, 'N') = 'O')
59119 ) AND
59120 (l_bflow_method_code = 'PRIOR_ENTRY')
59121 )
59122 THEN
59123 IF
59124 --
59125 1 = 2
59126 --
59127 THEN
59128 xla_accounting_err_pkg.build_message
59129 (p_appli_s_name => 'XLA'
59130 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
59131 ,p_token_1 => 'LINE_NUMBER'
59132 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
59133 ,p_token_2 => 'LINE_TYPE_NAME'
59134 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
59135 l_component_type
59136 ,l_component_code
59137 ,l_component_type_code
59138 ,l_component_appl_id
59139 ,l_amb_context_code
59140 ,l_entity_code
59141 ,l_event_class_code
59142 )
59143 ,p_token_3 => 'OWNER'
59144 ,p_value_3 => xla_lookups_pkg.get_meaning(
59145 p_lookup_type => 'XLA_OWNER_TYPE'
59146 ,p_lookup_code => l_component_type_code
59147 )
59148 ,p_token_4 => 'PRODUCT_NAME'
59149 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
59150 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
59151 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
59152 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
59153 ,p_ae_header_id => NULL
59154 );
59155
59156 IF (C_LEVEL_ERROR>= g_log_level) THEN
59157 trace
59158 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
59159 ,p_level => C_LEVEL_ERROR
59160 ,p_module => l_log_module);
59161 END IF;
59162 END IF;
59163 END IF;
59164 --
59165 --
59166 ------------------------------------------------------------------------------------------------
59167 -- 4219869 Business Flow
59168 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
59169 -- Prior Entry. Currently, the following code is always generated.
59170 ------------------------------------------------------------------------------------------------
59171 XLA_AE_LINES_PKG.ValidateCurrentLine;
59172
59173 ------------------------------------------------------------------------------------
59174 -- 4219869 Business Flow
59175 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
59176 ------------------------------------------------------------------------------------
59177 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
59178
59179 ----------------------------------------------------------------------------------
59180 -- 4219869 Business Flow
59181 -- Update journal entry status -- Need to generate this within IF <condition>
59182 ----------------------------------------------------------------------------------
59183 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
59184 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
59185 ,p_balance_type_code => l_balance_type_code
59186 );
59187
59188 -------------------------------------------------------------------------------------------
59189 -- 4262811 - Generate the Accrual Reversal lines
59190 -------------------------------------------------------------------------------------------
59191 BEGIN
59192 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
59193 (g_array_event(p_event_id).array_value_num('header_index'));
59194 IF l_acc_rev_flag IS NULL THEN
59195 l_acc_rev_flag := 'N';
59199 l_acc_rev_flag := 'N';
59196 END IF;
59197 EXCEPTION
59198 WHEN OTHERS THEN
59200 END;
59201 --
59202 IF (l_acc_rev_flag = 'Y') THEN
59203
59204 -- 4645092 ------------------------------------------------------------------------------
59205 -- To allow MPA report to determine if it should generate report process
59206 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
59207 ------------------------------------------------------------------------------------------
59208
59209 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
59210 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
59211 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
59212 -- call ADRs
59213 -- Bug 4922099
59214 --
59215 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
59216 (NVL(l_actual_upg_option, 'N') = 'O') OR
59217 (NVL(l_enc_upg_option, 'N') = 'O')
59218 )
59219 THEN
59220 NULL;
59221 --
59222 --
59223
59224 l_ccid := AcctDerRule_4(
59225 p_application_id => p_application_id
59226 , p_ae_header_id => l_ae_header_id
59227 , p_source_5 => p_source_5
59228 , x_transaction_coa_id => l_adr_transaction_coa_id
59229 , x_accounting_coa_id => l_adr_accounting_coa_id
59230 , x_value_type_code => l_adr_value_type_code
59231 , p_side => 'NA'
59232 );
59233
59234 xla_ae_lines_pkg.set_ccid(
59235 p_code_combination_id => l_ccid
59236 , p_value_type_code => l_adr_value_type_code
59237 , p_transaction_coa_id => l_adr_transaction_coa_id
59238 , p_accounting_coa_id => l_adr_accounting_coa_id
59239 , p_adr_code => 'DIST_CCID'
59240 , p_adr_type_code => 'S'
59241 , p_component_type => l_component_type
59242 , p_component_code => l_component_code
59243 , p_component_type_code => l_component_type_code
59244 , p_component_appl_id => l_component_appl_id
59245 , p_amb_context_code => l_amb_context_code
59246 , p_side => 'NA'
59247 );
59248
59249
59250 --
59251 --
59252 END IF;
59253
59254 --
59255 -- Update the line information that should be overwritten
59256 --
59257 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
59258 p_header_num => 1);
59259 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
59260
59261 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
59262
59263 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
59264 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
59265 END IF;
59266
59267 --
59268 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
59269 --
59270 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
59271 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
59272 ELSE
59273 ---------------------------------------------------------------------------------------------------
59274 -- 4262811a Switch Sign
59275 ---------------------------------------------------------------------------------------------------
59276 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
59277 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
59278 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59279 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
59280 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59281 -- 5132302
59282 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
59283 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59284
59285 END IF;
59286
59287 -- 4955764
59288 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
59289 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
59290
59291
59292 XLA_AE_LINES_PKG.ValidateCurrentLine;
59293 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
59294
59295 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
59296 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
59297 ,p_balance_type_code => l_balance_type_code);
59298
59299 END IF;
59300
59301 -----------------------------------------------------------------------------------------
59302 -- 4262811 Multiperiod Accounting
59303 -----------------------------------------------------------------------------------------
59304 -- No MPA option is assigned.
59305
59306
59307 END IF;
59308 END IF;
59309 --
59310
59311 --
59312 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59313 trace
59314 (p_msg => 'END of AcctLineType_121'
59315 ,p_level => C_LEVEL_PROCEDURE
59316 ,p_module => l_log_module);
59317 END IF;
59318 --
59319 EXCEPTION
59320 WHEN xla_exceptions_pkg.application_exception THEN
59321 RAISE;
59325 END AcctLineType_121;
59322 WHEN OTHERS THEN
59323 xla_exceptions_pkg.raise_message
59324 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_121');
59326 --
59327
59328 ---------------------------------------
59329 --
59330 -- PRIVATE FUNCTION
59331 -- AcctLineType_122
59332 --
59333 ---------------------------------------
59334 PROCEDURE AcctLineType_122 (
59335 p_application_id IN NUMBER
59336 ,p_event_id IN NUMBER
59337 ,p_calculate_acctd_flag IN VARCHAR2
59338 ,p_calculate_g_l_flag IN VARCHAR2
59339 ,p_actual_flag IN OUT VARCHAR2
59340 ,p_balance_type_code OUT VARCHAR2
59341 ,p_gain_or_loss_ref OUT VARCHAR2
59342
59343 --Distribution GL Account
59344 , p_source_5 IN NUMBER
59345 --Distribution Source Type
59346 , p_source_20 IN VARCHAR2
59347 --Receivable Activity Type
59348 , p_source_21 IN VARCHAR2
59349 --Distribution Line Identifier
59350 , p_source_22 IN NUMBER
59351 --Distribution Type
59352 , p_source_23 IN VARCHAR2
59353 --Exchange Date
59354 , p_source_26 IN DATE
59355 --Exchange Rate
59356 , p_source_27 IN NUMBER
59357 --Exchange Rate Type
59358 , p_source_28 IN VARCHAR2
59359 --Transaction Distribution Identifier
59360 , p_source_34 IN NUMBER
59361 --Transaction Distribution Type
59362 , p_source_35 IN VARCHAR2
59363 --Receipt Applied To Application Identifier
59364 , p_source_58 IN NUMBER
59365 --Transaction Entity Code
59366 , p_source_59 IN VARCHAR2
59367 --Transaction Identifier
59368 , p_source_60 IN NUMBER
59369 --Applying Document Currency Code
59370 , p_source_61 IN VARCHAR2
59371 --Distribution Party Identifier
59372 , p_source_63 IN NUMBER
59373 --Distribution Party Site Id
59374 , p_source_64 IN NUMBER
59375 --Distribution Party Type
59376 , p_source_65 IN VARCHAR2
59377 --Distribution Multi Fund Additional Entry
59378 , p_source_67 IN VARCHAR2
59379 --DIST_ENT_AMT_FROM
59380 , p_source_68 IN NUMBER
59381 --Accounting Amount
59382 , p_source_69 IN NUMBER
59383 )
59384 IS
59385
59386 l_component_type VARCHAR2(80);
59387 l_component_code VARCHAR2(30);
59388 l_component_type_code VARCHAR2(1);
59389 l_component_appl_id INTEGER;
59390 l_amb_context_code VARCHAR2(30);
59391 l_entity_code VARCHAR2(30);
59392 l_event_class_code VARCHAR2(30);
59393 l_ae_header_id NUMBER;
59394 l_event_type_code VARCHAR2(30);
59395 l_line_definition_code VARCHAR2(30);
59396 l_line_definition_owner_code VARCHAR2(1);
59397 --
59398 -- adr variables
59399 l_segment VARCHAR2(30);
59400 l_ccid NUMBER;
59401 l_adr_transaction_coa_id NUMBER;
59402 l_adr_accounting_coa_id NUMBER;
59403 l_adr_flexfield_segment_code VARCHAR2(30);
59404 l_adr_flex_value_set_id NUMBER;
59405 l_adr_value_type_code VARCHAR2(30);
59406 l_adr_value_combination_id NUMBER;
59407 l_adr_value_segment_code VARCHAR2(30);
59408
59409 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
59410 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
59411 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
59412 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
59413
59414 -- 4262811 Variables ------------------------------------------------------------------------------------------
59415 l_entered_amt_idx NUMBER;
59416 l_accted_amt_idx NUMBER;
59417 l_acc_rev_flag VARCHAR2(1);
59418 l_accrual_line_num NUMBER;
59419 l_tmp_amt NUMBER;
59420 l_acc_rev_natural_side_code VARCHAR2(1);
59421
59422 l_num_entries NUMBER;
59423 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
59424 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
59425 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
59426 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
59427 l_recog_line_1 NUMBER;
59428 l_recog_line_2 NUMBER;
59429
59430 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
59431 l_bflow_applied_to_amt NUMBER; -- 5132302
59432 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
59433
59434 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
59435
59436 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
59437 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
59438
59439 ---------------------------------------------------------------------------------------------------------------
59440
59441
59442 --
59443 -- bulk performance
59444 --
59445 l_balance_type_code VARCHAR2(1);
59446 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
59447 l_log_module VARCHAR2(240);
59448
59449 --
59450 -- Upgrade strategy
59451 --
59452 l_actual_upg_option VARCHAR2(1);
59453 l_enc_upg_option VARCHAR2(1);
59454
59455 --
59456 BEGIN
59457 --
59458 IF g_log_enabled THEN
59459 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_122';
59460 END IF;
59461 --
59462 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59463
59464 trace
59468
59465 (p_msg => 'BEGIN of AcctLineType_122'
59466 ,p_level => C_LEVEL_PROCEDURE
59467 ,p_module => l_log_module);
59469 END IF;
59470 --
59471 l_component_type := 'AMB_JLT';
59472 l_component_code := 'RCT_REFUND';
59473 l_component_type_code := 'S';
59474 l_component_appl_id := 222;
59475 l_amb_context_code := 'DEFAULT';
59476 l_entity_code := 'RECEIPTS';
59477 l_event_class_code := 'RECEIPT';
59478 l_event_type_code := 'RECEIPT_ALL';
59479 l_line_definition_owner_code := 'S';
59480 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
59481 --
59482 l_balance_type_code := 'A';
59483 l_segment := NULL;
59484 l_ccid := NULL;
59485 l_adr_transaction_coa_id := NULL;
59486 l_adr_accounting_coa_id := NULL;
59487 l_adr_flexfield_segment_code := NULL;
59488 l_adr_flex_value_set_id := NULL;
59489 l_adr_value_type_code := NULL;
59490 l_adr_value_combination_id := NULL;
59491 l_adr_value_segment_code := NULL;
59492
59493 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
59494 l_bflow_class_code := ''; -- 4219869 Business Flow
59495 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
59496 l_budgetary_control_flag := 'N';
59497
59498 l_bflow_applied_to_amt_idx := NULL; -- 5132302
59499 l_bflow_applied_to_amt := NULL; -- 5132302
59500 l_entered_amt_idx := NULL; -- 4262811
59501 l_accted_amt_idx := NULL; -- 4262811
59502 l_acc_rev_flag := NULL; -- 4262811
59503 l_accrual_line_num := NULL; -- 4262811
59504 l_tmp_amt := NULL; -- 4262811
59505 --
59506
59507 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
59508 l_balance_type_code <> 'B' THEN
59509 IF (NVL(p_source_20,'
59510 ') = 'ACTIVITY' AND
59511 NVL(p_source_21,'
59512 ') = 'CCREFUND' AND
59513 NVL(p_source_67,'
59514 ') = 'N') OR
59515 (NVL(p_source_20,'
59516 ') = 'ACTIVITY' AND
59517 NVL(p_source_21,'
59518 ') = 'CM_REFUND' AND
59519 NVL(p_source_67,'
59520 ') = 'N')
59521 THEN
59522
59523 --
59524 XLA_AE_LINES_PKG.SetNewLine;
59525
59526 p_balance_type_code := l_balance_type_code;
59527 -- set the flag so later we will know whether the gain loss line needs to be created
59528
59529 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
59530 p_actual_flag :='A';
59531 END IF;
59532
59533 --
59534 -- bulk performance
59535 --
59536 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
59537 p_header_num => 0); -- 4262811
59538 --
59539 -- set accounting line options
59540 --
59541 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
59542 p_natural_side_code => 'C'
59543 , p_gain_or_loss_flag => 'N'
59544 , p_gl_transfer_mode_code => 'S'
59545 , p_acct_entry_type_code => 'A'
59546 , p_switch_side_flag => 'Y'
59547 , p_merge_duplicate_code => 'A'
59548 );
59549 --
59550 l_acc_rev_natural_side_code := 'D'; -- 4262811
59551 --
59552 --
59553 -- set accounting line type info
59554 --
59555 xla_ae_lines_pkg.SetAcctLineType
59556 (p_component_type => l_component_type
59557 ,p_event_type_code => l_event_type_code
59558 ,p_line_definition_owner_code => l_line_definition_owner_code
59559 ,p_line_definition_code => l_line_definition_code
59560 ,p_accounting_line_code => l_component_code
59561 ,p_accounting_line_type_code => l_component_type_code
59562 ,p_accounting_line_appl_id => l_component_appl_id
59563 ,p_amb_context_code => l_amb_context_code
59564 ,p_entity_code => l_entity_code
59565 ,p_event_class_code => l_event_class_code);
59566 --
59567 -- set accounting class
59568 --
59569 xla_ae_lines_pkg.SetAcctClass(
59570 p_accounting_class_code => 'REFUND'
59571 , p_ae_header_id => l_ae_header_id
59572 );
59573
59574 --
59575 -- set rounding class
59576 --
59577 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
59578 'RECEIVABLE';
59579
59580 --
59581 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
59582 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
59583 --
59584 -- bulk performance
59585 --
59586 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
59587
59588 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
59589 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
59590
59591 -- 4955764
59592 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
59593 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
59594
59595 -- 4458381 Public Sector Enh
59596
59597 --
59598 -- set accounting attributes for the line type
59599 --
59600 l_entered_amt_idx := 8;
59601 l_accted_amt_idx := 13;
59602 l_bflow_applied_to_amt_idx := NULL; -- 5132302
59603 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
59604 l_rec_acct_attrs.array_num_value(1) := p_source_58;
59605 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
59606 l_rec_acct_attrs.array_char_value(2) := p_source_35;
59607 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
59608 l_rec_acct_attrs.array_char_value(3) := p_source_59;
59609 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
59610 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
59611 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
59612 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
59613 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
59614 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
59615 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
59616 l_rec_acct_attrs.array_char_value(7) := p_source_23;
59617 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
59618 l_rec_acct_attrs.array_num_value(8) := p_source_68;
59619 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
59620 l_rec_acct_attrs.array_char_value(9) := p_source_61;
59621 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
59622 l_rec_acct_attrs.array_date_value(10) := p_source_26;
59623 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
59624 l_rec_acct_attrs.array_num_value(11) := p_source_27;
59625 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
59626 l_rec_acct_attrs.array_char_value(12) := p_source_28;
59627 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
59628 l_rec_acct_attrs.array_num_value(13) := p_source_69;
59629 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
59630 l_rec_acct_attrs.array_num_value(14) := p_source_63;
59631 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
59632 l_rec_acct_attrs.array_num_value(15) := p_source_64;
59633 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
59634 l_rec_acct_attrs.array_char_value(16) := p_source_65;
59635
59636 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
59637 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
59638
59639 ---------------------------------------------------------------------------------------------------------------
59640 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
59641 ---------------------------------------------------------------------------------------------------------------
59642 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
59643
59644 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59645 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
59646
59647 IF xla_accounting_cache_pkg.GetValueChar
59648 (p_source_code => 'LEDGER_CATEGORY_CODE'
59649 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
59650 AND l_bflow_method_code = 'PRIOR_ENTRY'
59651 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
59652 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
59653 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
59654 )
59655 THEN
59656 xla_ae_lines_pkg.BflowUpgEntry
59657 (p_business_method_code => l_bflow_method_code
59658 ,p_business_class_code => l_bflow_class_code
59659 ,p_balance_type => l_balance_type_code);
59660 ELSE
59661 NULL;
59662 -- No business flow processing for business flow method of NONE.
59663 END IF;
59664
59665 --
59666 -- call analytical criteria
59667 --
59668
59669 --
59670 -- call description
59671 --
59672 -- No description or it is inherited.
59673 --
59674 -- call ADRs
59675 -- Bug 4922099
59676 --
59677 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
59678 (NVL(l_actual_upg_option, 'N') = 'O') OR
59679 (NVL(l_enc_upg_option, 'N') = 'O')
59680 )
59681 THEN
59682 NULL;
59683 --
59684 --
59685
59686 l_ccid := AcctDerRule_4(
59687 p_application_id => p_application_id
59688 , p_ae_header_id => l_ae_header_id
59689 , p_source_5 => p_source_5
59690 , x_transaction_coa_id => l_adr_transaction_coa_id
59691 , x_accounting_coa_id => l_adr_accounting_coa_id
59692 , x_value_type_code => l_adr_value_type_code
59693 , p_side => 'NA'
59694 );
59695
59696 xla_ae_lines_pkg.set_ccid(
59697 p_code_combination_id => l_ccid
59698 , p_value_type_code => l_adr_value_type_code
59699 , p_transaction_coa_id => l_adr_transaction_coa_id
59700 , p_accounting_coa_id => l_adr_accounting_coa_id
59701 , p_adr_code => 'DIST_CCID'
59702 , p_adr_type_code => 'S'
59703 , p_component_type => l_component_type
59704 , p_component_code => l_component_code
59705 , p_component_type_code => l_component_type_code
59706 , p_component_appl_id => l_component_appl_id
59707 , p_amb_context_code => l_amb_context_code
59708 , p_side => 'NA'
59709 );
59710
59711
59712 --
59713 --
59714 END IF;
59715 --
59716 -- Bug 4922099
59717 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
59718 (NVL(l_enc_upg_option, 'N') = 'O')
59719 ) AND
59720 (l_bflow_method_code = 'PRIOR_ENTRY')
59721 )
59722 THEN
59723 IF
59724 --
59725 1 = 2
59726 --
59727 THEN
59728 xla_accounting_err_pkg.build_message
59729 (p_appli_s_name => 'XLA'
59730 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
59731 ,p_token_1 => 'LINE_NUMBER'
59732 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
59733 ,p_token_2 => 'LINE_TYPE_NAME'
59734 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
59735 l_component_type
59736 ,l_component_code
59737 ,l_component_type_code
59738 ,l_component_appl_id
59739 ,l_amb_context_code
59740 ,l_entity_code
59741 ,l_event_class_code
59742 )
59743 ,p_token_3 => 'OWNER'
59744 ,p_value_3 => xla_lookups_pkg.get_meaning(
59745 p_lookup_type => 'XLA_OWNER_TYPE'
59746 ,p_lookup_code => l_component_type_code
59747 )
59748 ,p_token_4 => 'PRODUCT_NAME'
59749 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
59750 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
59751 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
59752 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
59753 ,p_ae_header_id => NULL
59754 );
59755
59756 IF (C_LEVEL_ERROR>= g_log_level) THEN
59757 trace
59758 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
59759 ,p_level => C_LEVEL_ERROR
59760 ,p_module => l_log_module);
59761 END IF;
59762 END IF;
59763 END IF;
59764 --
59765 --
59766 ------------------------------------------------------------------------------------------------
59767 -- 4219869 Business Flow
59768 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
59769 -- Prior Entry. Currently, the following code is always generated.
59770 ------------------------------------------------------------------------------------------------
59771 XLA_AE_LINES_PKG.ValidateCurrentLine;
59772
59773 ------------------------------------------------------------------------------------
59774 -- 4219869 Business Flow
59775 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
59776 ------------------------------------------------------------------------------------
59777 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
59778
59779 ----------------------------------------------------------------------------------
59780 -- 4219869 Business Flow
59781 -- Update journal entry status -- Need to generate this within IF <condition>
59782 ----------------------------------------------------------------------------------
59783 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
59784 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
59785 ,p_balance_type_code => l_balance_type_code
59786 );
59787
59788 -------------------------------------------------------------------------------------------
59789 -- 4262811 - Generate the Accrual Reversal lines
59790 -------------------------------------------------------------------------------------------
59791 BEGIN
59792 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
59793 (g_array_event(p_event_id).array_value_num('header_index'));
59794 IF l_acc_rev_flag IS NULL THEN
59795 l_acc_rev_flag := 'N';
59796 END IF;
59797 EXCEPTION
59798 WHEN OTHERS THEN
59799 l_acc_rev_flag := 'N';
59800 END;
59801 --
59802 IF (l_acc_rev_flag = 'Y') THEN
59803
59804 -- 4645092 ------------------------------------------------------------------------------
59805 -- To allow MPA report to determine if it should generate report process
59806 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
59807 ------------------------------------------------------------------------------------------
59808
59809 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
59810 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
59811 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
59812 -- call ADRs
59813 -- Bug 4922099
59814 --
59815 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
59816 (NVL(l_actual_upg_option, 'N') = 'O') OR
59817 (NVL(l_enc_upg_option, 'N') = 'O')
59818 )
59819 THEN
59820 NULL;
59821 --
59822 --
59823
59824 l_ccid := AcctDerRule_4(
59825 p_application_id => p_application_id
59826 , p_ae_header_id => l_ae_header_id
59827 , p_source_5 => p_source_5
59828 , x_transaction_coa_id => l_adr_transaction_coa_id
59829 , x_accounting_coa_id => l_adr_accounting_coa_id
59830 , x_value_type_code => l_adr_value_type_code
59831 , p_side => 'NA'
59832 );
59833
59834 xla_ae_lines_pkg.set_ccid(
59835 p_code_combination_id => l_ccid
59836 , p_value_type_code => l_adr_value_type_code
59837 , p_transaction_coa_id => l_adr_transaction_coa_id
59838 , p_accounting_coa_id => l_adr_accounting_coa_id
59839 , p_adr_code => 'DIST_CCID'
59840 , p_adr_type_code => 'S'
59841 , p_component_type => l_component_type
59842 , p_component_code => l_component_code
59843 , p_component_type_code => l_component_type_code
59844 , p_component_appl_id => l_component_appl_id
59845 , p_amb_context_code => l_amb_context_code
59846 , p_side => 'NA'
59847 );
59848
59849
59850 --
59851 --
59852 END IF;
59853
59854 --
59855 -- Update the line information that should be overwritten
59856 --
59857 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
59858 p_header_num => 1);
59859 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
59860
59861 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
59862
59863 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
59864 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
59865 END IF;
59866
59867 --
59868 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
59869 --
59870 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
59871 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
59872 ELSE
59873 ---------------------------------------------------------------------------------------------------
59874 -- 4262811a Switch Sign
59875 ---------------------------------------------------------------------------------------------------
59876 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
59877 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
59878 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59879 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
59880 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59881 -- 5132302
59882 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
59883 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
59884
59885 END IF;
59886
59887 -- 4955764
59888 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
59889 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
59890
59891
59892 XLA_AE_LINES_PKG.ValidateCurrentLine;
59893 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
59894
59895 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
59896 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
59897 ,p_balance_type_code => l_balance_type_code);
59898
59899 END IF;
59900
59901 -----------------------------------------------------------------------------------------
59902 -- 4262811 Multiperiod Accounting
59903 -----------------------------------------------------------------------------------------
59904 -- No MPA option is assigned.
59905
59906
59907 END IF;
59908 END IF;
59909 --
59910
59911 --
59912 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
59913 trace
59914 (p_msg => 'END of AcctLineType_122'
59915 ,p_level => C_LEVEL_PROCEDURE
59916 ,p_module => l_log_module);
59917 END IF;
59918 --
59919 EXCEPTION
59920 WHEN xla_exceptions_pkg.application_exception THEN
59921 RAISE;
59922 WHEN OTHERS THEN
59923 xla_exceptions_pkg.raise_message
59924 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_122');
59925 END AcctLineType_122;
59926 --
59927
59928 ---------------------------------------
59929 --
59930 -- PRIVATE FUNCTION
59931 -- AcctLineType_123
59932 --
59933 ---------------------------------------
59934 PROCEDURE AcctLineType_123 (
59935 p_application_id IN NUMBER
59936 ,p_event_id IN NUMBER
59937 ,p_calculate_acctd_flag IN VARCHAR2
59938 ,p_calculate_g_l_flag IN VARCHAR2
59939 ,p_actual_flag IN OUT VARCHAR2
59940 ,p_balance_type_code OUT VARCHAR2
59941 ,p_gain_or_loss_ref OUT VARCHAR2
59942
59943 --Distribution GL Account
59944 , p_source_5 IN NUMBER
59945 --Distribution Source Type
59946 , p_source_20 IN VARCHAR2
59947 --Distribution Line Identifier
59948 , p_source_22 IN NUMBER
59949 --Distribution Type
59950 , p_source_23 IN VARCHAR2
59951 --Exchange Date
59952 , p_source_26 IN DATE
59953 --Exchange Rate
59954 , p_source_27 IN NUMBER
59955 --Exchange Rate Type
59956 , p_source_28 IN VARCHAR2
59957 --Transaction Distribution Identifier
59958 , p_source_34 IN NUMBER
59959 --Transaction Distribution Type
59960 , p_source_35 IN VARCHAR2
59961 --Receipt Applied To Application Identifier
59962 , p_source_58 IN NUMBER
59963 --Transaction Entity Code
59964 , p_source_59 IN VARCHAR2
59965 --Transaction Identifier
59966 , p_source_60 IN NUMBER
59967 --Applying Document Currency Code
59968 , p_source_61 IN VARCHAR2
59969 --Distribution Party Identifier
59970 , p_source_63 IN NUMBER
59971 --Distribution Party Site Id
59972 , p_source_64 IN NUMBER
59973 --Distribution Party Type
59974 , p_source_65 IN VARCHAR2
59975 --Distribution Multi Fund Additional Entry
59976 , p_source_67 IN VARCHAR2
59977 --DIST_ENT_AMT_FROM
59978 , p_source_68 IN NUMBER
59979 --Accounting Amount
59980 , p_source_69 IN NUMBER
59981 --Distribution Source Table
59982 , p_source_71 IN VARCHAR2
59983 )
59984 IS
59985
59986 l_component_type VARCHAR2(80);
59987 l_component_code VARCHAR2(30);
59988 l_component_type_code VARCHAR2(1);
59989 l_component_appl_id INTEGER;
59990 l_amb_context_code VARCHAR2(30);
59991 l_entity_code VARCHAR2(30);
59992 l_event_class_code VARCHAR2(30);
59993 l_ae_header_id NUMBER;
59994 l_event_type_code VARCHAR2(30);
59995 l_line_definition_code VARCHAR2(30);
59996 l_line_definition_owner_code VARCHAR2(1);
60000 l_ccid NUMBER;
59997 --
59998 -- adr variables
59999 l_segment VARCHAR2(30);
60001 l_adr_transaction_coa_id NUMBER;
60002 l_adr_accounting_coa_id NUMBER;
60003 l_adr_flexfield_segment_code VARCHAR2(30);
60004 l_adr_flex_value_set_id NUMBER;
60005 l_adr_value_type_code VARCHAR2(30);
60006 l_adr_value_combination_id NUMBER;
60007 l_adr_value_segment_code VARCHAR2(30);
60008
60009 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
60010 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
60011 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
60012 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
60013
60014 -- 4262811 Variables ------------------------------------------------------------------------------------------
60015 l_entered_amt_idx NUMBER;
60016 l_accted_amt_idx NUMBER;
60017 l_acc_rev_flag VARCHAR2(1);
60018 l_accrual_line_num NUMBER;
60019 l_tmp_amt NUMBER;
60020 l_acc_rev_natural_side_code VARCHAR2(1);
60021
60022 l_num_entries NUMBER;
60023 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
60024 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
60025 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
60026 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
60027 l_recog_line_1 NUMBER;
60028 l_recog_line_2 NUMBER;
60029
60030 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
60031 l_bflow_applied_to_amt NUMBER; -- 5132302
60032 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
60033
60034 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
60035
60036 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
60037 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
60038
60039 ---------------------------------------------------------------------------------------------------------------
60040
60041
60042 --
60043 -- bulk performance
60044 --
60045 l_balance_type_code VARCHAR2(1);
60046 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
60047 l_log_module VARCHAR2(240);
60048
60049 --
60050 -- Upgrade strategy
60051 --
60052 l_actual_upg_option VARCHAR2(1);
60053 l_enc_upg_option VARCHAR2(1);
60054
60055 --
60056 BEGIN
60057 --
60058 IF g_log_enabled THEN
60059 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_123';
60060 END IF;
60061 --
60062 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60063
60064 trace
60065 (p_msg => 'BEGIN of AcctLineType_123'
60066 ,p_level => C_LEVEL_PROCEDURE
60067 ,p_module => l_log_module);
60068
60069 END IF;
60070 --
60071 l_component_type := 'AMB_JLT';
60072 l_component_code := 'RCT_REMIT';
60073 l_component_type_code := 'S';
60074 l_component_appl_id := 222;
60075 l_amb_context_code := 'DEFAULT';
60076 l_entity_code := 'RECEIPTS';
60077 l_event_class_code := 'RECEIPT';
60078 l_event_type_code := 'RECEIPT_ALL';
60079 l_line_definition_owner_code := 'S';
60080 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
60081 --
60082 l_balance_type_code := 'A';
60083 l_segment := NULL;
60084 l_ccid := NULL;
60085 l_adr_transaction_coa_id := NULL;
60086 l_adr_accounting_coa_id := NULL;
60087 l_adr_flexfield_segment_code := NULL;
60088 l_adr_flex_value_set_id := NULL;
60089 l_adr_value_type_code := NULL;
60090 l_adr_value_combination_id := NULL;
60091 l_adr_value_segment_code := NULL;
60092
60093 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
60094 l_bflow_class_code := ''; -- 4219869 Business Flow
60095 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
60096 l_budgetary_control_flag := 'N';
60097
60098 l_bflow_applied_to_amt_idx := NULL; -- 5132302
60099 l_bflow_applied_to_amt := NULL; -- 5132302
60100 l_entered_amt_idx := NULL; -- 4262811
60101 l_accted_amt_idx := NULL; -- 4262811
60102 l_acc_rev_flag := NULL; -- 4262811
60103 l_accrual_line_num := NULL; -- 4262811
60104 l_tmp_amt := NULL; -- 4262811
60105 --
60106
60107 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
60108 l_balance_type_code <> 'B' THEN
60109 IF NVL(p_source_20,'
60110 ') = 'REMITTANCE' AND
60111 NVL(p_source_71,'
60112 ') = 'CRH' AND
60113 NVL(p_source_67,'
60114 ') = 'N'
60115 THEN
60116
60117 --
60118 XLA_AE_LINES_PKG.SetNewLine;
60119
60120 p_balance_type_code := l_balance_type_code;
60121 -- set the flag so later we will know whether the gain loss line needs to be created
60122
60123 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
60124 p_actual_flag :='A';
60125 END IF;
60126
60127 --
60128 -- bulk performance
60129 --
60130 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
60131 p_header_num => 0); -- 4262811
60132 --
60133 -- set accounting line options
60134 --
60135 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
60136 p_natural_side_code => 'C'
60137 , p_gain_or_loss_flag => 'N'
60138 , p_gl_transfer_mode_code => 'S'
60139 , p_acct_entry_type_code => 'A'
60140 , p_switch_side_flag => 'Y'
60141 , p_merge_duplicate_code => 'A'
60142 );
60143 --
60144 l_acc_rev_natural_side_code := 'D'; -- 4262811
60145 --
60146 --
60147 -- set accounting line type info
60148 --
60149 xla_ae_lines_pkg.SetAcctLineType
60150 (p_component_type => l_component_type
60151 ,p_event_type_code => l_event_type_code
60152 ,p_line_definition_owner_code => l_line_definition_owner_code
60153 ,p_line_definition_code => l_line_definition_code
60154 ,p_accounting_line_code => l_component_code
60155 ,p_accounting_line_type_code => l_component_type_code
60156 ,p_accounting_line_appl_id => l_component_appl_id
60157 ,p_amb_context_code => l_amb_context_code
60158 ,p_entity_code => l_entity_code
60159 ,p_event_class_code => l_event_class_code);
60160 --
60161 -- set accounting class
60162 --
60163 xla_ae_lines_pkg.SetAcctClass(
60164 p_accounting_class_code => 'REMITTANCE'
60165 , p_ae_header_id => l_ae_header_id
60166 );
60167
60168 --
60169 -- set rounding class
60170 --
60171 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
60172 'RECEIVABLE';
60173
60174 --
60175 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
60176 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
60177 --
60178 -- bulk performance
60179 --
60180 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
60181
60182 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
60183 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
60184
60185 -- 4955764
60186 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
60187 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
60188
60189 -- 4458381 Public Sector Enh
60190
60191 --
60192 -- set accounting attributes for the line type
60193 --
60194 l_entered_amt_idx := 8;
60195 l_accted_amt_idx := 13;
60196 l_bflow_applied_to_amt_idx := NULL; -- 5132302
60197 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
60198 l_rec_acct_attrs.array_num_value(1) := p_source_58;
60199 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
60200 l_rec_acct_attrs.array_char_value(2) := p_source_35;
60201 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
60202 l_rec_acct_attrs.array_char_value(3) := p_source_59;
60203 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
60204 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
60205 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
60206 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
60207 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
60208 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
60209 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
60210 l_rec_acct_attrs.array_char_value(7) := p_source_23;
60211 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
60212 l_rec_acct_attrs.array_num_value(8) := p_source_68;
60213 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
60214 l_rec_acct_attrs.array_char_value(9) := p_source_61;
60215 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
60216 l_rec_acct_attrs.array_date_value(10) := p_source_26;
60217 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
60218 l_rec_acct_attrs.array_num_value(11) := p_source_27;
60219 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
60220 l_rec_acct_attrs.array_char_value(12) := p_source_28;
60221 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
60222 l_rec_acct_attrs.array_num_value(13) := p_source_69;
60223 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
60224 l_rec_acct_attrs.array_num_value(14) := p_source_63;
60225 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
60229
60226 l_rec_acct_attrs.array_num_value(15) := p_source_64;
60227 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
60228 l_rec_acct_attrs.array_char_value(16) := p_source_65;
60230 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
60231 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
60232
60233 ---------------------------------------------------------------------------------------------------------------
60234 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
60235 ---------------------------------------------------------------------------------------------------------------
60236 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
60237
60238 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
60239 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
60240
60241 IF xla_accounting_cache_pkg.GetValueChar
60242 (p_source_code => 'LEDGER_CATEGORY_CODE'
60243 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
60244 AND l_bflow_method_code = 'PRIOR_ENTRY'
60245 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
60246 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
60247 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
60248 )
60249 THEN
60250 xla_ae_lines_pkg.BflowUpgEntry
60251 (p_business_method_code => l_bflow_method_code
60252 ,p_business_class_code => l_bflow_class_code
60253 ,p_balance_type => l_balance_type_code);
60254 ELSE
60255 NULL;
60256 -- No business flow processing for business flow method of NONE.
60257 END IF;
60258
60259 --
60260 -- call analytical criteria
60261 --
60262
60263 --
60264 -- call description
60265 --
60266 -- No description or it is inherited.
60267 --
60268 -- call ADRs
60269 -- Bug 4922099
60270 --
60271 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
60272 (NVL(l_actual_upg_option, 'N') = 'O') OR
60273 (NVL(l_enc_upg_option, 'N') = 'O')
60274 )
60275 THEN
60276 NULL;
60277 --
60278 --
60279
60280 l_ccid := AcctDerRule_4(
60281 p_application_id => p_application_id
60282 , p_ae_header_id => l_ae_header_id
60283 , p_source_5 => p_source_5
60284 , x_transaction_coa_id => l_adr_transaction_coa_id
60285 , x_accounting_coa_id => l_adr_accounting_coa_id
60286 , x_value_type_code => l_adr_value_type_code
60287 , p_side => 'NA'
60288 );
60289
60290 xla_ae_lines_pkg.set_ccid(
60291 p_code_combination_id => l_ccid
60292 , p_value_type_code => l_adr_value_type_code
60293 , p_transaction_coa_id => l_adr_transaction_coa_id
60294 , p_accounting_coa_id => l_adr_accounting_coa_id
60295 , p_adr_code => 'DIST_CCID'
60296 , p_adr_type_code => 'S'
60297 , p_component_type => l_component_type
60298 , p_component_code => l_component_code
60299 , p_component_type_code => l_component_type_code
60300 , p_component_appl_id => l_component_appl_id
60301 , p_amb_context_code => l_amb_context_code
60302 , p_side => 'NA'
60303 );
60304
60305
60306 --
60307 --
60308 END IF;
60309 --
60310 -- Bug 4922099
60311 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
60312 (NVL(l_enc_upg_option, 'N') = 'O')
60313 ) AND
60314 (l_bflow_method_code = 'PRIOR_ENTRY')
60315 )
60316 THEN
60317 IF
60318 --
60319 1 = 2
60320 --
60321 THEN
60322 xla_accounting_err_pkg.build_message
60323 (p_appli_s_name => 'XLA'
60324 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
60325 ,p_token_1 => 'LINE_NUMBER'
60326 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
60327 ,p_token_2 => 'LINE_TYPE_NAME'
60328 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
60329 l_component_type
60330 ,l_component_code
60331 ,l_component_type_code
60332 ,l_component_appl_id
60333 ,l_amb_context_code
60334 ,l_entity_code
60335 ,l_event_class_code
60336 )
60337 ,p_token_3 => 'OWNER'
60338 ,p_value_3 => xla_lookups_pkg.get_meaning(
60339 p_lookup_type => 'XLA_OWNER_TYPE'
60340 ,p_lookup_code => l_component_type_code
60341 )
60342 ,p_token_4 => 'PRODUCT_NAME'
60343 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
60344 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
60345 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
60346 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
60347 ,p_ae_header_id => NULL
60348 );
60349
60350 IF (C_LEVEL_ERROR>= g_log_level) THEN
60351 trace
60352 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
60353 ,p_level => C_LEVEL_ERROR
60354 ,p_module => l_log_module);
60355 END IF;
60356 END IF;
60357 END IF;
60358 --
60359 --
60360 ------------------------------------------------------------------------------------------------
60361 -- 4219869 Business Flow
60362 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
60363 -- Prior Entry. Currently, the following code is always generated.
60364 ------------------------------------------------------------------------------------------------
60365 XLA_AE_LINES_PKG.ValidateCurrentLine;
60366
60367 ------------------------------------------------------------------------------------
60368 -- 4219869 Business Flow
60369 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
60370 ------------------------------------------------------------------------------------
60371 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
60372
60373 ----------------------------------------------------------------------------------
60374 -- 4219869 Business Flow
60375 -- Update journal entry status -- Need to generate this within IF <condition>
60376 ----------------------------------------------------------------------------------
60377 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
60378 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
60379 ,p_balance_type_code => l_balance_type_code
60380 );
60381
60382 -------------------------------------------------------------------------------------------
60383 -- 4262811 - Generate the Accrual Reversal lines
60384 -------------------------------------------------------------------------------------------
60385 BEGIN
60386 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
60387 (g_array_event(p_event_id).array_value_num('header_index'));
60388 IF l_acc_rev_flag IS NULL THEN
60389 l_acc_rev_flag := 'N';
60390 END IF;
60391 EXCEPTION
60392 WHEN OTHERS THEN
60393 l_acc_rev_flag := 'N';
60394 END;
60395 --
60396 IF (l_acc_rev_flag = 'Y') THEN
60397
60398 -- 4645092 ------------------------------------------------------------------------------
60399 -- To allow MPA report to determine if it should generate report process
60400 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
60401 ------------------------------------------------------------------------------------------
60402
60403 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
60404 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
60405 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
60406 -- call ADRs
60407 -- Bug 4922099
60408 --
60409 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
60410 (NVL(l_actual_upg_option, 'N') = 'O') OR
60411 (NVL(l_enc_upg_option, 'N') = 'O')
60412 )
60413 THEN
60414 NULL;
60415 --
60416 --
60417
60418 l_ccid := AcctDerRule_4(
60419 p_application_id => p_application_id
60420 , p_ae_header_id => l_ae_header_id
60421 , p_source_5 => p_source_5
60422 , x_transaction_coa_id => l_adr_transaction_coa_id
60423 , x_accounting_coa_id => l_adr_accounting_coa_id
60424 , x_value_type_code => l_adr_value_type_code
60425 , p_side => 'NA'
60426 );
60427
60428 xla_ae_lines_pkg.set_ccid(
60429 p_code_combination_id => l_ccid
60430 , p_value_type_code => l_adr_value_type_code
60431 , p_transaction_coa_id => l_adr_transaction_coa_id
60432 , p_accounting_coa_id => l_adr_accounting_coa_id
60433 , p_adr_code => 'DIST_CCID'
60434 , p_adr_type_code => 'S'
60435 , p_component_type => l_component_type
60439 , p_amb_context_code => l_amb_context_code
60436 , p_component_code => l_component_code
60437 , p_component_type_code => l_component_type_code
60438 , p_component_appl_id => l_component_appl_id
60440 , p_side => 'NA'
60441 );
60442
60443
60444 --
60445 --
60446 END IF;
60447
60448 --
60449 -- Update the line information that should be overwritten
60450 --
60451 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
60452 p_header_num => 1);
60453 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
60454
60455 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
60456
60457 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
60458 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
60459 END IF;
60460
60461 --
60462 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
60463 --
60464 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
60465 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
60466 ELSE
60467 ---------------------------------------------------------------------------------------------------
60468 -- 4262811a Switch Sign
60469 ---------------------------------------------------------------------------------------------------
60470 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
60471 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
60472 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60473 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
60474 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60475 -- 5132302
60476 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
60477 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
60478
60479 END IF;
60480
60481 -- 4955764
60482 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
60483 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
60484
60485
60486 XLA_AE_LINES_PKG.ValidateCurrentLine;
60487 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
60488
60489 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
60490 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
60491 ,p_balance_type_code => l_balance_type_code);
60492
60493 END IF;
60494
60495 -----------------------------------------------------------------------------------------
60496 -- 4262811 Multiperiod Accounting
60497 -----------------------------------------------------------------------------------------
60498 -- No MPA option is assigned.
60499
60500
60501 END IF;
60502 END IF;
60503 --
60504
60505 --
60506 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60507 trace
60508 (p_msg => 'END of AcctLineType_123'
60509 ,p_level => C_LEVEL_PROCEDURE
60510 ,p_module => l_log_module);
60511 END IF;
60512 --
60513 EXCEPTION
60514 WHEN xla_exceptions_pkg.application_exception THEN
60515 RAISE;
60516 WHEN OTHERS THEN
60517 xla_exceptions_pkg.raise_message
60518 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_123');
60519 END AcctLineType_123;
60520 --
60521
60522 ---------------------------------------
60523 --
60524 -- PRIVATE FUNCTION
60525 -- AcctLineType_124
60526 --
60527 ---------------------------------------
60528 PROCEDURE AcctLineType_124 (
60529 p_application_id IN NUMBER
60530 ,p_event_id IN NUMBER
60531 ,p_calculate_acctd_flag IN VARCHAR2
60532 ,p_calculate_g_l_flag IN VARCHAR2
60533 ,p_actual_flag IN OUT VARCHAR2
60534 ,p_balance_type_code OUT VARCHAR2
60535 ,p_gain_or_loss_ref OUT VARCHAR2
60536
60537 --Distribution GL Account
60538 , p_source_5 IN NUMBER
60539 --Distribution Source Type
60540 , p_source_20 IN VARCHAR2
60541 --Distribution Line Identifier
60542 , p_source_22 IN NUMBER
60543 --Distribution Type
60544 , p_source_23 IN VARCHAR2
60545 --Exchange Date
60546 , p_source_26 IN DATE
60547 --Exchange Rate
60548 , p_source_27 IN NUMBER
60549 --Exchange Rate Type
60550 , p_source_28 IN VARCHAR2
60551 --Transaction Distribution Identifier
60552 , p_source_34 IN NUMBER
60553 --Transaction Distribution Type
60554 , p_source_35 IN VARCHAR2
60555 --Receipt Applied To Application Identifier
60556 , p_source_58 IN NUMBER
60557 --Transaction Entity Code
60558 , p_source_59 IN VARCHAR2
60559 --Transaction Identifier
60560 , p_source_60 IN NUMBER
60561 --Applying Document Currency Code
60562 , p_source_61 IN VARCHAR2
60563 --Distribution Party Identifier
60564 , p_source_63 IN NUMBER
60565 --Distribution Party Site Id
60566 , p_source_64 IN NUMBER
60567 --Distribution Party Type
60568 , p_source_65 IN VARCHAR2
60572 , p_source_68 IN NUMBER
60569 --Distribution Multi Fund Additional Entry
60570 , p_source_67 IN VARCHAR2
60571 --DIST_ENT_AMT_FROM
60573 --Accounting Amount
60574 , p_source_69 IN NUMBER
60575 --Distribution Source Table
60576 , p_source_71 IN VARCHAR2
60577 )
60578 IS
60579
60580 l_component_type VARCHAR2(80);
60581 l_component_code VARCHAR2(30);
60582 l_component_type_code VARCHAR2(1);
60583 l_component_appl_id INTEGER;
60584 l_amb_context_code VARCHAR2(30);
60585 l_entity_code VARCHAR2(30);
60586 l_event_class_code VARCHAR2(30);
60587 l_ae_header_id NUMBER;
60588 l_event_type_code VARCHAR2(30);
60589 l_line_definition_code VARCHAR2(30);
60590 l_line_definition_owner_code VARCHAR2(1);
60591 --
60592 -- adr variables
60593 l_segment VARCHAR2(30);
60594 l_ccid NUMBER;
60595 l_adr_transaction_coa_id NUMBER;
60596 l_adr_accounting_coa_id NUMBER;
60597 l_adr_flexfield_segment_code VARCHAR2(30);
60598 l_adr_flex_value_set_id NUMBER;
60599 l_adr_value_type_code VARCHAR2(30);
60600 l_adr_value_combination_id NUMBER;
60601 l_adr_value_segment_code VARCHAR2(30);
60602
60603 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
60604 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
60605 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
60606 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
60607
60608 -- 4262811 Variables ------------------------------------------------------------------------------------------
60609 l_entered_amt_idx NUMBER;
60610 l_accted_amt_idx NUMBER;
60611 l_acc_rev_flag VARCHAR2(1);
60612 l_accrual_line_num NUMBER;
60613 l_tmp_amt NUMBER;
60614 l_acc_rev_natural_side_code VARCHAR2(1);
60615
60616 l_num_entries NUMBER;
60617 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
60618 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
60619 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
60620 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
60621 l_recog_line_1 NUMBER;
60622 l_recog_line_2 NUMBER;
60623
60624 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
60625 l_bflow_applied_to_amt NUMBER; -- 5132302
60626 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
60627
60628 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
60629
60630 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
60631 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
60632
60633 ---------------------------------------------------------------------------------------------------------------
60634
60635
60636 --
60637 -- bulk performance
60638 --
60639 l_balance_type_code VARCHAR2(1);
60640 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
60641 l_log_module VARCHAR2(240);
60642
60643 --
60644 -- Upgrade strategy
60645 --
60646 l_actual_upg_option VARCHAR2(1);
60647 l_enc_upg_option VARCHAR2(1);
60648
60649 --
60650 BEGIN
60651 --
60652 IF g_log_enabled THEN
60653 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_124';
60654 END IF;
60655 --
60656 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
60657
60658 trace
60659 (p_msg => 'BEGIN of AcctLineType_124'
60660 ,p_level => C_LEVEL_PROCEDURE
60661 ,p_module => l_log_module);
60662
60663 END IF;
60664 --
60665 l_component_type := 'AMB_JLT';
60666 l_component_code := 'RCT_REMIT_BR';
60667 l_component_type_code := 'S';
60668 l_component_appl_id := 222;
60669 l_amb_context_code := 'DEFAULT';
60670 l_entity_code := 'RECEIPTS';
60671 l_event_class_code := 'RECEIPT';
60672 l_event_type_code := 'RECEIPT_ALL';
60673 l_line_definition_owner_code := 'S';
60674 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
60675 --
60676 l_balance_type_code := 'A';
60677 l_segment := NULL;
60678 l_ccid := NULL;
60679 l_adr_transaction_coa_id := NULL;
60680 l_adr_accounting_coa_id := NULL;
60681 l_adr_flexfield_segment_code := NULL;
60682 l_adr_flex_value_set_id := NULL;
60683 l_adr_value_type_code := NULL;
60684 l_adr_value_combination_id := NULL;
60685 l_adr_value_segment_code := NULL;
60686
60687 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
60688 l_bflow_class_code := ''; -- 4219869 Business Flow
60689 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
60690 l_budgetary_control_flag := 'N';
60691
60692 l_bflow_applied_to_amt_idx := NULL; -- 5132302
60693 l_bflow_applied_to_amt := NULL; -- 5132302
60694 l_entered_amt_idx := NULL; -- 4262811
60695 l_accted_amt_idx := NULL; -- 4262811
60696 l_acc_rev_flag := NULL; -- 4262811
60697 l_accrual_line_num := NULL; -- 4262811
60698 l_tmp_amt := NULL; -- 4262811
60699 --
60700
60701 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
60702 l_balance_type_code <> 'B' THEN
60703 IF NVL(p_source_20,'
60704 ') = 'REMITTANCE' AND
60705 NVL(p_source_71,'
60706 ') = 'RA' AND
60707 NVL(p_source_67,'
60708 ') = 'N'
60709 THEN
60710
60711 --
60712 XLA_AE_LINES_PKG.SetNewLine;
60713
60714 p_balance_type_code := l_balance_type_code;
60715 -- set the flag so later we will know whether the gain loss line needs to be created
60716
60717 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
60718 p_actual_flag :='A';
60719 END IF;
60720
60721 --
60722 -- bulk performance
60723 --
60724 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
60725 p_header_num => 0); -- 4262811
60726 --
60727 -- set accounting line options
60728 --
60729 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
60730 p_natural_side_code => 'C'
60731 , p_gain_or_loss_flag => 'N'
60732 , p_gl_transfer_mode_code => 'S'
60733 , p_acct_entry_type_code => 'A'
60734 , p_switch_side_flag => 'Y'
60735 , p_merge_duplicate_code => 'A'
60736 );
60737 --
60738 l_acc_rev_natural_side_code := 'D'; -- 4262811
60739 --
60740 --
60741 -- set accounting line type info
60742 --
60743 xla_ae_lines_pkg.SetAcctLineType
60744 (p_component_type => l_component_type
60745 ,p_event_type_code => l_event_type_code
60746 ,p_line_definition_owner_code => l_line_definition_owner_code
60747 ,p_line_definition_code => l_line_definition_code
60748 ,p_accounting_line_code => l_component_code
60749 ,p_accounting_line_type_code => l_component_type_code
60750 ,p_accounting_line_appl_id => l_component_appl_id
60751 ,p_amb_context_code => l_amb_context_code
60752 ,p_entity_code => l_entity_code
60753 ,p_event_class_code => l_event_class_code);
60754 --
60755 -- set accounting class
60756 --
60757 xla_ae_lines_pkg.SetAcctClass(
60758 p_accounting_class_code => 'REM_BR'
60759 , p_ae_header_id => l_ae_header_id
60760 );
60761
60762 --
60763 -- set rounding class
60764 --
60765 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
60766 'RECEIVABLE';
60767
60768 --
60769 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
60770 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
60771 --
60772 -- bulk performance
60773 --
60774 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
60775
60776 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
60777 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
60778
60779 -- 4955764
60780 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
60781 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
60782
60783 -- 4458381 Public Sector Enh
60784
60785 --
60786 -- set accounting attributes for the line type
60787 --
60788 l_entered_amt_idx := 8;
60789 l_accted_amt_idx := 13;
60790 l_bflow_applied_to_amt_idx := NULL; -- 5132302
60791 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
60792 l_rec_acct_attrs.array_num_value(1) := p_source_58;
60793 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
60794 l_rec_acct_attrs.array_char_value(2) := p_source_35;
60795 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
60796 l_rec_acct_attrs.array_char_value(3) := p_source_59;
60797 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
60798 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
60799 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
60800 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
60801 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
60802 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
60803 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
60804 l_rec_acct_attrs.array_char_value(7) := p_source_23;
60805 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
60806 l_rec_acct_attrs.array_num_value(8) := p_source_68;
60807 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
60808 l_rec_acct_attrs.array_char_value(9) := p_source_61;
60809 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
60810 l_rec_acct_attrs.array_date_value(10) := p_source_26;
60811 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
60812 l_rec_acct_attrs.array_num_value(11) := p_source_27;
60813 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
60814 l_rec_acct_attrs.array_char_value(12) := p_source_28;
60815 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
60816 l_rec_acct_attrs.array_num_value(13) := p_source_69;
60817 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
60818 l_rec_acct_attrs.array_num_value(14) := p_source_63;
60819 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
60820 l_rec_acct_attrs.array_num_value(15) := p_source_64;
60821 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
60822 l_rec_acct_attrs.array_char_value(16) := p_source_65;
60823
60824 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
60825 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
60826
60827 ---------------------------------------------------------------------------------------------------------------
60828 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
60829 ---------------------------------------------------------------------------------------------------------------
60830 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
60831
60832 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
60833 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
60834
60835 IF xla_accounting_cache_pkg.GetValueChar
60836 (p_source_code => 'LEDGER_CATEGORY_CODE'
60837 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
60838 AND l_bflow_method_code = 'PRIOR_ENTRY'
60839 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
60840 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
60841 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
60842 )
60843 THEN
60844 xla_ae_lines_pkg.BflowUpgEntry
60845 (p_business_method_code => l_bflow_method_code
60846 ,p_business_class_code => l_bflow_class_code
60847 ,p_balance_type => l_balance_type_code);
60848 ELSE
60849 NULL;
60850 -- No business flow processing for business flow method of NONE.
60851 END IF;
60852
60853 --
60854 -- call analytical criteria
60855 --
60856
60857 --
60858 -- call description
60859 --
60860 -- No description or it is inherited.
60861 --
60862 -- call ADRs
60863 -- Bug 4922099
60864 --
60865 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
60866 (NVL(l_actual_upg_option, 'N') = 'O') OR
60867 (NVL(l_enc_upg_option, 'N') = 'O')
60868 )
60869 THEN
60870 NULL;
60871 --
60872 --
60873
60874 l_ccid := AcctDerRule_4(
60875 p_application_id => p_application_id
60876 , p_ae_header_id => l_ae_header_id
60877 , p_source_5 => p_source_5
60878 , x_transaction_coa_id => l_adr_transaction_coa_id
60879 , x_accounting_coa_id => l_adr_accounting_coa_id
60880 , x_value_type_code => l_adr_value_type_code
60881 , p_side => 'NA'
60882 );
60883
60884 xla_ae_lines_pkg.set_ccid(
60885 p_code_combination_id => l_ccid
60886 , p_value_type_code => l_adr_value_type_code
60887 , p_transaction_coa_id => l_adr_transaction_coa_id
60888 , p_accounting_coa_id => l_adr_accounting_coa_id
60889 , p_adr_code => 'DIST_CCID'
60890 , p_adr_type_code => 'S'
60891 , p_component_type => l_component_type
60892 , p_component_code => l_component_code
60893 , p_component_type_code => l_component_type_code
60894 , p_component_appl_id => l_component_appl_id
60895 , p_amb_context_code => l_amb_context_code
60896 , p_side => 'NA'
60897 );
60898
60899
60900 --
60901 --
60902 END IF;
60903 --
60904 -- Bug 4922099
60905 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
60906 (NVL(l_enc_upg_option, 'N') = 'O')
60907 ) AND
60908 (l_bflow_method_code = 'PRIOR_ENTRY')
60909 )
60910 THEN
60911 IF
60912 --
60913 1 = 2
60914 --
60915 THEN
60916 xla_accounting_err_pkg.build_message
60917 (p_appli_s_name => 'XLA'
60918 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
60919 ,p_token_1 => 'LINE_NUMBER'
60920 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
60921 ,p_token_2 => 'LINE_TYPE_NAME'
60922 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
60923 l_component_type
60924 ,l_component_code
60925 ,l_component_type_code
60926 ,l_component_appl_id
60927 ,l_amb_context_code
60928 ,l_entity_code
60929 ,l_event_class_code
60930 )
60931 ,p_token_3 => 'OWNER'
60932 ,p_value_3 => xla_lookups_pkg.get_meaning(
60933 p_lookup_type => 'XLA_OWNER_TYPE'
60934 ,p_lookup_code => l_component_type_code
60935 )
60936 ,p_token_4 => 'PRODUCT_NAME'
60937 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
60938 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
60939 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
60940 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
60941 ,p_ae_header_id => NULL
60942 );
60943
60944 IF (C_LEVEL_ERROR>= g_log_level) THEN
60945 trace
60946 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
60947 ,p_level => C_LEVEL_ERROR
60948 ,p_module => l_log_module);
60949 END IF;
60950 END IF;
60951 END IF;
60952 --
60953 --
60954 ------------------------------------------------------------------------------------------------
60955 -- 4219869 Business Flow
60956 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
60957 -- Prior Entry. Currently, the following code is always generated.
60958 ------------------------------------------------------------------------------------------------
60959 XLA_AE_LINES_PKG.ValidateCurrentLine;
60960
60961 ------------------------------------------------------------------------------------
60962 -- 4219869 Business Flow
60963 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
60964 ------------------------------------------------------------------------------------
60965 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
60966
60967 ----------------------------------------------------------------------------------
60968 -- 4219869 Business Flow
60969 -- Update journal entry status -- Need to generate this within IF <condition>
60970 ----------------------------------------------------------------------------------
60971 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
60972 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
60973 ,p_balance_type_code => l_balance_type_code
60974 );
60975
60976 -------------------------------------------------------------------------------------------
60977 -- 4262811 - Generate the Accrual Reversal lines
60978 -------------------------------------------------------------------------------------------
60979 BEGIN
60980 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
60981 (g_array_event(p_event_id).array_value_num('header_index'));
60985 EXCEPTION
60982 IF l_acc_rev_flag IS NULL THEN
60983 l_acc_rev_flag := 'N';
60984 END IF;
60986 WHEN OTHERS THEN
60987 l_acc_rev_flag := 'N';
60988 END;
60989 --
60990 IF (l_acc_rev_flag = 'Y') THEN
60991
60992 -- 4645092 ------------------------------------------------------------------------------
60993 -- To allow MPA report to determine if it should generate report process
60994 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
60995 ------------------------------------------------------------------------------------------
60996
60997 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
60998 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
60999 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
61000 -- call ADRs
61001 -- Bug 4922099
61002 --
61003 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
61004 (NVL(l_actual_upg_option, 'N') = 'O') OR
61005 (NVL(l_enc_upg_option, 'N') = 'O')
61006 )
61007 THEN
61008 NULL;
61009 --
61010 --
61011
61012 l_ccid := AcctDerRule_4(
61013 p_application_id => p_application_id
61014 , p_ae_header_id => l_ae_header_id
61015 , p_source_5 => p_source_5
61016 , x_transaction_coa_id => l_adr_transaction_coa_id
61017 , x_accounting_coa_id => l_adr_accounting_coa_id
61018 , x_value_type_code => l_adr_value_type_code
61019 , p_side => 'NA'
61020 );
61021
61022 xla_ae_lines_pkg.set_ccid(
61023 p_code_combination_id => l_ccid
61024 , p_value_type_code => l_adr_value_type_code
61025 , p_transaction_coa_id => l_adr_transaction_coa_id
61026 , p_accounting_coa_id => l_adr_accounting_coa_id
61027 , p_adr_code => 'DIST_CCID'
61028 , p_adr_type_code => 'S'
61029 , p_component_type => l_component_type
61030 , p_component_code => l_component_code
61031 , p_component_type_code => l_component_type_code
61032 , p_component_appl_id => l_component_appl_id
61033 , p_amb_context_code => l_amb_context_code
61034 , p_side => 'NA'
61035 );
61036
61037
61038 --
61039 --
61040 END IF;
61041
61042 --
61043 -- Update the line information that should be overwritten
61044 --
61045 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
61046 p_header_num => 1);
61047 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
61048
61049 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
61050
61051 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
61052 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
61053 END IF;
61054
61055 --
61056 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
61057 --
61058 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
61059 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
61060 ELSE
61061 ---------------------------------------------------------------------------------------------------
61062 -- 4262811a Switch Sign
61063 ---------------------------------------------------------------------------------------------------
61064 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
61065 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
61066 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61067 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
61068 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61069 -- 5132302
61070 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
61071 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61072
61073 END IF;
61074
61075 -- 4955764
61076 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
61077 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
61078
61079
61080 XLA_AE_LINES_PKG.ValidateCurrentLine;
61081 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
61082
61083 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
61084 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
61085 ,p_balance_type_code => l_balance_type_code);
61086
61087 END IF;
61088
61089 -----------------------------------------------------------------------------------------
61090 -- 4262811 Multiperiod Accounting
61091 -----------------------------------------------------------------------------------------
61092 -- No MPA option is assigned.
61093
61094
61095 END IF;
61096 END IF;
61097 --
61098
61099 --
61100 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61101 trace
61102 (p_msg => 'END of AcctLineType_124'
61103 ,p_level => C_LEVEL_PROCEDURE
61104 ,p_module => l_log_module);
61105 END IF;
61106 --
61107 EXCEPTION
61108 WHEN xla_exceptions_pkg.application_exception THEN
61109 RAISE;
61110 WHEN OTHERS THEN
61111 xla_exceptions_pkg.raise_message
61112 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_124');
61113 END AcctLineType_124;
61114 --
61115
61116 ---------------------------------------
61117 --
61118 -- PRIVATE FUNCTION
61119 -- AcctLineType_125
61120 --
61121 ---------------------------------------
61122 PROCEDURE AcctLineType_125 (
61123 p_application_id IN NUMBER
61124 ,p_event_id IN NUMBER
61125 ,p_calculate_acctd_flag IN VARCHAR2
61126 ,p_calculate_g_l_flag IN VARCHAR2
61127 ,p_actual_flag IN OUT VARCHAR2
61128 ,p_balance_type_code OUT VARCHAR2
61129 ,p_gain_or_loss_ref OUT VARCHAR2
61130
61131 --Distribution GL Account
61132 , p_source_5 IN NUMBER
61133 --Distribution Source Type
61134 , p_source_20 IN VARCHAR2
61135 --Distribution Line Identifier
61136 , p_source_22 IN NUMBER
61137 --Distribution Type
61138 , p_source_23 IN VARCHAR2
61139 --Entered Amount
61140 , p_source_24 IN NUMBER
61141 --Currency Code
61142 , p_source_25 IN VARCHAR2
61143 --Applied To Document Accounting Amount
61144 , p_source_29 IN NUMBER
61145 --Transaction Distribution Identifier
61146 , p_source_34 IN NUMBER
61147 --Transaction Distribution Type
61148 , p_source_35 IN VARCHAR2
61149 --Applied To Document Exchange Date
61150 , p_source_57 IN DATE
61151 --Receipt Applied To Application Identifier
61152 , p_source_58 IN NUMBER
61153 --Transaction Entity Code
61154 , p_source_59 IN VARCHAR2
61155 --Transaction Identifier
61156 , p_source_60 IN NUMBER
61157 --Applied To Document Exchange Rate
61158 , p_source_62 IN NUMBER
61159 --Distribution Party Identifier
61160 , p_source_63 IN NUMBER
61161 --Distribution Party Site Id
61162 , p_source_64 IN NUMBER
61163 --Distribution Party Type
61164 , p_source_65 IN VARCHAR2
61165 --Distribution Multi Fund Additional Entry
61166 , p_source_67 IN VARCHAR2
61167 --Applied To Document Exchange Rate Type
61168 , p_source_70 IN VARCHAR2
61169 )
61170 IS
61171
61172 l_component_type VARCHAR2(80);
61173 l_component_code VARCHAR2(30);
61174 l_component_type_code VARCHAR2(1);
61175 l_component_appl_id INTEGER;
61176 l_amb_context_code VARCHAR2(30);
61177 l_entity_code VARCHAR2(30);
61178 l_event_class_code VARCHAR2(30);
61179 l_ae_header_id NUMBER;
61180 l_event_type_code VARCHAR2(30);
61181 l_line_definition_code VARCHAR2(30);
61182 l_line_definition_owner_code VARCHAR2(1);
61183 --
61184 -- adr variables
61185 l_segment VARCHAR2(30);
61186 l_ccid NUMBER;
61190 l_adr_flex_value_set_id NUMBER;
61187 l_adr_transaction_coa_id NUMBER;
61188 l_adr_accounting_coa_id NUMBER;
61189 l_adr_flexfield_segment_code VARCHAR2(30);
61191 l_adr_value_type_code VARCHAR2(30);
61192 l_adr_value_combination_id NUMBER;
61193 l_adr_value_segment_code VARCHAR2(30);
61194
61195 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
61196 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
61197 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
61198 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
61199
61200 -- 4262811 Variables ------------------------------------------------------------------------------------------
61201 l_entered_amt_idx NUMBER;
61202 l_accted_amt_idx NUMBER;
61203 l_acc_rev_flag VARCHAR2(1);
61204 l_accrual_line_num NUMBER;
61205 l_tmp_amt NUMBER;
61206 l_acc_rev_natural_side_code VARCHAR2(1);
61207
61208 l_num_entries NUMBER;
61209 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
61210 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
61211 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
61212 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
61213 l_recog_line_1 NUMBER;
61214 l_recog_line_2 NUMBER;
61215
61216 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
61217 l_bflow_applied_to_amt NUMBER; -- 5132302
61218 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
61219
61220 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
61221
61222 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
61223 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
61224
61225 ---------------------------------------------------------------------------------------------------------------
61226
61227
61228 --
61229 -- bulk performance
61230 --
61231 l_balance_type_code VARCHAR2(1);
61232 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
61233 l_log_module VARCHAR2(240);
61234
61235 --
61236 -- Upgrade strategy
61237 --
61238 l_actual_upg_option VARCHAR2(1);
61239 l_enc_upg_option VARCHAR2(1);
61240
61241 --
61242 BEGIN
61243 --
61244 IF g_log_enabled THEN
61245 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_125';
61246 END IF;
61247 --
61248 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61249
61250 trace
61251 (p_msg => 'BEGIN of AcctLineType_125'
61252 ,p_level => C_LEVEL_PROCEDURE
61253 ,p_module => l_log_module);
61254
61255 END IF;
61256 --
61257 l_component_type := 'AMB_JLT';
61258 l_component_code := 'RCT_TAX';
61259 l_component_type_code := 'S';
61260 l_component_appl_id := 222;
61261 l_amb_context_code := 'DEFAULT';
61262 l_entity_code := 'RECEIPTS';
61263 l_event_class_code := 'RECEIPT';
61264 l_event_type_code := 'RECEIPT_ALL';
61265 l_line_definition_owner_code := 'S';
61266 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
61267 --
61268 l_balance_type_code := 'A';
61269 l_segment := NULL;
61270 l_ccid := NULL;
61271 l_adr_transaction_coa_id := NULL;
61272 l_adr_accounting_coa_id := NULL;
61273 l_adr_flexfield_segment_code := NULL;
61274 l_adr_flex_value_set_id := NULL;
61275 l_adr_value_type_code := NULL;
61276 l_adr_value_combination_id := NULL;
61277 l_adr_value_segment_code := NULL;
61278
61279 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
61280 l_bflow_class_code := ''; -- 4219869 Business Flow
61281 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
61282 l_budgetary_control_flag := 'N';
61283
61284 l_bflow_applied_to_amt_idx := NULL; -- 5132302
61285 l_bflow_applied_to_amt := NULL; -- 5132302
61286 l_entered_amt_idx := NULL; -- 4262811
61287 l_accted_amt_idx := NULL; -- 4262811
61288 l_acc_rev_flag := NULL; -- 4262811
61289 l_accrual_line_num := NULL; -- 4262811
61290 l_tmp_amt := NULL; -- 4262811
61291 --
61292
61293 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
61294 l_balance_type_code <> 'B' THEN
61295 IF NVL(p_source_20,'
61296 ') = 'TAX' AND
61297 NVL(p_source_67,'
61298 ') = 'N'
61299 THEN
61300
61301 --
61302 XLA_AE_LINES_PKG.SetNewLine;
61303
61304 p_balance_type_code := l_balance_type_code;
61305 -- set the flag so later we will know whether the gain loss line needs to be created
61306
61307 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
61308 p_actual_flag :='A';
61309 END IF;
61310
61311 --
61312 -- bulk performance
61313 --
61314 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
61315 p_header_num => 0); -- 4262811
61316 --
61317 -- set accounting line options
61318 --
61319 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
61320 p_natural_side_code => 'C'
61321 , p_gain_or_loss_flag => 'N'
61322 , p_gl_transfer_mode_code => 'S'
61323 , p_acct_entry_type_code => 'A'
61324 , p_switch_side_flag => 'Y'
61325 , p_merge_duplicate_code => 'A'
61326 );
61327 --
61328 l_acc_rev_natural_side_code := 'D'; -- 4262811
61329 --
61330 --
61331 -- set accounting line type info
61332 --
61333 xla_ae_lines_pkg.SetAcctLineType
61334 (p_component_type => l_component_type
61335 ,p_event_type_code => l_event_type_code
61336 ,p_line_definition_owner_code => l_line_definition_owner_code
61337 ,p_line_definition_code => l_line_definition_code
61338 ,p_accounting_line_code => l_component_code
61339 ,p_accounting_line_type_code => l_component_type_code
61340 ,p_accounting_line_appl_id => l_component_appl_id
61341 ,p_amb_context_code => l_amb_context_code
61342 ,p_entity_code => l_entity_code
61343 ,p_event_class_code => l_event_class_code);
61344 --
61345 -- set accounting class
61346 --
61347 xla_ae_lines_pkg.SetAcctClass(
61348 p_accounting_class_code => 'TAX'
61349 , p_ae_header_id => l_ae_header_id
61350 );
61351
61352 --
61353 -- set rounding class
61354 --
61355 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
61356 'RECEIVABLE';
61357
61358 --
61359 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
61360 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
61361 --
61362 -- bulk performance
61363 --
61364 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
61365
61366 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
61367 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
61368
61369 -- 4955764
61370 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
61371 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
61372
61373 -- 4458381 Public Sector Enh
61374
61375 --
61376 -- set accounting attributes for the line type
61377 --
61378 l_entered_amt_idx := 8;
61379 l_accted_amt_idx := 13;
61380 l_bflow_applied_to_amt_idx := NULL; -- 5132302
61381 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
61382 l_rec_acct_attrs.array_num_value(1) := p_source_58;
61383 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
61384 l_rec_acct_attrs.array_char_value(2) := p_source_35;
61385 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
61386 l_rec_acct_attrs.array_char_value(3) := p_source_59;
61387 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
61388 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
61389 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
61390 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
61391 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
61392 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
61393 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
61394 l_rec_acct_attrs.array_char_value(7) := p_source_23;
61395 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
61396 l_rec_acct_attrs.array_num_value(8) := p_source_24;
61397 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
61398 l_rec_acct_attrs.array_char_value(9) := p_source_25;
61399 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
61400 l_rec_acct_attrs.array_date_value(10) := p_source_57;
61401 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
61402 l_rec_acct_attrs.array_num_value(11) := p_source_62;
61403 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
61404 l_rec_acct_attrs.array_char_value(12) := p_source_70;
61405 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
61406 l_rec_acct_attrs.array_num_value(13) := p_source_29;
61407 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
61408 l_rec_acct_attrs.array_num_value(14) := p_source_63;
61409 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
61410 l_rec_acct_attrs.array_num_value(15) := p_source_64;
61411 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
61412 l_rec_acct_attrs.array_char_value(16) := p_source_65;
61413
61414 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
61415 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
61416
61417 ---------------------------------------------------------------------------------------------------------------
61418 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
61419 ---------------------------------------------------------------------------------------------------------------
61420 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
61421
61422 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
61423 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
61424
61425 IF xla_accounting_cache_pkg.GetValueChar
61426 (p_source_code => 'LEDGER_CATEGORY_CODE'
61427 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
61428 AND l_bflow_method_code = 'PRIOR_ENTRY'
61429 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
61430 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
61431 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
61432 )
61433 THEN
61434 xla_ae_lines_pkg.BflowUpgEntry
61435 (p_business_method_code => l_bflow_method_code
61436 ,p_business_class_code => l_bflow_class_code
61437 ,p_balance_type => l_balance_type_code);
61438 ELSE
61439 NULL;
61440 -- No business flow processing for business flow method of NONE.
61441 END IF;
61442
61443 --
61444 -- call analytical criteria
61445 --
61446
61447 --
61448 -- call description
61449 --
61450 -- No description or it is inherited.
61451 --
61452 -- call ADRs
61453 -- Bug 4922099
61454 --
61455 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
61456 (NVL(l_actual_upg_option, 'N') = 'O') OR
61457 (NVL(l_enc_upg_option, 'N') = 'O')
61458 )
61459 THEN
61460 NULL;
61461 --
61462 --
61463
61464 l_ccid := AcctDerRule_4(
61465 p_application_id => p_application_id
61466 , p_ae_header_id => l_ae_header_id
61467 , p_source_5 => p_source_5
61468 , x_transaction_coa_id => l_adr_transaction_coa_id
61469 , x_accounting_coa_id => l_adr_accounting_coa_id
61470 , x_value_type_code => l_adr_value_type_code
61471 , p_side => 'NA'
61472 );
61473
61474 xla_ae_lines_pkg.set_ccid(
61475 p_code_combination_id => l_ccid
61476 , p_value_type_code => l_adr_value_type_code
61477 , p_transaction_coa_id => l_adr_transaction_coa_id
61478 , p_accounting_coa_id => l_adr_accounting_coa_id
61479 , p_adr_code => 'DIST_CCID'
61480 , p_adr_type_code => 'S'
61481 , p_component_type => l_component_type
61482 , p_component_code => l_component_code
61483 , p_component_type_code => l_component_type_code
61484 , p_component_appl_id => l_component_appl_id
61485 , p_amb_context_code => l_amb_context_code
61486 , p_side => 'NA'
61487 );
61488
61489
61490 --
61491 --
61492 END IF;
61493 --
61494 -- Bug 4922099
61495 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
61496 (NVL(l_enc_upg_option, 'N') = 'O')
61497 ) AND
61498 (l_bflow_method_code = 'PRIOR_ENTRY')
61499 )
61500 THEN
61501 IF
61502 --
61503 1 = 2
61504 --
61505 THEN
61506 xla_accounting_err_pkg.build_message
61507 (p_appli_s_name => 'XLA'
61508 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
61509 ,p_token_1 => 'LINE_NUMBER'
61510 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
61511 ,p_token_2 => 'LINE_TYPE_NAME'
61512 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
61513 l_component_type
61514 ,l_component_code
61515 ,l_component_type_code
61516 ,l_component_appl_id
61517 ,l_amb_context_code
61518 ,l_entity_code
61519 ,l_event_class_code
61520 )
61521 ,p_token_3 => 'OWNER'
61522 ,p_value_3 => xla_lookups_pkg.get_meaning(
61523 p_lookup_type => 'XLA_OWNER_TYPE'
61524 ,p_lookup_code => l_component_type_code
61525 )
61526 ,p_token_4 => 'PRODUCT_NAME'
61527 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
61528 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
61529 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
61530 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
61531 ,p_ae_header_id => NULL
61532 );
61533
61534 IF (C_LEVEL_ERROR>= g_log_level) THEN
61535 trace
61536 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
61537 ,p_level => C_LEVEL_ERROR
61538 ,p_module => l_log_module);
61539 END IF;
61540 END IF;
61541 END IF;
61542 --
61543 --
61544 ------------------------------------------------------------------------------------------------
61545 -- 4219869 Business Flow
61546 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
61547 -- Prior Entry. Currently, the following code is always generated.
61548 ------------------------------------------------------------------------------------------------
61549 XLA_AE_LINES_PKG.ValidateCurrentLine;
61550
61551 ------------------------------------------------------------------------------------
61552 -- 4219869 Business Flow
61553 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
61554 ------------------------------------------------------------------------------------
61555 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
61556
61557 ----------------------------------------------------------------------------------
61558 -- 4219869 Business Flow
61559 -- Update journal entry status -- Need to generate this within IF <condition>
61560 ----------------------------------------------------------------------------------
61561 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
61562 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
61563 ,p_balance_type_code => l_balance_type_code
61564 );
61565
61566 -------------------------------------------------------------------------------------------
61567 -- 4262811 - Generate the Accrual Reversal lines
61568 -------------------------------------------------------------------------------------------
61569 BEGIN
61570 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
61571 (g_array_event(p_event_id).array_value_num('header_index'));
61572 IF l_acc_rev_flag IS NULL THEN
61573 l_acc_rev_flag := 'N';
61574 END IF;
61575 EXCEPTION
61576 WHEN OTHERS THEN
61577 l_acc_rev_flag := 'N';
61578 END;
61579 --
61580 IF (l_acc_rev_flag = 'Y') THEN
61581
61582 -- 4645092 ------------------------------------------------------------------------------
61583 -- To allow MPA report to determine if it should generate report process
61584 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
61585 ------------------------------------------------------------------------------------------
61586
61587 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
61588 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
61589 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
61590 -- call ADRs
61591 -- Bug 4922099
61595 (NVL(l_enc_upg_option, 'N') = 'O')
61592 --
61593 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
61594 (NVL(l_actual_upg_option, 'N') = 'O') OR
61596 )
61597 THEN
61598 NULL;
61599 --
61600 --
61601
61602 l_ccid := AcctDerRule_4(
61603 p_application_id => p_application_id
61604 , p_ae_header_id => l_ae_header_id
61605 , p_source_5 => p_source_5
61606 , x_transaction_coa_id => l_adr_transaction_coa_id
61607 , x_accounting_coa_id => l_adr_accounting_coa_id
61608 , x_value_type_code => l_adr_value_type_code
61609 , p_side => 'NA'
61610 );
61611
61612 xla_ae_lines_pkg.set_ccid(
61613 p_code_combination_id => l_ccid
61614 , p_value_type_code => l_adr_value_type_code
61615 , p_transaction_coa_id => l_adr_transaction_coa_id
61616 , p_accounting_coa_id => l_adr_accounting_coa_id
61617 , p_adr_code => 'DIST_CCID'
61618 , p_adr_type_code => 'S'
61619 , p_component_type => l_component_type
61620 , p_component_code => l_component_code
61621 , p_component_type_code => l_component_type_code
61622 , p_component_appl_id => l_component_appl_id
61623 , p_amb_context_code => l_amb_context_code
61624 , p_side => 'NA'
61625 );
61626
61627
61628 --
61629 --
61630 END IF;
61631
61632 --
61633 -- Update the line information that should be overwritten
61634 --
61635 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
61636 p_header_num => 1);
61637 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
61638
61639 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
61640
61641 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
61642 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
61643 END IF;
61644
61645 --
61646 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
61647 --
61648 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
61649 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
61650 ELSE
61651 ---------------------------------------------------------------------------------------------------
61652 -- 4262811a Switch Sign
61653 ---------------------------------------------------------------------------------------------------
61654 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
61655 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
61656 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61657 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
61658 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61659 -- 5132302
61660 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
61661 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
61662
61663 END IF;
61664
61665 -- 4955764
61666 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
61667 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
61668
61669
61670 XLA_AE_LINES_PKG.ValidateCurrentLine;
61671 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
61672
61673 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
61674 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
61675 ,p_balance_type_code => l_balance_type_code);
61676
61677 END IF;
61678
61679 -----------------------------------------------------------------------------------------
61680 -- 4262811 Multiperiod Accounting
61681 -----------------------------------------------------------------------------------------
61682 -- No MPA option is assigned.
61683
61684
61685 END IF;
61686 END IF;
61687 --
61688
61689 --
61690 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61691 trace
61692 (p_msg => 'END of AcctLineType_125'
61693 ,p_level => C_LEVEL_PROCEDURE
61694 ,p_module => l_log_module);
61695 END IF;
61696 --
61697 EXCEPTION
61698 WHEN xla_exceptions_pkg.application_exception THEN
61699 RAISE;
61700 WHEN OTHERS THEN
61701 xla_exceptions_pkg.raise_message
61705
61702 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_125');
61703 END AcctLineType_125;
61704 --
61709 -- AcctLineType_126
61706 ---------------------------------------
61707 --
61708 -- PRIVATE FUNCTION
61710 --
61711 ---------------------------------------
61712 PROCEDURE AcctLineType_126 (
61713 p_application_id IN NUMBER
61714 ,p_event_id IN NUMBER
61715 ,p_calculate_acctd_flag IN VARCHAR2
61716 ,p_calculate_g_l_flag IN VARCHAR2
61717 ,p_actual_flag IN OUT VARCHAR2
61718 ,p_balance_type_code OUT VARCHAR2
61719 ,p_gain_or_loss_ref OUT VARCHAR2
61720
61721 --Remittance Bank Account Unapplied Account
61722 , p_source_17 IN NUMBER
61723 --Distribution Source Type
61724 , p_source_20 IN VARCHAR2
61725 --Receivable Activity Type
61726 , p_source_21 IN VARCHAR2
61727 --Distribution Line Identifier
61728 , p_source_22 IN NUMBER
61729 --Distribution Type
61730 , p_source_23 IN VARCHAR2
61731 --Exchange Date
61732 , p_source_26 IN DATE
61733 --Exchange Rate
61734 , p_source_27 IN NUMBER
61735 --Exchange Rate Type
61736 , p_source_28 IN VARCHAR2
61737 --Transaction Distribution Identifier
61738 , p_source_34 IN NUMBER
61739 --Transaction Distribution Type
61740 , p_source_35 IN VARCHAR2
61741 --Receipt Applied To Application Identifier
61742 , p_source_58 IN NUMBER
61743 --Transaction Entity Code
61744 , p_source_59 IN VARCHAR2
61745 --Transaction Identifier
61746 , p_source_60 IN NUMBER
61747 --Applying Document Currency Code
61748 , p_source_61 IN VARCHAR2
61749 --Distribution Party Type
61750 , p_source_65 IN VARCHAR2
61751 --Distribution Multi Fund Additional Entry
61752 , p_source_67 IN VARCHAR2
61753 --DIST_ENT_AMT_FROM
61754 , p_source_68 IN NUMBER
61755 --Accounting Amount
61756 , p_source_69 IN NUMBER
61757 --Distribution Source Table
61758 , p_source_71 IN VARCHAR2
61759 --Receipt Pay From Customer
61760 , p_source_72 IN NUMBER
61761 --Receipt Customer Site Use Identifier
61762 , p_source_73 IN NUMBER
61763 )
61764 IS
61765
61766 l_component_type VARCHAR2(80);
61767 l_component_code VARCHAR2(30);
61768 l_component_type_code VARCHAR2(1);
61769 l_component_appl_id INTEGER;
61770 l_amb_context_code VARCHAR2(30);
61771 l_entity_code VARCHAR2(30);
61772 l_event_class_code VARCHAR2(30);
61773 l_ae_header_id NUMBER;
61774 l_event_type_code VARCHAR2(30);
61775 l_line_definition_code VARCHAR2(30);
61776 l_line_definition_owner_code VARCHAR2(1);
61777 --
61778 -- adr variables
61779 l_segment VARCHAR2(30);
61780 l_ccid NUMBER;
61781 l_adr_transaction_coa_id NUMBER;
61782 l_adr_accounting_coa_id NUMBER;
61783 l_adr_flexfield_segment_code VARCHAR2(30);
61784 l_adr_flex_value_set_id NUMBER;
61785 l_adr_value_type_code VARCHAR2(30);
61786 l_adr_value_combination_id NUMBER;
61787 l_adr_value_segment_code VARCHAR2(30);
61788
61789 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
61790 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
61791 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
61792 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
61793
61794 -- 4262811 Variables ------------------------------------------------------------------------------------------
61795 l_entered_amt_idx NUMBER;
61796 l_accted_amt_idx NUMBER;
61797 l_acc_rev_flag VARCHAR2(1);
61798 l_accrual_line_num NUMBER;
61799 l_tmp_amt NUMBER;
61800 l_acc_rev_natural_side_code VARCHAR2(1);
61801
61802 l_num_entries NUMBER;
61803 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
61804 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
61805 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
61806 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
61807 l_recog_line_1 NUMBER;
61808 l_recog_line_2 NUMBER;
61809
61810 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
61811 l_bflow_applied_to_amt NUMBER; -- 5132302
61812 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
61813
61814 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
61815
61816 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
61817 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
61818
61819 ---------------------------------------------------------------------------------------------------------------
61820
61821
61822 --
61823 -- bulk performance
61824 --
61825 l_balance_type_code VARCHAR2(1);
61826 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
61827 l_log_module VARCHAR2(240);
61828
61829 --
61830 -- Upgrade strategy
61831 --
61832 l_actual_upg_option VARCHAR2(1);
61833 l_enc_upg_option VARCHAR2(1);
61834
61835 --
61836 BEGIN
61837 --
61838 IF g_log_enabled THEN
61839 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_126';
61840 END IF;
61841 --
61842 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
61843
61844 trace
61845 (p_msg => 'BEGIN of AcctLineType_126'
61846 ,p_level => C_LEVEL_PROCEDURE
61847 ,p_module => l_log_module);
61848
61849 END IF;
61850 --
61851 l_component_type := 'AMB_JLT';
61852 l_component_code := 'RCT_UNAPP';
61853 l_component_type_code := 'S';
61854 l_component_appl_id := 222;
61855 l_amb_context_code := 'DEFAULT';
61856 l_entity_code := 'RECEIPTS';
61857 l_event_class_code := 'RECEIPT';
61858 l_event_type_code := 'RECEIPT_ALL';
61859 l_line_definition_owner_code := 'S';
61860 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
61861 --
61862 l_balance_type_code := 'A';
61863 l_segment := NULL;
61864 l_ccid := NULL;
61865 l_adr_transaction_coa_id := NULL;
61866 l_adr_accounting_coa_id := NULL;
61867 l_adr_flexfield_segment_code := NULL;
61868 l_adr_flex_value_set_id := NULL;
61869 l_adr_value_type_code := NULL;
61870 l_adr_value_combination_id := NULL;
61871 l_adr_value_segment_code := NULL;
61872
61873 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
61874 l_bflow_class_code := ''; -- 4219869 Business Flow
61875 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
61876 l_budgetary_control_flag := 'N';
61877
61878 l_bflow_applied_to_amt_idx := NULL; -- 5132302
61879 l_bflow_applied_to_amt := NULL; -- 5132302
61880 l_entered_amt_idx := NULL; -- 4262811
61881 l_accted_amt_idx := NULL; -- 4262811
61882 l_acc_rev_flag := NULL; -- 4262811
61883 l_accrual_line_num := NULL; -- 4262811
61884 l_tmp_amt := NULL; -- 4262811
61885 --
61886
61887 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
61888 l_balance_type_code <> 'B' THEN
61889 IF (NVL(p_source_20,'
61890 ') = 'OTHER ACC' AND
61891 NVL(p_source_21,'
61892 ') = 'CLAIM_INVESTIGATION' AND
61893 NVL(p_source_67,'
61894 ') = 'N') OR
61895 (NVL(p_source_20,'
61896 ') = 'FACTOR' AND
61897 NVL(p_source_71,'
61898 ') = 'RA' AND
61899 NVL(p_source_67,'
61900 ') = 'N') OR
61901 (NVL(p_source_20,'
61902 ') = 'OTHER ACC' AND
61903 NVL(p_source_67,'
61904 ') = 'N' AND
61905 NVL(p_source_21,'
61906 ') = 'NETTING') OR
61907 (NVL(p_source_20,'
61908 ') = 'OTHER ACC' AND
61909 NVL(p_source_67,'
61910 ') = 'N' AND
61911 NVL(p_source_21,'
61912 ') = 'PREPAYMENT') OR
61913 (NVL(p_source_20,'
61914 ') = 'ACTIVITY' AND
61915 NVL(p_source_67,'
61916 ') = 'N' AND
61917 NVL(p_source_21,'
61918 ') = 'CCREFUND') OR
61919 (NVL(p_source_20,'
61920 ') = 'REMITTANCE' AND
61921 NVL(p_source_67,'
61922 ') = 'N' AND
61923 NVL(p_source_71,'
61924 ') = 'RA') OR
61925 (NVL(p_source_20,'
61926 ') = 'ACTIVITY' AND
61927 NVL(p_source_67,'
61928 ') = 'N' AND
61929 NVL(p_source_21,'
61930 ') = 'WRITEOFF') OR
61931 (NVL(p_source_20,'
61932 ') = 'ACTIVITY' AND
61933 NVL(p_source_67,'
61934 ') = 'N' AND
61935 NVL(p_source_21,'
61936 ') = 'CM_REFUND') OR
61937 (NVL(p_source_20,'
61938 ') = 'ACTIVITY' AND
61939 NVL(p_source_21,'
61940 ') = 'ADJUST' AND
61941 NVL(p_source_67,'
61942 ') = 'N') OR
61943 (NVL(p_source_20,'
61944 ') = 'ACTIVITY' AND
61945 NVL(p_source_67,'
61946 ') = 'N' AND
61947 NVL(p_source_21,'
61948 ') = 'CC_CHARGEBACK') OR
61949 (NVL(p_source_20,'
61950 ') = 'ACTIVITY' AND
61951 NVL(p_source_67,'
61952 ') = 'N' AND
61953 NVL(p_source_21,'
61954 ') = 'NETTING')
61955 THEN
61956
61957 --
61958 XLA_AE_LINES_PKG.SetNewLine;
61959
61960 p_balance_type_code := l_balance_type_code;
61961 -- set the flag so later we will know whether the gain loss line needs to be created
61962
61963 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
61964 p_actual_flag :='A';
61965 END IF;
61966
61967 --
61968 -- bulk performance
61969 --
61970 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
61971 p_header_num => 0); -- 4262811
61972 --
61973 -- set accounting line options
61974 --
61975 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
61976 p_natural_side_code => 'D'
61977 , p_gain_or_loss_flag => 'N'
61978 , p_gl_transfer_mode_code => 'S'
61979 , p_acct_entry_type_code => 'A'
61980 , p_switch_side_flag => 'Y'
61981 , p_merge_duplicate_code => 'A'
61982 );
61983 --
61984 l_acc_rev_natural_side_code := 'C'; -- 4262811
61985 --
61986 --
61987 -- set accounting line type info
61988 --
61989 xla_ae_lines_pkg.SetAcctLineType
61990 (p_component_type => l_component_type
61991 ,p_event_type_code => l_event_type_code
61992 ,p_line_definition_owner_code => l_line_definition_owner_code
61993 ,p_line_definition_code => l_line_definition_code
61994 ,p_accounting_line_code => l_component_code
61995 ,p_accounting_line_type_code => l_component_type_code
61996 ,p_accounting_line_appl_id => l_component_appl_id
61997 ,p_amb_context_code => l_amb_context_code
61998 ,p_entity_code => l_entity_code
61999 ,p_event_class_code => l_event_class_code);
62000 --
62001 -- set accounting class
62002 --
62003 xla_ae_lines_pkg.SetAcctClass(
62004 p_accounting_class_code => 'UNAPP'
62005 , p_ae_header_id => l_ae_header_id
62006 );
62007
62008 --
62009 -- set rounding class
62010 --
62011 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
62012 'RECEIVABLE';
62013
62014 --
62015 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
62016 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
62017 --
62018 -- bulk performance
62019 --
62020 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
62021
62022 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
62023 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
62024
62025 -- 4955764
62026 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
62027 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
62028
62029 -- 4458381 Public Sector Enh
62030
62031 --
62032 -- set accounting attributes for the line type
62033 --
62034 l_entered_amt_idx := 8;
62035 l_accted_amt_idx := 13;
62036 l_bflow_applied_to_amt_idx := NULL; -- 5132302
62037 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
62038 l_rec_acct_attrs.array_num_value(1) := p_source_58;
62039 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
62040 l_rec_acct_attrs.array_char_value(2) := p_source_35;
62041 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
62042 l_rec_acct_attrs.array_char_value(3) := p_source_59;
62043 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
62044 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
62045 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
62046 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
62047 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
62048 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
62049 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
62050 l_rec_acct_attrs.array_char_value(7) := p_source_23;
62051 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
62052 l_rec_acct_attrs.array_num_value(8) := p_source_68;
62053 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
62054 l_rec_acct_attrs.array_char_value(9) := p_source_61;
62055 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
62056 l_rec_acct_attrs.array_date_value(10) := p_source_26;
62057 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
62058 l_rec_acct_attrs.array_num_value(11) := p_source_27;
62059 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
62060 l_rec_acct_attrs.array_char_value(12) := p_source_28;
62061 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
62062 l_rec_acct_attrs.array_num_value(13) := p_source_69;
62063 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
62064 l_rec_acct_attrs.array_num_value(14) := p_source_72;
62065 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
62066 l_rec_acct_attrs.array_num_value(15) := p_source_73;
62067 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
62068 l_rec_acct_attrs.array_char_value(16) := p_source_65;
62069
62070 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
62071 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
62072
62073 ---------------------------------------------------------------------------------------------------------------
62074 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
62075 ---------------------------------------------------------------------------------------------------------------
62076 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
62077
62078 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62079 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62080
62081 IF xla_accounting_cache_pkg.GetValueChar
62082 (p_source_code => 'LEDGER_CATEGORY_CODE'
62083 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
62084 AND l_bflow_method_code = 'PRIOR_ENTRY'
62085 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
62086 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
62087 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
62088 )
62089 THEN
62090 xla_ae_lines_pkg.BflowUpgEntry
62091 (p_business_method_code => l_bflow_method_code
62092 ,p_business_class_code => l_bflow_class_code
62093 ,p_balance_type => l_balance_type_code);
62094 ELSE
62095 NULL;
62096 -- No business flow processing for business flow method of NONE.
62097 END IF;
62098
62099 --
62100 -- call analytical criteria
62101 --
62102
62103 --
62104 -- call description
62105 --
62106 -- No description or it is inherited.
62107 --
62108 -- call ADRs
62109 -- Bug 4922099
62110 --
62111 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
62112 (NVL(l_actual_upg_option, 'N') = 'O') OR
62113 (NVL(l_enc_upg_option, 'N') = 'O')
62114 )
62115 THEN
62116 NULL;
62117 --
62118 --
62119
62120 l_ccid := AcctDerRule_24(
62121 p_application_id => p_application_id
62122 , p_ae_header_id => l_ae_header_id
62123 , p_source_17 => p_source_17
62124 , x_transaction_coa_id => l_adr_transaction_coa_id
62125 , x_accounting_coa_id => l_adr_accounting_coa_id
62126 , x_value_type_code => l_adr_value_type_code
62127 , p_side => 'NA'
62128 );
62129
62130 xla_ae_lines_pkg.set_ccid(
62131 p_code_combination_id => l_ccid
62132 , p_value_type_code => l_adr_value_type_code
62133 , p_transaction_coa_id => l_adr_transaction_coa_id
62134 , p_accounting_coa_id => l_adr_accounting_coa_id
62135 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
62136 , p_adr_type_code => 'S'
62137 , p_component_type => l_component_type
62138 , p_component_code => l_component_code
62139 , p_component_type_code => l_component_type_code
62140 , p_component_appl_id => l_component_appl_id
62141 , p_amb_context_code => l_amb_context_code
62142 , p_side => 'NA'
62143 );
62144
62145
62146 --
62147 --
62148 END IF;
62149 --
62150 -- Bug 4922099
62151 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
62152 (NVL(l_enc_upg_option, 'N') = 'O')
62153 ) AND
62154 (l_bflow_method_code = 'PRIOR_ENTRY')
62155 )
62156 THEN
62157 IF
62158 --
62159 1 = 2
62160 --
62161 THEN
62162 xla_accounting_err_pkg.build_message
62163 (p_appli_s_name => 'XLA'
62164 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
62165 ,p_token_1 => 'LINE_NUMBER'
62166 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
62167 ,p_token_2 => 'LINE_TYPE_NAME'
62168 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
62169 l_component_type
62170 ,l_component_code
62171 ,l_component_type_code
62172 ,l_component_appl_id
62173 ,l_amb_context_code
62174 ,l_entity_code
62175 ,l_event_class_code
62176 )
62177 ,p_token_3 => 'OWNER'
62178 ,p_value_3 => xla_lookups_pkg.get_meaning(
62179 p_lookup_type => 'XLA_OWNER_TYPE'
62180 ,p_lookup_code => l_component_type_code
62181 )
62182 ,p_token_4 => 'PRODUCT_NAME'
62183 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
62184 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
62185 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
62186 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
62187 ,p_ae_header_id => NULL
62188 );
62189
62190 IF (C_LEVEL_ERROR>= g_log_level) THEN
62191 trace
62192 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
62193 ,p_level => C_LEVEL_ERROR
62194 ,p_module => l_log_module);
62195 END IF;
62196 END IF;
62197 END IF;
62198 --
62199 --
62200 ------------------------------------------------------------------------------------------------
62201 -- 4219869 Business Flow
62202 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
62203 -- Prior Entry. Currently, the following code is always generated.
62204 ------------------------------------------------------------------------------------------------
62205 XLA_AE_LINES_PKG.ValidateCurrentLine;
62206
62207 ------------------------------------------------------------------------------------
62211 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
62208 -- 4219869 Business Flow
62209 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
62210 ------------------------------------------------------------------------------------
62212
62213 ----------------------------------------------------------------------------------
62214 -- 4219869 Business Flow
62215 -- Update journal entry status -- Need to generate this within IF <condition>
62216 ----------------------------------------------------------------------------------
62217 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
62218 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
62219 ,p_balance_type_code => l_balance_type_code
62220 );
62221
62222 -------------------------------------------------------------------------------------------
62223 -- 4262811 - Generate the Accrual Reversal lines
62224 -------------------------------------------------------------------------------------------
62225 BEGIN
62226 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
62227 (g_array_event(p_event_id).array_value_num('header_index'));
62228 IF l_acc_rev_flag IS NULL THEN
62229 l_acc_rev_flag := 'N';
62230 END IF;
62231 EXCEPTION
62232 WHEN OTHERS THEN
62233 l_acc_rev_flag := 'N';
62234 END;
62235 --
62236 IF (l_acc_rev_flag = 'Y') THEN
62237
62238 -- 4645092 ------------------------------------------------------------------------------
62239 -- To allow MPA report to determine if it should generate report process
62240 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
62241 ------------------------------------------------------------------------------------------
62242
62243 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
62244 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
62245 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
62246 -- call ADRs
62247 -- Bug 4922099
62248 --
62249 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
62250 (NVL(l_actual_upg_option, 'N') = 'O') OR
62251 (NVL(l_enc_upg_option, 'N') = 'O')
62252 )
62253 THEN
62254 NULL;
62255 --
62256 --
62257
62258 l_ccid := AcctDerRule_24(
62259 p_application_id => p_application_id
62260 , p_ae_header_id => l_ae_header_id
62261 , p_source_17 => p_source_17
62262 , x_transaction_coa_id => l_adr_transaction_coa_id
62263 , x_accounting_coa_id => l_adr_accounting_coa_id
62264 , x_value_type_code => l_adr_value_type_code
62265 , p_side => 'NA'
62266 );
62267
62268 xla_ae_lines_pkg.set_ccid(
62269 p_code_combination_id => l_ccid
62270 , p_value_type_code => l_adr_value_type_code
62271 , p_transaction_coa_id => l_adr_transaction_coa_id
62272 , p_accounting_coa_id => l_adr_accounting_coa_id
62273 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
62274 , p_adr_type_code => 'S'
62275 , p_component_type => l_component_type
62276 , p_component_code => l_component_code
62277 , p_component_type_code => l_component_type_code
62278 , p_component_appl_id => l_component_appl_id
62279 , p_amb_context_code => l_amb_context_code
62280 , p_side => 'NA'
62281 );
62282
62283
62284 --
62285 --
62286 END IF;
62287
62288 --
62289 -- Update the line information that should be overwritten
62290 --
62291 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
62292 p_header_num => 1);
62293 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
62294
62295 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
62296
62297 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
62298 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
62299 END IF;
62300
62301 --
62302 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
62303 --
62304 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
62305 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
62306 ELSE
62307 ---------------------------------------------------------------------------------------------------
62308 -- 4262811a Switch Sign
62309 ---------------------------------------------------------------------------------------------------
62310 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
62311 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
62312 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62313 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
62314 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62315 -- 5132302
62316 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
62317 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62318
62319 END IF;
62320
62321 -- 4955764
62322 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
62323 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
62324
62325
62326 XLA_AE_LINES_PKG.ValidateCurrentLine;
62327 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
62328
62329 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
62330 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
62331 ,p_balance_type_code => l_balance_type_code);
62332
62333 END IF;
62334
62335 -----------------------------------------------------------------------------------------
62336 -- 4262811 Multiperiod Accounting
62337 -----------------------------------------------------------------------------------------
62338 -- No MPA option is assigned.
62339
62340
62341 END IF;
62342 END IF;
62343 --
62344
62345 --
62346 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62347 trace
62348 (p_msg => 'END of AcctLineType_126'
62349 ,p_level => C_LEVEL_PROCEDURE
62350 ,p_module => l_log_module);
62351 END IF;
62352 --
62353 EXCEPTION
62354 WHEN xla_exceptions_pkg.application_exception THEN
62355 RAISE;
62356 WHEN OTHERS THEN
62357 xla_exceptions_pkg.raise_message
62358 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_126');
62359 END AcctLineType_126;
62360 --
62361
62362 ---------------------------------------
62363 --
62364 -- PRIVATE FUNCTION
62365 -- AcctLineType_127
62366 --
62367 ---------------------------------------
62368 PROCEDURE AcctLineType_127 (
62369 p_application_id IN NUMBER
62370 ,p_event_id IN NUMBER
62371 ,p_calculate_acctd_flag IN VARCHAR2
62372 ,p_calculate_g_l_flag IN VARCHAR2
62373 ,p_actual_flag IN OUT VARCHAR2
62374 ,p_balance_type_code OUT VARCHAR2
62375 ,p_gain_or_loss_ref OUT VARCHAR2
62376
62377 --Remittance Bank Account Unapplied Account
62378 , p_source_17 IN NUMBER
62379 --Distribution Source Type
62380 , p_source_20 IN VARCHAR2
62381 --Distribution Line Identifier
62382 , p_source_22 IN NUMBER
62383 --Distribution Type
62384 , p_source_23 IN VARCHAR2
62385 --Exchange Date
62386 , p_source_26 IN DATE
62387 --Exchange Rate
62388 , p_source_27 IN NUMBER
62389 --Exchange Rate Type
62390 , p_source_28 IN VARCHAR2
62391 --Transaction Distribution Identifier
62392 , p_source_34 IN NUMBER
62393 --Transaction Distribution Type
62394 , p_source_35 IN VARCHAR2
62395 --Receipt Applied To Application Identifier
62396 , p_source_58 IN NUMBER
62397 --Transaction Entity Code
62398 , p_source_59 IN VARCHAR2
62399 --Transaction Identifier
62400 , p_source_60 IN NUMBER
62401 --Applying Document Currency Code
62402 , p_source_61 IN VARCHAR2
62403 --Distribution Party Type
62404 , p_source_65 IN VARCHAR2
62405 --Distribution Multi Fund Additional Entry
62406 , p_source_67 IN VARCHAR2
62407 --DIST_ENT_AMT_FROM
62408 , p_source_68 IN NUMBER
62409 --Accounting Amount
62410 , p_source_69 IN NUMBER
62411 --Distribution Source Table
62412 , p_source_71 IN VARCHAR2
62413 --Receipt Pay From Customer
62414 , p_source_72 IN NUMBER
62415 --Receipt Customer Site Use Identifier
62416 , p_source_73 IN NUMBER
62417 --Receipt Application Status
62418 , p_source_74 IN VARCHAR2
62419 )
62420 IS
62421
62422 l_component_type VARCHAR2(80);
62423 l_component_code VARCHAR2(30);
62424 l_component_type_code VARCHAR2(1);
62425 l_component_appl_id INTEGER;
62426 l_amb_context_code VARCHAR2(30);
62427 l_entity_code VARCHAR2(30);
62428 l_event_class_code VARCHAR2(30);
62429 l_ae_header_id NUMBER;
62430 l_event_type_code VARCHAR2(30);
62431 l_line_definition_code VARCHAR2(30);
62432 l_line_definition_owner_code VARCHAR2(1);
62433 --
62434 -- adr variables
62435 l_segment VARCHAR2(30);
62436 l_ccid NUMBER;
62437 l_adr_transaction_coa_id NUMBER;
62438 l_adr_accounting_coa_id NUMBER;
62439 l_adr_flexfield_segment_code VARCHAR2(30);
62440 l_adr_flex_value_set_id NUMBER;
62441 l_adr_value_type_code VARCHAR2(30);
62442 l_adr_value_combination_id NUMBER;
62443 l_adr_value_segment_code VARCHAR2(30);
62444
62445 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
62446 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
62447 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
62448 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
62449
62450 -- 4262811 Variables ------------------------------------------------------------------------------------------
62451 l_entered_amt_idx NUMBER;
62452 l_accted_amt_idx NUMBER;
62453 l_acc_rev_flag VARCHAR2(1);
62454 l_accrual_line_num NUMBER;
62455 l_tmp_amt NUMBER;
62456 l_acc_rev_natural_side_code VARCHAR2(1);
62457
62458 l_num_entries NUMBER;
62459 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
62460 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
62461 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
62462 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
62463 l_recog_line_1 NUMBER;
62464 l_recog_line_2 NUMBER;
62465
62466 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
62467 l_bflow_applied_to_amt NUMBER; -- 5132302
62468 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
62469
62470 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
62471
62472 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
62473 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
62474
62475 ---------------------------------------------------------------------------------------------------------------
62476
62477
62478 --
62479 -- bulk performance
62480 --
62481 l_balance_type_code VARCHAR2(1);
62482 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
62483 l_log_module VARCHAR2(240);
62484
62485 --
62486 -- Upgrade strategy
62487 --
62488 l_actual_upg_option VARCHAR2(1);
62489 l_enc_upg_option VARCHAR2(1);
62490
62491 --
62492 BEGIN
62493 --
62494 IF g_log_enabled THEN
62495 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_127';
62496 END IF;
62497 --
62498 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62499
62500 trace
62501 (p_msg => 'BEGIN of AcctLineType_127'
62502 ,p_level => C_LEVEL_PROCEDURE
62503 ,p_module => l_log_module);
62504
62505 END IF;
62506 --
62507 l_component_type := 'AMB_JLT';
62508 l_component_code := 'RCT_UNAPP_DEBIT';
62509 l_component_type_code := 'S';
62510 l_component_appl_id := 222;
62511 l_amb_context_code := 'DEFAULT';
62512 l_entity_code := 'RECEIPTS';
62513 l_event_class_code := 'RECEIPT';
62514 l_event_type_code := 'RECEIPT_ALL';
62515 l_line_definition_owner_code := 'S';
62516 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
62517 --
62518 l_balance_type_code := 'A';
62519 l_segment := NULL;
62520 l_ccid := NULL;
62521 l_adr_transaction_coa_id := NULL;
62522 l_adr_accounting_coa_id := NULL;
62523 l_adr_flexfield_segment_code := NULL;
62524 l_adr_flex_value_set_id := NULL;
62525 l_adr_value_type_code := NULL;
62526 l_adr_value_combination_id := NULL;
62527 l_adr_value_segment_code := NULL;
62528
62529 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
62530 l_bflow_class_code := ''; -- 4219869 Business Flow
62531 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
62532 l_budgetary_control_flag := 'N';
62533
62534 l_bflow_applied_to_amt_idx := NULL; -- 5132302
62535 l_bflow_applied_to_amt := NULL; -- 5132302
62536 l_entered_amt_idx := NULL; -- 4262811
62537 l_accted_amt_idx := NULL; -- 4262811
62538 l_acc_rev_flag := NULL; -- 4262811
62539 l_accrual_line_num := NULL; -- 4262811
62540 l_tmp_amt := NULL; -- 4262811
62541 --
62542
62543 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
62544 l_balance_type_code <> 'B' THEN
62545 IF ((NVL(p_source_20,'
62546 ') = 'REC' AND
62547 NVL(p_source_67,'
62548 ') = 'N') OR
62549 (NVL(p_source_67,'
62550 ') = 'N' AND
62551 NVL(p_source_20,'
62552 ') = 'CASH') OR
62553 (NVL(p_source_67,'
62554 ') = 'N' AND
62555 NVL(p_source_20,'
62556 ') = 'CONFIRMATION') OR
62557 (NVL(p_source_67,'
62558 ') = 'N' AND
62559 NVL(p_source_20,'
62560 ') = 'CURR_ROUND') OR
62561 (NVL(p_source_67,'
62562 ') = 'N' AND
62563 NVL(p_source_20,'
62564 ') = 'DEFERRED_TAX') OR
62565 (NVL(p_source_67,'
62566 ') = 'N' AND
62567 NVL(p_source_71,'
62568 ') = 'CRH' AND
62569 NVL(p_source_20,'
62570 ') = 'FACTOR') OR
62571 (NVL(p_source_67,'
62572 ') = 'N' AND
62573 NVL(p_source_20,'
62574 ') = 'ACC') OR
62575 (NVL(p_source_67,'
62576 ') = 'N' AND
62577 NVL(p_source_20,'
62578 ') = 'REMITTANCE' AND
62579 NVL(p_source_71,'
62580 ') = 'CRH') OR
62581 (NVL(p_source_67,'
62582 ') = 'N' AND
62583 NVL(p_source_20,'
62584 ') = 'SHORT_TERM_DEBT') OR
62585 (NVL(p_source_67,'
62586 ') = 'N' AND
62587 NVL(p_source_20,'
62588 ') = 'TAX') OR
62589 (NVL(p_source_67,'
62590 ') = 'N' AND
62591 NVL(p_source_20,'
62592 ') = 'UNID') OR
62593 (NVL(p_source_67,'
62594 ') = 'N' AND
62595 NVL(p_source_20,'
62596 ') = 'BANK_CHARGES') OR
62597 (NVL(p_source_67,'
62598 ') = 'N' AND
62599 NVL(p_source_20,'
62600 ') = 'EDISC') OR
62601 (NVL(p_source_67,'
62602 ') = 'N' AND
62603 NVL(p_source_20,'
62604 ') = 'UNEDISC')
62605 ) AND NVL(p_source_74,'
62606 ') <> 'UNID'
62607 THEN
62608
62609 --
62610 XLA_AE_LINES_PKG.SetNewLine;
62611
62612 p_balance_type_code := l_balance_type_code;
62613 -- set the flag so later we will know whether the gain loss line needs to be created
62614
62615 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
62616 p_actual_flag :='A';
62617 END IF;
62618
62619 --
62620 -- bulk performance
62621 --
62622 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
62623 p_header_num => 0); -- 4262811
62624 --
62625 -- set accounting line options
62626 --
62627 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
62628 p_natural_side_code => 'D'
62629 , p_gain_or_loss_flag => 'N'
62630 , p_gl_transfer_mode_code => 'S'
62631 , p_acct_entry_type_code => 'A'
62632 , p_switch_side_flag => 'Y'
62633 , p_merge_duplicate_code => 'A'
62634 );
62635 --
62636 l_acc_rev_natural_side_code := 'C'; -- 4262811
62637 --
62638 --
62639 -- set accounting line type info
62640 --
62641 xla_ae_lines_pkg.SetAcctLineType
62642 (p_component_type => l_component_type
62643 ,p_event_type_code => l_event_type_code
62644 ,p_line_definition_owner_code => l_line_definition_owner_code
62645 ,p_line_definition_code => l_line_definition_code
62646 ,p_accounting_line_code => l_component_code
62647 ,p_accounting_line_type_code => l_component_type_code
62648 ,p_accounting_line_appl_id => l_component_appl_id
62649 ,p_amb_context_code => l_amb_context_code
62650 ,p_entity_code => l_entity_code
62651 ,p_event_class_code => l_event_class_code);
62652 --
62653 -- set accounting class
62654 --
62655 xla_ae_lines_pkg.SetAcctClass(
62656 p_accounting_class_code => 'UNAPP'
62657 , p_ae_header_id => l_ae_header_id
62658 );
62659
62660 --
62661 -- set rounding class
62662 --
62663 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
62664 'RECEIVABLE';
62665
62666 --
62667 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
62668 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
62669 --
62670 -- bulk performance
62671 --
62672 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
62673
62674 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
62675 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
62676
62677 -- 4955764
62678 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
62679 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
62680
62681 -- 4458381 Public Sector Enh
62682
62683 --
62684 -- set accounting attributes for the line type
62685 --
62686 l_entered_amt_idx := 8;
62687 l_accted_amt_idx := 13;
62688 l_bflow_applied_to_amt_idx := NULL; -- 5132302
62689 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
62690 l_rec_acct_attrs.array_num_value(1) := p_source_58;
62691 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
62692 l_rec_acct_attrs.array_char_value(2) := p_source_35;
62693 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
62694 l_rec_acct_attrs.array_char_value(3) := p_source_59;
62695 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
62696 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
62697 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
62698 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
62702 l_rec_acct_attrs.array_char_value(7) := p_source_23;
62699 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
62700 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
62701 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
62703 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
62704 l_rec_acct_attrs.array_num_value(8) := p_source_68;
62705 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
62706 l_rec_acct_attrs.array_char_value(9) := p_source_61;
62707 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
62708 l_rec_acct_attrs.array_date_value(10) := p_source_26;
62709 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
62710 l_rec_acct_attrs.array_num_value(11) := p_source_27;
62711 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
62712 l_rec_acct_attrs.array_char_value(12) := p_source_28;
62713 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
62714 l_rec_acct_attrs.array_num_value(13) := p_source_69;
62715 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
62716 l_rec_acct_attrs.array_num_value(14) := p_source_72;
62717 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
62718 l_rec_acct_attrs.array_num_value(15) := p_source_73;
62719 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
62720 l_rec_acct_attrs.array_char_value(16) := p_source_65;
62721
62722 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
62723 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
62724
62725 ---------------------------------------------------------------------------------------------------------------
62726 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
62727 ---------------------------------------------------------------------------------------------------------------
62728 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
62729
62730 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62731 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
62732
62733 IF xla_accounting_cache_pkg.GetValueChar
62734 (p_source_code => 'LEDGER_CATEGORY_CODE'
62735 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
62736 AND l_bflow_method_code = 'PRIOR_ENTRY'
62737 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
62738 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
62739 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
62740 )
62741 THEN
62742 xla_ae_lines_pkg.BflowUpgEntry
62743 (p_business_method_code => l_bflow_method_code
62744 ,p_business_class_code => l_bflow_class_code
62745 ,p_balance_type => l_balance_type_code);
62746 ELSE
62747 NULL;
62748 -- No business flow processing for business flow method of NONE.
62749 END IF;
62750
62751 --
62752 -- call analytical criteria
62753 --
62754
62755 --
62756 -- call description
62757 --
62758 -- No description or it is inherited.
62759 --
62760 -- call ADRs
62761 -- Bug 4922099
62762 --
62763 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
62764 (NVL(l_actual_upg_option, 'N') = 'O') OR
62765 (NVL(l_enc_upg_option, 'N') = 'O')
62766 )
62767 THEN
62768 NULL;
62769 --
62770 --
62771
62772 l_ccid := AcctDerRule_24(
62773 p_application_id => p_application_id
62774 , p_ae_header_id => l_ae_header_id
62775 , p_source_17 => p_source_17
62776 , x_transaction_coa_id => l_adr_transaction_coa_id
62777 , x_accounting_coa_id => l_adr_accounting_coa_id
62778 , x_value_type_code => l_adr_value_type_code
62779 , p_side => 'NA'
62780 );
62781
62782 xla_ae_lines_pkg.set_ccid(
62783 p_code_combination_id => l_ccid
62784 , p_value_type_code => l_adr_value_type_code
62785 , p_transaction_coa_id => l_adr_transaction_coa_id
62786 , p_accounting_coa_id => l_adr_accounting_coa_id
62787 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
62788 , p_adr_type_code => 'S'
62789 , p_component_type => l_component_type
62790 , p_component_code => l_component_code
62791 , p_component_type_code => l_component_type_code
62792 , p_component_appl_id => l_component_appl_id
62793 , p_amb_context_code => l_amb_context_code
62794 , p_side => 'NA'
62795 );
62796
62797
62798 --
62799 --
62800 END IF;
62801 --
62802 -- Bug 4922099
62803 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
62804 (NVL(l_enc_upg_option, 'N') = 'O')
62805 ) AND
62806 (l_bflow_method_code = 'PRIOR_ENTRY')
62807 )
62808 THEN
62809 IF
62810 --
62811 1 = 2
62812 --
62813 THEN
62814 xla_accounting_err_pkg.build_message
62815 (p_appli_s_name => 'XLA'
62816 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
62817 ,p_token_1 => 'LINE_NUMBER'
62818 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
62819 ,p_token_2 => 'LINE_TYPE_NAME'
62820 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
62821 l_component_type
62822 ,l_component_code
62823 ,l_component_type_code
62824 ,l_component_appl_id
62825 ,l_amb_context_code
62826 ,l_entity_code
62827 ,l_event_class_code
62828 )
62829 ,p_token_3 => 'OWNER'
62830 ,p_value_3 => xla_lookups_pkg.get_meaning(
62831 p_lookup_type => 'XLA_OWNER_TYPE'
62832 ,p_lookup_code => l_component_type_code
62833 )
62834 ,p_token_4 => 'PRODUCT_NAME'
62835 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
62836 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
62837 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
62838 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
62839 ,p_ae_header_id => NULL
62840 );
62841
62842 IF (C_LEVEL_ERROR>= g_log_level) THEN
62843 trace
62844 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
62845 ,p_level => C_LEVEL_ERROR
62846 ,p_module => l_log_module);
62847 END IF;
62848 END IF;
62849 END IF;
62850 --
62851 --
62852 ------------------------------------------------------------------------------------------------
62853 -- 4219869 Business Flow
62854 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
62855 -- Prior Entry. Currently, the following code is always generated.
62856 ------------------------------------------------------------------------------------------------
62857 XLA_AE_LINES_PKG.ValidateCurrentLine;
62858
62859 ------------------------------------------------------------------------------------
62860 -- 4219869 Business Flow
62861 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
62862 ------------------------------------------------------------------------------------
62863 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
62864
62865 ----------------------------------------------------------------------------------
62866 -- 4219869 Business Flow
62867 -- Update journal entry status -- Need to generate this within IF <condition>
62868 ----------------------------------------------------------------------------------
62869 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
62870 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
62871 ,p_balance_type_code => l_balance_type_code
62872 );
62873
62874 -------------------------------------------------------------------------------------------
62875 -- 4262811 - Generate the Accrual Reversal lines
62876 -------------------------------------------------------------------------------------------
62877 BEGIN
62878 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
62879 (g_array_event(p_event_id).array_value_num('header_index'));
62880 IF l_acc_rev_flag IS NULL THEN
62881 l_acc_rev_flag := 'N';
62882 END IF;
62883 EXCEPTION
62884 WHEN OTHERS THEN
62885 l_acc_rev_flag := 'N';
62886 END;
62887 --
62888 IF (l_acc_rev_flag = 'Y') THEN
62889
62890 -- 4645092 ------------------------------------------------------------------------------
62891 -- To allow MPA report to determine if it should generate report process
62892 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
62893 ------------------------------------------------------------------------------------------
62894
62895 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
62896 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
62897 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
62898 -- call ADRs
62899 -- Bug 4922099
62900 --
62901 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
62902 (NVL(l_actual_upg_option, 'N') = 'O') OR
62903 (NVL(l_enc_upg_option, 'N') = 'O')
62904 )
62905 THEN
62906 NULL;
62907 --
62908 --
62909
62910 l_ccid := AcctDerRule_24(
62911 p_application_id => p_application_id
62912 , p_ae_header_id => l_ae_header_id
62913 , p_source_17 => p_source_17
62914 , x_transaction_coa_id => l_adr_transaction_coa_id
62915 , x_accounting_coa_id => l_adr_accounting_coa_id
62916 , x_value_type_code => l_adr_value_type_code
62917 , p_side => 'NA'
62918 );
62919
62920 xla_ae_lines_pkg.set_ccid(
62921 p_code_combination_id => l_ccid
62922 , p_value_type_code => l_adr_value_type_code
62923 , p_transaction_coa_id => l_adr_transaction_coa_id
62924 , p_accounting_coa_id => l_adr_accounting_coa_id
62925 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
62926 , p_adr_type_code => 'S'
62927 , p_component_type => l_component_type
62928 , p_component_code => l_component_code
62929 , p_component_type_code => l_component_type_code
62930 , p_component_appl_id => l_component_appl_id
62931 , p_amb_context_code => l_amb_context_code
62932 , p_side => 'NA'
62933 );
62934
62935
62936 --
62937 --
62938 END IF;
62939
62940 --
62941 -- Update the line information that should be overwritten
62942 --
62943 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
62944 p_header_num => 1);
62945 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
62946
62947 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
62948
62949 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
62950 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
62951 END IF;
62952
62953 --
62954 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
62955 --
62956 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
62957 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
62958 ELSE
62959 ---------------------------------------------------------------------------------------------------
62960 -- 4262811a Switch Sign
62961 ---------------------------------------------------------------------------------------------------
62962 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
62963 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
62964 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62965 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
62966 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62967 -- 5132302
62968 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
62969 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
62970
62971 END IF;
62972
62973 -- 4955764
62974 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
62975 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
62976
62977
62978 XLA_AE_LINES_PKG.ValidateCurrentLine;
62979 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
62980
62981 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
62982 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
62983 ,p_balance_type_code => l_balance_type_code);
62984
62985 END IF;
62986
62987 -----------------------------------------------------------------------------------------
62988 -- 4262811 Multiperiod Accounting
62989 -----------------------------------------------------------------------------------------
62990 -- No MPA option is assigned.
62991
62992
62993 END IF;
62994 END IF;
62995 --
62996
62997 --
62998 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
62999 trace
63000 (p_msg => 'END of AcctLineType_127'
63001 ,p_level => C_LEVEL_PROCEDURE
63002 ,p_module => l_log_module);
63003 END IF;
63004 --
63005 EXCEPTION
63006 WHEN xla_exceptions_pkg.application_exception THEN
63007 RAISE;
63008 WHEN OTHERS THEN
63009 xla_exceptions_pkg.raise_message
63010 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_127');
63011 END AcctLineType_127;
63012 --
63013
63014 ---------------------------------------
63015 --
63016 -- PRIVATE FUNCTION
63017 -- AcctLineType_128
63018 --
63019 ---------------------------------------
63020 PROCEDURE AcctLineType_128 (
63021 p_application_id IN NUMBER
63022 ,p_event_id IN NUMBER
63023 ,p_calculate_acctd_flag IN VARCHAR2
63024 ,p_calculate_g_l_flag IN VARCHAR2
63025 ,p_actual_flag IN OUT VARCHAR2
63026 ,p_balance_type_code OUT VARCHAR2
63027 ,p_gain_or_loss_ref OUT VARCHAR2
63028
63029 --Remittance Bank Account Unapplied Account
63030 , p_source_17 IN NUMBER
63031 --Distribution Source Type
63032 , p_source_20 IN VARCHAR2
63033 --Distribution Line Identifier
63034 , p_source_22 IN NUMBER
63035 --Distribution Type
63036 , p_source_23 IN VARCHAR2
63037 --Entered Amount
63038 , p_source_24 IN NUMBER
63039 --Currency Code
63040 , p_source_25 IN VARCHAR2
63041 --Exchange Date
63042 , p_source_26 IN DATE
63043 --Exchange Rate
63044 , p_source_27 IN NUMBER
63045 --Exchange Rate Type
63046 , p_source_28 IN VARCHAR2
63047 --Transaction Distribution Identifier
63048 , p_source_34 IN NUMBER
63049 --Transaction Distribution Type
63050 , p_source_35 IN VARCHAR2
63051 --Receipt Applied To Application Identifier
63052 , p_source_58 IN NUMBER
63053 --Transaction Entity Code
63054 , p_source_59 IN VARCHAR2
63055 --Transaction Identifier
63056 , p_source_60 IN NUMBER
63057 --Distribution Party Type
63058 , p_source_65 IN VARCHAR2
63059 --Distribution Multi Fund Additional Entry
63060 , p_source_67 IN VARCHAR2
63061 --Accounting Amount
63062 , p_source_69 IN NUMBER
63063 --Distribution Source Table
63064 , p_source_71 IN VARCHAR2
63065 --Receipt Application Status
63066 , p_source_74 IN VARCHAR2
63067 --Receipt Previous Pay From Customer
63068 , p_source_75 IN NUMBER
63069 --Receipt Previous Customer Site Use Id
63070 , p_source_76 IN NUMBER
63071 )
63072 IS
63073
63074 l_component_type VARCHAR2(80);
63075 l_component_code VARCHAR2(30);
63076 l_component_type_code VARCHAR2(1);
63077 l_component_appl_id INTEGER;
63078 l_amb_context_code VARCHAR2(30);
63079 l_entity_code VARCHAR2(30);
63080 l_event_class_code VARCHAR2(30);
63081 l_ae_header_id NUMBER;
63082 l_event_type_code VARCHAR2(30);
63083 l_line_definition_code VARCHAR2(30);
63084 l_line_definition_owner_code VARCHAR2(1);
63085 --
63086 -- adr variables
63087 l_segment VARCHAR2(30);
63088 l_ccid NUMBER;
63089 l_adr_transaction_coa_id NUMBER;
63090 l_adr_accounting_coa_id NUMBER;
63091 l_adr_flexfield_segment_code VARCHAR2(30);
63092 l_adr_flex_value_set_id NUMBER;
63093 l_adr_value_type_code VARCHAR2(30);
63094 l_adr_value_combination_id NUMBER;
63095 l_adr_value_segment_code VARCHAR2(30);
63096
63097 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
63098 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
63099 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
63100 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
63101
63102 -- 4262811 Variables ------------------------------------------------------------------------------------------
63103 l_entered_amt_idx NUMBER;
63104 l_accted_amt_idx NUMBER;
63105 l_acc_rev_flag VARCHAR2(1);
63106 l_accrual_line_num NUMBER;
63107 l_tmp_amt NUMBER;
63108 l_acc_rev_natural_side_code VARCHAR2(1);
63109
63110 l_num_entries NUMBER;
63111 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
63112 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
63113 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
63114 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
63115 l_recog_line_1 NUMBER;
63116 l_recog_line_2 NUMBER;
63117
63118 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
63119 l_bflow_applied_to_amt NUMBER; -- 5132302
63120 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
63121
63122 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
63123
63124 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
63125 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
63126
63127 ---------------------------------------------------------------------------------------------------------------
63128
63129
63130 --
63131 -- bulk performance
63132 --
63133 l_balance_type_code VARCHAR2(1);
63134 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
63135 l_log_module VARCHAR2(240);
63136
63137 --
63138 -- Upgrade strategy
63139 --
63140 l_actual_upg_option VARCHAR2(1);
63141 l_enc_upg_option VARCHAR2(1);
63142
63143 --
63144 BEGIN
63145 --
63146 IF g_log_enabled THEN
63147 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_128';
63148 END IF;
63149 --
63150 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63151
63152 trace
63153 (p_msg => 'BEGIN of AcctLineType_128'
63154 ,p_level => C_LEVEL_PROCEDURE
63155 ,p_module => l_log_module);
63156
63157 END IF;
63158 --
63159 l_component_type := 'AMB_JLT';
63160 l_component_code := 'RCT_UNAPP_UNID';
63161 l_component_type_code := 'S';
63162 l_component_appl_id := 222;
63163 l_amb_context_code := 'DEFAULT';
63164 l_entity_code := 'RECEIPTS';
63165 l_event_class_code := 'RECEIPT';
63166 l_event_type_code := 'RECEIPT_ALL';
63167 l_line_definition_owner_code := 'S';
63168 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
63169 --
63170 l_balance_type_code := 'A';
63171 l_segment := NULL;
63172 l_ccid := NULL;
63173 l_adr_transaction_coa_id := NULL;
63174 l_adr_accounting_coa_id := NULL;
63175 l_adr_flexfield_segment_code := NULL;
63176 l_adr_flex_value_set_id := NULL;
63177 l_adr_value_type_code := NULL;
63178 l_adr_value_combination_id := NULL;
63179 l_adr_value_segment_code := NULL;
63180
63181 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
63182 l_bflow_class_code := ''; -- 4219869 Business Flow
63183 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
63184 l_budgetary_control_flag := 'N';
63185
63186 l_bflow_applied_to_amt_idx := NULL; -- 5132302
63187 l_bflow_applied_to_amt := NULL; -- 5132302
63188 l_entered_amt_idx := NULL; -- 4262811
63189 l_accted_amt_idx := NULL; -- 4262811
63190 l_acc_rev_flag := NULL; -- 4262811
63191 l_accrual_line_num := NULL; -- 4262811
63192 l_tmp_amt := NULL; -- 4262811
63193 --
63194
63195 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
63196 l_balance_type_code <> 'B' THEN
63197 IF NVL(p_source_74,'
63198 ') = 'UNID' AND
63199 p_source_75 IS NOT NULL AND
63200 p_source_76 IS NOT NULL AND
63201 ((NVL(p_source_20,'
63202 ') = 'CASH' AND
63203 NVL(p_source_67,'
63204 ') = 'N') OR
63205 (NVL(p_source_20,'
63206 ') = 'REMITTANCE' AND
63207 NVL(p_source_71,'
63208 ') = 'CRH' AND
63209 NVL(p_source_67,'
63210 ') = 'N') OR
63211 (NVL(p_source_20,'
63212 ') = 'CONFIRMATION' AND
63213 NVL(p_source_67,'
63214 ') = 'N') OR
63215 (NVL(p_source_20,'
63216 ') = 'FACTOR' AND
63217 NVL(p_source_71,'
63218 ') = 'CRH' AND
63219 NVL(p_source_67,'
63220 ') = 'N') OR
63221 (NVL(p_source_20,'
63222 ') = 'SHORT_TERM_DEBT' AND
63223 NVL(p_source_67,'
63224 ') = 'N') OR
63225 (NVL(p_source_20,'
63226 ') = 'BANK_CHARGES' AND
63227 NVL(p_source_67,'
63228 ') = 'N') OR
63229 (NVL(p_source_20,'
63230 ') = 'UNID' AND
63231 NVL(p_source_67,'
63232 ') = 'N')
63233 ) THEN
63234
63235 --
63236 XLA_AE_LINES_PKG.SetNewLine;
63237
63238 p_balance_type_code := l_balance_type_code;
63239 -- set the flag so later we will know whether the gain loss line needs to be created
63240
63241 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
63242 p_actual_flag :='A';
63243 END IF;
63244
63245 --
63246 -- bulk performance
63247 --
63248 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
63252 --
63249 p_header_num => 0); -- 4262811
63250 --
63251 -- set accounting line options
63253 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
63254 p_natural_side_code => 'D'
63255 , p_gain_or_loss_flag => 'N'
63256 , p_gl_transfer_mode_code => 'S'
63257 , p_acct_entry_type_code => 'A'
63258 , p_switch_side_flag => 'Y'
63259 , p_merge_duplicate_code => 'A'
63260 );
63261 --
63262 l_acc_rev_natural_side_code := 'C'; -- 4262811
63263 --
63264 --
63265 -- set accounting line type info
63266 --
63267 xla_ae_lines_pkg.SetAcctLineType
63268 (p_component_type => l_component_type
63269 ,p_event_type_code => l_event_type_code
63270 ,p_line_definition_owner_code => l_line_definition_owner_code
63271 ,p_line_definition_code => l_line_definition_code
63272 ,p_accounting_line_code => l_component_code
63273 ,p_accounting_line_type_code => l_component_type_code
63274 ,p_accounting_line_appl_id => l_component_appl_id
63275 ,p_amb_context_code => l_amb_context_code
63276 ,p_entity_code => l_entity_code
63277 ,p_event_class_code => l_event_class_code);
63278 --
63279 -- set accounting class
63280 --
63281 xla_ae_lines_pkg.SetAcctClass(
63282 p_accounting_class_code => 'UNAPP'
63283 , p_ae_header_id => l_ae_header_id
63284 );
63285
63286 --
63287 -- set rounding class
63288 --
63289 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
63290 'RECEIVABLE';
63291
63292 --
63293 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
63294 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
63295 --
63296 -- bulk performance
63297 --
63298 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
63299
63300 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
63301 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
63302
63303 -- 4955764
63304 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
63305 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
63306
63307 -- 4458381 Public Sector Enh
63308
63309 --
63310 -- set accounting attributes for the line type
63311 --
63312 l_entered_amt_idx := 8;
63313 l_accted_amt_idx := 13;
63314 l_bflow_applied_to_amt_idx := NULL; -- 5132302
63315 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
63316 l_rec_acct_attrs.array_num_value(1) := p_source_58;
63317 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
63318 l_rec_acct_attrs.array_char_value(2) := p_source_35;
63319 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
63320 l_rec_acct_attrs.array_char_value(3) := p_source_59;
63321 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
63322 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
63323 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
63324 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
63325 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
63326 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
63327 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
63328 l_rec_acct_attrs.array_char_value(7) := p_source_23;
63329 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
63330 l_rec_acct_attrs.array_num_value(8) := p_source_24;
63331 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
63332 l_rec_acct_attrs.array_char_value(9) := p_source_25;
63333 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
63334 l_rec_acct_attrs.array_date_value(10) := p_source_26;
63335 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
63336 l_rec_acct_attrs.array_num_value(11) := p_source_27;
63337 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
63338 l_rec_acct_attrs.array_char_value(12) := p_source_28;
63339 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
63340 l_rec_acct_attrs.array_num_value(13) := p_source_69;
63341 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
63342 l_rec_acct_attrs.array_num_value(14) := p_source_75;
63343 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
63344 l_rec_acct_attrs.array_num_value(15) := p_source_76;
63345 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
63346 l_rec_acct_attrs.array_char_value(16) := p_source_65;
63347
63348 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
63349 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
63350
63351 ---------------------------------------------------------------------------------------------------------------
63352 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
63353 ---------------------------------------------------------------------------------------------------------------
63354 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
63355
63359 IF xla_accounting_cache_pkg.GetValueChar
63356 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
63357 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
63358
63360 (p_source_code => 'LEDGER_CATEGORY_CODE'
63361 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
63362 AND l_bflow_method_code = 'PRIOR_ENTRY'
63363 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
63364 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
63365 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
63366 )
63367 THEN
63368 xla_ae_lines_pkg.BflowUpgEntry
63369 (p_business_method_code => l_bflow_method_code
63370 ,p_business_class_code => l_bflow_class_code
63371 ,p_balance_type => l_balance_type_code);
63372 ELSE
63373 NULL;
63374 -- No business flow processing for business flow method of NONE.
63375 END IF;
63376
63377 --
63378 -- call analytical criteria
63379 --
63380
63381 --
63382 -- call description
63383 --
63384 -- No description or it is inherited.
63385 --
63386 -- call ADRs
63387 -- Bug 4922099
63388 --
63389 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
63390 (NVL(l_actual_upg_option, 'N') = 'O') OR
63391 (NVL(l_enc_upg_option, 'N') = 'O')
63392 )
63393 THEN
63394 NULL;
63395 --
63396 --
63397
63398 l_ccid := AcctDerRule_24(
63399 p_application_id => p_application_id
63400 , p_ae_header_id => l_ae_header_id
63401 , p_source_17 => p_source_17
63402 , x_transaction_coa_id => l_adr_transaction_coa_id
63403 , x_accounting_coa_id => l_adr_accounting_coa_id
63404 , x_value_type_code => l_adr_value_type_code
63405 , p_side => 'NA'
63406 );
63407
63408 xla_ae_lines_pkg.set_ccid(
63409 p_code_combination_id => l_ccid
63410 , p_value_type_code => l_adr_value_type_code
63411 , p_transaction_coa_id => l_adr_transaction_coa_id
63412 , p_accounting_coa_id => l_adr_accounting_coa_id
63413 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
63414 , p_adr_type_code => 'S'
63415 , p_component_type => l_component_type
63416 , p_component_code => l_component_code
63417 , p_component_type_code => l_component_type_code
63418 , p_component_appl_id => l_component_appl_id
63419 , p_amb_context_code => l_amb_context_code
63420 , p_side => 'NA'
63421 );
63422
63423
63424 --
63425 --
63426 END IF;
63427 --
63428 -- Bug 4922099
63429 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
63430 (NVL(l_enc_upg_option, 'N') = 'O')
63431 ) AND
63432 (l_bflow_method_code = 'PRIOR_ENTRY')
63433 )
63434 THEN
63435 IF
63436 --
63437 1 = 2
63438 --
63439 THEN
63440 xla_accounting_err_pkg.build_message
63441 (p_appli_s_name => 'XLA'
63442 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
63443 ,p_token_1 => 'LINE_NUMBER'
63444 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
63445 ,p_token_2 => 'LINE_TYPE_NAME'
63446 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
63447 l_component_type
63448 ,l_component_code
63449 ,l_component_type_code
63450 ,l_component_appl_id
63451 ,l_amb_context_code
63452 ,l_entity_code
63453 ,l_event_class_code
63454 )
63455 ,p_token_3 => 'OWNER'
63456 ,p_value_3 => xla_lookups_pkg.get_meaning(
63457 p_lookup_type => 'XLA_OWNER_TYPE'
63458 ,p_lookup_code => l_component_type_code
63459 )
63460 ,p_token_4 => 'PRODUCT_NAME'
63461 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
63462 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
63463 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
63464 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
63465 ,p_ae_header_id => NULL
63466 );
63467
63468 IF (C_LEVEL_ERROR>= g_log_level) THEN
63469 trace
63470 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
63471 ,p_level => C_LEVEL_ERROR
63472 ,p_module => l_log_module);
63473 END IF;
63474 END IF;
63475 END IF;
63476 --
63477 --
63478 ------------------------------------------------------------------------------------------------
63479 -- 4219869 Business Flow
63480 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
63481 -- Prior Entry. Currently, the following code is always generated.
63482 ------------------------------------------------------------------------------------------------
63483 XLA_AE_LINES_PKG.ValidateCurrentLine;
63484
63485 ------------------------------------------------------------------------------------
63486 -- 4219869 Business Flow
63487 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
63488 ------------------------------------------------------------------------------------
63489 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
63490
63491 ----------------------------------------------------------------------------------
63492 -- 4219869 Business Flow
63493 -- Update journal entry status -- Need to generate this within IF <condition>
63494 ----------------------------------------------------------------------------------
63495 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
63496 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
63497 ,p_balance_type_code => l_balance_type_code
63498 );
63499
63500 -------------------------------------------------------------------------------------------
63501 -- 4262811 - Generate the Accrual Reversal lines
63502 -------------------------------------------------------------------------------------------
63503 BEGIN
63504 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
63505 (g_array_event(p_event_id).array_value_num('header_index'));
63506 IF l_acc_rev_flag IS NULL THEN
63507 l_acc_rev_flag := 'N';
63508 END IF;
63509 EXCEPTION
63510 WHEN OTHERS THEN
63511 l_acc_rev_flag := 'N';
63512 END;
63513 --
63514 IF (l_acc_rev_flag = 'Y') THEN
63515
63516 -- 4645092 ------------------------------------------------------------------------------
63517 -- To allow MPA report to determine if it should generate report process
63518 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
63519 ------------------------------------------------------------------------------------------
63520
63521 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
63522 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
63523 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
63524 -- call ADRs
63525 -- Bug 4922099
63526 --
63527 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
63528 (NVL(l_actual_upg_option, 'N') = 'O') OR
63529 (NVL(l_enc_upg_option, 'N') = 'O')
63530 )
63531 THEN
63532 NULL;
63533 --
63534 --
63535
63536 l_ccid := AcctDerRule_24(
63537 p_application_id => p_application_id
63538 , p_ae_header_id => l_ae_header_id
63539 , p_source_17 => p_source_17
63540 , x_transaction_coa_id => l_adr_transaction_coa_id
63541 , x_accounting_coa_id => l_adr_accounting_coa_id
63542 , x_value_type_code => l_adr_value_type_code
63543 , p_side => 'NA'
63544 );
63545
63546 xla_ae_lines_pkg.set_ccid(
63547 p_code_combination_id => l_ccid
63548 , p_value_type_code => l_adr_value_type_code
63549 , p_transaction_coa_id => l_adr_transaction_coa_id
63550 , p_accounting_coa_id => l_adr_accounting_coa_id
63551 , p_adr_code => 'RMT_BNK_UNAPP_CCID'
63552 , p_adr_type_code => 'S'
63553 , p_component_type => l_component_type
63554 , p_component_code => l_component_code
63555 , p_component_type_code => l_component_type_code
63556 , p_component_appl_id => l_component_appl_id
63557 , p_amb_context_code => l_amb_context_code
63558 , p_side => 'NA'
63559 );
63560
63561
63562 --
63563 --
63564 END IF;
63565
63566 --
63567 -- Update the line information that should be overwritten
63568 --
63569 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
63570 p_header_num => 1);
63571 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
63572
63573 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
63574
63575 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
63576 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
63577 END IF;
63578
63579 --
63580 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
63581 --
63582 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
63583 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
63584 ELSE
63585 ---------------------------------------------------------------------------------------------------
63586 -- 4262811a Switch Sign
63587 ---------------------------------------------------------------------------------------------------
63588 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
63589 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
63590 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63591 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
63592 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63593 -- 5132302
63594 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
63595 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
63596
63597 END IF;
63598
63599 -- 4955764
63600 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
63601 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
63602
63603
63604 XLA_AE_LINES_PKG.ValidateCurrentLine;
63605 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
63606
63607 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
63608 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
63609 ,p_balance_type_code => l_balance_type_code);
63610
63611 END IF;
63612
63613 -----------------------------------------------------------------------------------------
63614 -- 4262811 Multiperiod Accounting
63615 -----------------------------------------------------------------------------------------
63616 -- No MPA option is assigned.
63617
63618
63619 END IF;
63620 END IF;
63621 --
63622
63623 --
63624 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63625 trace
63626 (p_msg => 'END of AcctLineType_128'
63627 ,p_level => C_LEVEL_PROCEDURE
63628 ,p_module => l_log_module);
63629 END IF;
63630 --
63631 EXCEPTION
63632 WHEN xla_exceptions_pkg.application_exception THEN
63633 RAISE;
63634 WHEN OTHERS THEN
63635 xla_exceptions_pkg.raise_message
63636 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_128');
63637 END AcctLineType_128;
63638 --
63639
63640 ---------------------------------------
63641 --
63642 -- PRIVATE FUNCTION
63643 -- AcctLineType_129
63644 --
63645 ---------------------------------------
63646 PROCEDURE AcctLineType_129 (
63647 p_application_id IN NUMBER
63648 ,p_event_id IN NUMBER
63649 ,p_calculate_acctd_flag IN VARCHAR2
63650 ,p_calculate_g_l_flag IN VARCHAR2
63651 ,p_actual_flag IN OUT VARCHAR2
63652 ,p_balance_type_code OUT VARCHAR2
63653 ,p_gain_or_loss_ref OUT VARCHAR2
63654
63655 --Distribution GL Account
63656 , p_source_5 IN NUMBER
63657 --Distribution Source Type
63658 , p_source_20 IN VARCHAR2
63659 --Distribution Line Identifier
63660 , p_source_22 IN NUMBER
63661 --Distribution Type
63662 , p_source_23 IN VARCHAR2
63663 --Entered Amount
63664 , p_source_24 IN NUMBER
63665 --Currency Code
63666 , p_source_25 IN VARCHAR2
63667 --Applied To Document Accounting Amount
63668 , p_source_29 IN NUMBER
63669 --Transaction Distribution Identifier
63670 , p_source_34 IN NUMBER
63671 --Transaction Distribution Type
63672 , p_source_35 IN VARCHAR2
63673 --Applied To Document Exchange Date
63674 , p_source_57 IN DATE
63675 --Receipt Applied To Application Identifier
63676 , p_source_58 IN NUMBER
63677 --Transaction Entity Code
63678 , p_source_59 IN VARCHAR2
63679 --Transaction Identifier
63680 , p_source_60 IN NUMBER
63681 --Applied To Document Exchange Rate
63682 , p_source_62 IN NUMBER
63683 --Distribution Party Identifier
63684 , p_source_63 IN NUMBER
63685 --Distribution Party Site Id
63686 , p_source_64 IN NUMBER
63687 --Distribution Party Type
63688 , p_source_65 IN VARCHAR2
63689 --Distribution Multi Fund Additional Entry
63690 , p_source_67 IN VARCHAR2
63691 --Applied To Document Exchange Rate Type
63692 , p_source_70 IN VARCHAR2
63693 )
63694 IS
63695
63696 l_component_type VARCHAR2(80);
63697 l_component_code VARCHAR2(30);
63698 l_component_type_code VARCHAR2(1);
63699 l_component_appl_id INTEGER;
63700 l_amb_context_code VARCHAR2(30);
63701 l_entity_code VARCHAR2(30);
63702 l_event_class_code VARCHAR2(30);
63703 l_ae_header_id NUMBER;
63704 l_event_type_code VARCHAR2(30);
63705 l_line_definition_code VARCHAR2(30);
63706 l_line_definition_owner_code VARCHAR2(1);
63707 --
63708 -- adr variables
63709 l_segment VARCHAR2(30);
63710 l_ccid NUMBER;
63711 l_adr_transaction_coa_id NUMBER;
63712 l_adr_accounting_coa_id NUMBER;
63713 l_adr_flexfield_segment_code VARCHAR2(30);
63714 l_adr_flex_value_set_id NUMBER;
63715 l_adr_value_type_code VARCHAR2(30);
63716 l_adr_value_combination_id NUMBER;
63717 l_adr_value_segment_code VARCHAR2(30);
63718
63719 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
63720 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
63721 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
63722 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
63723
63724 -- 4262811 Variables ------------------------------------------------------------------------------------------
63725 l_entered_amt_idx NUMBER;
63726 l_accted_amt_idx NUMBER;
63727 l_acc_rev_flag VARCHAR2(1);
63728 l_accrual_line_num NUMBER;
63729 l_tmp_amt NUMBER;
63730 l_acc_rev_natural_side_code VARCHAR2(1);
63731
63732 l_num_entries NUMBER;
63733 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
63734 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
63735 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
63736 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
63737 l_recog_line_1 NUMBER;
63738 l_recog_line_2 NUMBER;
63739
63740 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
63741 l_bflow_applied_to_amt NUMBER; -- 5132302
63742 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
63743
63744 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
63745
63746 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
63747 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
63748
63749 ---------------------------------------------------------------------------------------------------------------
63750
63751
63752 --
63753 -- bulk performance
63754 --
63755 l_balance_type_code VARCHAR2(1);
63756 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
63757 l_log_module VARCHAR2(240);
63758
63759 --
63760 -- Upgrade strategy
63761 --
63762 l_actual_upg_option VARCHAR2(1);
63763 l_enc_upg_option VARCHAR2(1);
63764
63765 --
63766 BEGIN
63767 --
63768 IF g_log_enabled THEN
63769 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_129';
63770 END IF;
63771 --
63772 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
63773
63774 trace
63775 (p_msg => 'BEGIN of AcctLineType_129'
63776 ,p_level => C_LEVEL_PROCEDURE
63777 ,p_module => l_log_module);
63778
63779 END IF;
63780 --
63781 l_component_type := 'AMB_JLT';
63782 l_component_code := 'RCT_UNEDISC';
63783 l_component_type_code := 'S';
63784 l_component_appl_id := 222;
63785 l_amb_context_code := 'DEFAULT';
63786 l_entity_code := 'RECEIPTS';
63787 l_event_class_code := 'RECEIPT';
63788 l_event_type_code := 'RECEIPT_ALL';
63789 l_line_definition_owner_code := 'S';
63790 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
63791 --
63792 l_balance_type_code := 'A';
63793 l_segment := NULL;
63794 l_ccid := NULL;
63795 l_adr_transaction_coa_id := NULL;
63796 l_adr_accounting_coa_id := NULL;
63797 l_adr_flexfield_segment_code := NULL;
63798 l_adr_flex_value_set_id := NULL;
63799 l_adr_value_type_code := NULL;
63800 l_adr_value_combination_id := NULL;
63801 l_adr_value_segment_code := NULL;
63802
63803 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
63804 l_bflow_class_code := ''; -- 4219869 Business Flow
63805 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
63806 l_budgetary_control_flag := 'N';
63807
63808 l_bflow_applied_to_amt_idx := NULL; -- 5132302
63809 l_bflow_applied_to_amt := NULL; -- 5132302
63810 l_entered_amt_idx := NULL; -- 4262811
63811 l_accted_amt_idx := NULL; -- 4262811
63812 l_acc_rev_flag := NULL; -- 4262811
63813 l_accrual_line_num := NULL; -- 4262811
63814 l_tmp_amt := NULL; -- 4262811
63815 --
63816
63817 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
63818 l_balance_type_code <> 'B' THEN
63819 IF NVL(p_source_20,'
63820 ') = 'UNEDISC' AND
63821 NVL(p_source_67,'
63822 ') = 'N'
63823 THEN
63824
63825 --
63826 XLA_AE_LINES_PKG.SetNewLine;
63827
63828 p_balance_type_code := l_balance_type_code;
63829 -- set the flag so later we will know whether the gain loss line needs to be created
63830
63831 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
63832 p_actual_flag :='A';
63833 END IF;
63834
63835 --
63836 -- bulk performance
63837 --
63838 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
63839 p_header_num => 0); -- 4262811
63840 --
63841 -- set accounting line options
63842 --
63843 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
63844 p_natural_side_code => 'C'
63845 , p_gain_or_loss_flag => 'N'
63846 , p_gl_transfer_mode_code => 'S'
63847 , p_acct_entry_type_code => 'A'
63848 , p_switch_side_flag => 'Y'
63849 , p_merge_duplicate_code => 'A'
63850 );
63851 --
63852 l_acc_rev_natural_side_code := 'D'; -- 4262811
63853 --
63854 --
63855 -- set accounting line type info
63856 --
63857 xla_ae_lines_pkg.SetAcctLineType
63858 (p_component_type => l_component_type
63859 ,p_event_type_code => l_event_type_code
63860 ,p_line_definition_owner_code => l_line_definition_owner_code
63861 ,p_line_definition_code => l_line_definition_code
63862 ,p_accounting_line_code => l_component_code
63863 ,p_accounting_line_type_code => l_component_type_code
63864 ,p_accounting_line_appl_id => l_component_appl_id
63865 ,p_amb_context_code => l_amb_context_code
63866 ,p_entity_code => l_entity_code
63867 ,p_event_class_code => l_event_class_code);
63868 --
63869 -- set accounting class
63870 --
63871 xla_ae_lines_pkg.SetAcctClass(
63872 p_accounting_class_code => 'UNEDISC'
63873 , p_ae_header_id => l_ae_header_id
63874 );
63875
63876 --
63877 -- set rounding class
63878 --
63879 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
63880 'RECEIVABLE';
63881
63882 --
63883 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
63884 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
63885 --
63886 -- bulk performance
63887 --
63888 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
63889
63890 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
63891 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
63892
63893 -- 4955764
63894 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
63895 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
63896
63897 -- 4458381 Public Sector Enh
63898
63899 --
63900 -- set accounting attributes for the line type
63901 --
63902 l_entered_amt_idx := 8;
63903 l_accted_amt_idx := 13;
63904 l_bflow_applied_to_amt_idx := NULL; -- 5132302
63905 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
63906 l_rec_acct_attrs.array_num_value(1) := p_source_58;
63907 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
63908 l_rec_acct_attrs.array_char_value(2) := p_source_35;
63909 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
63910 l_rec_acct_attrs.array_char_value(3) := p_source_59;
63911 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
63912 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
63913 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
63914 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
63915 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
63916 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
63917 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
63918 l_rec_acct_attrs.array_char_value(7) := p_source_23;
63919 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
63920 l_rec_acct_attrs.array_num_value(8) := p_source_24;
63921 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
63922 l_rec_acct_attrs.array_char_value(9) := p_source_25;
63923 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
63924 l_rec_acct_attrs.array_date_value(10) := p_source_57;
63925 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
63926 l_rec_acct_attrs.array_num_value(11) := p_source_62;
63927 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
63928 l_rec_acct_attrs.array_char_value(12) := p_source_70;
63929 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
63930 l_rec_acct_attrs.array_num_value(13) := p_source_29;
63931 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
63932 l_rec_acct_attrs.array_num_value(14) := p_source_63;
63933 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
63934 l_rec_acct_attrs.array_num_value(15) := p_source_64;
63935 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
63936 l_rec_acct_attrs.array_char_value(16) := p_source_65;
63937
63938 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
63939 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
63940
63941 ---------------------------------------------------------------------------------------------------------------
63942 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
63943 ---------------------------------------------------------------------------------------------------------------
63944 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
63945
63946 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
63947 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
63948
63949 IF xla_accounting_cache_pkg.GetValueChar
63950 (p_source_code => 'LEDGER_CATEGORY_CODE'
63951 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
63952 AND l_bflow_method_code = 'PRIOR_ENTRY'
63953 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
63954 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
63955 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
63956 )
63957 THEN
63958 xla_ae_lines_pkg.BflowUpgEntry
63959 (p_business_method_code => l_bflow_method_code
63960 ,p_business_class_code => l_bflow_class_code
63961 ,p_balance_type => l_balance_type_code);
63962 ELSE
63963 NULL;
63964 -- No business flow processing for business flow method of NONE.
63965 END IF;
63966
63967 --
63968 -- call analytical criteria
63969 --
63970
63971 --
63972 -- call description
63973 --
63974 -- No description or it is inherited.
63975 --
63976 -- call ADRs
63977 -- Bug 4922099
63978 --
63979 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
63980 (NVL(l_actual_upg_option, 'N') = 'O') OR
63981 (NVL(l_enc_upg_option, 'N') = 'O')
63982 )
63983 THEN
63984 NULL;
63985 --
63986 --
63987
63988 l_ccid := AcctDerRule_4(
63989 p_application_id => p_application_id
63990 , p_ae_header_id => l_ae_header_id
63991 , p_source_5 => p_source_5
63992 , x_transaction_coa_id => l_adr_transaction_coa_id
63993 , x_accounting_coa_id => l_adr_accounting_coa_id
63994 , x_value_type_code => l_adr_value_type_code
63995 , p_side => 'NA'
63996 );
63997
63998 xla_ae_lines_pkg.set_ccid(
63999 p_code_combination_id => l_ccid
64000 , p_value_type_code => l_adr_value_type_code
64001 , p_transaction_coa_id => l_adr_transaction_coa_id
64002 , p_accounting_coa_id => l_adr_accounting_coa_id
64003 , p_adr_code => 'DIST_CCID'
64004 , p_adr_type_code => 'S'
64005 , p_component_type => l_component_type
64006 , p_component_code => l_component_code
64007 , p_component_type_code => l_component_type_code
64008 , p_component_appl_id => l_component_appl_id
64009 , p_amb_context_code => l_amb_context_code
64010 , p_side => 'NA'
64011 );
64012
64013
64014 --
64015 --
64016 END IF;
64017 --
64018 -- Bug 4922099
64019 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
64020 (NVL(l_enc_upg_option, 'N') = 'O')
64021 ) AND
64022 (l_bflow_method_code = 'PRIOR_ENTRY')
64023 )
64024 THEN
64025 IF
64026 --
64027 1 = 2
64028 --
64029 THEN
64030 xla_accounting_err_pkg.build_message
64031 (p_appli_s_name => 'XLA'
64032 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64033 ,p_token_1 => 'LINE_NUMBER'
64034 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
64035 ,p_token_2 => 'LINE_TYPE_NAME'
64036 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
64037 l_component_type
64038 ,l_component_code
64039 ,l_component_type_code
64040 ,l_component_appl_id
64041 ,l_amb_context_code
64042 ,l_entity_code
64043 ,l_event_class_code
64044 )
64045 ,p_token_3 => 'OWNER'
64046 ,p_value_3 => xla_lookups_pkg.get_meaning(
64047 p_lookup_type => 'XLA_OWNER_TYPE'
64048 ,p_lookup_code => l_component_type_code
64049 )
64050 ,p_token_4 => 'PRODUCT_NAME'
64051 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
64052 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
64053 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
64054 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
64055 ,p_ae_header_id => NULL
64056 );
64057
64058 IF (C_LEVEL_ERROR>= g_log_level) THEN
64059 trace
64060 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64061 ,p_level => C_LEVEL_ERROR
64062 ,p_module => l_log_module);
64063 END IF;
64067 --
64064 END IF;
64065 END IF;
64066 --
64068 ------------------------------------------------------------------------------------------------
64069 -- 4219869 Business Flow
64070 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
64071 -- Prior Entry. Currently, the following code is always generated.
64072 ------------------------------------------------------------------------------------------------
64073 XLA_AE_LINES_PKG.ValidateCurrentLine;
64074
64075 ------------------------------------------------------------------------------------
64076 -- 4219869 Business Flow
64077 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
64078 ------------------------------------------------------------------------------------
64079 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
64080
64081 ----------------------------------------------------------------------------------
64082 -- 4219869 Business Flow
64083 -- Update journal entry status -- Need to generate this within IF <condition>
64084 ----------------------------------------------------------------------------------
64085 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
64086 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
64087 ,p_balance_type_code => l_balance_type_code
64088 );
64089
64090 -------------------------------------------------------------------------------------------
64091 -- 4262811 - Generate the Accrual Reversal lines
64092 -------------------------------------------------------------------------------------------
64093 BEGIN
64094 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
64095 (g_array_event(p_event_id).array_value_num('header_index'));
64096 IF l_acc_rev_flag IS NULL THEN
64097 l_acc_rev_flag := 'N';
64098 END IF;
64099 EXCEPTION
64100 WHEN OTHERS THEN
64101 l_acc_rev_flag := 'N';
64102 END;
64103 --
64104 IF (l_acc_rev_flag = 'Y') THEN
64105
64106 -- 4645092 ------------------------------------------------------------------------------
64107 -- To allow MPA report to determine if it should generate report process
64108 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
64109 ------------------------------------------------------------------------------------------
64110
64111 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
64112 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
64113 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
64114 -- call ADRs
64115 -- Bug 4922099
64116 --
64117 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
64118 (NVL(l_actual_upg_option, 'N') = 'O') OR
64119 (NVL(l_enc_upg_option, 'N') = 'O')
64120 )
64121 THEN
64122 NULL;
64123 --
64124 --
64125
64126 l_ccid := AcctDerRule_4(
64127 p_application_id => p_application_id
64128 , p_ae_header_id => l_ae_header_id
64129 , p_source_5 => p_source_5
64130 , x_transaction_coa_id => l_adr_transaction_coa_id
64131 , x_accounting_coa_id => l_adr_accounting_coa_id
64132 , x_value_type_code => l_adr_value_type_code
64133 , p_side => 'NA'
64134 );
64135
64136 xla_ae_lines_pkg.set_ccid(
64137 p_code_combination_id => l_ccid
64138 , p_value_type_code => l_adr_value_type_code
64139 , p_transaction_coa_id => l_adr_transaction_coa_id
64140 , p_accounting_coa_id => l_adr_accounting_coa_id
64141 , p_adr_code => 'DIST_CCID'
64142 , p_adr_type_code => 'S'
64143 , p_component_type => l_component_type
64144 , p_component_code => l_component_code
64145 , p_component_type_code => l_component_type_code
64146 , p_component_appl_id => l_component_appl_id
64147 , p_amb_context_code => l_amb_context_code
64148 , p_side => 'NA'
64149 );
64150
64151
64152 --
64153 --
64154 END IF;
64155
64156 --
64157 -- Update the line information that should be overwritten
64158 --
64159 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
64160 p_header_num => 1);
64161 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
64162
64163 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
64164
64165 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
64166 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
64167 END IF;
64168
64169 --
64170 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
64171 --
64172 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
64173 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
64174 ELSE
64175 ---------------------------------------------------------------------------------------------------
64176 -- 4262811a Switch Sign
64177 ---------------------------------------------------------------------------------------------------
64178 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
64179 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
64180 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64181 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
64182 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64183 -- 5132302
64184 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
64185 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64186
64187 END IF;
64188
64189 -- 4955764
64190 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
64191 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
64192
64193
64194 XLA_AE_LINES_PKG.ValidateCurrentLine;
64195 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
64196
64197 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
64198 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
64199 ,p_balance_type_code => l_balance_type_code);
64200
64201 END IF;
64202
64203 -----------------------------------------------------------------------------------------
64204 -- 4262811 Multiperiod Accounting
64205 -----------------------------------------------------------------------------------------
64206 -- No MPA option is assigned.
64207
64208
64209 END IF;
64210 END IF;
64211 --
64212
64213 --
64214 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64215 trace
64216 (p_msg => 'END of AcctLineType_129'
64217 ,p_level => C_LEVEL_PROCEDURE
64218 ,p_module => l_log_module);
64219 END IF;
64220 --
64221 EXCEPTION
64222 WHEN xla_exceptions_pkg.application_exception THEN
64223 RAISE;
64224 WHEN OTHERS THEN
64225 xla_exceptions_pkg.raise_message
64226 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_129');
64227 END AcctLineType_129;
64228 --
64229
64230 ---------------------------------------
64231 --
64232 -- PRIVATE FUNCTION
64233 -- AcctLineType_130
64234 --
64235 ---------------------------------------
64236 PROCEDURE AcctLineType_130 (
64237 p_application_id IN NUMBER
64238 ,p_event_id IN NUMBER
64239 ,p_calculate_acctd_flag IN VARCHAR2
64240 ,p_calculate_g_l_flag IN VARCHAR2
64241 ,p_actual_flag IN OUT VARCHAR2
64242 ,p_balance_type_code OUT VARCHAR2
64243 ,p_gain_or_loss_ref OUT VARCHAR2
64244
64245 --Distribution GL Account
64246 , p_source_5 IN NUMBER
64247 --Distribution Source Type
64248 , p_source_20 IN VARCHAR2
64249 --Distribution Line Identifier
64250 , p_source_22 IN NUMBER
64251 --Distribution Type
64252 , p_source_23 IN VARCHAR2
64253 --Entered Amount
64254 , p_source_24 IN NUMBER
64255 --Currency Code
64256 , p_source_25 IN VARCHAR2
64257 --Applied To Document Accounting Amount
64258 , p_source_29 IN NUMBER
64259 --Transaction Distribution Identifier
64260 , p_source_34 IN NUMBER
64261 --Transaction Distribution Type
64262 , p_source_35 IN VARCHAR2
64263 --Applied To Document Exchange Date
64264 , p_source_57 IN DATE
64265 --Receipt Applied To Application Identifier
64266 , p_source_58 IN NUMBER
64267 --Transaction Entity Code
64268 , p_source_59 IN VARCHAR2
64269 --Transaction Identifier
64270 , p_source_60 IN NUMBER
64271 --Applied To Document Exchange Rate
64272 , p_source_62 IN NUMBER
64273 --Distribution Party Identifier
64274 , p_source_63 IN NUMBER
64275 --Distribution Party Site Id
64276 , p_source_64 IN NUMBER
64277 --Distribution Party Type
64278 , p_source_65 IN VARCHAR2
64279 --Distribution Multi Fund Additional Entry
64280 , p_source_67 IN VARCHAR2
64281 --Applied To Document Exchange Rate Type
64282 , p_source_70 IN VARCHAR2
64283 )
64284 IS
64285
64286 l_component_type VARCHAR2(80);
64287 l_component_code VARCHAR2(30);
64288 l_component_type_code VARCHAR2(1);
64289 l_component_appl_id INTEGER;
64290 l_amb_context_code VARCHAR2(30);
64291 l_entity_code VARCHAR2(30);
64292 l_event_class_code VARCHAR2(30);
64293 l_ae_header_id NUMBER;
64294 l_event_type_code VARCHAR2(30);
64295 l_line_definition_code VARCHAR2(30);
64296 l_line_definition_owner_code VARCHAR2(1);
64297 --
64298 -- adr variables
64299 l_segment VARCHAR2(30);
64300 l_ccid NUMBER;
64301 l_adr_transaction_coa_id NUMBER;
64302 l_adr_accounting_coa_id NUMBER;
64303 l_adr_flexfield_segment_code VARCHAR2(30);
64304 l_adr_flex_value_set_id NUMBER;
64305 l_adr_value_type_code VARCHAR2(30);
64306 l_adr_value_combination_id NUMBER;
64307 l_adr_value_segment_code VARCHAR2(30);
64308
64309 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
64310 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
64311 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
64312 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
64313
64314 -- 4262811 Variables ------------------------------------------------------------------------------------------
64315 l_entered_amt_idx NUMBER;
64316 l_accted_amt_idx NUMBER;
64317 l_acc_rev_flag VARCHAR2(1);
64318 l_accrual_line_num NUMBER;
64319 l_tmp_amt NUMBER;
64320 l_acc_rev_natural_side_code VARCHAR2(1);
64321
64322 l_num_entries NUMBER;
64323 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
64324 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
64325 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
64326 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
64327 l_recog_line_1 NUMBER;
64328 l_recog_line_2 NUMBER;
64329
64330 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
64331 l_bflow_applied_to_amt NUMBER; -- 5132302
64332 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
64333
64334 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
64335
64336 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
64337 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
64338
64339 ---------------------------------------------------------------------------------------------------------------
64340
64341
64342 --
64343 -- bulk performance
64344 --
64345 l_balance_type_code VARCHAR2(1);
64346 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
64347 l_log_module VARCHAR2(240);
64348
64349 --
64350 -- Upgrade strategy
64351 --
64352 l_actual_upg_option VARCHAR2(1);
64353 l_enc_upg_option VARCHAR2(1);
64354
64355 --
64356 BEGIN
64357 --
64358 IF g_log_enabled THEN
64359 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_130';
64360 END IF;
64361 --
64362 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64363
64364 trace
64365 (p_msg => 'BEGIN of AcctLineType_130'
64366 ,p_level => C_LEVEL_PROCEDURE
64367 ,p_module => l_log_module);
64368
64369 END IF;
64370 --
64371 l_component_type := 'AMB_JLT';
64372 l_component_code := 'RCT_UNEDISC_NON_REC_TAX';
64373 l_component_type_code := 'S';
64374 l_component_appl_id := 222;
64375 l_amb_context_code := 'DEFAULT';
64376 l_entity_code := 'RECEIPTS';
64377 l_event_class_code := 'RECEIPT';
64378 l_event_type_code := 'RECEIPT_ALL';
64379 l_line_definition_owner_code := 'S';
64380 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
64381 --
64382 l_balance_type_code := 'A';
64383 l_segment := NULL;
64384 l_ccid := NULL;
64385 l_adr_transaction_coa_id := NULL;
64386 l_adr_accounting_coa_id := NULL;
64387 l_adr_flexfield_segment_code := NULL;
64388 l_adr_flex_value_set_id := NULL;
64392
64389 l_adr_value_type_code := NULL;
64390 l_adr_value_combination_id := NULL;
64391 l_adr_value_segment_code := NULL;
64393 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
64394 l_bflow_class_code := ''; -- 4219869 Business Flow
64395 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
64396 l_budgetary_control_flag := 'N';
64397
64398 l_bflow_applied_to_amt_idx := NULL; -- 5132302
64399 l_bflow_applied_to_amt := NULL; -- 5132302
64400 l_entered_amt_idx := NULL; -- 4262811
64401 l_accted_amt_idx := NULL; -- 4262811
64402 l_acc_rev_flag := NULL; -- 4262811
64403 l_accrual_line_num := NULL; -- 4262811
64404 l_tmp_amt := NULL; -- 4262811
64405 --
64406
64407 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
64408 l_balance_type_code <> 'B' THEN
64409 IF NVL(p_source_20,'
64410 ') = 'UNEDISC_NON_REC_TAX' AND
64411 NVL(p_source_67,'
64412 ') = 'N'
64413 THEN
64414
64415 --
64416 XLA_AE_LINES_PKG.SetNewLine;
64417
64418 p_balance_type_code := l_balance_type_code;
64419 -- set the flag so later we will know whether the gain loss line needs to be created
64420
64421 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
64422 p_actual_flag :='A';
64423 END IF;
64424
64425 --
64426 -- bulk performance
64427 --
64428 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
64429 p_header_num => 0); -- 4262811
64430 --
64431 -- set accounting line options
64432 --
64433 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
64434 p_natural_side_code => 'C'
64435 , p_gain_or_loss_flag => 'N'
64436 , p_gl_transfer_mode_code => 'S'
64437 , p_acct_entry_type_code => 'A'
64438 , p_switch_side_flag => 'Y'
64439 , p_merge_duplicate_code => 'A'
64440 );
64441 --
64442 l_acc_rev_natural_side_code := 'D'; -- 4262811
64443 --
64444 --
64445 -- set accounting line type info
64446 --
64447 xla_ae_lines_pkg.SetAcctLineType
64448 (p_component_type => l_component_type
64449 ,p_event_type_code => l_event_type_code
64450 ,p_line_definition_owner_code => l_line_definition_owner_code
64451 ,p_line_definition_code => l_line_definition_code
64452 ,p_accounting_line_code => l_component_code
64453 ,p_accounting_line_type_code => l_component_type_code
64454 ,p_accounting_line_appl_id => l_component_appl_id
64455 ,p_amb_context_code => l_amb_context_code
64456 ,p_entity_code => l_entity_code
64457 ,p_event_class_code => l_event_class_code);
64458 --
64459 -- set accounting class
64460 --
64461 xla_ae_lines_pkg.SetAcctClass(
64462 p_accounting_class_code => 'UNEDISC_NON_REC_TAX'
64463 , p_ae_header_id => l_ae_header_id
64464 );
64465
64466 --
64467 -- set rounding class
64468 --
64469 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
64470 'RECEIVABLE';
64471
64472 --
64473 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
64474 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
64475 --
64476 -- bulk performance
64477 --
64478 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
64479
64480 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
64481 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
64482
64483 -- 4955764
64484 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
64485 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
64486
64487 -- 4458381 Public Sector Enh
64488
64489 --
64490 -- set accounting attributes for the line type
64491 --
64492 l_entered_amt_idx := 8;
64493 l_accted_amt_idx := 13;
64494 l_bflow_applied_to_amt_idx := NULL; -- 5132302
64495 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
64496 l_rec_acct_attrs.array_num_value(1) := p_source_58;
64497 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
64498 l_rec_acct_attrs.array_char_value(2) := p_source_35;
64499 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
64500 l_rec_acct_attrs.array_char_value(3) := p_source_59;
64501 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
64502 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
64503 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
64504 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
64505 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
64506 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
64507 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
64508 l_rec_acct_attrs.array_char_value(7) := p_source_23;
64509 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
64510 l_rec_acct_attrs.array_num_value(8) := p_source_24;
64511 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
64515 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
64512 l_rec_acct_attrs.array_char_value(9) := p_source_25;
64513 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
64514 l_rec_acct_attrs.array_date_value(10) := p_source_57;
64516 l_rec_acct_attrs.array_num_value(11) := p_source_62;
64517 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
64518 l_rec_acct_attrs.array_char_value(12) := p_source_70;
64519 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
64520 l_rec_acct_attrs.array_num_value(13) := p_source_29;
64521 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
64522 l_rec_acct_attrs.array_num_value(14) := p_source_63;
64523 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
64524 l_rec_acct_attrs.array_num_value(15) := p_source_64;
64525 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
64526 l_rec_acct_attrs.array_char_value(16) := p_source_65;
64527
64528 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
64529 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
64530
64531 ---------------------------------------------------------------------------------------------------------------
64532 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
64533 ---------------------------------------------------------------------------------------------------------------
64534 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
64535
64536 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
64537 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
64538
64539 IF xla_accounting_cache_pkg.GetValueChar
64540 (p_source_code => 'LEDGER_CATEGORY_CODE'
64541 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
64542 AND l_bflow_method_code = 'PRIOR_ENTRY'
64543 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
64544 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
64545 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
64546 )
64547 THEN
64548 xla_ae_lines_pkg.BflowUpgEntry
64549 (p_business_method_code => l_bflow_method_code
64550 ,p_business_class_code => l_bflow_class_code
64551 ,p_balance_type => l_balance_type_code);
64552 ELSE
64553 NULL;
64554 -- No business flow processing for business flow method of NONE.
64555 END IF;
64556
64557 --
64558 -- call analytical criteria
64559 --
64560
64561 --
64562 -- call description
64563 --
64564 -- No description or it is inherited.
64565 --
64566 -- call ADRs
64567 -- Bug 4922099
64568 --
64569 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
64570 (NVL(l_actual_upg_option, 'N') = 'O') OR
64571 (NVL(l_enc_upg_option, 'N') = 'O')
64572 )
64573 THEN
64574 NULL;
64575 --
64576 --
64577
64578 l_ccid := AcctDerRule_4(
64579 p_application_id => p_application_id
64580 , p_ae_header_id => l_ae_header_id
64581 , p_source_5 => p_source_5
64582 , x_transaction_coa_id => l_adr_transaction_coa_id
64583 , x_accounting_coa_id => l_adr_accounting_coa_id
64584 , x_value_type_code => l_adr_value_type_code
64585 , p_side => 'NA'
64586 );
64587
64588 xla_ae_lines_pkg.set_ccid(
64592 , p_accounting_coa_id => l_adr_accounting_coa_id
64589 p_code_combination_id => l_ccid
64590 , p_value_type_code => l_adr_value_type_code
64591 , p_transaction_coa_id => l_adr_transaction_coa_id
64593 , p_adr_code => 'DIST_CCID'
64594 , p_adr_type_code => 'S'
64595 , p_component_type => l_component_type
64596 , p_component_code => l_component_code
64597 , p_component_type_code => l_component_type_code
64598 , p_component_appl_id => l_component_appl_id
64599 , p_amb_context_code => l_amb_context_code
64600 , p_side => 'NA'
64601 );
64602
64603
64604 --
64605 --
64606 END IF;
64607 --
64608 -- Bug 4922099
64609 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
64610 (NVL(l_enc_upg_option, 'N') = 'O')
64611 ) AND
64612 (l_bflow_method_code = 'PRIOR_ENTRY')
64613 )
64614 THEN
64615 IF
64616 --
64617 1 = 2
64618 --
64619 THEN
64620 xla_accounting_err_pkg.build_message
64621 (p_appli_s_name => 'XLA'
64622 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64623 ,p_token_1 => 'LINE_NUMBER'
64624 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
64625 ,p_token_2 => 'LINE_TYPE_NAME'
64626 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
64627 l_component_type
64628 ,l_component_code
64629 ,l_component_type_code
64630 ,l_component_appl_id
64631 ,l_amb_context_code
64632 ,l_entity_code
64633 ,l_event_class_code
64634 )
64635 ,p_token_3 => 'OWNER'
64636 ,p_value_3 => xla_lookups_pkg.get_meaning(
64637 p_lookup_type => 'XLA_OWNER_TYPE'
64638 ,p_lookup_code => l_component_type_code
64639 )
64640 ,p_token_4 => 'PRODUCT_NAME'
64641 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
64642 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
64643 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
64644 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
64648 IF (C_LEVEL_ERROR>= g_log_level) THEN
64645 ,p_ae_header_id => NULL
64646 );
64647
64649 trace
64650 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
64651 ,p_level => C_LEVEL_ERROR
64652 ,p_module => l_log_module);
64653 END IF;
64654 END IF;
64655 END IF;
64656 --
64657 --
64658 ------------------------------------------------------------------------------------------------
64659 -- 4219869 Business Flow
64660 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
64661 -- Prior Entry. Currently, the following code is always generated.
64662 ------------------------------------------------------------------------------------------------
64663 XLA_AE_LINES_PKG.ValidateCurrentLine;
64664
64665 ------------------------------------------------------------------------------------
64666 -- 4219869 Business Flow
64667 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
64668 ------------------------------------------------------------------------------------
64669 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
64670
64671 ----------------------------------------------------------------------------------
64672 -- 4219869 Business Flow
64673 -- Update journal entry status -- Need to generate this within IF <condition>
64674 ----------------------------------------------------------------------------------
64675 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
64676 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
64677 ,p_balance_type_code => l_balance_type_code
64678 );
64679
64680 -------------------------------------------------------------------------------------------
64681 -- 4262811 - Generate the Accrual Reversal lines
64682 -------------------------------------------------------------------------------------------
64683 BEGIN
64684 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
64685 (g_array_event(p_event_id).array_value_num('header_index'));
64686 IF l_acc_rev_flag IS NULL THEN
64687 l_acc_rev_flag := 'N';
64688 END IF;
64689 EXCEPTION
64690 WHEN OTHERS THEN
64691 l_acc_rev_flag := 'N';
64692 END;
64693 --
64694 IF (l_acc_rev_flag = 'Y') THEN
64695
64696 -- 4645092 ------------------------------------------------------------------------------
64697 -- To allow MPA report to determine if it should generate report process
64698 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
64699 ------------------------------------------------------------------------------------------
64700
64701 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
64702 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
64703 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
64704 -- call ADRs
64705 -- Bug 4922099
64706 --
64707 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
64708 (NVL(l_actual_upg_option, 'N') = 'O') OR
64709 (NVL(l_enc_upg_option, 'N') = 'O')
64710 )
64711 THEN
64712 NULL;
64713 --
64714 --
64715
64716 l_ccid := AcctDerRule_4(
64717 p_application_id => p_application_id
64718 , p_ae_header_id => l_ae_header_id
64719 , p_source_5 => p_source_5
64720 , x_transaction_coa_id => l_adr_transaction_coa_id
64721 , x_accounting_coa_id => l_adr_accounting_coa_id
64722 , x_value_type_code => l_adr_value_type_code
64723 , p_side => 'NA'
64724 );
64725
64726 xla_ae_lines_pkg.set_ccid(
64727 p_code_combination_id => l_ccid
64728 , p_value_type_code => l_adr_value_type_code
64729 , p_transaction_coa_id => l_adr_transaction_coa_id
64730 , p_accounting_coa_id => l_adr_accounting_coa_id
64731 , p_adr_code => 'DIST_CCID'
64732 , p_adr_type_code => 'S'
64733 , p_component_type => l_component_type
64734 , p_component_code => l_component_code
64735 , p_component_type_code => l_component_type_code
64736 , p_component_appl_id => l_component_appl_id
64737 , p_amb_context_code => l_amb_context_code
64738 , p_side => 'NA'
64739 );
64740
64741
64742 --
64743 --
64744 END IF;
64745
64746 --
64747 -- Update the line information that should be overwritten
64748 --
64749 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
64750 p_header_num => 1);
64751 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
64752
64753 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
64754
64755 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
64756 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
64757 END IF;
64758
64759 --
64760 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
64761 --
64762 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
64763 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
64764 ELSE
64765 ---------------------------------------------------------------------------------------------------
64766 -- 4262811a Switch Sign
64767 ---------------------------------------------------------------------------------------------------
64768 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
64769 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
64770 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64771 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
64772 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64773 -- 5132302
64774 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
64775 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
64776
64777 END IF;
64778
64779 -- 4955764
64780 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
64781 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
64782
64783
64784 XLA_AE_LINES_PKG.ValidateCurrentLine;
64785 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
64786
64787 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
64788 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
64789 ,p_balance_type_code => l_balance_type_code);
64790
64791 END IF;
64792
64793 -----------------------------------------------------------------------------------------
64794 -- 4262811 Multiperiod Accounting
64795 -----------------------------------------------------------------------------------------
64796 -- No MPA option is assigned.
64797
64798
64799 END IF;
64800 END IF;
64801 --
64802
64803 --
64804 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64805 trace
64806 (p_msg => 'END of AcctLineType_130'
64807 ,p_level => C_LEVEL_PROCEDURE
64808 ,p_module => l_log_module);
64809 END IF;
64810 --
64811 EXCEPTION
64812 WHEN xla_exceptions_pkg.application_exception THEN
64813 RAISE;
64814 WHEN OTHERS THEN
64815 xla_exceptions_pkg.raise_message
64816 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_130');
64817 END AcctLineType_130;
64818 --
64819
64820 ---------------------------------------
64821 --
64822 -- PRIVATE FUNCTION
64823 -- AcctLineType_131
64824 --
64825 ---------------------------------------
64826 PROCEDURE AcctLineType_131 (
64827 p_application_id IN NUMBER
64828 ,p_event_id IN NUMBER
64829 ,p_calculate_acctd_flag IN VARCHAR2
64830 ,p_calculate_g_l_flag IN VARCHAR2
64831 ,p_actual_flag IN OUT VARCHAR2
64832 ,p_balance_type_code OUT VARCHAR2
64833 ,p_gain_or_loss_ref OUT VARCHAR2
64834
64835 --Distribution GL Account
64836 , p_source_5 IN NUMBER
64837 --Distribution Source Type
64838 , p_source_20 IN VARCHAR2
64839 --Distribution Line Identifier
64840 , p_source_22 IN NUMBER
64841 --Distribution Type
64842 , p_source_23 IN VARCHAR2
64843 --Exchange Date
64844 , p_source_26 IN DATE
64845 --Exchange Rate
64846 , p_source_27 IN NUMBER
64847 --Exchange Rate Type
64848 , p_source_28 IN VARCHAR2
64849 --Transaction Distribution Identifier
64850 , p_source_34 IN NUMBER
64851 --Transaction Distribution Type
64852 , p_source_35 IN VARCHAR2
64853 --Receipt Applied To Application Identifier
64854 , p_source_58 IN NUMBER
64855 --Transaction Entity Code
64856 , p_source_59 IN VARCHAR2
64857 --Transaction Identifier
64858 , p_source_60 IN NUMBER
64859 --Applying Document Currency Code
64860 , p_source_61 IN VARCHAR2
64861 --Distribution Party Identifier
64862 , p_source_63 IN NUMBER
64863 --Distribution Party Site Id
64864 , p_source_64 IN NUMBER
64865 --Distribution Party Type
64866 , p_source_65 IN VARCHAR2
64867 --Distribution Multi Fund Additional Entry
64868 , p_source_67 IN VARCHAR2
64869 --DIST_ENT_AMT_FROM
64870 , p_source_68 IN NUMBER
64871 --Accounting Amount
64872 , p_source_69 IN NUMBER
64873 )
64874 IS
64875
64876 l_component_type VARCHAR2(80);
64877 l_component_code VARCHAR2(30);
64878 l_component_type_code VARCHAR2(1);
64879 l_component_appl_id INTEGER;
64880 l_amb_context_code VARCHAR2(30);
64881 l_entity_code VARCHAR2(30);
64882 l_event_class_code VARCHAR2(30);
64883 l_ae_header_id NUMBER;
64884 l_event_type_code VARCHAR2(30);
64885 l_line_definition_code VARCHAR2(30);
64886 l_line_definition_owner_code VARCHAR2(1);
64887 --
64888 -- adr variables
64889 l_segment VARCHAR2(30);
64890 l_ccid NUMBER;
64891 l_adr_transaction_coa_id NUMBER;
64892 l_adr_accounting_coa_id NUMBER;
64893 l_adr_flexfield_segment_code VARCHAR2(30);
64894 l_adr_flex_value_set_id NUMBER;
64895 l_adr_value_type_code VARCHAR2(30);
64896 l_adr_value_combination_id NUMBER;
64897 l_adr_value_segment_code VARCHAR2(30);
64898
64899 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
64900 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
64901 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
64902 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
64903
64904 -- 4262811 Variables ------------------------------------------------------------------------------------------
64905 l_entered_amt_idx NUMBER;
64906 l_accted_amt_idx NUMBER;
64907 l_acc_rev_flag VARCHAR2(1);
64908 l_accrual_line_num NUMBER;
64909 l_tmp_amt NUMBER;
64910 l_acc_rev_natural_side_code VARCHAR2(1);
64911
64912 l_num_entries NUMBER;
64913 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
64914 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
64915 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
64916 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
64917 l_recog_line_1 NUMBER;
64918 l_recog_line_2 NUMBER;
64919
64920 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
64921 l_bflow_applied_to_amt NUMBER; -- 5132302
64922 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
64923
64924 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
64925
64926 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
64930
64927 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
64928
64929 ---------------------------------------------------------------------------------------------------------------
64931
64932 --
64933 -- bulk performance
64934 --
64935 l_balance_type_code VARCHAR2(1);
64936 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
64937 l_log_module VARCHAR2(240);
64938
64939 --
64940 -- Upgrade strategy
64941 --
64942 l_actual_upg_option VARCHAR2(1);
64943 l_enc_upg_option VARCHAR2(1);
64944
64945 --
64946 BEGIN
64947 --
64948 IF g_log_enabled THEN
64949 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_131';
64950 END IF;
64951 --
64952 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
64953
64954 trace
64955 (p_msg => 'BEGIN of AcctLineType_131'
64956 ,p_level => C_LEVEL_PROCEDURE
64957 ,p_module => l_log_module);
64958
64959 END IF;
64960 --
64961 l_component_type := 'AMB_JLT';
64962 l_component_code := 'RCT_UNID';
64963 l_component_type_code := 'S';
64964 l_component_appl_id := 222;
64965 l_amb_context_code := 'DEFAULT';
64966 l_entity_code := 'RECEIPTS';
64967 l_event_class_code := 'RECEIPT';
64968 l_event_type_code := 'RECEIPT_ALL';
64969 l_line_definition_owner_code := 'S';
64970 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
64971 --
64972 l_balance_type_code := 'A';
64973 l_segment := NULL;
64974 l_ccid := NULL;
64975 l_adr_transaction_coa_id := NULL;
64976 l_adr_accounting_coa_id := NULL;
64977 l_adr_flexfield_segment_code := NULL;
64978 l_adr_flex_value_set_id := NULL;
64979 l_adr_value_type_code := NULL;
64983 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
64980 l_adr_value_combination_id := NULL;
64981 l_adr_value_segment_code := NULL;
64982
64984 l_bflow_class_code := ''; -- 4219869 Business Flow
64985 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
64986 l_budgetary_control_flag := 'N';
64987
64988 l_bflow_applied_to_amt_idx := NULL; -- 5132302
64989 l_bflow_applied_to_amt := NULL; -- 5132302
64990 l_entered_amt_idx := NULL; -- 4262811
64991 l_accted_amt_idx := NULL; -- 4262811
64992 l_acc_rev_flag := NULL; -- 4262811
64993 l_accrual_line_num := NULL; -- 4262811
64994 l_tmp_amt := NULL; -- 4262811
64995 --
64996
64997 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
64998 l_balance_type_code <> 'B' THEN
64999 IF NVL(p_source_20,'
65000 ') = 'UNID' AND
65001 NVL(p_source_67,'
65002 ') = 'N'
65003 THEN
65004
65005 --
65006 XLA_AE_LINES_PKG.SetNewLine;
65007
65008 p_balance_type_code := l_balance_type_code;
65009 -- set the flag so later we will know whether the gain loss line needs to be created
65010
65011 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
65012 p_actual_flag :='A';
65013 END IF;
65014
65015 --
65016 -- bulk performance
65017 --
65018 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
65019 p_header_num => 0); -- 4262811
65020 --
65021 -- set accounting line options
65022 --
65023 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
65024 p_natural_side_code => 'C'
65025 , p_gain_or_loss_flag => 'N'
65026 , p_gl_transfer_mode_code => 'S'
65027 , p_acct_entry_type_code => 'A'
65028 , p_switch_side_flag => 'Y'
65029 , p_merge_duplicate_code => 'A'
65030 );
65031 --
65032 l_acc_rev_natural_side_code := 'D'; -- 4262811
65033 --
65034 --
65035 -- set accounting line type info
65036 --
65037 xla_ae_lines_pkg.SetAcctLineType
65038 (p_component_type => l_component_type
65039 ,p_event_type_code => l_event_type_code
65040 ,p_line_definition_owner_code => l_line_definition_owner_code
65041 ,p_line_definition_code => l_line_definition_code
65042 ,p_accounting_line_code => l_component_code
65043 ,p_accounting_line_type_code => l_component_type_code
65044 ,p_accounting_line_appl_id => l_component_appl_id
65045 ,p_amb_context_code => l_amb_context_code
65046 ,p_entity_code => l_entity_code
65047 ,p_event_class_code => l_event_class_code);
65048 --
65049 -- set accounting class
65050 --
65051 xla_ae_lines_pkg.SetAcctClass(
65052 p_accounting_class_code => 'UNID'
65053 , p_ae_header_id => l_ae_header_id
65054 );
65055
65056 --
65057 -- set rounding class
65058 --
65059 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
65060 'RECEIVABLE';
65061
65062 --
65063 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
65064 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
65065 --
65066 -- bulk performance
65067 --
65068 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
65069
65070 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
65071 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
65072
65073 -- 4955764
65074 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
65075 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
65076
65077 -- 4458381 Public Sector Enh
65078
65079 --
65080 -- set accounting attributes for the line type
65081 --
65082 l_entered_amt_idx := 8;
65083 l_accted_amt_idx := 13;
65084 l_bflow_applied_to_amt_idx := NULL; -- 5132302
65085 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
65086 l_rec_acct_attrs.array_num_value(1) := p_source_58;
65087 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
65088 l_rec_acct_attrs.array_char_value(2) := p_source_35;
65089 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
65090 l_rec_acct_attrs.array_char_value(3) := p_source_59;
65091 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
65092 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
65093 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
65094 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
65095 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
65096 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
65097 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
65098 l_rec_acct_attrs.array_char_value(7) := p_source_23;
65099 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
65100 l_rec_acct_attrs.array_num_value(8) := p_source_68;
65101 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
65102 l_rec_acct_attrs.array_char_value(9) := p_source_61;
65103 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
65104 l_rec_acct_attrs.array_date_value(10) := p_source_26;
65105 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
65106 l_rec_acct_attrs.array_num_value(11) := p_source_27;
65107 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
65108 l_rec_acct_attrs.array_char_value(12) := p_source_28;
65109 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
65110 l_rec_acct_attrs.array_num_value(13) := p_source_69;
65111 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
65112 l_rec_acct_attrs.array_num_value(14) := p_source_63;
65113 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
65114 l_rec_acct_attrs.array_num_value(15) := p_source_64;
65115 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
65116 l_rec_acct_attrs.array_char_value(16) := p_source_65;
65117
65118 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
65119 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
65120
65121 ---------------------------------------------------------------------------------------------------------------
65122 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
65123 ---------------------------------------------------------------------------------------------------------------
65124 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
65125
65126 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
65127 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
65128
65129 IF xla_accounting_cache_pkg.GetValueChar
65130 (p_source_code => 'LEDGER_CATEGORY_CODE'
65131 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
65132 AND l_bflow_method_code = 'PRIOR_ENTRY'
65133 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
65134 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
65135 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
65136 )
65137 THEN
65138 xla_ae_lines_pkg.BflowUpgEntry
65139 (p_business_method_code => l_bflow_method_code
65140 ,p_business_class_code => l_bflow_class_code
65141 ,p_balance_type => l_balance_type_code);
65142 ELSE
65143 NULL;
65144 -- No business flow processing for business flow method of NONE.
65145 END IF;
65146
65147 --
65148 -- call analytical criteria
65149 --
65150
65151 --
65152 -- call description
65153 --
65154 -- No description or it is inherited.
65155 --
65156 -- call ADRs
65157 -- Bug 4922099
65158 --
65159 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
65160 (NVL(l_actual_upg_option, 'N') = 'O') OR
65161 (NVL(l_enc_upg_option, 'N') = 'O')
65162 )
65163 THEN
65164 NULL;
65165 --
65166 --
65167
65168 l_ccid := AcctDerRule_4(
65169 p_application_id => p_application_id
65170 , p_ae_header_id => l_ae_header_id
65171 , p_source_5 => p_source_5
65172 , x_transaction_coa_id => l_adr_transaction_coa_id
65173 , x_accounting_coa_id => l_adr_accounting_coa_id
65174 , x_value_type_code => l_adr_value_type_code
65175 , p_side => 'NA'
65176 );
65177
65178 xla_ae_lines_pkg.set_ccid(
65179 p_code_combination_id => l_ccid
65180 , p_value_type_code => l_adr_value_type_code
65181 , p_transaction_coa_id => l_adr_transaction_coa_id
65182 , p_accounting_coa_id => l_adr_accounting_coa_id
65183 , p_adr_code => 'DIST_CCID'
65184 , p_adr_type_code => 'S'
65185 , p_component_type => l_component_type
65186 , p_component_code => l_component_code
65187 , p_component_type_code => l_component_type_code
65188 , p_component_appl_id => l_component_appl_id
65189 , p_amb_context_code => l_amb_context_code
65190 , p_side => 'NA'
65191 );
65192
65193
65194 --
65195 --
65196 END IF;
65197 --
65198 -- Bug 4922099
65199 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
65200 (NVL(l_enc_upg_option, 'N') = 'O')
65201 ) AND
65202 (l_bflow_method_code = 'PRIOR_ENTRY')
65203 )
65204 THEN
65205 IF
65206 --
65207 1 = 2
65208 --
65209 THEN
65210 xla_accounting_err_pkg.build_message
65211 (p_appli_s_name => 'XLA'
65212 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
65213 ,p_token_1 => 'LINE_NUMBER'
65214 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
65215 ,p_token_2 => 'LINE_TYPE_NAME'
65216 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
65217 l_component_type
65218 ,l_component_code
65219 ,l_component_type_code
65220 ,l_component_appl_id
65221 ,l_amb_context_code
65222 ,l_entity_code
65223 ,l_event_class_code
65224 )
65225 ,p_token_3 => 'OWNER'
65226 ,p_value_3 => xla_lookups_pkg.get_meaning(
65227 p_lookup_type => 'XLA_OWNER_TYPE'
65228 ,p_lookup_code => l_component_type_code
65229 )
65230 ,p_token_4 => 'PRODUCT_NAME'
65231 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
65232 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
65233 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
65234 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
65235 ,p_ae_header_id => NULL
65236 );
65237
65238 IF (C_LEVEL_ERROR>= g_log_level) THEN
65239 trace
65240 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
65241 ,p_level => C_LEVEL_ERROR
65242 ,p_module => l_log_module);
65243 END IF;
65244 END IF;
65245 END IF;
65246 --
65247 --
65248 ------------------------------------------------------------------------------------------------
65249 -- 4219869 Business Flow
65250 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
65251 -- Prior Entry. Currently, the following code is always generated.
65252 ------------------------------------------------------------------------------------------------
65253 XLA_AE_LINES_PKG.ValidateCurrentLine;
65254
65255 ------------------------------------------------------------------------------------
65256 -- 4219869 Business Flow
65257 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
65258 ------------------------------------------------------------------------------------
65259 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
65260
65261 ----------------------------------------------------------------------------------
65262 -- 4219869 Business Flow
65263 -- Update journal entry status -- Need to generate this within IF <condition>
65264 ----------------------------------------------------------------------------------
65265 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
65266 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
65267 ,p_balance_type_code => l_balance_type_code
65268 );
65269
65270 -------------------------------------------------------------------------------------------
65271 -- 4262811 - Generate the Accrual Reversal lines
65272 -------------------------------------------------------------------------------------------
65273 BEGIN
65274 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
65278 END IF;
65275 (g_array_event(p_event_id).array_value_num('header_index'));
65276 IF l_acc_rev_flag IS NULL THEN
65277 l_acc_rev_flag := 'N';
65279 EXCEPTION
65280 WHEN OTHERS THEN
65281 l_acc_rev_flag := 'N';
65282 END;
65283 --
65284 IF (l_acc_rev_flag = 'Y') THEN
65285
65286 -- 4645092 ------------------------------------------------------------------------------
65287 -- To allow MPA report to determine if it should generate report process
65288 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
65289 ------------------------------------------------------------------------------------------
65290
65291 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
65292 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
65293 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
65294 -- call ADRs
65295 -- Bug 4922099
65296 --
65297 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
65298 (NVL(l_actual_upg_option, 'N') = 'O') OR
65299 (NVL(l_enc_upg_option, 'N') = 'O')
65300 )
65301 THEN
65302 NULL;
65303 --
65304 --
65305
65306 l_ccid := AcctDerRule_4(
65307 p_application_id => p_application_id
65308 , p_ae_header_id => l_ae_header_id
65309 , p_source_5 => p_source_5
65310 , x_transaction_coa_id => l_adr_transaction_coa_id
65311 , x_accounting_coa_id => l_adr_accounting_coa_id
65312 , x_value_type_code => l_adr_value_type_code
65313 , p_side => 'NA'
65314 );
65315
65316 xla_ae_lines_pkg.set_ccid(
65317 p_code_combination_id => l_ccid
65318 , p_value_type_code => l_adr_value_type_code
65319 , p_transaction_coa_id => l_adr_transaction_coa_id
65320 , p_accounting_coa_id => l_adr_accounting_coa_id
65321 , p_adr_code => 'DIST_CCID'
65322 , p_adr_type_code => 'S'
65323 , p_component_type => l_component_type
65324 , p_component_code => l_component_code
65325 , p_component_type_code => l_component_type_code
65326 , p_component_appl_id => l_component_appl_id
65327 , p_amb_context_code => l_amb_context_code
65328 , p_side => 'NA'
65329 );
65330
65331
65332 --
65333 --
65334 END IF;
65335
65336 --
65337 -- Update the line information that should be overwritten
65338 --
65339 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
65340 p_header_num => 1);
65341 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
65342
65343 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
65344
65345 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
65346 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
65347 END IF;
65348
65349 --
65350 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
65351 --
65355 ---------------------------------------------------------------------------------------------------
65352 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
65353 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
65354 ELSE
65356 -- 4262811a Switch Sign
65357 ---------------------------------------------------------------------------------------------------
65358 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
65359 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65360 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65361 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65362 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65363 -- 5132302
65364 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
65365 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65366
65367 END IF;
65368
65369 -- 4955764
65370 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
65371 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
65372
65373
65374 XLA_AE_LINES_PKG.ValidateCurrentLine;
65375 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
65376
65377 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
65378 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
65379 ,p_balance_type_code => l_balance_type_code);
65380
65381 END IF;
65382
65383 -----------------------------------------------------------------------------------------
65384 -- 4262811 Multiperiod Accounting
65385 -----------------------------------------------------------------------------------------
65386 -- No MPA option is assigned.
65387
65388
65389 END IF;
65390 END IF;
65391 --
65392
65393 --
65394 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
65395 trace
65396 (p_msg => 'END of AcctLineType_131'
65397 ,p_level => C_LEVEL_PROCEDURE
65398 ,p_module => l_log_module);
65399 END IF;
65400 --
65401 EXCEPTION
65402 WHEN xla_exceptions_pkg.application_exception THEN
65403 RAISE;
65404 WHEN OTHERS THEN
65405 xla_exceptions_pkg.raise_message
65406 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_131');
65407 END AcctLineType_131;
65408 --
65409
65410 ---------------------------------------
65411 --
65412 -- PRIVATE FUNCTION
65413 -- AcctLineType_132
65414 --
65415 ---------------------------------------
65416 PROCEDURE AcctLineType_132 (
65417 p_application_id IN NUMBER
65418 ,p_event_id IN NUMBER
65419 ,p_calculate_acctd_flag IN VARCHAR2
65420 ,p_calculate_g_l_flag IN VARCHAR2
65421 ,p_actual_flag IN OUT VARCHAR2
65422 ,p_balance_type_code OUT VARCHAR2
65423 ,p_gain_or_loss_ref OUT VARCHAR2
65424
65425 --Remittance Bank Account Unidentified Account
65426 , p_source_18 IN NUMBER
65427 --Distribution Source Type
65428 , p_source_20 IN VARCHAR2
65429 --Distribution Line Identifier
65430 , p_source_22 IN NUMBER
65431 --Distribution Type
65432 , p_source_23 IN VARCHAR2
65433 --Entered Amount
65434 , p_source_24 IN NUMBER
65435 --Currency Code
65436 , p_source_25 IN VARCHAR2
65437 --Exchange Date
65438 , p_source_26 IN DATE
65439 --Exchange Rate
65440 , p_source_27 IN NUMBER
65441 --Exchange Rate Type
65442 , p_source_28 IN VARCHAR2
65443 --Transaction Distribution Identifier
65444 , p_source_34 IN NUMBER
65445 --Transaction Distribution Type
65446 , p_source_35 IN VARCHAR2
65447 --Receipt Applied To Application Identifier
65448 , p_source_58 IN NUMBER
65449 --Transaction Entity Code
65450 , p_source_59 IN VARCHAR2
65451 --Transaction Identifier
65452 , p_source_60 IN NUMBER
65453 --Distribution Party Identifier
65454 , p_source_63 IN NUMBER
65455 --Distribution Party Site Id
65456 , p_source_64 IN NUMBER
65457 --Distribution Party Type
65458 , p_source_65 IN VARCHAR2
65459 --Distribution Multi Fund Additional Entry
65460 , p_source_67 IN VARCHAR2
65464 , p_source_71 IN VARCHAR2
65461 --Accounting Amount
65462 , p_source_69 IN NUMBER
65463 --Distribution Source Table
65465 --Receipt Application Status
65466 , p_source_74 IN VARCHAR2
65467 --Receipt Previous Pay From Customer
65468 , p_source_75 IN NUMBER
65469 --Receipt Previous Customer Site Use Id
65470 , p_source_76 IN NUMBER
65471 )
65472 IS
65473
65474 l_component_type VARCHAR2(80);
65475 l_component_code VARCHAR2(30);
65476 l_component_type_code VARCHAR2(1);
65477 l_component_appl_id INTEGER;
65478 l_amb_context_code VARCHAR2(30);
65479 l_entity_code VARCHAR2(30);
65480 l_event_class_code VARCHAR2(30);
65481 l_ae_header_id NUMBER;
65482 l_event_type_code VARCHAR2(30);
65483 l_line_definition_code VARCHAR2(30);
65484 l_line_definition_owner_code VARCHAR2(1);
65485 --
65486 -- adr variables
65487 l_segment VARCHAR2(30);
65488 l_ccid NUMBER;
65489 l_adr_transaction_coa_id NUMBER;
65490 l_adr_accounting_coa_id NUMBER;
65491 l_adr_flexfield_segment_code VARCHAR2(30);
65492 l_adr_flex_value_set_id NUMBER;
65493 l_adr_value_type_code VARCHAR2(30);
65494 l_adr_value_combination_id NUMBER;
65495 l_adr_value_segment_code VARCHAR2(30);
65496
65497 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
65498 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
65499 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
65500 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
65501
65502 -- 4262811 Variables ------------------------------------------------------------------------------------------
65503 l_entered_amt_idx NUMBER;
65504 l_accted_amt_idx NUMBER;
65505 l_acc_rev_flag VARCHAR2(1);
65509
65506 l_accrual_line_num NUMBER;
65507 l_tmp_amt NUMBER;
65508 l_acc_rev_natural_side_code VARCHAR2(1);
65510 l_num_entries NUMBER;
65511 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
65512 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
65513 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
65514 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
65515 l_recog_line_1 NUMBER;
65516 l_recog_line_2 NUMBER;
65517
65518 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
65519 l_bflow_applied_to_amt NUMBER; -- 5132302
65520 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
65521
65522 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
65523
65524 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
65525 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
65526
65527 ---------------------------------------------------------------------------------------------------------------
65528
65529
65530 --
65531 -- bulk performance
65532 --
65533 l_balance_type_code VARCHAR2(1);
65534 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
65535 l_log_module VARCHAR2(240);
65536
65537 --
65538 -- Upgrade strategy
65539 --
65540 l_actual_upg_option VARCHAR2(1);
65541 l_enc_upg_option VARCHAR2(1);
65542
65543 --
65544 BEGIN
65545 --
65546 IF g_log_enabled THEN
65547 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_132';
65548 END IF;
65549 --
65550 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
65551
65552 trace
65553 (p_msg => 'BEGIN of AcctLineType_132'
65554 ,p_level => C_LEVEL_PROCEDURE
65555 ,p_module => l_log_module);
65556
65557 END IF;
65558 --
65559 l_component_type := 'AMB_JLT';
65560 l_component_code := 'RCT_UNID_BALANCE';
65561 l_component_type_code := 'S';
65562 l_component_appl_id := 222;
65563 l_amb_context_code := 'DEFAULT';
65564 l_entity_code := 'RECEIPTS';
65565 l_event_class_code := 'RECEIPT';
65566 l_event_type_code := 'RECEIPT_ALL';
65567 l_line_definition_owner_code := 'S';
65568 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
65569 --
65570 l_balance_type_code := 'A';
65571 l_segment := NULL;
65572 l_ccid := NULL;
65573 l_adr_transaction_coa_id := NULL;
65574 l_adr_accounting_coa_id := NULL;
65578 l_adr_value_combination_id := NULL;
65575 l_adr_flexfield_segment_code := NULL;
65576 l_adr_flex_value_set_id := NULL;
65577 l_adr_value_type_code := NULL;
65579 l_adr_value_segment_code := NULL;
65580
65581 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
65582 l_bflow_class_code := ''; -- 4219869 Business Flow
65583 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
65584 l_budgetary_control_flag := 'N';
65585
65586 l_bflow_applied_to_amt_idx := NULL; -- 5132302
65587 l_bflow_applied_to_amt := NULL; -- 5132302
65588 l_entered_amt_idx := NULL; -- 4262811
65589 l_accted_amt_idx := NULL; -- 4262811
65590 l_acc_rev_flag := NULL; -- 4262811
65591 l_accrual_line_num := NULL; -- 4262811
65592 l_tmp_amt := NULL; -- 4262811
65593 --
65594
65595 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
65596 l_balance_type_code <> 'B' THEN
65597 IF NVL(p_source_74,'
65598 ') = 'UNID' AND
65599 p_source_75 IS NULL AND
65600 p_source_76 IS NULL AND
65601 ((NVL(p_source_20,'
65602 ') = 'CASH' AND
65603 NVL(p_source_67,'
65604 ') = 'N') OR
65605 (NVL(p_source_20,'
65606 ') = 'REMITTANCE' AND
65607 NVL(p_source_71,'
65608 ') = 'CRH' AND
65609 NVL(p_source_67,'
65610 ') = 'N') OR
65611 (NVL(p_source_20,'
65612 ') = 'CONFIRMATION' AND
65613 NVL(p_source_67,'
65614 ') = 'N') OR
65615 (NVL(p_source_20,'
65616 ') = 'FACTOR' AND
65617 NVL(p_source_71,'
65618 ') = 'CRH' AND
65619 NVL(p_source_67,'
65620 ') = 'N') OR
65621 (NVL(p_source_20,'
65622 ') = 'SHORT_TERM_DEBT' AND
65623 NVL(p_source_67,'
65624 ') = 'N') OR
65625 (NVL(p_source_20,'
65626 ') = 'BANK_CHARGES' AND
65627 NVL(p_source_67,'
65628 ') = 'N') OR
65629 (NVL(p_source_20,'
65630 ') = 'UNID' AND
65631 NVL(p_source_67,'
65632 ') = 'N')
65633 ) THEN
65634
65635 --
65636 XLA_AE_LINES_PKG.SetNewLine;
65637
65638 p_balance_type_code := l_balance_type_code;
65639 -- set the flag so later we will know whether the gain loss line needs to be created
65640
65641 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
65642 p_actual_flag :='A';
65643 END IF;
65644
65645 --
65646 -- bulk performance
65647 --
65648 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
65649 p_header_num => 0); -- 4262811
65650 --
65651 -- set accounting line options
65652 --
65653 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
65654 p_natural_side_code => 'D'
65655 , p_gain_or_loss_flag => 'N'
65656 , p_gl_transfer_mode_code => 'S'
65657 , p_acct_entry_type_code => 'A'
65658 , p_switch_side_flag => 'Y'
65659 , p_merge_duplicate_code => 'A'
65660 );
65661 --
65662 l_acc_rev_natural_side_code := 'C'; -- 4262811
65663 --
65664 --
65665 -- set accounting line type info
65666 --
65667 xla_ae_lines_pkg.SetAcctLineType
65668 (p_component_type => l_component_type
65669 ,p_event_type_code => l_event_type_code
65670 ,p_line_definition_owner_code => l_line_definition_owner_code
65671 ,p_line_definition_code => l_line_definition_code
65672 ,p_accounting_line_code => l_component_code
65673 ,p_accounting_line_type_code => l_component_type_code
65674 ,p_accounting_line_appl_id => l_component_appl_id
65675 ,p_amb_context_code => l_amb_context_code
65676 ,p_entity_code => l_entity_code
65677 ,p_event_class_code => l_event_class_code);
65678 --
65679 -- set accounting class
65680 --
65681 xla_ae_lines_pkg.SetAcctClass(
65682 p_accounting_class_code => 'UNID'
65683 , p_ae_header_id => l_ae_header_id
65684 );
65685
65686 --
65687 -- set rounding class
65688 --
65689 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
65690 'RECEIVABLE';
65691
65692 --
65693 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
65694 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
65695 --
65696 -- bulk performance
65697 --
65698 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
65699
65700 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
65701 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
65702
65703 -- 4955764
65704 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
65705 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
65706
65707 -- 4458381 Public Sector Enh
65708
65709 --
65710 -- set accounting attributes for the line type
65711 --
65712 l_entered_amt_idx := 8;
65713 l_accted_amt_idx := 13;
65714 l_bflow_applied_to_amt_idx := NULL; -- 5132302
65715 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
65716 l_rec_acct_attrs.array_num_value(1) := p_source_58;
65717 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
65718 l_rec_acct_attrs.array_char_value(2) := p_source_35;
65719 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
65720 l_rec_acct_attrs.array_char_value(3) := p_source_59;
65721 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
65722 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
65723 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
65724 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
65725 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
65726 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
65727 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
65728 l_rec_acct_attrs.array_char_value(7) := p_source_23;
65729 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
65730 l_rec_acct_attrs.array_num_value(8) := p_source_24;
65731 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
65732 l_rec_acct_attrs.array_char_value(9) := p_source_25;
65733 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
65734 l_rec_acct_attrs.array_date_value(10) := p_source_26;
65735 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
65736 l_rec_acct_attrs.array_num_value(11) := p_source_27;
65737 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
65738 l_rec_acct_attrs.array_char_value(12) := p_source_28;
65739 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
65740 l_rec_acct_attrs.array_num_value(13) := p_source_69;
65741 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
65742 l_rec_acct_attrs.array_num_value(14) := p_source_63;
65743 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
65744 l_rec_acct_attrs.array_num_value(15) := p_source_64;
65745 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
65746 l_rec_acct_attrs.array_char_value(16) := p_source_65;
65747
65748 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
65749 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
65750
65751 ---------------------------------------------------------------------------------------------------------------
65752 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
65753 ---------------------------------------------------------------------------------------------------------------
65754 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
65755
65756 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
65757 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
65758
65759 IF xla_accounting_cache_pkg.GetValueChar
65760 (p_source_code => 'LEDGER_CATEGORY_CODE'
65761 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
65762 AND l_bflow_method_code = 'PRIOR_ENTRY'
65763 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
65764 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
65765 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
65766 )
65767 THEN
65768 xla_ae_lines_pkg.BflowUpgEntry
65769 (p_business_method_code => l_bflow_method_code
65770 ,p_business_class_code => l_bflow_class_code
65771 ,p_balance_type => l_balance_type_code);
65772 ELSE
65773 NULL;
65774 -- No business flow processing for business flow method of NONE.
65775 END IF;
65776
65777 --
65778 -- call analytical criteria
65779 --
65780
65781 --
65782 -- call description
65783 --
65784 -- No description or it is inherited.
65785 --
65786 -- call ADRs
65787 -- Bug 4922099
65788 --
65789 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
65790 (NVL(l_actual_upg_option, 'N') = 'O') OR
65791 (NVL(l_enc_upg_option, 'N') = 'O')
65792 )
65793 THEN
65794 NULL;
65795 --
65796 --
65797
65798 l_ccid := AcctDerRule_25(
65799 p_application_id => p_application_id
65800 , p_ae_header_id => l_ae_header_id
65801 , p_source_18 => p_source_18
65802 , x_transaction_coa_id => l_adr_transaction_coa_id
65803 , x_accounting_coa_id => l_adr_accounting_coa_id
65804 , x_value_type_code => l_adr_value_type_code
65805 , p_side => 'NA'
65806 );
65807
65808 xla_ae_lines_pkg.set_ccid(
65809 p_code_combination_id => l_ccid
65810 , p_value_type_code => l_adr_value_type_code
65811 , p_transaction_coa_id => l_adr_transaction_coa_id
65812 , p_accounting_coa_id => l_adr_accounting_coa_id
65813 , p_adr_code => 'RMT_BNK_UNID_CCID'
65814 , p_adr_type_code => 'S'
65815 , p_component_type => l_component_type
65816 , p_component_code => l_component_code
65817 , p_component_type_code => l_component_type_code
65818 , p_component_appl_id => l_component_appl_id
65819 , p_amb_context_code => l_amb_context_code
65820 , p_side => 'NA'
65821 );
65822
65823
65824 --
65825 --
65826 END IF;
65827 --
65828 -- Bug 4922099
65829 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
65830 (NVL(l_enc_upg_option, 'N') = 'O')
65831 ) AND
65832 (l_bflow_method_code = 'PRIOR_ENTRY')
65833 )
65834 THEN
65835 IF
65836 --
65837 1 = 2
65838 --
65839 THEN
65840 xla_accounting_err_pkg.build_message
65841 (p_appli_s_name => 'XLA'
65842 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
65843 ,p_token_1 => 'LINE_NUMBER'
65844 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
65845 ,p_token_2 => 'LINE_TYPE_NAME'
65846 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
65847 l_component_type
65848 ,l_component_code
65849 ,l_component_type_code
65850 ,l_component_appl_id
65851 ,l_amb_context_code
65852 ,l_entity_code
65853 ,l_event_class_code
65854 )
65855 ,p_token_3 => 'OWNER'
65856 ,p_value_3 => xla_lookups_pkg.get_meaning(
65857 p_lookup_type => 'XLA_OWNER_TYPE'
65858 ,p_lookup_code => l_component_type_code
65859 )
65860 ,p_token_4 => 'PRODUCT_NAME'
65861 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
65862 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
65863 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
65864 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
65865 ,p_ae_header_id => NULL
65866 );
65867
65868 IF (C_LEVEL_ERROR>= g_log_level) THEN
65869 trace
65870 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
65871 ,p_level => C_LEVEL_ERROR
65872 ,p_module => l_log_module);
65873 END IF;
65874 END IF;
65875 END IF;
65876 --
65877 --
65878 ------------------------------------------------------------------------------------------------
65879 -- 4219869 Business Flow
65880 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
65881 -- Prior Entry. Currently, the following code is always generated.
65882 ------------------------------------------------------------------------------------------------
65883 XLA_AE_LINES_PKG.ValidateCurrentLine;
65884
65885 ------------------------------------------------------------------------------------
65886 -- 4219869 Business Flow
65887 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
65888 ------------------------------------------------------------------------------------
65889 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
65890
65891 ----------------------------------------------------------------------------------
65892 -- 4219869 Business Flow
65893 -- Update journal entry status -- Need to generate this within IF <condition>
65894 ----------------------------------------------------------------------------------
65895 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
65896 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
65897 ,p_balance_type_code => l_balance_type_code
65898 );
65899
65900 -------------------------------------------------------------------------------------------
65901 -- 4262811 - Generate the Accrual Reversal lines
65902 -------------------------------------------------------------------------------------------
65903 BEGIN
65904 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
65905 (g_array_event(p_event_id).array_value_num('header_index'));
65906 IF l_acc_rev_flag IS NULL THEN
65907 l_acc_rev_flag := 'N';
65908 END IF;
65909 EXCEPTION
65910 WHEN OTHERS THEN
65911 l_acc_rev_flag := 'N';
65912 END;
65913 --
65914 IF (l_acc_rev_flag = 'Y') THEN
65915
65916 -- 4645092 ------------------------------------------------------------------------------
65917 -- To allow MPA report to determine if it should generate report process
65918 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
65919 ------------------------------------------------------------------------------------------
65920
65921 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
65922 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
65923 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
65924 -- call ADRs
65925 -- Bug 4922099
65926 --
65927 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
65928 (NVL(l_actual_upg_option, 'N') = 'O') OR
65929 (NVL(l_enc_upg_option, 'N') = 'O')
65930 )
65931 THEN
65932 NULL;
65933 --
65934 --
65935
65936 l_ccid := AcctDerRule_25(
65937 p_application_id => p_application_id
65938 , p_ae_header_id => l_ae_header_id
65939 , p_source_18 => p_source_18
65940 , x_transaction_coa_id => l_adr_transaction_coa_id
65941 , x_accounting_coa_id => l_adr_accounting_coa_id
65942 , x_value_type_code => l_adr_value_type_code
65943 , p_side => 'NA'
65944 );
65945
65946 xla_ae_lines_pkg.set_ccid(
65947 p_code_combination_id => l_ccid
65948 , p_value_type_code => l_adr_value_type_code
65949 , p_transaction_coa_id => l_adr_transaction_coa_id
65950 , p_accounting_coa_id => l_adr_accounting_coa_id
65951 , p_adr_code => 'RMT_BNK_UNID_CCID'
65952 , p_adr_type_code => 'S'
65953 , p_component_type => l_component_type
65954 , p_component_code => l_component_code
65955 , p_component_type_code => l_component_type_code
65956 , p_component_appl_id => l_component_appl_id
65957 , p_amb_context_code => l_amb_context_code
65958 , p_side => 'NA'
65959 );
65960
65961
65962 --
65963 --
65964 END IF;
65965
65966 --
65967 -- Update the line information that should be overwritten
65968 --
65969 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
65970 p_header_num => 1);
65971 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
65972
65973 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
65974
65975 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
65976 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
65977 END IF;
65978
65979 --
65980 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
65981 --
65982 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
65983 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
65984 ELSE
65985 ---------------------------------------------------------------------------------------------------
65986 -- 4262811a Switch Sign
65987 ---------------------------------------------------------------------------------------------------
65988 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
65989 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65990 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65991 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
65992 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65993 -- 5132302
65994 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
65995 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
65996
65997 END IF;
65998
65999 -- 4955764
66000 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
66001 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
66002
66003
66004 XLA_AE_LINES_PKG.ValidateCurrentLine;
66005 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
66006
66007 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
66008 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
66009 ,p_balance_type_code => l_balance_type_code);
66010
66011 END IF;
66012
66013 -----------------------------------------------------------------------------------------
66014 -- 4262811 Multiperiod Accounting
66015 -----------------------------------------------------------------------------------------
66016 -- No MPA option is assigned.
66017
66018
66019 END IF;
66020 END IF;
66021 --
66022
66023 --
66024 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
66025 trace
66026 (p_msg => 'END of AcctLineType_132'
66027 ,p_level => C_LEVEL_PROCEDURE
66028 ,p_module => l_log_module);
66029 END IF;
66030 --
66031 EXCEPTION
66032 WHEN xla_exceptions_pkg.application_exception THEN
66033 RAISE;
66034 WHEN OTHERS THEN
66035 xla_exceptions_pkg.raise_message
66036 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_132');
66037 END AcctLineType_132;
66038 --
66039
66040 ---------------------------------------
66041 --
66042 -- PRIVATE FUNCTION
66043 -- AcctLineType_133
66044 --
66045 ---------------------------------------
66046 PROCEDURE AcctLineType_133 (
66047 p_application_id IN NUMBER
66048 ,p_event_id IN NUMBER
66049 ,p_calculate_acctd_flag IN VARCHAR2
66050 ,p_calculate_g_l_flag IN VARCHAR2
66051 ,p_actual_flag IN OUT VARCHAR2
66052 ,p_balance_type_code OUT VARCHAR2
66053 ,p_gain_or_loss_ref OUT VARCHAR2
66054
66055 --Distribution GL Account
66056 , p_source_5 IN NUMBER
66057 --Distribution Source Type
66058 , p_source_20 IN VARCHAR2
66059 --Receivable Activity Type
66060 , p_source_21 IN VARCHAR2
66061 --Distribution Line Identifier
66062 , p_source_22 IN NUMBER
66063 --Distribution Type
66064 , p_source_23 IN VARCHAR2
66065 --Exchange Date
66066 , p_source_26 IN DATE
66067 --Exchange Rate
66068 , p_source_27 IN NUMBER
66069 --Exchange Rate Type
66070 , p_source_28 IN VARCHAR2
66071 --Transaction Distribution Identifier
66072 , p_source_34 IN NUMBER
66073 --Transaction Distribution Type
66074 , p_source_35 IN VARCHAR2
66075 --Receipt Applied To Application Identifier
66076 , p_source_58 IN NUMBER
66077 --Transaction Entity Code
66078 , p_source_59 IN VARCHAR2
66079 --Transaction Identifier
66080 , p_source_60 IN NUMBER
66081 --Applying Document Currency Code
66082 , p_source_61 IN VARCHAR2
66083 --Distribution Party Identifier
66084 , p_source_63 IN NUMBER
66085 --Distribution Party Site Id
66086 , p_source_64 IN NUMBER
66087 --Distribution Party Type
66088 , p_source_65 IN VARCHAR2
66089 --Distribution Multi Fund Additional Entry
66090 , p_source_67 IN VARCHAR2
66091 --DIST_ENT_AMT_FROM
66092 , p_source_68 IN NUMBER
66093 --Accounting Amount
66094 , p_source_69 IN NUMBER
66095 )
66096 IS
66097
66098 l_component_type VARCHAR2(80);
66099 l_component_code VARCHAR2(30);
66100 l_component_type_code VARCHAR2(1);
66101 l_component_appl_id INTEGER;
66102 l_amb_context_code VARCHAR2(30);
66103 l_entity_code VARCHAR2(30);
66104 l_event_class_code VARCHAR2(30);
66105 l_ae_header_id NUMBER;
66106 l_event_type_code VARCHAR2(30);
66107 l_line_definition_code VARCHAR2(30);
66108 l_line_definition_owner_code VARCHAR2(1);
66109 --
66110 -- adr variables
66111 l_segment VARCHAR2(30);
66112 l_ccid NUMBER;
66113 l_adr_transaction_coa_id NUMBER;
66114 l_adr_accounting_coa_id NUMBER;
66115 l_adr_flexfield_segment_code VARCHAR2(30);
66116 l_adr_flex_value_set_id NUMBER;
66117 l_adr_value_type_code VARCHAR2(30);
66118 l_adr_value_combination_id NUMBER;
66119 l_adr_value_segment_code VARCHAR2(30);
66120
66121 l_bflow_method_code VARCHAR2(30); -- 4219869 Business Flow
66122 l_bflow_class_code VARCHAR2(30); -- 4219869 Business Flow
66123 l_inherit_desc_flag VARCHAR2(1); -- 4219869 Business Flow
66124 l_budgetary_control_flag VARCHAR2(1); -- 4458381 Public Sector Enh
66125
66126 -- 4262811 Variables ------------------------------------------------------------------------------------------
66127 l_entered_amt_idx NUMBER;
66128 l_accted_amt_idx NUMBER;
66129 l_acc_rev_flag VARCHAR2(1);
66130 l_accrual_line_num NUMBER;
66131 l_tmp_amt NUMBER;
66132 l_acc_rev_natural_side_code VARCHAR2(1);
66133
66134 l_num_entries NUMBER;
66135 l_gl_dates xla_ae_journal_entry_pkg.t_array_date;
66136 l_accted_amts xla_ae_journal_entry_pkg.t_array_num;
66137 l_entered_amts xla_ae_journal_entry_pkg.t_array_num;
66138 l_period_names xla_ae_journal_entry_pkg.t_array_V15L;
66139 l_recog_line_1 NUMBER;
66140 l_recog_line_2 NUMBER;
66141
66142 l_bflow_applied_to_amt_idx NUMBER; -- 5132302
66143 l_bflow_applied_to_amt NUMBER; -- 5132302
66144 l_bflow_applied_to_amts xla_ae_journal_entry_pkg.t_array_num; -- 5132302
66145
66146 l_event_id NUMBER; -- To handle MPA header Description: xla_ae_header_pkg.SetHdrDescription
66147
66148 --l_rounding_ccy VARCHAR2(15); -- To handle MPA rounding 4262811b
66149 l_same_currency BOOLEAN; -- To handle MPA rounding 4262811b
66150
66151 ---------------------------------------------------------------------------------------------------------------
66152
66153
66154 --
66155 -- bulk performance
66156 --
66157 l_balance_type_code VARCHAR2(1);
66158 l_rec_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
66159 l_log_module VARCHAR2(240);
66160
66161 --
66162 -- Upgrade strategy
66163 --
66164 l_actual_upg_option VARCHAR2(1);
66165 l_enc_upg_option VARCHAR2(1);
66166
66167 --
66168 BEGIN
66169 --
66170 IF g_log_enabled THEN
66171 l_log_module := C_DEFAULT_MODULE||'.AcctLineType_133';
66172 END IF;
66173 --
66174 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
66175
66176 trace
66177 (p_msg => 'BEGIN of AcctLineType_133'
66178 ,p_level => C_LEVEL_PROCEDURE
66179 ,p_module => l_log_module);
66180
66181 END IF;
66182 --
66183 l_component_type := 'AMB_JLT';
66184 l_component_code := 'RCT_WRITEOFF';
66185 l_component_type_code := 'S';
66186 l_component_appl_id := 222;
66187 l_amb_context_code := 'DEFAULT';
66188 l_entity_code := 'RECEIPTS';
66189 l_event_class_code := 'RECEIPT';
66190 l_event_type_code := 'RECEIPT_ALL';
66191 l_line_definition_owner_code := 'S';
66192 l_line_definition_code := 'AR_RCT_DEFAULT_ACCRUAL';
66193 --
66194 l_balance_type_code := 'A';
66195 l_segment := NULL;
66196 l_ccid := NULL;
66197 l_adr_transaction_coa_id := NULL;
66198 l_adr_accounting_coa_id := NULL;
66199 l_adr_flexfield_segment_code := NULL;
66200 l_adr_flex_value_set_id := NULL;
66201 l_adr_value_type_code := NULL;
66202 l_adr_value_combination_id := NULL;
66203 l_adr_value_segment_code := NULL;
66204
66205 l_bflow_method_code := 'NONE'; -- 4219869 Business Flow
66206 l_bflow_class_code := ''; -- 4219869 Business Flow
66207 l_inherit_desc_flag := 'N'; -- 4219869 Business Flow
66208 l_budgetary_control_flag := 'N';
66209
66210 l_bflow_applied_to_amt_idx := NULL; -- 5132302
66211 l_bflow_applied_to_amt := NULL; -- 5132302
66212 l_entered_amt_idx := NULL; -- 4262811
66213 l_accted_amt_idx := NULL; -- 4262811
66214 l_acc_rev_flag := NULL; -- 4262811
66215 l_accrual_line_num := NULL; -- 4262811
66216 l_tmp_amt := NULL; -- 4262811
66217 --
66218
66219 IF XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id = XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id OR
66220 l_balance_type_code <> 'B' THEN
66221 IF NVL(p_source_20,'
66222 ') = 'ACTIVITY' AND
66223 NVL(p_source_21,'
66224 ') = 'WRITEOFF' AND
66225 NVL(p_source_67,'
66226 ') = 'N'
66227 THEN
66228
66229 --
66230 XLA_AE_LINES_PKG.SetNewLine;
66231
66232 p_balance_type_code := l_balance_type_code;
66233 -- set the flag so later we will know whether the gain loss line needs to be created
66234
66235 IF(l_balance_type_code = 'A' and p_actual_flag is null) THEN
66236 p_actual_flag :='A';
66237 END IF;
66238
66239 --
66240 -- bulk performance
66241 --
66242 XLA_AE_LINES_PKG.set_ae_header_id (p_ae_header_id => p_event_id ,
66243 p_header_num => 0); -- 4262811
66244 --
66245 -- set accounting line options
66246 --
66247 l_ae_header_id:= xla_ae_lines_pkg.SetAcctLineOption(
66248 p_natural_side_code => 'C'
66249 , p_gain_or_loss_flag => 'N'
66250 , p_gl_transfer_mode_code => 'S'
66251 , p_acct_entry_type_code => 'A'
66252 , p_switch_side_flag => 'Y'
66253 , p_merge_duplicate_code => 'A'
66254 );
66255 --
66256 l_acc_rev_natural_side_code := 'D'; -- 4262811
66257 --
66258 --
66259 -- set accounting line type info
66260 --
66261 xla_ae_lines_pkg.SetAcctLineType
66262 (p_component_type => l_component_type
66263 ,p_event_type_code => l_event_type_code
66264 ,p_line_definition_owner_code => l_line_definition_owner_code
66265 ,p_line_definition_code => l_line_definition_code
66266 ,p_accounting_line_code => l_component_code
66267 ,p_accounting_line_type_code => l_component_type_code
66268 ,p_accounting_line_appl_id => l_component_appl_id
66269 ,p_amb_context_code => l_amb_context_code
66270 ,p_entity_code => l_entity_code
66271 ,p_event_class_code => l_event_class_code);
66272 --
66273 -- set accounting class
66274 --
66275 xla_ae_lines_pkg.SetAcctClass(
66276 p_accounting_class_code => 'WRITE_OFF'
66277 , p_ae_header_id => l_ae_header_id
66278 );
66279
66280 --
66281 -- set rounding class
66282 --
66283 XLA_AE_LINES_PKG.g_rec_lines.array_rounding_class(XLA_AE_LINES_PKG.g_LineNumber) :=
66284 'RECEIVABLE';
66285
66286 --
66287 xla_ae_lines_pkg.g_rec_lines.array_calculate_acctd_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_acctd_flag;
66288 xla_ae_lines_pkg.g_rec_lines.array_calculate_g_l_flag(xla_ae_lines_pkg.g_LineNumber) := p_calculate_g_l_flag;
66289 --
66290 -- bulk performance
66291 --
66292 XLA_AE_LINES_PKG.g_rec_lines.array_balance_type_code(XLA_AE_LINES_PKG.g_LineNumber) := l_balance_type_code;
66293
66294 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_id(XLA_AE_LINES_PKG.g_LineNumber) :=
66295 XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id;
66296
66297 -- 4955764
66298 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
66299 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('header_index'));
66300
66301 -- 4458381 Public Sector Enh
66302
66303 --
66304 -- set accounting attributes for the line type
66305 --
66306 l_entered_amt_idx := 8;
66307 l_accted_amt_idx := 13;
66308 l_bflow_applied_to_amt_idx := NULL; -- 5132302
66309 l_rec_acct_attrs.array_acct_attr_code(1) := 'APPLIED_TO_APPLICATION_ID';
66310 l_rec_acct_attrs.array_num_value(1) := p_source_58;
66311 l_rec_acct_attrs.array_acct_attr_code(2) := 'APPLIED_TO_DISTRIBUTION_TYPE';
66312 l_rec_acct_attrs.array_char_value(2) := p_source_35;
66313 l_rec_acct_attrs.array_acct_attr_code(3) := 'APPLIED_TO_ENTITY_CODE';
66314 l_rec_acct_attrs.array_char_value(3) := p_source_59;
66315 l_rec_acct_attrs.array_acct_attr_code(4) := 'APPLIED_TO_FIRST_DIST_ID';
66316 l_rec_acct_attrs.array_num_value(4) := to_char(p_source_34);
66317 l_rec_acct_attrs.array_acct_attr_code(5) := 'APPLIED_TO_FIRST_SYS_TRAN_ID';
66318 l_rec_acct_attrs.array_num_value(5) := to_char(p_source_60);
66319 l_rec_acct_attrs.array_acct_attr_code(6) := 'DISTRIBUTION_IDENTIFIER_1';
66320 l_rec_acct_attrs.array_num_value(6) := to_char(p_source_22);
66321 l_rec_acct_attrs.array_acct_attr_code(7) := 'DISTRIBUTION_TYPE';
66322 l_rec_acct_attrs.array_char_value(7) := p_source_23;
66323 l_rec_acct_attrs.array_acct_attr_code(8) := 'ENTERED_CURRENCY_AMOUNT';
66324 l_rec_acct_attrs.array_num_value(8) := p_source_68;
66325 l_rec_acct_attrs.array_acct_attr_code(9) := 'ENTERED_CURRENCY_CODE';
66326 l_rec_acct_attrs.array_char_value(9) := p_source_61;
66327 l_rec_acct_attrs.array_acct_attr_code(10) := 'EXCHANGE_DATE';
66328 l_rec_acct_attrs.array_date_value(10) := p_source_26;
66329 l_rec_acct_attrs.array_acct_attr_code(11) := 'EXCHANGE_RATE';
66330 l_rec_acct_attrs.array_num_value(11) := p_source_27;
66331 l_rec_acct_attrs.array_acct_attr_code(12) := 'EXCHANGE_RATE_TYPE';
66332 l_rec_acct_attrs.array_char_value(12) := p_source_28;
66333 l_rec_acct_attrs.array_acct_attr_code(13) := 'LEDGER_AMOUNT';
66334 l_rec_acct_attrs.array_num_value(13) := p_source_69;
66335 l_rec_acct_attrs.array_acct_attr_code(14) := 'PARTY_ID';
66336 l_rec_acct_attrs.array_num_value(14) := p_source_63;
66337 l_rec_acct_attrs.array_acct_attr_code(15) := 'PARTY_SITE_ID';
66338 l_rec_acct_attrs.array_num_value(15) := p_source_64;
66339 l_rec_acct_attrs.array_acct_attr_code(16) := 'PARTY_TYPE';
66340 l_rec_acct_attrs.array_char_value(16) := p_source_65;
66341
66342 XLA_AE_LINES_PKG.SetLineAcctAttrs(l_rec_acct_attrs);
66343 p_gain_or_loss_ref := XLA_AE_LINES_PKG.g_rec_lines.array_gain_or_loss_ref(XLA_AE_LINES_PKG.g_LineNumber);
66344
66345 ---------------------------------------------------------------------------------------------------------------
66346 -- 4336173 -- assign Business Flow Class (replace code in xla_ae_lines_pkg.Business_Flow_Validation)
66347 ---------------------------------------------------------------------------------------------------------------
66348 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := l_bflow_class_code;
66349
66350 l_actual_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_actual_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
66351 l_enc_upg_option := XLA_AE_LINES_PKG.g_rec_lines.array_enc_upg_option(XLA_AE_LINES_PKG.g_LineNumber);
66352
66353 IF xla_accounting_cache_pkg.GetValueChar
66354 (p_source_code => 'LEDGER_CATEGORY_CODE'
66355 ,p_target_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id) IN ('PRIMARY','ALC')
66356 AND l_bflow_method_code = 'PRIOR_ENTRY'
66357 -- AND (l_actual_upg_option = 'Y' OR l_enc_upg_option = 'Y') Bug 4922099
66358 AND ( (NVL(l_actual_upg_option, 'N') IN ('Y', 'O')) OR
66359 (NVL(l_enc_upg_option, 'N') IN ('Y', 'O'))
66360 )
66361 THEN
66362 xla_ae_lines_pkg.BflowUpgEntry
66363 (p_business_method_code => l_bflow_method_code
66364 ,p_business_class_code => l_bflow_class_code
66365 ,p_balance_type => l_balance_type_code);
66366 ELSE
66367 NULL;
66368 -- No business flow processing for business flow method of NONE.
66369 END IF;
66370
66371 --
66372 -- call analytical criteria
66373 --
66374
66375 --
66376 -- call description
66377 --
66378 -- No description or it is inherited.
66379 --
66380 -- call ADRs
66381 -- Bug 4922099
66382 --
66383 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
66384 (NVL(l_actual_upg_option, 'N') = 'O') OR
66385 (NVL(l_enc_upg_option, 'N') = 'O')
66386 )
66387 THEN
66388 NULL;
66389 --
66390 --
66391
66392 l_ccid := AcctDerRule_4(
66393 p_application_id => p_application_id
66394 , p_ae_header_id => l_ae_header_id
66395 , p_source_5 => p_source_5
66396 , x_transaction_coa_id => l_adr_transaction_coa_id
66397 , x_accounting_coa_id => l_adr_accounting_coa_id
66398 , x_value_type_code => l_adr_value_type_code
66399 , p_side => 'NA'
66400 );
66401
66402 xla_ae_lines_pkg.set_ccid(
66403 p_code_combination_id => l_ccid
66404 , p_value_type_code => l_adr_value_type_code
66405 , p_transaction_coa_id => l_adr_transaction_coa_id
66406 , p_accounting_coa_id => l_adr_accounting_coa_id
66407 , p_adr_code => 'DIST_CCID'
66408 , p_adr_type_code => 'S'
66409 , p_component_type => l_component_type
66410 , p_component_code => l_component_code
66411 , p_component_type_code => l_component_type_code
66412 , p_component_appl_id => l_component_appl_id
66413 , p_amb_context_code => l_amb_context_code
66414 , p_side => 'NA'
66415 );
66416
66417
66418 --
66419 --
66420 END IF;
66421 --
66422 -- Bug 4922099
66423 IF ( ( (NVL(l_actual_upg_option, 'N') = 'O') OR
66424 (NVL(l_enc_upg_option, 'N') = 'O')
66425 ) AND
66426 (l_bflow_method_code = 'PRIOR_ENTRY')
66427 )
66428 THEN
66429 IF
66430 --
66431 1 = 2
66432 --
66433 THEN
66434 xla_accounting_err_pkg.build_message
66435 (p_appli_s_name => 'XLA'
66436 ,p_msg_name => 'XLA_UPG_OVERRIDE_ADR_UNDEFINED'
66437 ,p_token_1 => 'LINE_NUMBER'
66438 ,p_value_1 => XLA_AE_LINES_PKG.g_LineNumber
66439 ,p_token_2 => 'LINE_TYPE_NAME'
66440 ,p_value_2 => XLA_AE_SOURCES_PKG.GetComponentName (
66441 l_component_type
66442 ,l_component_code
66443 ,l_component_type_code
66444 ,l_component_appl_id
66445 ,l_amb_context_code
66446 ,l_entity_code
66447 ,l_event_class_code
66448 )
66449 ,p_token_3 => 'OWNER'
66450 ,p_value_3 => xla_lookups_pkg.get_meaning(
66451 p_lookup_type => 'XLA_OWNER_TYPE'
66452 ,p_lookup_code => l_component_type_code
66453 )
66454 ,p_token_4 => 'PRODUCT_NAME'
66455 ,p_value_4 => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.application_name
66456 ,p_entity_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
66457 ,p_event_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
66458 ,p_ledger_id => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id
66459 ,p_ae_header_id => NULL
66460 );
66461
66462 IF (C_LEVEL_ERROR>= g_log_level) THEN
66463 trace
66464 (p_msg => 'ERROR: XLA_UPG_OVERRIDE_ADR_UNDEFINED'
66465 ,p_level => C_LEVEL_ERROR
66466 ,p_module => l_log_module);
66467 END IF;
66468 END IF;
66469 END IF;
66470 --
66471 --
66472 ------------------------------------------------------------------------------------------------
66473 -- 4219869 Business Flow
66474 -- NOTE: XLA_AE_LINES_PKG.ValidateCurrentLine should NOT be generated if business flow method is
66475 -- Prior Entry. Currently, the following code is always generated.
66476 ------------------------------------------------------------------------------------------------
66477 XLA_AE_LINES_PKG.ValidateCurrentLine;
66478
66479 ------------------------------------------------------------------------------------
66480 -- 4219869 Business Flow
66481 -- Populated credit and debit amounts -- Need to generate this within IF <condition>
66482 ------------------------------------------------------------------------------------
66483 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
66484
66485 ----------------------------------------------------------------------------------
66486 -- 4219869 Business Flow
66487 -- Update journal entry status -- Need to generate this within IF <condition>
66488 ----------------------------------------------------------------------------------
66489 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
66490 (p_hdr_idx => g_array_event(p_event_id).array_value_num('header_index')
66491 ,p_balance_type_code => l_balance_type_code
66492 );
66493
66494 -------------------------------------------------------------------------------------------
66495 -- 4262811 - Generate the Accrual Reversal lines
66496 -------------------------------------------------------------------------------------------
66497 BEGIN
66498 l_acc_rev_flag := XLA_AE_HEADER_PKG.g_rec_header_new.array_accrual_reversal_flag
66499 (g_array_event(p_event_id).array_value_num('header_index'));
66500 IF l_acc_rev_flag IS NULL THEN
66501 l_acc_rev_flag := 'N';
66502 END IF;
66503 EXCEPTION
66504 WHEN OTHERS THEN
66505 l_acc_rev_flag := 'N';
66506 END;
66507 --
66508 IF (l_acc_rev_flag = 'Y') THEN
66509
66510 -- 4645092 ------------------------------------------------------------------------------
66511 -- To allow MPA report to determine if it should generate report process
66512 XLA_ACCOUNTING_PKG.g_mpa_accrual_exists := 'Y';
66516 XLA_AE_LINES_PKG.CopyLineInfo(l_accrual_line_num);
66513 ------------------------------------------------------------------------------------------
66514
66515 l_accrual_line_num := XLA_AE_LINES_PKG.g_LineNumber;
66517 -- added call to set_ccid to execute mapping for secondary accrual reversal entries bug 7444204
66518 -- call ADRs
66519 -- Bug 4922099
66520 --
66521 IF ( (l_bflow_method_code <> 'PRIOR_ENTRY') OR
66522 (NVL(l_actual_upg_option, 'N') = 'O') OR
66523 (NVL(l_enc_upg_option, 'N') = 'O')
66524 )
66525 THEN
66526 NULL;
66527 --
66528 --
66529
66530 l_ccid := AcctDerRule_4(
66531 p_application_id => p_application_id
66532 , p_ae_header_id => l_ae_header_id
66533 , p_source_5 => p_source_5
66534 , x_transaction_coa_id => l_adr_transaction_coa_id
66535 , x_accounting_coa_id => l_adr_accounting_coa_id
66536 , x_value_type_code => l_adr_value_type_code
66537 , p_side => 'NA'
66538 );
66539
66540 xla_ae_lines_pkg.set_ccid(
66541 p_code_combination_id => l_ccid
66542 , p_value_type_code => l_adr_value_type_code
66543 , p_transaction_coa_id => l_adr_transaction_coa_id
66544 , p_accounting_coa_id => l_adr_accounting_coa_id
66545 , p_adr_code => 'DIST_CCID'
66546 , p_adr_type_code => 'S'
66547 , p_component_type => l_component_type
66548 , p_component_code => l_component_code
66549 , p_component_type_code => l_component_type_code
66550 , p_component_appl_id => l_component_appl_id
66551 , p_amb_context_code => l_amb_context_code
66552 , p_side => 'NA'
66553 );
66554
66555
66556 --
66557 --
66558 END IF;
66559
66560 --
66561 -- Update the line information that should be overwritten
66562 --
66563 XLA_AE_LINES_PKG.set_ae_header_id(p_ae_header_id => p_event_id ,
66564 p_header_num => 1);
66565 XLA_AE_LINES_PKG.g_rec_lines.array_header_num(XLA_AE_LINES_PKG.g_LineNumber) :=1;
66566
66567 XLA_AE_LINES_PKG.g_rec_lines.array_business_class_code(XLA_AE_LINES_PKG.g_LineNumber) := NULL; -- 4669271
66568
66569 IF l_bflow_method_code <> 'NONE' THEN -- 4655713b
66570 XLA_AE_LINES_PKG.g_rec_lines.array_reversal_code(XLA_AE_LINES_PKG.g_LineNumber) := CONCAT('MPA_',l_bflow_method_code);
66571 END IF;
66572
66573 --
66574 -- Depending on the Reversal Method setup, do a switch side or changes sign for the amounts
66575 --
66576 IF (XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_reversal_option = 'SIDE') THEN
66577 XLA_AE_LINES_PKG.g_rec_lines.array_natural_side_code(XLA_AE_LINES_PKG.g_LineNumber) := l_acc_rev_natural_side_code;
66578 ELSE
66579 ---------------------------------------------------------------------------------------------------
66580 -- 4262811a Switch Sign
66581 ---------------------------------------------------------------------------------------------------
66582 XLA_AE_LINES_PKG.g_rec_lines.array_switch_side_flag(XLA_AE_LINES_PKG.g_LineNumber) := 'N'; -- 5052518
66583 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
66584 XLA_AE_LINES_PKG.g_rec_lines.array_ledger_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66585 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) :=
66586 XLA_AE_LINES_PKG.g_rec_lines.array_entered_amount(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66587 -- 5132302
66588 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) :=
66589 XLA_AE_LINES_PKG.g_rec_lines.array_bflow_applied_to_amt(XLA_AE_LINES_PKG.g_LineNumber) * -1;
66590
66591 END IF;
66592
66593 -- 4955764
66594 XLA_AE_LINES_PKG.g_rec_lines.array_gl_date(XLA_AE_LINES_PKG.g_LineNumber) :=
66595 XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(g_array_event(p_event_id).array_value_num('acc_rev_header_index'));
66596
66597
66598 XLA_AE_LINES_PKG.ValidateCurrentLine;
66599 XLA_AE_LINES_PKG.SetDebitCreditAmounts;
66600
66601 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus
66602 (p_hdr_idx => g_array_event(p_event_id).array_value_num('acc_rev_header_index')
66603 ,p_balance_type_code => l_balance_type_code);
66604
66605 END IF;
66606
66607 -----------------------------------------------------------------------------------------
66608 -- 4262811 Multiperiod Accounting
66609 -----------------------------------------------------------------------------------------
66610 -- No MPA option is assigned.
66611
66612
66613 END IF;
66614 END IF;
66615 --
66616
66617 --
66618 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
66619 trace
66620 (p_msg => 'END of AcctLineType_133'
66621 ,p_level => C_LEVEL_PROCEDURE
66622 ,p_module => l_log_module);
66623 END IF;
66624 --
66625 EXCEPTION
66626 WHEN xla_exceptions_pkg.application_exception THEN
66627 RAISE;
66628 WHEN OTHERS THEN
66629 xla_exceptions_pkg.raise_message
66630 (p_location => 'XLA_00222_AAD_S_000005_PKG.AcctLineType_133');
66631 END AcctLineType_133;
66632 --
66633
66634 ---------------------------------------
66635 --
66636 -- PRIVATE PROCEDURE
66637 -- insert_sources_134
66638 --
66639 ----------------------------------------
66640 --
66641 PROCEDURE insert_sources_134(
66642 p_target_ledger_id IN NUMBER
66643 , p_language IN VARCHAR2
66644 , p_sla_ledger_id IN NUMBER
66645 , p_pad_start_date IN DATE
66646 , p_pad_end_date IN DATE
66647 )
66648 IS
66649
66650 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT_ALL';
66651 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT';
66652 p_apps_owner VARCHAR2(30);
66653 l_log_module VARCHAR2(240);
66654 BEGIN
66655 IF g_log_enabled THEN
66656 l_log_module := C_DEFAULT_MODULE||'.insert_sources_134';
66657 END IF;
66658 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
66659
66660 trace
66661 (p_msg => 'BEGIN of insert_sources_134'
66662 ,p_level => C_LEVEL_PROCEDURE
66663 ,p_module => l_log_module);
66664
66665 END IF;
66666
66667 -- select APPS owner
66668 SELECT oracle_username
66669 INTO p_apps_owner
66670 FROM fnd_oracle_userid
66671 WHERE read_only_flag = 'U'
66672 ;
66673
66674 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
66675 trace
66676 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
66677 ' - p_language = '||p_language||
66678 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
66679 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
66680 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
66681 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
66682 ,p_level => C_LEVEL_STATEMENT
66683 ,p_module => l_log_module);
66684 END IF;
66685
66686
66687 --
66688 INSERT INTO xla_diag_sources --hdr2
66689 (
66690 event_id
66691 , ledger_id
66692 , sla_ledger_id
66693 , description_language
66694 , object_name
66695 , object_type_code
66696 , line_number
66697 , source_application_id
66698 , source_type_code
66699 , source_code
66700 , source_value
66701 , source_meaning
66702 , created_by
66703 , creation_date
66704 , last_update_date
66705 , last_updated_by
66706 , last_update_login
66707 , program_update_date
66708 , program_application_id
66709 , program_id
66710 , request_id
66711 )
66712 SELECT
66713 event_id
66714 , p_target_ledger_id
66715 , p_sla_ledger_id
66716 , p_language
66717 , object_name
66718 , object_type_code
66719 , line_number
66720 , source_application_id
66721 , source_type_code
66722 , source_code
66723 , SUBSTR(source_value ,1,1996)
66724 , SUBSTR(source_meaning ,1,200)
66725 , xla_environment_pkg.g_Usr_Id
66726 , TRUNC(SYSDATE)
66727 , TRUNC(SYSDATE)
66728 , xla_environment_pkg.g_Usr_Id
66729 , xla_environment_pkg.g_Login_Id
66730 , TRUNC(SYSDATE)
66731 , xla_environment_pkg.g_Prog_Appl_Id
66732 , xla_environment_pkg.g_Prog_Id
66733 , xla_environment_pkg.g_Req_Id
66734 FROM (
66735 SELECT xet.event_id event_id
66736 , 0 line_number
66737 , CASE r
66738 WHEN 1 THEN 'AR_RECEIVABLES_TRX_ACT_S_V'
66742 WHEN 5 THEN 'AR_ADJUSTMENTS_H_V'
66739 WHEN 2 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
66740 WHEN 3 THEN 'AR_BILL_TO_SITE_USES_S_V'
66741 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
66743 WHEN 6 THEN 'AR_ADJUSTMENTS_H_V'
66744 WHEN 7 THEN 'AR_ADJUSTMENTS_H_V'
66745
66746 ELSE null
66747 END object_name
66748 , CASE r
66749 WHEN 1 THEN 'HEADER'
66750 WHEN 2 THEN 'HEADER'
66751 WHEN 3 THEN 'HEADER'
66752 WHEN 4 THEN 'HEADER'
66753 WHEN 5 THEN 'HEADER'
66754 WHEN 6 THEN 'HEADER'
66755 WHEN 7 THEN 'HEADER'
66756
66757 ELSE null
66758 END object_type_code
66759 , CASE r
66760 WHEN 1 THEN '222'
66761 WHEN 2 THEN '222'
66762 WHEN 3 THEN '222'
66763 WHEN 4 THEN '222'
66764 WHEN 5 THEN '222'
66765 WHEN 6 THEN '222'
66766 WHEN 7 THEN '222'
66767
66768 ELSE null
66769 END source_application_id
66770 , 'S' source_type_code
66771 , CASE r
66772 WHEN 1 THEN 'REC_ACT_TYPE'
66773 WHEN 2 THEN 'BILL_CUST_ACCOUNT_ID'
66774 WHEN 3 THEN 'BILL_USES_SITE_USE_ID'
66775 WHEN 4 THEN 'XLA_PARTY_TYPE'
66776 WHEN 5 THEN 'ADJ_DOC_SEQUENCE_CATEGORY'
66777 WHEN 6 THEN 'ADJ_DOC_SEQUENCE_ID'
66778 WHEN 7 THEN 'ADJ_DOC_SEQUENCE_VALUE'
66779
66780 ELSE null
66781 END source_code
66782 , CASE r
66783 WHEN 1 THEN TO_CHAR(h6.REC_ACT_TYPE)
66784 WHEN 2 THEN TO_CHAR(h2.BILL_CUST_ACCOUNT_ID)
66785 WHEN 3 THEN TO_CHAR(h3.BILL_USES_SITE_USE_ID)
66786 WHEN 4 THEN TO_CHAR(h7.XLA_PARTY_TYPE)
66787 WHEN 5 THEN TO_CHAR(h1.ADJ_DOC_SEQUENCE_CATEGORY)
66788 WHEN 6 THEN TO_CHAR(h1.ADJ_DOC_SEQUENCE_ID)
66789 WHEN 7 THEN TO_CHAR(h1.ADJ_DOC_SEQUENCE_VALUE)
66790
66791 ELSE null
66792 END source_value
66793 , null source_meaning
66794 FROM xla_events_gt xet
66795 , AR_ADJUSTMENTS_H_V h1
66796 , AR_BILL_TO_CUSTOMERS_S_V h2
66797 , AR_BILL_TO_SITE_USES_S_V h3
66798 , AR_RECEIVABLES_TRX_ACT_S_V h6
66799 , AR_TRANSACTIONS_S_V h7
66800 ,(select rownum r from all_objects where rownum <= 7 and owner = p_apps_owner)
66801 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
66802 AND xet.event_class_code = C_EVENT_CLASS_CODE
66803 AND h1.event_id = xet.event_id
66804 AND h2.event_id = h1.event_id
66805 AND h3.event_id = h1.event_id
66806 AND h6.event_id (+) = h1.event_id
66807 AND h7.event_id = h1.event_id
66808
66809 )
66810 ;
66811 --
66812 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
66813
66814 trace
66815 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
66816 ,p_level => C_LEVEL_STATEMENT
66817 ,p_module => l_log_module);
66818
66819 END IF;
66820 --
66821
66822
66823
66824 --
66825 INSERT INTO xla_diag_sources --line2
66826 (
66827 event_id
66828 , ledger_id
66829 , sla_ledger_id
66830 , description_language
66831 , object_name
66832 , object_type_code
66833 , line_number
66834 , source_application_id
66835 , source_type_code
66836 , source_code
66837 , source_value
66838 , source_meaning
66839 , created_by
66840 , creation_date
66841 , last_update_date
66842 , last_updated_by
66843 , last_update_login
66844 , program_update_date
66845 , program_application_id
66846 , program_id
66847 , request_id
66848 )
66849 SELECT event_id
66850 , p_target_ledger_id
66851 , p_sla_ledger_id
66852 , p_language
66853 , object_name
66854 , object_type_code
66855 , line_number
66856 , source_application_id
66857 , source_type_code
66858 , source_code
66859 , SUBSTR(source_value,1,1996)
66860 , SUBSTR(source_meaning ,1,200)
66861 , xla_environment_pkg.g_Usr_Id
66862 , TRUNC(SYSDATE)
66863 , TRUNC(SYSDATE)
66864 , xla_environment_pkg.g_Usr_Id
66865 , xla_environment_pkg.g_Login_Id
66866 , TRUNC(SYSDATE)
66867 , xla_environment_pkg.g_Prog_Appl_Id
66868 , xla_environment_pkg.g_Prog_Id
66869 , xla_environment_pkg.g_Req_Id
66870 FROM (
66871 SELECT xet.event_id event_id
66872 , l5.line_number line_number
66873 , CASE r
66874 WHEN 1 THEN 'AR_DISTRIBUTIONS_L_V'
66875 WHEN 2 THEN 'AR_DISTRIBUTIONS_L_V'
66876 WHEN 3 THEN 'AR_DISTRIBUTIONS_L_V'
66877 WHEN 4 THEN 'AR_DISTRIBUTIONS_L_V'
66878 WHEN 5 THEN 'AR_DISTRIBUTIONS_L_V'
66879 WHEN 6 THEN 'AR_DISTRIBUTIONS_L_V'
66880 WHEN 7 THEN 'AR_DISTRIBUTIONS_BASE_V'
66881 WHEN 8 THEN 'AR_DISTRIBUTIONS_BASE_V'
66882 WHEN 9 THEN 'AR_DISTRIBUTIONS_BASE_V'
66883 WHEN 10 THEN 'AR_DISTRIBUTIONS_BASE_V'
66884
66885 ELSE null
66886 END object_name
66887 , CASE r
66888 WHEN 1 THEN 'LINE'
66889 WHEN 2 THEN 'LINE'
66890 WHEN 3 THEN 'LINE'
66891 WHEN 4 THEN 'LINE'
66892 WHEN 5 THEN 'LINE'
66893 WHEN 6 THEN 'LINE'
66894 WHEN 7 THEN 'LINE'
66895 WHEN 8 THEN 'LINE'
66896 WHEN 9 THEN 'LINE'
66897 WHEN 10 THEN 'LINE'
66898
66899 ELSE null
66900 END object_type_code
66901 , CASE r
66902 WHEN 1 THEN '222'
66903 WHEN 2 THEN '222'
66904 WHEN 3 THEN '222'
66905 WHEN 4 THEN '222'
66906 WHEN 5 THEN '222'
66907 WHEN 6 THEN '222'
66908 WHEN 7 THEN '222'
66909 WHEN 8 THEN '222'
66910 WHEN 9 THEN '222'
66911 WHEN 10 THEN '222'
66912
66913 ELSE null
66914 END source_application_id
66915 , 'S' source_type_code
66916 , CASE r
66917 WHEN 1 THEN 'DIST_CODE_COMBINATION_ID'
66918 WHEN 2 THEN 'DIST_SOURCE_TYPE'
66919 WHEN 3 THEN 'DIST_LINE_ID'
66920 WHEN 4 THEN 'DISTRIBUTION_TYPE'
66921 WHEN 5 THEN 'DIST_ENT_AMT'
66922 WHEN 6 THEN 'DIST_CURRENCY_CODE'
66923 WHEN 7 THEN 'DIST_CUR_CONVERSION_DATE'
66924 WHEN 8 THEN 'DIST_CUR_CONVERSION_RATE'
66925 WHEN 9 THEN 'DIST_CUR_CONVERSION_TYPE'
66926 WHEN 10 THEN 'DIST_TO_ACCTD_AMT'
66927
66928 ELSE null
66929 END source_code
66930 , CASE r
66931 WHEN 1 THEN TO_CHAR(l5.DIST_CODE_COMBINATION_ID)
66932 WHEN 2 THEN TO_CHAR(l5.DIST_SOURCE_TYPE)
66933 WHEN 3 THEN TO_CHAR(l5.DIST_LINE_ID)
66934 WHEN 4 THEN TO_CHAR(l5.DISTRIBUTION_TYPE)
66935 WHEN 5 THEN TO_CHAR(l5.DIST_ENT_AMT)
66936 WHEN 6 THEN TO_CHAR(l5.DIST_CURRENCY_CODE)
66937 WHEN 7 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_DATE)
66938 WHEN 8 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_RATE)
66939 WHEN 9 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_TYPE)
66940 WHEN 10 THEN TO_CHAR(l4.DIST_TO_ACCTD_AMT)
66941
66942 ELSE null
66943 END source_value
66944 , null source_meaning
66945 FROM xla_events_gt xet
66946 , AR_DISTRIBUTIONS_BASE_V l4
66947 , AR_DISTRIBUTIONS_L_V l5
66948 , (select rownum r from all_objects where rownum <= 10 and owner = p_apps_owner)
66949 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
66950 AND xet.event_class_code = C_EVENT_CLASS_CODE
66951 AND l4.event_id = xet.event_id
66952 AND l5.event_id = l4.event_id
66953 AND l5.line_number = l4.line_number
66954
66955 )
66956 ;
66957 --
66958 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
66959
66960 trace
66961 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
66962 ,p_level => C_LEVEL_STATEMENT
66963 ,p_module => l_log_module);
66964
66965 END IF;
66966
66967
66968 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
66969 trace
66970 (p_msg => 'END of insert_sources_134'
66971 ,p_level => C_LEVEL_PROCEDURE
66972 ,p_module => l_log_module);
66973 END IF;
66974 EXCEPTION
66975 WHEN xla_exceptions_pkg.application_exception THEN
66976 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
66977 trace
66978 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
66979 ,p_level => C_LEVEL_EXCEPTION
66980 ,p_module => l_log_module);
66981 END IF;
66982 RAISE;
66983 WHEN OTHERS THEN
66984 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
66985 trace
66986 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
66987 ,p_level => C_LEVEL_EXCEPTION
66988 ,p_module => l_log_module);
66989 END IF;
66990 xla_exceptions_pkg.raise_message
66991 (p_location => 'XLA_00222_AAD_S_000005_PKG.insert_sources_134');
66992 END insert_sources_134;
66993 --
66994
66995 ---------------------------------------
66996 --
66997 -- PRIVATE FUNCTION
66998 -- EventClass_134
66999 --
67000 ----------------------------------------
67001 --
67002 FUNCTION EventClass_134
67003 (p_application_id IN NUMBER
67004 ,p_base_ledger_id IN NUMBER
67005 ,p_target_ledger_id IN NUMBER
67006 ,p_language IN VARCHAR2
67007 ,p_currency_code IN VARCHAR2
67008 ,p_sla_ledger_id IN NUMBER
67009 ,p_pad_start_date IN DATE
67010 ,p_pad_end_date IN DATE
67011 ,p_primary_ledger_id IN NUMBER)
67012 RETURN BOOLEAN IS
67013 --
67014 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT_ALL';
67015 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'ADJUSTMENT';
67016
67017 l_calculate_acctd_flag VARCHAR2(1) :='N';
67018 l_calculate_g_l_flag VARCHAR2(1) :='Y';
67019 --
67020 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67021 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67022 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
67023 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
67024 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67025 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
67026 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
67027 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67028 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
67029 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
67030 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67031 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67032 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67033 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
67034 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
67035 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
67036 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
67037 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
67038 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
67039 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
67040 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
67041 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
67042 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
67043 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
67044 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
67045 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
67046
67047 l_event_id NUMBER;
67048 l_previous_event_id NUMBER;
67049 l_first_event_id NUMBER;
67050 l_last_event_id NUMBER;
67051
67052 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
67053 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
67054 --
67055 --
67056 l_result BOOLEAN := TRUE;
67057 l_rows NUMBER := 1000;
67058 l_event_type_name VARCHAR2(80) := 'All';
67059 l_event_class_name VARCHAR2(80) := 'Adjustment';
67060 l_description VARCHAR2(4000);
67061 l_transaction_reversal NUMBER;
67062 l_ae_header_id NUMBER;
67063 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
67064 l_log_module VARCHAR2(240);
67065 --
67066 l_acct_reversal_source VARCHAR2(30);
67067 l_trx_reversal_source VARCHAR2(30);
67068
67069 l_continue_with_lines BOOLEAN := TRUE;
67070 --
67071 l_acc_rev_gl_date_source DATE; -- 4262811
67072 --
67073 type t_array_event_id is table of number index by binary_integer;
67074
67075 l_rec_array_event t_rec_array_event;
67076 l_null_rec_array_event t_rec_array_event;
67077 l_array_ae_header_id xla_number_array_type;
67078 l_actual_flag VARCHAR2(1) := NULL;
67079 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
67080 l_balance_type_code VARCHAR2(1) :=NULL;
67081 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
67082
67083 --
67084 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
67085 --
67086
67087 TYPE t_array_source_21 IS TABLE OF AR_RECEIVABLES_TRX_ACT_S_V.REC_ACT_TYPE%TYPE INDEX BY BINARY_INTEGER;
67088 TYPE t_array_source_30 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
67089 TYPE t_array_source_31 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
67090 TYPE t_array_source_32 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
67091 TYPE t_array_source_77 IS TABLE OF AR_ADJUSTMENTS_H_V.ADJ_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
67092 TYPE t_array_source_78 IS TABLE OF AR_ADJUSTMENTS_H_V.ADJ_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
67093 TYPE t_array_source_79 IS TABLE OF AR_ADJUSTMENTS_H_V.ADJ_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
67094
67098 TYPE t_array_source_23 IS TABLE OF AR_DISTRIBUTIONS_L_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
67095 TYPE t_array_source_5 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
67096 TYPE t_array_source_20 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
67097 TYPE t_array_source_22 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
67099 TYPE t_array_source_24 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
67100 TYPE t_array_source_25 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
67101 TYPE t_array_source_26 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
67102 TYPE t_array_source_27 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
67103 TYPE t_array_source_28 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
67104 TYPE t_array_source_29 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
67105
67106 l_array_source_21 t_array_source_21;
67107 l_array_source_30 t_array_source_30;
67108 l_array_source_31 t_array_source_31;
67109 l_array_source_32 t_array_source_32;
67110 l_array_source_77 t_array_source_77;
67111 l_array_source_78 t_array_source_78;
67112 l_array_source_79 t_array_source_79;
67113
67114 l_array_source_5 t_array_source_5;
67115 l_array_source_20 t_array_source_20;
67116 l_array_source_22 t_array_source_22;
67117 l_array_source_23 t_array_source_23;
67118 l_array_source_24 t_array_source_24;
67119 l_array_source_25 t_array_source_25;
67120 l_array_source_26 t_array_source_26;
67121 l_array_source_27 t_array_source_27;
67122 l_array_source_28 t_array_source_28;
67123 l_array_source_29 t_array_source_29;
67124
67125 --
67126 CURSOR header_cur
67127 IS
67128 SELECT /*+ leading(xet) cardinality(xet,1) */
67129 -- Event Class Code: ADJUSTMENT
67130 xet.entity_id
67131 ,xet.legal_entity_id
67132 ,xet.entity_code
67133 ,xet.transaction_number
67134 ,xet.event_id
67135 ,xet.event_class_code
67136 ,xet.event_type_code
67137 ,xet.event_number
67138 ,xet.event_date
67139 ,xet.transaction_date
67140 ,xet.reference_num_1
67141 ,xet.reference_num_2
67142 ,xet.reference_num_3
67143 ,xet.reference_num_4
67144 ,xet.reference_char_1
67145 ,xet.reference_char_2
67146 ,xet.reference_char_3
67147 ,xet.reference_char_4
67148 ,xet.reference_date_1
67149 ,xet.reference_date_2
67150 ,xet.reference_date_3
67151 ,xet.reference_date_4
67152 ,xet.event_created_by
67153 ,xet.budgetary_control_flag
67154 , h6.REC_ACT_TYPE source_21
67155 , h2.BILL_CUST_ACCOUNT_ID source_30
67156 , h3.BILL_USES_SITE_USE_ID source_31
67157 , h7.XLA_PARTY_TYPE source_32
67158 , h1.ADJ_DOC_SEQUENCE_CATEGORY source_77
67159 , h1.ADJ_DOC_SEQUENCE_ID source_78
67160 , h1.ADJ_DOC_SEQUENCE_VALUE source_79
67161 FROM xla_events_gt xet
67162 , AR_ADJUSTMENTS_H_V h1
67163 , AR_BILL_TO_CUSTOMERS_S_V h2
67164 , AR_BILL_TO_SITE_USES_S_V h3
67165 , AR_RECEIVABLES_TRX_ACT_S_V h6
67166 , AR_TRANSACTIONS_S_V h7
67167 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
67168 and xet.event_class_code = C_EVENT_CLASS_CODE
67169 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
67170 AND h2.event_id = h1.event_id
67171 AND h3.event_id = h1.event_id
67172 AND h6.event_id (+) = h1.event_id
67173 AND h7.event_id = h1.event_id
67174
67175 ORDER BY event_id
67176 ;
67177
67178
67179 --
67180 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
67181 IS
67182 SELECT /*+ leading(xet) cardinality(xet,1) */
67183 -- Event Class Code: ADJUSTMENT
67184 xet.entity_id
67185 ,xet.legal_entity_id
67186 ,xet.entity_code
67187 ,xet.transaction_number
67188 ,xet.event_id
67189 ,xet.event_class_code
67190 ,xet.event_type_code
67191 ,xet.event_number
67192 ,xet.event_date
67193 ,xet.transaction_date
67194 ,xet.reference_num_1
67195 ,xet.reference_num_2
67196 ,xet.reference_num_3
67197 ,xet.reference_num_4
67198 ,xet.reference_char_1
67199 ,xet.reference_char_2
67200 ,xet.reference_char_3
67201 ,xet.reference_char_4
67202 ,xet.reference_date_1
67203 ,xet.reference_date_2
67204 ,xet.reference_date_3
67205 ,xet.reference_date_4
67206 ,xet.event_created_by
67207 ,xet.budgetary_control_flag
67208 , l4.LINE_NUMBER
67209 , l5.DIST_CODE_COMBINATION_ID source_5
67210 , l5.DIST_SOURCE_TYPE source_20
67211 , l5.DIST_LINE_ID source_22
67212 , l5.DISTRIBUTION_TYPE source_23
67213 , l5.DIST_ENT_AMT source_24
67214 , l5.DIST_CURRENCY_CODE source_25
67215 , l4.DIST_CUR_CONVERSION_DATE source_26
67216 , l4.DIST_CUR_CONVERSION_RATE source_27
67217 , l4.DIST_CUR_CONVERSION_TYPE source_28
67218 , l4.DIST_TO_ACCTD_AMT source_29
67219 FROM xla_events_gt xet
67220 , AR_DISTRIBUTIONS_BASE_V l4
67221 , AR_DISTRIBUTIONS_L_V l5
67222 WHERE xet.event_id between x_first_event_id and x_last_event_id
67223 and xet.event_date between p_pad_start_date and p_pad_end_date
67224 and xet.event_class_code = C_EVENT_CLASS_CODE
67225 and xet.event_status_code <> 'N' AND l4.event_id = xet.event_id
67226 AND l5.event_id = l4.event_id
67227 AND l5.line_number = l4.line_number
67228 ;
67229
67230 --
67231 BEGIN
67232 IF g_log_enabled THEN
67233 l_log_module := C_DEFAULT_MODULE||'.EventClass_134';
67234 END IF;
67235 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
67236 trace
67237 (p_msg => 'BEGIN of EventClass_134'
67238 ,p_level => C_LEVEL_PROCEDURE
67239 ,p_module => l_log_module);
67240 END IF;
67241
67242 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67243 trace
67244 (p_msg => 'p_application_id = '||p_application_id||
67245 ' - p_base_ledger_id = '||p_base_ledger_id||
67246 ' - p_target_ledger_id = '||p_target_ledger_id||
67247 ' - p_language = '||p_language||
67248 ' - p_currency_code = '||p_currency_code||
67249 ' - p_sla_ledger_id = '||p_sla_ledger_id
67250 ,p_level => C_LEVEL_STATEMENT
67251 ,p_module => l_log_module);
67252 END IF;
67253 --
67254 -- initialze arrays
67255 --
67256 g_array_event.DELETE;
67257 l_rec_array_event := l_null_rec_array_event;
67258 --
67259 --------------------------------------
67260 -- 4262811 Initialze MPA Line Number
67261 --------------------------------------
67262 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
67263
67264 --
67265
67266 --
67267 OPEN header_cur;
67268 --
67269 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67270 trace
67271 (p_msg => 'SQL - FETCH header_cur'
67272 ,p_level => C_LEVEL_STATEMENT
67273 ,p_module => l_log_module);
67274 END IF;
67275 --
67276 LOOP
67277 FETCH header_cur BULK COLLECT INTO
67278 l_array_entity_id
67279 , l_array_legal_entity_id
67280 , l_array_entity_code
67281 , l_array_transaction_num
67282 , l_array_event_id
67283 , l_array_class_code
67284 , l_array_event_type
67285 , l_array_event_number
67286 , l_array_event_date
67287 , l_array_transaction_date
67288 , l_array_reference_num_1
67289 , l_array_reference_num_2
67290 , l_array_reference_num_3
67291 , l_array_reference_num_4
67292 , l_array_reference_char_1
67293 , l_array_reference_char_2
67294 , l_array_reference_char_3
67295 , l_array_reference_char_4
67296 , l_array_reference_date_1
67297 , l_array_reference_date_2
67298 , l_array_reference_date_3
67299 , l_array_reference_date_4
67300 , l_array_event_created_by
67301 , l_array_budgetary_control_flag
67302 , l_array_source_21
67303 , l_array_source_30
67304 , l_array_source_31
67305 , l_array_source_32
67306 , l_array_source_77
67307 , l_array_source_78
67308 , l_array_source_79
67309 LIMIT l_rows;
67310 --
67311 IF (C_LEVEL_EVENT >= g_log_level) THEN
67312 trace
67313 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
67314 ,p_level => C_LEVEL_EVENT
67315 ,p_module => l_log_module);
67316 END IF;
67317 --
67318 EXIT WHEN l_array_entity_id.COUNT = 0;
67319
67320 -- initialize arrays
67321 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
67322 XLA_AE_LINES_PKG.g_rec_lines := NULL;
67323
67324 --
67325 -- Bug 4458708
67326 --
67327 XLA_AE_LINES_PKG.g_LineNumber := 0;
67328
67329
67330 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
67331 g_last_hdr_idx := l_array_event_id.LAST;
67332 --
67333 -- loop for the headers. Each iteration is for each header extract row
67334 -- fetched in header cursor
67335 --
67336 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
67337
67338 --
67339 -- set event info as cache for other routines to refer event attributes
67340 --
67341 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
67342 (p_application_id => p_application_id
67343 ,p_primary_ledger_id => p_primary_ledger_id
67344 ,p_base_ledger_id => p_base_ledger_id
67345 ,p_target_ledger_id => p_target_ledger_id
67346 ,p_entity_id => l_array_entity_id(hdr_idx)
67347 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
67348 ,p_entity_code => l_array_entity_code(hdr_idx)
67349 ,p_transaction_num => l_array_transaction_num(hdr_idx)
67350 ,p_event_id => l_array_event_id(hdr_idx)
67351 ,p_event_class_code => l_array_class_code(hdr_idx)
67352 ,p_event_type_code => l_array_event_type(hdr_idx)
67353 ,p_event_number => l_array_event_number(hdr_idx)
67354 ,p_event_date => l_array_event_date(hdr_idx)
67355 ,p_transaction_date => l_array_transaction_date(hdr_idx)
67356 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
67357 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
67358 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
67359 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
67360 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
67361 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
67362 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
67363 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
67364 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
67365 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
67366 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
67367 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
67368 ,p_event_created_by => l_array_event_created_by(hdr_idx)
67369 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
67370
67371 --
67372 -- set the status of entry to C_VALID (0)
67373 --
67374 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
67375
67376 --
67377 -- initialize a row for ae header
67378 --
67379 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
67380
67381 l_event_id := l_array_event_id(hdr_idx);
67382
67383 --
67384 -- storing the hdr_idx for event. May be used by line cursor.
67385 --
67386 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
67387
67388 --
67389 -- store sources from header extract. This can be improved to
67390 -- store only those sources from header extract that may be used in lines
67391 --
67392
67396 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
67393 g_array_event(l_event_id).array_value_char('source_21') := l_array_source_21(hdr_idx);
67394 g_array_event(l_event_id).array_value_num('source_30') := l_array_source_30(hdr_idx);
67395 g_array_event(l_event_id).array_value_num('source_31') := l_array_source_31(hdr_idx);
67397 g_array_event(l_event_id).array_value_char('source_77') := l_array_source_77(hdr_idx);
67398 g_array_event(l_event_id).array_value_num('source_78') := l_array_source_78(hdr_idx);
67399 g_array_event(l_event_id).array_value_num('source_79') := l_array_source_79(hdr_idx);
67400
67401 --
67402 -- initilaize the status of ae headers for diffrent balance types
67403 -- the status is initialised to C_NOT_CREATED (2)
67404 --
67405 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
67406 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
67407 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
67408
67409 --
67410 -- call api to validate and store accounting attributes for header
67411 --
67412
67413 ------------------------------------------------------------
67414 -- Accrual Reversal : to get date for Standard Source (NONE)
67415 ------------------------------------------------------------
67416 l_acc_rev_gl_date_source := NULL;
67417
67418 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
67419 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_77');
67420 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
67421 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_78');
67422 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
67423 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_79');
67424 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
67425 l_rec_acct_attrs.array_date_value(4) :=
67426 xla_ae_sources_pkg.GetSystemSourceDate(
67427 p_source_code => 'XLA_EVENT_DATE'
67428 , p_source_type_code => 'Y'
67429 , p_source_application_id => 602
67430 );
67431
67432
67433 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
67434
67435 XLA_AE_HEADER_PKG.SetJeCategoryName;
67436
67437 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
67438 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
67439 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
67440 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
67441 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
67442
67443
67444 -- No header level analytical criteria
67445
67446 --
67447 --accounting attribute enhancement, bug 3612931
67448 --
67449 l_trx_reversal_source := SUBSTR(NULL, 1,30);
67450
67451 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
67452 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
67453
67454 xla_accounting_err_pkg.build_message
67455 (p_appli_s_name => 'XLA'
67456 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
67457 ,p_token_1 => 'ACCT_ATTR_NAME'
67458 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
67459 ,p_token_2 => 'PRODUCT_NAME'
67460 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
67461 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
67462 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
67463 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
67464
67465 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
67466 --
67467 -- following sets the accounting attributes needed to reverse
67468 -- accounting for a distributeion
67469 --
67470 xla_ae_lines_pkg.SetTrxReversalAttrs
67471 (p_event_id => l_event_id
67472 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
67473 ,p_trx_reversal_source => l_trx_reversal_source);
67474
67475 END IF;
67476
67477
67478 ----------------------------------------------------------------
67479 -- 4262811 - update the header statuses to invalid in need be
67480 ----------------------------------------------------------------
67481 --
67482 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
67483
67484
67485 -----------------------------------------------
67486 -- No accrual reversal for the event class/type
67487 -----------------------------------------------
67488 ----------------------------------------------------------------
67489
67490 --
67491 -- this ends the header loop iteration for one bulk fetch
67492 --
67493 END LOOP;
67494
67495 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
67496 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
67497
67498 --
67499 -- insert dummy rows into lines gt table that were created due to
67500 -- transaction reversals
67501 --
67502 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
67503 l_result := XLA_AE_LINES_PKG.InsertLines;
67504 END IF;
67505
67506 --
67507 -- reset the temp_line_num for each set of events fetched from header
67508 -- cursor rather than doing it for each new event in line cursor
67509 -- Bug 3939231
67510 --
67511 xla_ae_lines_pkg.g_temp_line_num := 0;
67512
67513
67514
67515 --
67516 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
67517 --
67518 --
67519 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67520
67521 trace
67522 (p_msg => 'SQL - FETCH line_cur'
67523 ,p_level => C_LEVEL_STATEMENT
67524 ,p_module => l_log_module);
67525
67526 END IF;
67527 --
67528 --
67529 LOOP
67530 --
67531 FETCH line_cur BULK COLLECT INTO
67532 l_array_entity_id
67533 , l_array_legal_entity_id
67534 , l_array_entity_code
67535 , l_array_transaction_num
67536 , l_array_event_id
67537 , l_array_class_code
67538 , l_array_event_type
67539 , l_array_event_number
67540 , l_array_event_date
67541 , l_array_transaction_date
67542 , l_array_reference_num_1
67543 , l_array_reference_num_2
67544 , l_array_reference_num_3
67545 , l_array_reference_num_4
67546 , l_array_reference_char_1
67547 , l_array_reference_char_2
67548 , l_array_reference_char_3
67549 , l_array_reference_char_4
67550 , l_array_reference_date_1
67551 , l_array_reference_date_2
67552 , l_array_reference_date_3
67553 , l_array_reference_date_4
67554 , l_array_event_created_by
67555 , l_array_budgetary_control_flag
67556 , l_array_extract_line_num
67557 , l_array_source_5
67558 , l_array_source_20
67559 , l_array_source_22
67560 , l_array_source_23
67561 , l_array_source_24
67562 , l_array_source_25
67563 , l_array_source_26
67564 , l_array_source_27
67565 , l_array_source_28
67566 , l_array_source_29
67567 LIMIT l_rows;
67568
67569 --
67570 IF (C_LEVEL_EVENT >= g_log_level) THEN
67571 trace
67572 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
67573 ,p_level => C_LEVEL_EVENT
67574 ,p_module => l_log_module);
67575 END IF;
67576 --
67577 EXIT WHEN l_array_entity_id.count = 0;
67578
67579 XLA_AE_LINES_PKG.g_rec_lines := null;
67580
67581 --
67582 -- Bug 4458708
67583 --
67584 XLA_AE_LINES_PKG.g_LineNumber := 0;
67585 --
67586 --
67587
67588 FOR Idx IN 1..l_array_event_id.count LOOP
67589 --
67590 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
67591 --
67592 l_event_id := l_array_event_id(idx); -- 5648433
67593
67594 --
67595 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
67596 --
67597
67598 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
67599 (g_array_event(l_event_id).array_value_num('header_index'))
67600 ,'N'
67601 ) <> 'Y'
67602 THEN
67603 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67604 trace
67605 (p_msg => 'Trancaction revesal option is not Y '
67606 ,p_level => C_LEVEL_STATEMENT
67607 ,p_module => l_log_module);
67608 END IF;
67609
67610 --
67611 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
67612 --
67613 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
67614 --
67615 -- set event info as cache for other routines to refer event attributes
67616 --
67617
67618 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
67622 (p_application_id => p_application_id
67619 l_previous_event_id := l_event_id;
67620
67621 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
67623 ,p_primary_ledger_id => p_primary_ledger_id
67624 ,p_base_ledger_id => p_base_ledger_id
67625 ,p_target_ledger_id => p_target_ledger_id
67626 ,p_entity_id => l_array_entity_id(Idx)
67627 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
67628 ,p_entity_code => l_array_entity_code(Idx)
67629 ,p_transaction_num => l_array_transaction_num(Idx)
67630 ,p_event_id => l_array_event_id(Idx)
67631 ,p_event_class_code => l_array_class_code(Idx)
67632 ,p_event_type_code => l_array_event_type(Idx)
67633 ,p_event_number => l_array_event_number(Idx)
67634 ,p_event_date => l_array_event_date(Idx)
67635 ,p_transaction_date => l_array_transaction_date(Idx)
67636 ,p_reference_num_1 => l_array_reference_num_1(Idx)
67637 ,p_reference_num_2 => l_array_reference_num_2(Idx)
67638 ,p_reference_num_3 => l_array_reference_num_3(Idx)
67639 ,p_reference_num_4 => l_array_reference_num_4(Idx)
67640 ,p_reference_char_1 => l_array_reference_char_1(Idx)
67641 ,p_reference_char_2 => l_array_reference_char_2(Idx)
67642 ,p_reference_char_3 => l_array_reference_char_3(Idx)
67643 ,p_reference_char_4 => l_array_reference_char_4(Idx)
67644 ,p_reference_date_1 => l_array_reference_date_1(Idx)
67645 ,p_reference_date_2 => l_array_reference_date_2(Idx)
67646 ,p_reference_date_3 => l_array_reference_date_3(Idx)
67647 ,p_reference_date_4 => l_array_reference_date_4(Idx)
67648 ,p_event_created_by => l_array_event_created_by(Idx)
67649 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
67650 --
67651 END IF;
67652
67653
67654
67655 --
67656 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
67657
67658 l_acct_reversal_source := SUBSTR(NULL, 1,30);
67659
67660 IF l_continue_with_lines THEN
67661 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
67662 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
67663
67664 xla_accounting_err_pkg.build_message
67665 (p_appli_s_name => 'XLA'
67666 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
67667 ,p_token_1 => 'LINE_NUMBER'
67668 ,p_value_1 => l_array_extract_line_num(Idx)
67669 ,p_token_2 => 'PRODUCT_NAME'
67670 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
67671 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
67672 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
67673 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
67674
67675 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
67676 --
67677 -- following sets the accounting attributes needed to reverse
67678 -- accounting for a distributeion
67679 --
67680
67681 --
67682 -- 5217187
67683 --
67684 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
67685 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
67686 g_array_event(l_event_id).array_value_num('header_index'));
67687 --
67688 --
67689
67690 -- No reversal code generated
67691
67692 xla_ae_lines_pkg.SetAcctReversalAttrs
67693 (p_event_id => l_event_id
67694 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
67695 ,p_calculate_acctd_flag => l_calculate_acctd_flag
67696 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
67697 END IF;
67698
67699 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
67700 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
67701
67702 --
67703 AcctLineType_29 (
67704 p_application_id => p_application_id
67705 ,p_event_id => l_event_id
67706 ,p_calculate_acctd_flag => l_calculate_acctd_flag
67707 ,p_calculate_g_l_flag => l_calculate_g_l_flag
67708 ,p_actual_flag => l_actual_flag
67709 ,p_balance_type_code => l_balance_type_code
67710 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
67711
67712 , p_source_5 => l_array_source_5(Idx)
67713 , p_source_20 => l_array_source_20(Idx)
67714 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
67715 , p_source_22 => l_array_source_22(Idx)
67716 , p_source_23 => l_array_source_23(Idx)
67717 , p_source_24 => l_array_source_24(Idx)
67718 , p_source_25 => l_array_source_25(Idx)
67719 , p_source_26 => l_array_source_26(Idx)
67720 , p_source_27 => l_array_source_27(Idx)
67721 , p_source_28 => l_array_source_28(Idx)
67722 , p_source_29 => l_array_source_29(Idx)
67723 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
67724 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
67725 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
67726 );
67727 If(l_balance_type_code = 'A') THEN
67728 l_actual_gain_loss_ref := l_gain_or_loss_ref;
67729 END IF;
67730
67731 --
67732
67733
67734 --
67735 AcctLineType_30 (
67736 p_application_id => p_application_id
67737 ,p_event_id => l_event_id
67738 ,p_calculate_acctd_flag => l_calculate_acctd_flag
67739 ,p_calculate_g_l_flag => l_calculate_g_l_flag
67740 ,p_actual_flag => l_actual_flag
67741 ,p_balance_type_code => l_balance_type_code
67742 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
67743
67744 , p_source_5 => l_array_source_5(Idx)
67745 , p_source_20 => l_array_source_20(Idx)
67746 , p_source_21 => g_array_event(l_event_id).array_value_char('source_21')
67747 , p_source_22 => l_array_source_22(Idx)
67748 , p_source_23 => l_array_source_23(Idx)
67749 , p_source_24 => l_array_source_24(Idx)
67750 , p_source_25 => l_array_source_25(Idx)
67751 , p_source_26 => l_array_source_26(Idx)
67752 , p_source_27 => l_array_source_27(Idx)
67753 , p_source_28 => l_array_source_28(Idx)
67754 , p_source_29 => l_array_source_29(Idx)
67755 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
67756 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
67757 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
67758 );
67759 If(l_balance_type_code = 'A') THEN
67760 l_actual_gain_loss_ref := l_gain_or_loss_ref;
67761 END IF;
67762
67763 --
67764
67765
67766 --
67767 AcctLineType_31 (
67768 p_application_id => p_application_id
67769 ,p_event_id => l_event_id
67770 ,p_calculate_acctd_flag => l_calculate_acctd_flag
67771 ,p_calculate_g_l_flag => l_calculate_g_l_flag
67772 ,p_actual_flag => l_actual_flag
67773 ,p_balance_type_code => l_balance_type_code
67774 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
67775
67776 , p_source_5 => l_array_source_5(Idx)
67777 , p_source_20 => l_array_source_20(Idx)
67778 , p_source_22 => l_array_source_22(Idx)
67779 , p_source_23 => l_array_source_23(Idx)
67780 , p_source_24 => l_array_source_24(Idx)
67781 , p_source_25 => l_array_source_25(Idx)
67782 , p_source_26 => l_array_source_26(Idx)
67783 , p_source_27 => l_array_source_27(Idx)
67784 , p_source_28 => l_array_source_28(Idx)
67785 , p_source_29 => l_array_source_29(Idx)
67786 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
67787 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
67788 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
67789 );
67790 If(l_balance_type_code = 'A') THEN
67791 l_actual_gain_loss_ref := l_gain_or_loss_ref;
67792 END IF;
67793
67794 --
67795
67796
67797 --
67798 AcctLineType_32 (
67799 p_application_id => p_application_id
67800 ,p_event_id => l_event_id
67801 ,p_calculate_acctd_flag => l_calculate_acctd_flag
67802 ,p_calculate_g_l_flag => l_calculate_g_l_flag
67803 ,p_actual_flag => l_actual_flag
67804 ,p_balance_type_code => l_balance_type_code
67805 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
67806
67807 , p_source_5 => l_array_source_5(Idx)
67808 , p_source_20 => l_array_source_20(Idx)
67809 , p_source_22 => l_array_source_22(Idx)
67810 , p_source_23 => l_array_source_23(Idx)
67811 , p_source_24 => l_array_source_24(Idx)
67812 , p_source_25 => l_array_source_25(Idx)
67813 , p_source_26 => l_array_source_26(Idx)
67814 , p_source_27 => l_array_source_27(Idx)
67815 , p_source_28 => l_array_source_28(Idx)
67816 , p_source_29 => l_array_source_29(Idx)
67817 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
67818 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
67819 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
67820 );
67821 If(l_balance_type_code = 'A') THEN
67822 l_actual_gain_loss_ref := l_gain_or_loss_ref;
67823 END IF;
67824
67825 --
67826
67827
67828 --
67829 AcctLineType_33 (
67830 p_application_id => p_application_id
67831 ,p_event_id => l_event_id
67832 ,p_calculate_acctd_flag => l_calculate_acctd_flag
67833 ,p_calculate_g_l_flag => l_calculate_g_l_flag
67834 ,p_actual_flag => l_actual_flag
67835 ,p_balance_type_code => l_balance_type_code
67836 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
67837
67838 , p_source_5 => l_array_source_5(Idx)
67839 , p_source_20 => l_array_source_20(Idx)
67840 , p_source_22 => l_array_source_22(Idx)
67841 , p_source_23 => l_array_source_23(Idx)
67842 , p_source_24 => l_array_source_24(Idx)
67843 , p_source_25 => l_array_source_25(Idx)
67844 , p_source_26 => l_array_source_26(Idx)
67845 , p_source_27 => l_array_source_27(Idx)
67846 , p_source_28 => l_array_source_28(Idx)
67847 , p_source_29 => l_array_source_29(Idx)
67848 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
67849 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
67850 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
67851 );
67852 If(l_balance_type_code = 'A') THEN
67853 l_actual_gain_loss_ref := l_gain_or_loss_ref;
67854 END IF;
67855
67856 --
67857
67858
67859 --
67860 AcctLineType_34 (
67861 p_application_id => p_application_id
67862 ,p_event_id => l_event_id
67863 ,p_calculate_acctd_flag => l_calculate_acctd_flag
67864 ,p_calculate_g_l_flag => l_calculate_g_l_flag
67865 ,p_actual_flag => l_actual_flag
67866 ,p_balance_type_code => l_balance_type_code
67867 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
67868
67869 , p_source_5 => l_array_source_5(Idx)
67870 , p_source_20 => l_array_source_20(Idx)
67871 , p_source_22 => l_array_source_22(Idx)
67872 , p_source_23 => l_array_source_23(Idx)
67873 , p_source_24 => l_array_source_24(Idx)
67874 , p_source_25 => l_array_source_25(Idx)
67875 , p_source_26 => l_array_source_26(Idx)
67876 , p_source_27 => l_array_source_27(Idx)
67877 , p_source_28 => l_array_source_28(Idx)
67878 , p_source_29 => l_array_source_29(Idx)
67879 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
67880 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
67881 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
67882 );
67883 If(l_balance_type_code = 'A') THEN
67884 l_actual_gain_loss_ref := l_gain_or_loss_ref;
67885 END IF;
67886
67887 --
67888
67889
67890 --
67891 AcctLineType_35 (
67892 p_application_id => p_application_id
67893 ,p_event_id => l_event_id
67894 ,p_calculate_acctd_flag => l_calculate_acctd_flag
67895 ,p_calculate_g_l_flag => l_calculate_g_l_flag
67896 ,p_actual_flag => l_actual_flag
67897 ,p_balance_type_code => l_balance_type_code
67898 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
67899
67900 , p_source_5 => l_array_source_5(Idx)
67901 , p_source_20 => l_array_source_20(Idx)
67902 , p_source_22 => l_array_source_22(Idx)
67903 , p_source_23 => l_array_source_23(Idx)
67904 , p_source_24 => l_array_source_24(Idx)
67905 , p_source_25 => l_array_source_25(Idx)
67906 , p_source_26 => l_array_source_26(Idx)
67907 , p_source_27 => l_array_source_27(Idx)
67908 , p_source_28 => l_array_source_28(Idx)
67909 , p_source_29 => l_array_source_29(Idx)
67910 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
67911 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
67912 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
67913 );
67914 If(l_balance_type_code = 'A') THEN
67915 l_actual_gain_loss_ref := l_gain_or_loss_ref;
67916 END IF;
67917
67918 --
67919
67920
67921 --
67922 AcctLineType_36 (
67923 p_application_id => p_application_id
67924 ,p_event_id => l_event_id
67925 ,p_calculate_acctd_flag => l_calculate_acctd_flag
67926 ,p_calculate_g_l_flag => l_calculate_g_l_flag
67927 ,p_actual_flag => l_actual_flag
67928 ,p_balance_type_code => l_balance_type_code
67929 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
67930
67931 , p_source_5 => l_array_source_5(Idx)
67932 , p_source_20 => l_array_source_20(Idx)
67933 , p_source_22 => l_array_source_22(Idx)
67934 , p_source_23 => l_array_source_23(Idx)
67935 , p_source_24 => l_array_source_24(Idx)
67936 , p_source_25 => l_array_source_25(Idx)
67937 , p_source_26 => l_array_source_26(Idx)
67938 , p_source_27 => l_array_source_27(Idx)
67939 , p_source_28 => l_array_source_28(Idx)
67940 , p_source_29 => l_array_source_29(Idx)
67941 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
67942 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
67943 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
67944 );
67945 If(l_balance_type_code = 'A') THEN
67946 l_actual_gain_loss_ref := l_gain_or_loss_ref;
67947 END IF;
67948
67949 --
67950
67951 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
67952 -- or secondary ledger that has different currency with primary
67953 -- or alc that is calculated by sla
67954 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
67955 (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'))
67956
67957 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
67958 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
67959 AND (l_actual_flag = 'A')) THEN
67960 XLA_AE_LINES_PKG.CreateGainOrLossLines(
67961 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
67962 ,p_application_id => p_application_id
67963 ,p_amb_context_code => 'DEFAULT'
67964 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
67965 ,p_event_class_code => C_EVENT_CLASS_CODE
67966 ,p_event_type_code => C_EVENT_TYPE_CODE
67967
67968 ,p_gain_ccid => -1
67969 ,p_loss_ccid => -1
67970
67971 ,p_actual_flag => l_actual_flag
67972 ,p_enc_flag => null
67973 ,p_actual_g_l_ref => l_actual_gain_loss_ref
67974 ,p_enc_g_l_ref => null
67975 );
67976 END IF;
67977 END IF;
67978 END IF;
67979
67980 ELSE
67981 --
67982 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
67983 --
67984 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
67985 trace
67986 (p_msg => 'Trancaction revesal option is Y'
67987 ,p_level => C_LEVEL_STATEMENT
67988 ,p_module => l_log_module);
67989 END IF;
67990 END IF;
67991
67992 END LOOP;
67993 l_result := XLA_AE_LINES_PKG.InsertLines ;
67994 end loop;
67995 close line_cur;
67996
67997
67998 --
67999 -- insert headers into xla_ae_headers_gt table
68000 --
68001 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
68002
68003 -- insert into errors table here.
68004
68005 END LOOP;
68006
68007 --
68008 -- 4865292
68009 --
68010 -- Compare g_hdr_extract_count with event count in
68011 -- CreateHeadersAndLines.
68012 --
68013 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
68014
68015 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68016 trace (p_msg => '# rows extracted from header extract objects '
68017 || ' (running total): '
68018 || g_hdr_extract_count
68019 ,p_level => C_LEVEL_STATEMENT
68020 ,p_module => l_log_module);
68021 END IF;
68022
68023 CLOSE header_cur;
68024 --
68025
68026 --
68027 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
68028 trace
68029 (p_msg => 'END of EventClass_134'
68030 ,p_level => C_LEVEL_PROCEDURE
68031 ,p_module => l_log_module);
68032 END IF;
68033 --
68034 RETURN l_result;
68035 EXCEPTION
68036 WHEN xla_exceptions_pkg.application_exception THEN
68037
68038 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
68039
68040
68041 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
68042
68043 RAISE;
68044
68045 WHEN NO_DATA_FOUND THEN
68046
68047 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
68048 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
68049
68050 FOR header_record IN header_cur
68051 LOOP
68055 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
68052 l_array_header_events(header_record.event_id) := header_record.event_id;
68053 END LOOP;
68054
68056 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
68057
68058 fnd_file.put_line(fnd_file.LOG, ' ');
68059 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
68060 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
68061 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
68062
68063 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
68064 LOOP
68065 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
68066 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
68067 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
68068 END IF;
68069 END LOOP;
68070
68071 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
68072 fnd_file.put_line(fnd_file.LOG, ' ');
68073
68074
68075 xla_exceptions_pkg.raise_message
68076 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_134');
68077
68078
68079 WHEN OTHERS THEN
68080 xla_exceptions_pkg.raise_message
68081 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_134');
68082 END EventClass_134;
68083 --
68084
68085 ---------------------------------------
68086 --
68087 -- PRIVATE PROCEDURE
68088 -- insert_sources_135
68089 --
68090 ----------------------------------------
68091 --
68092 PROCEDURE insert_sources_135(
68093 p_target_ledger_id IN NUMBER
68094 , p_language IN VARCHAR2
68095 , p_sla_ledger_id IN NUMBER
68096 , p_pad_start_date IN DATE
68097 , p_pad_end_date IN DATE
68098 )
68099 IS
68100
68101 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK_ALL';
68102 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK';
68103 p_apps_owner VARCHAR2(30);
68104 l_log_module VARCHAR2(240);
68105 BEGIN
68106 IF g_log_enabled THEN
68107 l_log_module := C_DEFAULT_MODULE||'.insert_sources_135';
68108 END IF;
68109 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
68110
68111 trace
68112 (p_msg => 'BEGIN of insert_sources_135'
68113 ,p_level => C_LEVEL_PROCEDURE
68114 ,p_module => l_log_module);
68115
68116 END IF;
68117
68118 -- select APPS owner
68119 SELECT oracle_username
68120 INTO p_apps_owner
68121 FROM fnd_oracle_userid
68122 WHERE read_only_flag = 'U'
68123 ;
68124
68125 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68126 trace
68127 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
68128 ' - p_language = '||p_language||
68129 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
68130 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
68131 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
68132 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
68133 ,p_level => C_LEVEL_STATEMENT
68134 ,p_module => l_log_module);
68135 END IF;
68136
68137
68138 --
68139 INSERT INTO xla_diag_sources --hdr2
68140 (
68141 event_id
68142 , ledger_id
68143 , sla_ledger_id
68144 , description_language
68145 , object_name
68146 , object_type_code
68147 , line_number
68148 , source_application_id
68149 , source_type_code
68150 , source_code
68151 , source_value
68152 , source_meaning
68153 , created_by
68154 , creation_date
68155 , last_update_date
68156 , last_updated_by
68157 , last_update_login
68158 , program_update_date
68159 , program_application_id
68160 , program_id
68161 , request_id
68162 )
68163 SELECT
68164 event_id
68165 , p_target_ledger_id
68166 , p_sla_ledger_id
68167 , p_language
68168 , object_name
68169 , object_type_code
68170 , line_number
68171 , source_application_id
68172 , source_type_code
68173 , source_code
68174 , SUBSTR(source_value ,1,1996)
68175 , SUBSTR(source_meaning ,1,200)
68176 , xla_environment_pkg.g_Usr_Id
68177 , TRUNC(SYSDATE)
68178 , TRUNC(SYSDATE)
68179 , xla_environment_pkg.g_Usr_Id
68180 , xla_environment_pkg.g_Login_Id
68181 , TRUNC(SYSDATE)
68182 , xla_environment_pkg.g_Prog_Appl_Id
68183 , xla_environment_pkg.g_Prog_Id
68184 , xla_environment_pkg.g_Req_Id
68185 FROM (
68186 SELECT xet.event_id event_id
68187 , 0 line_number
68188 , CASE r
68189 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
68190 WHEN 2 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
68191 WHEN 3 THEN 'AR_BILL_TO_SITE_USES_S_V'
68192 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
68193 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
68194 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
68195 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
68196
68197 ELSE null
68201 WHEN 2 THEN 'HEADER'
68198 END object_name
68199 , CASE r
68200 WHEN 1 THEN 'HEADER'
68202 WHEN 3 THEN 'HEADER'
68203 WHEN 4 THEN 'HEADER'
68204 WHEN 5 THEN 'HEADER'
68205 WHEN 6 THEN 'HEADER'
68206 WHEN 7 THEN 'HEADER'
68207
68208 ELSE null
68209 END object_type_code
68210 , CASE r
68211 WHEN 1 THEN '222'
68212 WHEN 2 THEN '222'
68213 WHEN 3 THEN '222'
68214 WHEN 4 THEN '222'
68215 WHEN 5 THEN '222'
68216 WHEN 6 THEN '222'
68217 WHEN 7 THEN '222'
68218
68219 ELSE null
68220 END source_application_id
68221 , 'S' source_type_code
68222 , CASE r
68223 WHEN 1 THEN 'TRX_DOC_SEQUENCE_VALUE'
68224 WHEN 2 THEN 'BILL_CUST_ACCOUNT_ID'
68225 WHEN 3 THEN 'BILL_USES_SITE_USE_ID'
68226 WHEN 4 THEN 'XLA_PARTY_TYPE'
68227 WHEN 5 THEN 'TRX_INVOICE_CURRENCY_CODE'
68228 WHEN 6 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
68229 WHEN 7 THEN 'TRX_DOC_SEQUENCE_ID'
68230
68231 ELSE null
68232 END source_code
68233 , CASE r
68234 WHEN 1 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
68235 WHEN 2 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
68236 WHEN 3 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
68237 WHEN 4 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
68238 WHEN 5 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
68239 WHEN 6 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
68240 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
68241
68242 ELSE null
68243 END source_value
68244 , null source_meaning
68245 FROM xla_events_gt xet
68246 , AR_BILL_TO_CUSTOMERS_S_V h1
68247 , AR_BILL_TO_SITE_USES_S_V h2
68248 , AR_TRANSACTIONS_S_V h5
68249 ,(select rownum r from all_objects where rownum <= 7 and owner = p_apps_owner)
68250 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
68251 AND xet.event_class_code = C_EVENT_CLASS_CODE
68252 AND h1.event_id = xet.event_id
68253 AND h2.event_id = h1.event_id
68254 AND h5.event_id = h1.event_id
68255
68256 )
68257 ;
68258 --
68259 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68260
68261 trace
68262 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
68263 ,p_level => C_LEVEL_STATEMENT
68264 ,p_module => l_log_module);
68265
68266 END IF;
68267 --
68268
68269
68270
68271 --
68272 INSERT INTO xla_diag_sources --line2
68273 (
68274 event_id
68275 , ledger_id
68276 , sla_ledger_id
68277 , description_language
68278 , object_name
68279 , object_type_code
68280 , line_number
68281 , source_application_id
68282 , source_type_code
68283 , source_code
68284 , source_value
68285 , source_meaning
68286 , created_by
68287 , creation_date
68288 , last_update_date
68289 , last_updated_by
68290 , last_update_login
68291 , program_update_date
68292 , program_application_id
68293 , program_id
68294 , request_id
68295 )
68296 SELECT event_id
68297 , p_target_ledger_id
68298 , p_sla_ledger_id
68299 , p_language
68300 , object_name
68301 , object_type_code
68302 , line_number
68303 , source_application_id
68304 , source_type_code
68305 , source_code
68306 , SUBSTR(source_value,1,1996)
68307 , SUBSTR(source_meaning ,1,200)
68308 , xla_environment_pkg.g_Usr_Id
68309 , TRUNC(SYSDATE)
68310 , TRUNC(SYSDATE)
68311 , xla_environment_pkg.g_Usr_Id
68312 , xla_environment_pkg.g_Login_Id
68313 , TRUNC(SYSDATE)
68314 , xla_environment_pkg.g_Prog_Appl_Id
68315 , xla_environment_pkg.g_Prog_Id
68316 , xla_environment_pkg.g_Req_Id
68317 FROM (
68318 SELECT xet.event_id event_id
68319 , l4.line_number line_number
68320 , CASE r
68321 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
68322 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
68323 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
68324 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
68325 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
68326 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
68327 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
68328 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
68329 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
68330
68331 ELSE null
68332 END object_name
68333 , CASE r
68334 WHEN 1 THEN 'LINE'
68335 WHEN 2 THEN 'LINE'
68336 WHEN 3 THEN 'LINE'
68337 WHEN 4 THEN 'LINE'
68338 WHEN 5 THEN 'LINE'
68339 WHEN 6 THEN 'LINE'
68340 WHEN 7 THEN 'LINE'
68341 WHEN 8 THEN 'LINE'
68345 END object_type_code
68342 WHEN 9 THEN 'LINE'
68343
68344 ELSE null
68346 , CASE r
68347 WHEN 1 THEN '222'
68348 WHEN 2 THEN '222'
68349 WHEN 3 THEN '222'
68350 WHEN 4 THEN '222'
68351 WHEN 5 THEN '222'
68352 WHEN 6 THEN '222'
68353 WHEN 7 THEN '222'
68354 WHEN 8 THEN '222'
68355 WHEN 9 THEN '222'
68356
68357 ELSE null
68358 END source_application_id
68359 , 'S' source_type_code
68360 , CASE r
68361 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
68362 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
68363 WHEN 3 THEN 'TRX_LINE_DIST_ID'
68364 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
68365 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
68366 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
68367 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
68368 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
68369 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
68370
68371 ELSE null
68372 END source_code
68373 , CASE r
68374 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
68375 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
68376 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
68377 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
68378 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
68379 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
68380 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
68381 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
68382 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
68383
68384 ELSE null
68385 END source_value
68386 , null source_meaning
68387 FROM xla_events_gt xet
68388 , AR_CUST_TRX_LINES_BASE_V l3
68389 , AR_CUST_TRX_LINES_L_V l4
68390 , (select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
68391 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
68392 AND xet.event_class_code = C_EVENT_CLASS_CODE
68393 AND l3.event_id = xet.event_id
68394 AND l4.event_id = l3.event_id
68395 AND l4.line_number = l3.line_number
68396
68397 )
68398 ;
68399 --
68400 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68401
68402 trace
68403 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
68404 ,p_level => C_LEVEL_STATEMENT
68405 ,p_module => l_log_module);
68406
68407 END IF;
68408
68409
68410 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
68411 trace
68412 (p_msg => 'END of insert_sources_135'
68413 ,p_level => C_LEVEL_PROCEDURE
68414 ,p_module => l_log_module);
68415 END IF;
68416 EXCEPTION
68417 WHEN xla_exceptions_pkg.application_exception THEN
68418 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
68419 trace
68420 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
68421 ,p_level => C_LEVEL_EXCEPTION
68422 ,p_module => l_log_module);
68423 END IF;
68424 RAISE;
68425 WHEN OTHERS THEN
68426 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
68427 trace
68428 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
68429 ,p_level => C_LEVEL_EXCEPTION
68430 ,p_module => l_log_module);
68431 END IF;
68432 xla_exceptions_pkg.raise_message
68433 (p_location => 'XLA_00222_AAD_S_000005_PKG.insert_sources_135');
68434 END insert_sources_135;
68435 --
68436
68437 ---------------------------------------
68438 --
68439 -- PRIVATE FUNCTION
68440 -- EventClass_135
68441 --
68442 ----------------------------------------
68443 --
68444 FUNCTION EventClass_135
68445 (p_application_id IN NUMBER
68446 ,p_base_ledger_id IN NUMBER
68447 ,p_target_ledger_id IN NUMBER
68448 ,p_language IN VARCHAR2
68449 ,p_currency_code IN VARCHAR2
68450 ,p_sla_ledger_id IN NUMBER
68451 ,p_pad_start_date IN DATE
68452 ,p_pad_end_date IN DATE
68453 ,p_primary_ledger_id IN NUMBER)
68454 RETURN BOOLEAN IS
68455 --
68456 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK_ALL';
68457 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CHARGEBACK';
68458
68459 l_calculate_acctd_flag VARCHAR2(1) :='N';
68460 l_calculate_g_l_flag VARCHAR2(1) :='N';
68461 --
68462 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
68463 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
68464 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
68465 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
68466 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
68467 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
68468 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
68469 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
68470 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
68474 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
68471 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
68472 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
68473 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
68475 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
68476 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
68477 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
68478 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
68479 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
68480 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
68481 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
68482 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
68483 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
68484 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
68485 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
68486 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
68487 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
68488
68489 l_event_id NUMBER;
68490 l_previous_event_id NUMBER;
68491 l_first_event_id NUMBER;
68492 l_last_event_id NUMBER;
68493
68494 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
68495 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
68496 --
68497 --
68498 l_result BOOLEAN := TRUE;
68499 l_rows NUMBER := 1000;
68500 l_event_type_name VARCHAR2(80) := 'All';
68501 l_event_class_name VARCHAR2(80) := 'Chargeback';
68502 l_description VARCHAR2(4000);
68503 l_transaction_reversal NUMBER;
68504 l_ae_header_id NUMBER;
68505 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
68506 l_log_module VARCHAR2(240);
68507 --
68508 l_acct_reversal_source VARCHAR2(30);
68509 l_trx_reversal_source VARCHAR2(30);
68510
68511 l_continue_with_lines BOOLEAN := TRUE;
68512 --
68513 l_acc_rev_gl_date_source DATE; -- 4262811
68514 --
68515 type t_array_event_id is table of number index by binary_integer;
68516
68517 l_rec_array_event t_rec_array_event;
68518 l_null_rec_array_event t_rec_array_event;
68519 l_array_ae_header_id xla_number_array_type;
68520 l_actual_flag VARCHAR2(1) := NULL;
68521 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
68522 l_balance_type_code VARCHAR2(1) :=NULL;
68523 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
68524
68525 --
68526 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
68527 --
68528
68529 TYPE t_array_source_3 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
68530 TYPE t_array_source_30 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
68531 TYPE t_array_source_31 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
68532 TYPE t_array_source_32 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
68533 TYPE t_array_source_37 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
68534 TYPE t_array_source_81 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
68535 TYPE t_array_source_82 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
68536
68537 TYPE t_array_source_19 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
68538 TYPE t_array_source_33 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
68539 TYPE t_array_source_34 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
68540 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
68541 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
68542 TYPE t_array_source_38 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
68543 TYPE t_array_source_39 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
68544 TYPE t_array_source_40 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
68545 TYPE t_array_source_41 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
68546
68547 l_array_source_3 t_array_source_3;
68548 l_array_source_30 t_array_source_30;
68549 l_array_source_31 t_array_source_31;
68550 l_array_source_32 t_array_source_32;
68551 l_array_source_37 t_array_source_37;
68552 l_array_source_81 t_array_source_81;
68553 l_array_source_82 t_array_source_82;
68554
68555 l_array_source_19 t_array_source_19;
68556 l_array_source_33 t_array_source_33;
68557 l_array_source_34 t_array_source_34;
68558 l_array_source_35 t_array_source_35;
68559 l_array_source_36 t_array_source_36;
68560 l_array_source_38 t_array_source_38;
68561 l_array_source_39 t_array_source_39;
68562 l_array_source_40 t_array_source_40;
68563 l_array_source_41 t_array_source_41;
68564
68565 --
68566 CURSOR header_cur
68567 IS
68568 SELECT /*+ leading(xet) cardinality(xet,1) */
68569 -- Event Class Code: CHARGEBACK
68570 xet.entity_id
68571 ,xet.legal_entity_id
68572 ,xet.entity_code
68576 ,xet.event_type_code
68573 ,xet.transaction_number
68574 ,xet.event_id
68575 ,xet.event_class_code
68577 ,xet.event_number
68578 ,xet.event_date
68579 ,xet.transaction_date
68580 ,xet.reference_num_1
68581 ,xet.reference_num_2
68582 ,xet.reference_num_3
68583 ,xet.reference_num_4
68584 ,xet.reference_char_1
68585 ,xet.reference_char_2
68586 ,xet.reference_char_3
68587 ,xet.reference_char_4
68588 ,xet.reference_date_1
68589 ,xet.reference_date_2
68590 ,xet.reference_date_3
68591 ,xet.reference_date_4
68592 ,xet.event_created_by
68593 ,xet.budgetary_control_flag
68594 , h5.TRX_DOC_SEQUENCE_VALUE source_3
68595 , h1.BILL_CUST_ACCOUNT_ID source_30
68596 , h2.BILL_USES_SITE_USE_ID source_31
68597 , h5.XLA_PARTY_TYPE source_32
68598 , h5.TRX_INVOICE_CURRENCY_CODE source_37
68599 , h5.TRX_DOC_SEQUENCE_CATEGORY source_81
68600 , h5.TRX_DOC_SEQUENCE_ID source_82
68601 FROM xla_events_gt xet
68602 , AR_BILL_TO_CUSTOMERS_S_V h1
68603 , AR_BILL_TO_SITE_USES_S_V h2
68604 , AR_TRANSACTIONS_S_V h5
68605 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
68606 and xet.event_class_code = C_EVENT_CLASS_CODE
68607 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
68608 AND h2.event_id = h1.event_id
68609 AND h5.event_id = h1.event_id
68610
68611 ORDER BY event_id
68612 ;
68613
68614
68615 --
68616 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
68617 IS
68618 SELECT /*+ leading(xet) cardinality(xet,1) */
68619 -- Event Class Code: CHARGEBACK
68620 xet.entity_id
68621 ,xet.legal_entity_id
68622 ,xet.entity_code
68623 ,xet.transaction_number
68624 ,xet.event_id
68625 ,xet.event_class_code
68626 ,xet.event_type_code
68627 ,xet.event_number
68628 ,xet.event_date
68629 ,xet.transaction_date
68630 ,xet.reference_num_1
68631 ,xet.reference_num_2
68632 ,xet.reference_num_3
68633 ,xet.reference_num_4
68634 ,xet.reference_char_1
68635 ,xet.reference_char_2
68636 ,xet.reference_char_3
68637 ,xet.reference_char_4
68638 ,xet.reference_date_1
68639 ,xet.reference_date_2
68640 ,xet.reference_date_3
68641 ,xet.reference_date_4
68642 ,xet.event_created_by
68643 ,xet.budgetary_control_flag
68644 , l3.LINE_NUMBER
68645 , l4.TRX_LINE_DIST_CCID source_19
68646 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_33
68647 , l4.TRX_LINE_DIST_ID source_34
68648 , l4.TRX_DISTRIBUTION_TYPE source_35
68649 , l4.TRX_LINE_DIST_AMT source_36
68650 , l3.TRX_LINE_CUR_CONVERSION_DATE source_38
68651 , l3.TRX_LINE_CUR_CONVERSION_RATE source_39
68652 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_40
68653 , l3.TRX_LINE_ACCTD_AMT source_41
68654 FROM xla_events_gt xet
68655 , AR_CUST_TRX_LINES_BASE_V l3
68656 , AR_CUST_TRX_LINES_L_V l4
68657 WHERE xet.event_id between x_first_event_id and x_last_event_id
68658 and xet.event_date between p_pad_start_date and p_pad_end_date
68659 and xet.event_class_code = C_EVENT_CLASS_CODE
68660 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
68661 AND l4.event_id = l3.event_id
68662 AND l4.line_number = l3.line_number
68663 ;
68664
68665 --
68666 BEGIN
68667 IF g_log_enabled THEN
68668 l_log_module := C_DEFAULT_MODULE||'.EventClass_135';
68669 END IF;
68670 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
68671 trace
68672 (p_msg => 'BEGIN of EventClass_135'
68673 ,p_level => C_LEVEL_PROCEDURE
68674 ,p_module => l_log_module);
68675 END IF;
68676
68677 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68678 trace
68679 (p_msg => 'p_application_id = '||p_application_id||
68680 ' - p_base_ledger_id = '||p_base_ledger_id||
68681 ' - p_target_ledger_id = '||p_target_ledger_id||
68682 ' - p_language = '||p_language||
68683 ' - p_currency_code = '||p_currency_code||
68684 ' - p_sla_ledger_id = '||p_sla_ledger_id
68685 ,p_level => C_LEVEL_STATEMENT
68686 ,p_module => l_log_module);
68687 END IF;
68688 --
68689 -- initialze arrays
68690 --
68691 g_array_event.DELETE;
68692 l_rec_array_event := l_null_rec_array_event;
68693 --
68694 --------------------------------------
68695 -- 4262811 Initialze MPA Line Number
68696 --------------------------------------
68697 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
68698
68699 --
68700
68701 --
68702 OPEN header_cur;
68703 --
68704 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68705 trace
68706 (p_msg => 'SQL - FETCH header_cur'
68707 ,p_level => C_LEVEL_STATEMENT
68708 ,p_module => l_log_module);
68709 END IF;
68710 --
68711 LOOP
68712 FETCH header_cur BULK COLLECT INTO
68713 l_array_entity_id
68714 , l_array_legal_entity_id
68715 , l_array_entity_code
68716 , l_array_transaction_num
68717 , l_array_event_id
68718 , l_array_class_code
68719 , l_array_event_type
68720 , l_array_event_number
68721 , l_array_event_date
68722 , l_array_transaction_date
68723 , l_array_reference_num_1
68724 , l_array_reference_num_2
68725 , l_array_reference_num_3
68729 , l_array_reference_char_3
68726 , l_array_reference_num_4
68727 , l_array_reference_char_1
68728 , l_array_reference_char_2
68730 , l_array_reference_char_4
68731 , l_array_reference_date_1
68732 , l_array_reference_date_2
68733 , l_array_reference_date_3
68734 , l_array_reference_date_4
68735 , l_array_event_created_by
68736 , l_array_budgetary_control_flag
68737 , l_array_source_3
68738 , l_array_source_30
68739 , l_array_source_31
68740 , l_array_source_32
68741 , l_array_source_37
68742 , l_array_source_81
68743 , l_array_source_82
68744 LIMIT l_rows;
68745 --
68746 IF (C_LEVEL_EVENT >= g_log_level) THEN
68747 trace
68748 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
68749 ,p_level => C_LEVEL_EVENT
68750 ,p_module => l_log_module);
68751 END IF;
68752 --
68753 EXIT WHEN l_array_entity_id.COUNT = 0;
68754
68755 -- initialize arrays
68756 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
68757 XLA_AE_LINES_PKG.g_rec_lines := NULL;
68758
68759 --
68760 -- Bug 4458708
68761 --
68762 XLA_AE_LINES_PKG.g_LineNumber := 0;
68763
68764
68765 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
68766 g_last_hdr_idx := l_array_event_id.LAST;
68767 --
68768 -- loop for the headers. Each iteration is for each header extract row
68769 -- fetched in header cursor
68770 --
68771 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
68772
68773 --
68774 -- set event info as cache for other routines to refer event attributes
68775 --
68776 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
68777 (p_application_id => p_application_id
68778 ,p_primary_ledger_id => p_primary_ledger_id
68779 ,p_base_ledger_id => p_base_ledger_id
68780 ,p_target_ledger_id => p_target_ledger_id
68781 ,p_entity_id => l_array_entity_id(hdr_idx)
68782 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
68783 ,p_entity_code => l_array_entity_code(hdr_idx)
68784 ,p_transaction_num => l_array_transaction_num(hdr_idx)
68785 ,p_event_id => l_array_event_id(hdr_idx)
68786 ,p_event_class_code => l_array_class_code(hdr_idx)
68787 ,p_event_type_code => l_array_event_type(hdr_idx)
68788 ,p_event_number => l_array_event_number(hdr_idx)
68789 ,p_event_date => l_array_event_date(hdr_idx)
68790 ,p_transaction_date => l_array_transaction_date(hdr_idx)
68791 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
68792 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
68793 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
68794 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
68795 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
68796 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
68797 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
68798 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
68799 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
68800 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
68801 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
68802 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
68803 ,p_event_created_by => l_array_event_created_by(hdr_idx)
68804 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
68805
68806 --
68807 -- set the status of entry to C_VALID (0)
68808 --
68809 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
68810
68811 --
68812 -- initialize a row for ae header
68813 --
68814 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
68815
68816 l_event_id := l_array_event_id(hdr_idx);
68817
68818 --
68819 -- storing the hdr_idx for event. May be used by line cursor.
68820 --
68821 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
68822
68823 --
68824 -- store sources from header extract. This can be improved to
68825 -- store only those sources from header extract that may be used in lines
68826 --
68827
68828 g_array_event(l_event_id).array_value_num('source_3') := l_array_source_3(hdr_idx);
68829 g_array_event(l_event_id).array_value_num('source_30') := l_array_source_30(hdr_idx);
68830 g_array_event(l_event_id).array_value_num('source_31') := l_array_source_31(hdr_idx);
68831 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
68832 g_array_event(l_event_id).array_value_char('source_37') := l_array_source_37(hdr_idx);
68833 g_array_event(l_event_id).array_value_char('source_81') := l_array_source_81(hdr_idx);
68834 g_array_event(l_event_id).array_value_num('source_82') := l_array_source_82(hdr_idx);
68835
68836 --
68837 -- initilaize the status of ae headers for diffrent balance types
68838 -- the status is initialised to C_NOT_CREATED (2)
68839 --
68840 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
68841 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
68842 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
68843
68844 --
68845 -- call api to validate and store accounting attributes for header
68846 --
68847
68848 ------------------------------------------------------------
68849 -- Accrual Reversal : to get date for Standard Source (NONE)
68850 ------------------------------------------------------------
68851 l_acc_rev_gl_date_source := NULL;
68852
68853 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
68854 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_81');
68855 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
68856 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_82');
68857 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
68858 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_3');
68859 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
68860 l_rec_acct_attrs.array_date_value(4) :=
68861 xla_ae_sources_pkg.GetSystemSourceDate(
68862 p_source_code => 'XLA_EVENT_DATE'
68863 , p_source_type_code => 'Y'
68864 , p_source_application_id => 602
68865 );
68866
68867
68868 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
68869
68870 XLA_AE_HEADER_PKG.SetJeCategoryName;
68871
68872 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
68873 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
68874 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
68875 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
68879 -- No header level analytical criteria
68876 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
68877
68878
68880
68881 --
68882 --accounting attribute enhancement, bug 3612931
68883 --
68884 l_trx_reversal_source := SUBSTR(NULL, 1,30);
68885
68886 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
68887 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
68888
68889 xla_accounting_err_pkg.build_message
68890 (p_appli_s_name => 'XLA'
68891 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
68892 ,p_token_1 => 'ACCT_ATTR_NAME'
68893 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
68894 ,p_token_2 => 'PRODUCT_NAME'
68895 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
68896 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
68897 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
68898 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
68899
68900 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
68901 --
68902 -- following sets the accounting attributes needed to reverse
68903 -- accounting for a distributeion
68904 --
68905 xla_ae_lines_pkg.SetTrxReversalAttrs
68906 (p_event_id => l_event_id
68907 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
68908 ,p_trx_reversal_source => l_trx_reversal_source);
68909
68910 END IF;
68911
68912
68913 ----------------------------------------------------------------
68914 -- 4262811 - update the header statuses to invalid in need be
68915 ----------------------------------------------------------------
68916 --
68917 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
68918
68919
68920 -----------------------------------------------
68921 -- No accrual reversal for the event class/type
68922 -----------------------------------------------
68923 ----------------------------------------------------------------
68924
68925 --
68926 -- this ends the header loop iteration for one bulk fetch
68927 --
68928 END LOOP;
68929
68930 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
68931 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
68932
68933 --
68934 -- insert dummy rows into lines gt table that were created due to
68935 -- transaction reversals
68936 --
68937 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
68938 l_result := XLA_AE_LINES_PKG.InsertLines;
68939 END IF;
68940
68941 --
68942 -- reset the temp_line_num for each set of events fetched from header
68943 -- cursor rather than doing it for each new event in line cursor
68944 -- Bug 3939231
68945 --
68946 xla_ae_lines_pkg.g_temp_line_num := 0;
68947
68948
68949
68950 --
68951 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
68952 --
68953 --
68954 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
68955
68956 trace
68957 (p_msg => 'SQL - FETCH line_cur'
68958 ,p_level => C_LEVEL_STATEMENT
68959 ,p_module => l_log_module);
68960
68961 END IF;
68962 --
68963 --
68964 LOOP
68965 --
68966 FETCH line_cur BULK COLLECT INTO
68967 l_array_entity_id
68968 , l_array_legal_entity_id
68969 , l_array_entity_code
68970 , l_array_transaction_num
68971 , l_array_event_id
68972 , l_array_class_code
68973 , l_array_event_type
68974 , l_array_event_number
68975 , l_array_event_date
68976 , l_array_transaction_date
68977 , l_array_reference_num_1
68978 , l_array_reference_num_2
68979 , l_array_reference_num_3
68980 , l_array_reference_num_4
68981 , l_array_reference_char_1
68982 , l_array_reference_char_2
68983 , l_array_reference_char_3
68984 , l_array_reference_char_4
68985 , l_array_reference_date_1
68986 , l_array_reference_date_2
68987 , l_array_reference_date_3
68988 , l_array_reference_date_4
68989 , l_array_event_created_by
68990 , l_array_budgetary_control_flag
68991 , l_array_extract_line_num
68992 , l_array_source_19
68993 , l_array_source_33
68994 , l_array_source_34
68995 , l_array_source_35
68996 , l_array_source_36
68997 , l_array_source_38
68998 , l_array_source_39
68999 , l_array_source_40
69000 , l_array_source_41
69001 LIMIT l_rows;
69002
69003 --
69004 IF (C_LEVEL_EVENT >= g_log_level) THEN
69005 trace
69006 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
69007 ,p_level => C_LEVEL_EVENT
69008 ,p_module => l_log_module);
69009 END IF;
69010 --
69011 EXIT WHEN l_array_entity_id.count = 0;
69012
69013 XLA_AE_LINES_PKG.g_rec_lines := null;
69014
69015 --
69016 -- Bug 4458708
69017 --
69018 XLA_AE_LINES_PKG.g_LineNumber := 0;
69019 --
69020 --
69021
69022 FOR Idx IN 1..l_array_event_id.count LOOP
69023 --
69024 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
69025 --
69026 l_event_id := l_array_event_id(idx); -- 5648433
69027
69028 --
69029 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
69030 --
69031
69032 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
69033 (g_array_event(l_event_id).array_value_num('header_index'))
69034 ,'N'
69035 ) <> 'Y'
69036 THEN
69037 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69038 trace
69039 (p_msg => 'Trancaction revesal option is not Y '
69040 ,p_level => C_LEVEL_STATEMENT
69041 ,p_module => l_log_module);
69042 END IF;
69043
69044 --
69045 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
69046 --
69047 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
69048 --
69049 -- set event info as cache for other routines to refer event attributes
69050 --
69051
69052 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
69053 l_previous_event_id := l_event_id;
69054
69055 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
69056 (p_application_id => p_application_id
69057 ,p_primary_ledger_id => p_primary_ledger_id
69058 ,p_base_ledger_id => p_base_ledger_id
69059 ,p_target_ledger_id => p_target_ledger_id
69060 ,p_entity_id => l_array_entity_id(Idx)
69061 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
69062 ,p_entity_code => l_array_entity_code(Idx)
69063 ,p_transaction_num => l_array_transaction_num(Idx)
69064 ,p_event_id => l_array_event_id(Idx)
69065 ,p_event_class_code => l_array_class_code(Idx)
69066 ,p_event_type_code => l_array_event_type(Idx)
69067 ,p_event_number => l_array_event_number(Idx)
69068 ,p_event_date => l_array_event_date(Idx)
69069 ,p_transaction_date => l_array_transaction_date(Idx)
69070 ,p_reference_num_1 => l_array_reference_num_1(Idx)
69071 ,p_reference_num_2 => l_array_reference_num_2(Idx)
69072 ,p_reference_num_3 => l_array_reference_num_3(Idx)
69073 ,p_reference_num_4 => l_array_reference_num_4(Idx)
69074 ,p_reference_char_1 => l_array_reference_char_1(Idx)
69075 ,p_reference_char_2 => l_array_reference_char_2(Idx)
69076 ,p_reference_char_3 => l_array_reference_char_3(Idx)
69077 ,p_reference_char_4 => l_array_reference_char_4(Idx)
69078 ,p_reference_date_1 => l_array_reference_date_1(Idx)
69079 ,p_reference_date_2 => l_array_reference_date_2(Idx)
69080 ,p_reference_date_3 => l_array_reference_date_3(Idx)
69081 ,p_reference_date_4 => l_array_reference_date_4(Idx)
69082 ,p_event_created_by => l_array_event_created_by(Idx)
69083 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
69084 --
69085 END IF;
69086
69087
69088
69089 --
69090 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
69091
69092 l_acct_reversal_source := SUBSTR(NULL, 1,30);
69093
69094 IF l_continue_with_lines THEN
69095 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
69096 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
69097
69098 xla_accounting_err_pkg.build_message
69099 (p_appli_s_name => 'XLA'
69100 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
69101 ,p_token_1 => 'LINE_NUMBER'
69102 ,p_value_1 => l_array_extract_line_num(Idx)
69103 ,p_token_2 => 'PRODUCT_NAME'
69104 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
69108
69105 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
69106 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
69107 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
69109 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
69110 --
69111 -- following sets the accounting attributes needed to reverse
69112 -- accounting for a distributeion
69113 --
69114
69115 --
69116 -- 5217187
69117 --
69118 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
69119 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
69120 g_array_event(l_event_id).array_value_num('header_index'));
69121 --
69122 --
69123
69124 -- No reversal code generated
69125
69126 xla_ae_lines_pkg.SetAcctReversalAttrs
69127 (p_event_id => l_event_id
69128 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
69129 ,p_calculate_acctd_flag => l_calculate_acctd_flag
69130 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
69131 END IF;
69132
69133 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
69134 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
69135
69136 --
69137 AcctLineType_37 (
69138 p_application_id => p_application_id
69139 ,p_event_id => l_event_id
69140 ,p_calculate_acctd_flag => l_calculate_acctd_flag
69141 ,p_calculate_g_l_flag => l_calculate_g_l_flag
69142 ,p_actual_flag => l_actual_flag
69143 ,p_balance_type_code => l_balance_type_code
69144 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
69145
69146 , p_source_19 => l_array_source_19(Idx)
69147 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
69148 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
69149 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
69150 , p_source_33 => l_array_source_33(Idx)
69151 , p_source_34 => l_array_source_34(Idx)
69152 , p_source_35 => l_array_source_35(Idx)
69153 , p_source_36 => l_array_source_36(Idx)
69154 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
69155 , p_source_38 => l_array_source_38(Idx)
69156 , p_source_39 => l_array_source_39(Idx)
69157 , p_source_40 => l_array_source_40(Idx)
69158 , p_source_41 => l_array_source_41(Idx)
69159 );
69160 If(l_balance_type_code = 'A') THEN
69161 l_actual_gain_loss_ref := l_gain_or_loss_ref;
69162 END IF;
69163
69164 --
69165
69166
69167 --
69168 AcctLineType_38 (
69169 p_application_id => p_application_id
69170 ,p_event_id => l_event_id
69171 ,p_calculate_acctd_flag => l_calculate_acctd_flag
69172 ,p_calculate_g_l_flag => l_calculate_g_l_flag
69173 ,p_actual_flag => l_actual_flag
69174 ,p_balance_type_code => l_balance_type_code
69175 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
69176
69177 , p_source_19 => l_array_source_19(Idx)
69178 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
69179 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
69180 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
69181 , p_source_33 => l_array_source_33(Idx)
69182 , p_source_34 => l_array_source_34(Idx)
69183 , p_source_35 => l_array_source_35(Idx)
69184 , p_source_36 => l_array_source_36(Idx)
69185 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
69186 , p_source_38 => l_array_source_38(Idx)
69187 , p_source_39 => l_array_source_39(Idx)
69188 , p_source_40 => l_array_source_40(Idx)
69189 , p_source_41 => l_array_source_41(Idx)
69190 );
69191 If(l_balance_type_code = 'A') THEN
69192 l_actual_gain_loss_ref := l_gain_or_loss_ref;
69193 END IF;
69194
69195 --
69196
69197 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
69198 -- or secondary ledger that has different currency with primary
69199 -- or alc that is calculated by sla
69200 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
69201 (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'))
69202
69203 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
69204 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
69205 AND (l_actual_flag = 'A')) THEN
69206 XLA_AE_LINES_PKG.CreateGainOrLossLines(
69207 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
69208 ,p_application_id => p_application_id
69209 ,p_amb_context_code => 'DEFAULT'
69210 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
69211 ,p_event_class_code => C_EVENT_CLASS_CODE
69212 ,p_event_type_code => C_EVENT_TYPE_CODE
69213
69214 ,p_gain_ccid => -1
69215 ,p_loss_ccid => -1
69216
69217 ,p_actual_flag => l_actual_flag
69218 ,p_enc_flag => null
69219 ,p_actual_g_l_ref => l_actual_gain_loss_ref
69220 ,p_enc_g_l_ref => null
69221 );
69222 END IF;
69223 END IF;
69224 END IF;
69225
69226 ELSE
69227 --
69228 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
69229 --
69230 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69231 trace
69232 (p_msg => 'Trancaction revesal option is Y'
69233 ,p_level => C_LEVEL_STATEMENT
69234 ,p_module => l_log_module);
69235 END IF;
69236 END IF;
69237
69238 END LOOP;
69239 l_result := XLA_AE_LINES_PKG.InsertLines ;
69240 end loop;
69241 close line_cur;
69242
69243
69244 --
69245 -- insert headers into xla_ae_headers_gt table
69246 --
69247 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
69248
69249 -- insert into errors table here.
69250
69251 END LOOP;
69252
69253 --
69254 -- 4865292
69255 --
69256 -- Compare g_hdr_extract_count with event count in
69257 -- CreateHeadersAndLines.
69258 --
69259 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
69260
69261 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69262 trace (p_msg => '# rows extracted from header extract objects '
69263 || ' (running total): '
69264 || g_hdr_extract_count
69265 ,p_level => C_LEVEL_STATEMENT
69266 ,p_module => l_log_module);
69267 END IF;
69268
69269 CLOSE header_cur;
69270 --
69271
69272 --
69273 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
69274 trace
69275 (p_msg => 'END of EventClass_135'
69276 ,p_level => C_LEVEL_PROCEDURE
69277 ,p_module => l_log_module);
69278 END IF;
69279 --
69280 RETURN l_result;
69281 EXCEPTION
69282 WHEN xla_exceptions_pkg.application_exception THEN
69283
69284 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
69285
69286
69287 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
69288
69289 RAISE;
69290
69291 WHEN NO_DATA_FOUND THEN
69292
69293 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
69294 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
69295
69296 FOR header_record IN header_cur
69297 LOOP
69298 l_array_header_events(header_record.event_id) := header_record.event_id;
69299 END LOOP;
69300
69301 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
69302 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
69303
69304 fnd_file.put_line(fnd_file.LOG, ' ');
69305 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
69306 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
69307 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
69308
69309 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
69310 LOOP
69311 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
69312 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
69313 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
69314 END IF;
69315 END LOOP;
69316
69317 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
69318 fnd_file.put_line(fnd_file.LOG, ' ');
69319
69320
69321 xla_exceptions_pkg.raise_message
69322 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_135');
69323
69324
69325 WHEN OTHERS THEN
69326 xla_exceptions_pkg.raise_message
69327 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_135');
69328 END EventClass_135;
69329 --
69330
69331 ---------------------------------------
69332 --
69333 -- PRIVATE PROCEDURE
69334 -- insert_sources_136
69335 --
69336 ----------------------------------------
69337 --
69338 PROCEDURE insert_sources_136(
69339 p_target_ledger_id IN NUMBER
69340 , p_language IN VARCHAR2
69341 , p_sla_ledger_id IN NUMBER
69342 , p_pad_start_date IN DATE
69343 , p_pad_end_date IN DATE
69344 )
69345 IS
69346
69347 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO_ALL';
69348 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO';
69349 p_apps_owner VARCHAR2(30);
69350 l_log_module VARCHAR2(240);
69351 BEGIN
69352 IF g_log_enabled THEN
69353 l_log_module := C_DEFAULT_MODULE||'.insert_sources_136';
69354 END IF;
69355 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
69356
69357 trace
69358 (p_msg => 'BEGIN of insert_sources_136'
69359 ,p_level => C_LEVEL_PROCEDURE
69360 ,p_module => l_log_module);
69361
69362 END IF;
69363
69364 -- select APPS owner
69365 SELECT oracle_username
69369 ;
69366 INTO p_apps_owner
69367 FROM fnd_oracle_userid
69368 WHERE read_only_flag = 'U'
69370
69371 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69372 trace
69373 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
69374 ' - p_language = '||p_language||
69375 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
69376 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
69377 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
69378 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
69379 ,p_level => C_LEVEL_STATEMENT
69380 ,p_module => l_log_module);
69381 END IF;
69382
69383
69384 --
69385 INSERT INTO xla_diag_sources --hdr2
69386 (
69387 event_id
69388 , ledger_id
69389 , sla_ledger_id
69390 , description_language
69391 , object_name
69392 , object_type_code
69393 , line_number
69394 , source_application_id
69395 , source_type_code
69396 , source_code
69397 , source_value
69398 , source_meaning
69399 , created_by
69400 , creation_date
69401 , last_update_date
69402 , last_updated_by
69403 , last_update_login
69404 , program_update_date
69405 , program_application_id
69406 , program_id
69407 , request_id
69408 )
69409 SELECT
69410 event_id
69411 , p_target_ledger_id
69412 , p_sla_ledger_id
69413 , p_language
69414 , object_name
69415 , object_type_code
69416 , line_number
69417 , source_application_id
69418 , source_type_code
69419 , source_code
69420 , SUBSTR(source_value ,1,1996)
69421 , SUBSTR(source_meaning ,1,200)
69422 , xla_environment_pkg.g_Usr_Id
69423 , TRUNC(SYSDATE)
69424 , TRUNC(SYSDATE)
69425 , xla_environment_pkg.g_Usr_Id
69426 , xla_environment_pkg.g_Login_Id
69427 , TRUNC(SYSDATE)
69428 , xla_environment_pkg.g_Prog_Appl_Id
69429 , xla_environment_pkg.g_Prog_Id
69430 , xla_environment_pkg.g_Req_Id
69431 FROM (
69432 SELECT xet.event_id event_id
69433 , 0 line_number
69434 , CASE r
69435 WHEN 1 THEN 'AR_SYSTEM_PARAM_H_V'
69436 WHEN 2 THEN 'AR_SYSTEM_PARAM_H_V'
69437 WHEN 3 THEN 'AR_CREDIT_MEMO_H_V'
69438 WHEN 4 THEN 'AR_CREDIT_MEMO_H_V'
69439 WHEN 5 THEN 'AR_CM_BILL_TO_CUST_H_V'
69440 WHEN 6 THEN 'AR_CM_BILL_SITE_USES_H_V'
69441
69442 ELSE null
69443 END object_name
69444 , CASE r
69445 WHEN 1 THEN 'HEADER'
69446 WHEN 2 THEN 'HEADER'
69447 WHEN 3 THEN 'HEADER'
69448 WHEN 4 THEN 'HEADER'
69449 WHEN 5 THEN 'HEADER'
69450 WHEN 6 THEN 'HEADER'
69451
69452 ELSE null
69453 END object_type_code
69454 , CASE r
69455 WHEN 1 THEN '222'
69456 WHEN 2 THEN '222'
69457 WHEN 3 THEN '222'
69458 WHEN 4 THEN '222'
69459 WHEN 5 THEN '222'
69460 WHEN 6 THEN '222'
69461
69462 ELSE null
69463 END source_application_id
69464 , 'S' source_type_code
69465 , CASE r
69466 WHEN 1 THEN 'CODE_COMBINATION_ID_GAIN'
69467 WHEN 2 THEN 'CODE_COMBINATION_ID_LOSS'
69468 WHEN 3 THEN 'XLA_PARTY_TYPE'
69469 WHEN 4 THEN 'CM_INVOICE_CURRENCY_CODE'
69470 WHEN 5 THEN 'CM_BILL_CUST_ACCOUNT_ID'
69471 WHEN 6 THEN 'CM_BILL_USES_SITE_USE_ID'
69472
69473 ELSE null
69474 END source_code
69475 , CASE r
69476 WHEN 1 THEN TO_CHAR(h8.CODE_COMBINATION_ID_GAIN)
69477 WHEN 2 THEN TO_CHAR(h8.CODE_COMBINATION_ID_LOSS)
69478 WHEN 3 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
69479 WHEN 4 THEN TO_CHAR(h5.CM_INVOICE_CURRENCY_CODE)
69480 WHEN 5 THEN TO_CHAR(h2.CM_BILL_CUST_ACCOUNT_ID)
69481 WHEN 6 THEN TO_CHAR(h1.CM_BILL_USES_SITE_USE_ID)
69482
69483 ELSE null
69484 END source_value
69485 , null source_meaning
69486 FROM xla_events_gt xet
69487 , AR_CM_BILL_SITE_USES_H_V h1
69488 , AR_CM_BILL_TO_CUST_H_V h2
69489 , AR_CREDIT_MEMO_H_V h5
69490 , AR_SYSTEM_PARAM_H_V h8
69491 ,(select rownum r from all_objects where rownum <= 6 and owner = p_apps_owner)
69492 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
69493 AND xet.event_class_code = C_EVENT_CLASS_CODE
69494 AND h1.event_id = xet.event_id
69495 AND h2.event_id = h1.event_id
69496 AND h5.event_id = h1.event_id
69497 AND h8.event_id (+) = h1.event_id
69498
69499 )
69500 ;
69501 --
69502 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69503
69504 trace
69505 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
69506 ,p_level => C_LEVEL_STATEMENT
69507 ,p_module => l_log_module);
69508
69509 END IF;
69510 --
69511
69512
69513
69514 --
69515 INSERT INTO xla_diag_sources --line2
69516 (
69517 event_id
69518 , ledger_id
69519 , sla_ledger_id
69520 , description_language
69521 , object_name
69522 , object_type_code
69523 , line_number
69524 , source_application_id
69525 , source_type_code
69526 , source_code
69527 , source_value
69528 , source_meaning
69529 , created_by
69530 , creation_date
69531 , last_update_date
69532 , last_updated_by
69533 , last_update_login
69534 , program_update_date
69535 , program_application_id
69536 , program_id
69537 , request_id
69538 )
69539 SELECT event_id
69540 , p_target_ledger_id
69541 , p_sla_ledger_id
69542 , p_language
69543 , object_name
69544 , object_type_code
69545 , line_number
69546 , source_application_id
69547 , source_type_code
69548 , source_code
69549 , SUBSTR(source_value,1,1996)
69550 , SUBSTR(source_meaning ,1,200)
69551 , xla_environment_pkg.g_Usr_Id
69552 , TRUNC(SYSDATE)
69553 , TRUNC(SYSDATE)
69554 , xla_environment_pkg.g_Usr_Id
69555 , xla_environment_pkg.g_Login_Id
69556 , TRUNC(SYSDATE)
69557 , xla_environment_pkg.g_Prog_Appl_Id
69558 , xla_environment_pkg.g_Prog_Id
69559 , xla_environment_pkg.g_Req_Id
69560 FROM (
69561 SELECT xet.event_id event_id
69562 , l3.line_number line_number
69563 , CASE r
69564 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
69565 WHEN 2 THEN 'AR_TRANSACTIONS_S_V'
69566 WHEN 3 THEN 'AR_TRANSACTIONS_S_V'
69567 WHEN 4 THEN 'AR_CM_LINES_L_V'
69568 WHEN 5 THEN 'AR_DISTRIBUTIONS_L_V'
69569 WHEN 6 THEN 'AR_DISTRIBUTIONS_L_V'
69570 WHEN 7 THEN 'AR_RECEIVABLES_TRX_ACT_S_V'
69571 WHEN 8 THEN 'AR_DISTRIBUTIONS_L_V'
69572 WHEN 9 THEN 'AR_CM_LINES_BASE_V'
69573 WHEN 10 THEN 'AR_CM_LINES_BASE_V'
69574 WHEN 11 THEN 'AR_CM_LINES_BASE_V'
69575 WHEN 12 THEN 'AR_CM_LINES_BASE_V'
69576 WHEN 13 THEN 'AR_CM_LINES_BASE_V'
69577 WHEN 14 THEN 'AR_CM_LINES_BASE_V'
69578 WHEN 15 THEN 'AR_CM_LINES_BASE_V'
69579 WHEN 16 THEN 'AR_CM_LINES_L_V'
69580 WHEN 17 THEN 'AR_CM_LINES_L_V'
69581 WHEN 18 THEN 'AR_CM_LINES_L_V'
69582
69583 ELSE null
69584 END object_name
69585 , CASE r
69586 WHEN 1 THEN 'LINE'
69587 WHEN 2 THEN 'LINE'
69588 WHEN 3 THEN 'LINE'
69589 WHEN 4 THEN 'LINE'
69590 WHEN 5 THEN 'LINE'
69591 WHEN 6 THEN 'LINE'
69592 WHEN 7 THEN 'LINE'
69593 WHEN 8 THEN 'LINE'
69594 WHEN 9 THEN 'LINE'
69595 WHEN 10 THEN 'LINE'
69596 WHEN 11 THEN 'LINE'
69597 WHEN 12 THEN 'LINE'
69598 WHEN 13 THEN 'LINE'
69599 WHEN 14 THEN 'LINE'
69600 WHEN 15 THEN 'LINE'
69601 WHEN 16 THEN 'LINE'
69602 WHEN 17 THEN 'LINE'
69603 WHEN 18 THEN 'LINE'
69604
69605 ELSE null
69606 END object_type_code
69610 WHEN 3 THEN '222'
69607 , CASE r
69608 WHEN 1 THEN '222'
69609 WHEN 2 THEN '222'
69611 WHEN 4 THEN '222'
69612 WHEN 5 THEN '222'
69613 WHEN 6 THEN '222'
69614 WHEN 7 THEN '222'
69615 WHEN 8 THEN '222'
69616 WHEN 9 THEN '222'
69617 WHEN 10 THEN '222'
69618 WHEN 11 THEN '222'
69619 WHEN 12 THEN '222'
69620 WHEN 13 THEN '222'
69621 WHEN 14 THEN '222'
69622 WHEN 15 THEN '222'
69623 WHEN 16 THEN '222'
69624 WHEN 17 THEN '222'
69625 WHEN 18 THEN '222'
69626
69627 ELSE null
69628 END source_application_id
69629 , 'S' source_type_code
69630 , CASE r
69631 WHEN 1 THEN 'TRX_TYPE_NAME'
69632 WHEN 2 THEN 'TRX_NUMBER'
69633 WHEN 3 THEN 'TRX_DOC_SEQUENCE_VALUE'
69634 WHEN 4 THEN 'CM_LINE_DIST_CCID'
69635 WHEN 5 THEN 'DIST_CODE_COMBINATION_ID'
69636 WHEN 6 THEN 'DIST_SOURCE_TYPE'
69637 WHEN 7 THEN 'REC_ACT_TYPE'
69638 WHEN 8 THEN 'DIST_ENT_AMT'
69639 WHEN 9 THEN 'CM_DIST_IDENTIFER'
69640 WHEN 10 THEN 'CM_DIST_TYPE'
69641 WHEN 11 THEN 'CM_LINE_CUR_CONVERSION_DATE'
69642 WHEN 12 THEN 'CM_LINE_CUR_CONVERSION_RATE'
69643 WHEN 13 THEN 'CM_LINE_CUR_CONVERSION_TYPE'
69644 WHEN 14 THEN 'GAIN_LOSS_REF'
69645 WHEN 15 THEN 'CM_LINE_ACCTD_AMT'
69646 WHEN 16 THEN 'CM_TAX_LINE_ID'
69647 WHEN 17 THEN 'CM_LINE_DIST_ACCOUNT_CLASS'
69648 WHEN 18 THEN 'CM_LINE_DIST_AMT'
69649
69650 ELSE null
69651 END source_code
69652 , CASE r
69653 WHEN 1 THEN TO_CHAR(l9.TRX_TYPE_NAME)
69654 WHEN 2 THEN TO_CHAR(l9.TRX_NUMBER)
69655 WHEN 3 THEN TO_CHAR(l9.TRX_DOC_SEQUENCE_VALUE)
69656 WHEN 4 THEN TO_CHAR(l4.CM_LINE_DIST_CCID)
69657 WHEN 5 THEN TO_CHAR(l6.DIST_CODE_COMBINATION_ID)
69658 WHEN 6 THEN TO_CHAR(l6.DIST_SOURCE_TYPE)
69659 WHEN 7 THEN TO_CHAR(l7.REC_ACT_TYPE)
69660 WHEN 8 THEN TO_CHAR(l6.DIST_ENT_AMT)
69661 WHEN 9 THEN TO_CHAR(l3.CM_DIST_IDENTIFER)
69662 WHEN 10 THEN TO_CHAR(l3.CM_DIST_TYPE)
69663 WHEN 11 THEN TO_CHAR(l3.CM_LINE_CUR_CONVERSION_DATE)
69664 WHEN 12 THEN TO_CHAR(l3.CM_LINE_CUR_CONVERSION_RATE)
69665 WHEN 13 THEN TO_CHAR(l3.CM_LINE_CUR_CONVERSION_TYPE)
69666 WHEN 14 THEN TO_CHAR(l3.GAIN_LOSS_REF)
69667 WHEN 15 THEN TO_CHAR(l3.CM_LINE_ACCTD_AMT)
69668 WHEN 16 THEN TO_CHAR(l4.CM_TAX_LINE_ID)
69669 WHEN 17 THEN TO_CHAR(l4.CM_LINE_DIST_ACCOUNT_CLASS)
69670 WHEN 18 THEN TO_CHAR(l4.CM_LINE_DIST_AMT)
69671
69672 ELSE null
69673 END source_value
69674 , null source_meaning
69675 FROM xla_events_gt xet
69676 , AR_CM_LINES_BASE_V l3
69677 , AR_CM_LINES_L_V l4
69678 , AR_DISTRIBUTIONS_L_V l6
69679 , AR_RECEIVABLES_TRX_ACT_S_V l7
69680 , AR_TRANSACTIONS_S_V l9
69681 , (select rownum r from all_objects where rownum <= 18 and owner = p_apps_owner)
69682 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
69683 AND xet.event_class_code = C_EVENT_CLASS_CODE
69684 AND l3.event_id = xet.event_id
69685 AND l4.event_id (+) = l3.event_id
69686 AND l4.line_number (+) = l3.line_number
69687 AND l6.event_id (+) = l3.event_id
69688 AND l6.line_number (+) = l3.line_number
69689 AND l7.event_id (+) = l3.event_id
69690 AND l7.line_number (+) = l3.line_number
69691 AND l9.event_id (+) = l3.event_id
69692 AND l9.line_number (+) = l3.line_number
69693
69694 )
69695 ;
69696 --
69697 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
69698
69699 trace
69700 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
69701 ,p_level => C_LEVEL_STATEMENT
69702 ,p_module => l_log_module);
69703
69704 END IF;
69705
69706
69707 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
69708 trace
69709 (p_msg => 'END of insert_sources_136'
69710 ,p_level => C_LEVEL_PROCEDURE
69711 ,p_module => l_log_module);
69712 END IF;
69713 EXCEPTION
69714 WHEN xla_exceptions_pkg.application_exception THEN
69715 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
69716 trace
69717 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
69718 ,p_level => C_LEVEL_EXCEPTION
69719 ,p_module => l_log_module);
69720 END IF;
69721 RAISE;
69722 WHEN OTHERS THEN
69723 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
69724 trace
69725 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
69726 ,p_level => C_LEVEL_EXCEPTION
69727 ,p_module => l_log_module);
69728 END IF;
69729 xla_exceptions_pkg.raise_message
69730 (p_location => 'XLA_00222_AAD_S_000005_PKG.insert_sources_136');
69731 END insert_sources_136;
69732 --
69733
69734 ---------------------------------------
69735 --
69736 -- PRIVATE FUNCTION
69737 -- EventClass_136
69738 --
69739 ----------------------------------------
69740 --
69741 FUNCTION EventClass_136
69742 (p_application_id IN NUMBER
69743 ,p_base_ledger_id IN NUMBER
69744 ,p_target_ledger_id IN NUMBER
69745 ,p_language IN VARCHAR2
69746 ,p_currency_code IN VARCHAR2
69747 ,p_sla_ledger_id IN NUMBER
69748 ,p_pad_start_date IN DATE
69749 ,p_pad_end_date IN DATE
69750 ,p_primary_ledger_id IN NUMBER)
69751 RETURN BOOLEAN IS
69752 --
69753 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO_ALL';
69754 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'CREDIT_MEMO';
69755
69756 l_calculate_acctd_flag VARCHAR2(1) :='N';
69757 l_calculate_g_l_flag VARCHAR2(1) :='Y';
69758 --
69759 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69760 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69761 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
69762 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
69763 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69764 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
69765 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
69766 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69767 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69768 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69769 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69770 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69771 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69772 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
69773 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
69774 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
69775 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
69776 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
69777 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69778 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69779 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69780 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
69781 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
69782 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
69783 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
69784 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
69785
69786 l_event_id NUMBER;
69787 l_previous_event_id NUMBER;
69788 l_first_event_id NUMBER;
69789 l_last_event_id NUMBER;
69790
69791 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
69792 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
69793 --
69794 --
69795 l_result BOOLEAN := TRUE;
69796 l_rows NUMBER := 1000;
69797 l_event_type_name VARCHAR2(80) := 'All';
69798 l_event_class_name VARCHAR2(80) := 'Credit Memo';
69799 l_description VARCHAR2(4000);
69800 l_transaction_reversal NUMBER;
69801 l_ae_header_id NUMBER;
69802 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
69803 l_log_module VARCHAR2(240);
69804 --
69805 l_acct_reversal_source VARCHAR2(30);
69806 l_trx_reversal_source VARCHAR2(30);
69807
69808 l_continue_with_lines BOOLEAN := TRUE;
69809 --
69810 l_acc_rev_gl_date_source DATE; -- 4262811
69811 --
69812 type t_array_event_id is table of number index by binary_integer;
69813
69814 l_rec_array_event t_rec_array_event;
69815 l_null_rec_array_event t_rec_array_event;
69816 l_array_ae_header_id xla_number_array_type;
69817 l_actual_flag VARCHAR2(1) := NULL;
69818 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
69819 l_balance_type_code VARCHAR2(1) :=NULL;
69820 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
69821
69827 TYPE t_array_source_8 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_LOSS%TYPE INDEX BY BINARY_INTEGER;
69822 --
69823 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
69824 --
69825
69826 TYPE t_array_source_7 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_GAIN%TYPE INDEX BY BINARY_INTEGER;
69828 TYPE t_array_source_32 IS TABLE OF AR_CREDIT_MEMO_H_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
69829 TYPE t_array_source_44 IS TABLE OF AR_CREDIT_MEMO_H_V.CM_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
69830 TYPE t_array_source_50 IS TABLE OF AR_CM_BILL_TO_CUST_H_V.CM_BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
69831 TYPE t_array_source_51 IS TABLE OF AR_CM_BILL_SITE_USES_H_V.CM_BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
69832
69833 TYPE t_array_source_1 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_TYPE_NAME%TYPE INDEX BY BINARY_INTEGER;
69834 TYPE t_array_source_2 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_NUMBER%TYPE INDEX BY BINARY_INTEGER;
69835 TYPE t_array_source_3 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
69836 TYPE t_array_source_4 IS TABLE OF AR_CM_LINES_L_V.CM_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
69837 TYPE t_array_source_5 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
69838 TYPE t_array_source_20 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
69839 TYPE t_array_source_21 IS TABLE OF AR_RECEIVABLES_TRX_ACT_S_V.REC_ACT_TYPE%TYPE INDEX BY BINARY_INTEGER;
69840 TYPE t_array_source_24 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
69841 TYPE t_array_source_42 IS TABLE OF AR_CM_LINES_BASE_V.CM_DIST_IDENTIFER%TYPE INDEX BY BINARY_INTEGER;
69842 TYPE t_array_source_43 IS TABLE OF AR_CM_LINES_BASE_V.CM_DIST_TYPE%TYPE INDEX BY BINARY_INTEGER;
69843 TYPE t_array_source_45 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
69844 TYPE t_array_source_46 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
69845 TYPE t_array_source_47 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
69846 TYPE t_array_source_48 IS TABLE OF AR_CM_LINES_BASE_V.GAIN_LOSS_REF%TYPE INDEX BY BINARY_INTEGER;
69847 TYPE t_array_source_49 IS TABLE OF AR_CM_LINES_BASE_V.CM_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
69848 TYPE t_array_source_52 IS TABLE OF AR_CM_LINES_L_V.CM_TAX_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
69849 TYPE t_array_source_53 IS TABLE OF AR_CM_LINES_L_V.CM_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
69850 TYPE t_array_source_54 IS TABLE OF AR_CM_LINES_L_V.CM_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
69851
69852 l_array_source_7 t_array_source_7;
69853 l_array_source_8 t_array_source_8;
69854 l_array_source_32 t_array_source_32;
69855 l_array_source_44 t_array_source_44;
69856 l_array_source_50 t_array_source_50;
69857 l_array_source_51 t_array_source_51;
69858
69859 l_array_source_1 t_array_source_1;
69860 l_array_source_2 t_array_source_2;
69861 l_array_source_3 t_array_source_3;
69862 l_array_source_4 t_array_source_4;
69863 l_array_source_5 t_array_source_5;
69864 l_array_source_20 t_array_source_20;
69865 l_array_source_21 t_array_source_21;
69866 l_array_source_24 t_array_source_24;
69867 l_array_source_42 t_array_source_42;
69868 l_array_source_43 t_array_source_43;
69869 l_array_source_45 t_array_source_45;
69870 l_array_source_46 t_array_source_46;
69871 l_array_source_47 t_array_source_47;
69872 l_array_source_48 t_array_source_48;
69873 l_array_source_49 t_array_source_49;
69874 l_array_source_52 t_array_source_52;
69875 l_array_source_53 t_array_source_53;
69876 l_array_source_54 t_array_source_54;
69877
69878 --
69879 CURSOR header_cur
69880 IS
69881 SELECT /*+ leading(xet) cardinality(xet,1) */
69882 -- Event Class Code: CREDIT_MEMO
69883 xet.entity_id
69884 ,xet.legal_entity_id
69885 ,xet.entity_code
69886 ,xet.transaction_number
69887 ,xet.event_id
69888 ,xet.event_class_code
69889 ,xet.event_type_code
69890 ,xet.event_number
69891 ,xet.event_date
69892 ,xet.transaction_date
69893 ,xet.reference_num_1
69894 ,xet.reference_num_2
69895 ,xet.reference_num_3
69896 ,xet.reference_num_4
69897 ,xet.reference_char_1
69898 ,xet.reference_char_2
69899 ,xet.reference_char_3
69900 ,xet.reference_char_4
69901 ,xet.reference_date_1
69902 ,xet.reference_date_2
69903 ,xet.reference_date_3
69904 ,xet.reference_date_4
69905 ,xet.event_created_by
69906 ,xet.budgetary_control_flag
69907 , h8.CODE_COMBINATION_ID_GAIN source_7
69908 , h8.CODE_COMBINATION_ID_LOSS source_8
69909 , h5.XLA_PARTY_TYPE source_32
69910 , h5.CM_INVOICE_CURRENCY_CODE source_44
69911 , h2.CM_BILL_CUST_ACCOUNT_ID source_50
69912 , h1.CM_BILL_USES_SITE_USE_ID source_51
69913 FROM xla_events_gt xet
69914 , AR_CM_BILL_SITE_USES_H_V h1
69915 , AR_CM_BILL_TO_CUST_H_V h2
69916 , AR_CREDIT_MEMO_H_V h5
69917 , AR_SYSTEM_PARAM_H_V h8
69918 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
69919 and xet.event_class_code = C_EVENT_CLASS_CODE
69920 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
69921 AND h2.event_id = h1.event_id
69922 AND h5.event_id = h1.event_id
69923 AND h8.event_id (+) = h1.event_id
69924
69925 ORDER BY event_id
69926 ;
69927
69928
69929 --
69930 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
69931 IS
69932 SELECT /*+ leading(xet) cardinality(xet,1) */
69933 -- Event Class Code: CREDIT_MEMO
69934 xet.entity_id
69935 ,xet.legal_entity_id
69936 ,xet.entity_code
69937 ,xet.transaction_number
69938 ,xet.event_id
69939 ,xet.event_class_code
69940 ,xet.event_type_code
69941 ,xet.event_number
69942 ,xet.event_date
69943 ,xet.transaction_date
69944 ,xet.reference_num_1
69945 ,xet.reference_num_2
69946 ,xet.reference_num_3
69947 ,xet.reference_num_4
69948 ,xet.reference_char_1
69949 ,xet.reference_char_2
69950 ,xet.reference_char_3
69951 ,xet.reference_char_4
69952 ,xet.reference_date_1
69953 ,xet.reference_date_2
69954 ,xet.reference_date_3
69955 ,xet.reference_date_4
69956 ,xet.event_created_by
69957 ,xet.budgetary_control_flag
69958 , l3.LINE_NUMBER
69959 , l9.TRX_TYPE_NAME source_1
69960 , l9.TRX_NUMBER source_2
69961 , l9.TRX_DOC_SEQUENCE_VALUE source_3
69962 , l4.CM_LINE_DIST_CCID source_4
69963 , l6.DIST_CODE_COMBINATION_ID source_5
69964 , l6.DIST_SOURCE_TYPE source_20
69965 , l7.REC_ACT_TYPE source_21
69966 , l6.DIST_ENT_AMT source_24
69967 , l3.CM_DIST_IDENTIFER source_42
69968 , l3.CM_DIST_TYPE source_43
69969 , l3.CM_LINE_CUR_CONVERSION_DATE source_45
69970 , l3.CM_LINE_CUR_CONVERSION_RATE source_46
69971 , l3.CM_LINE_CUR_CONVERSION_TYPE source_47
69972 , l3.GAIN_LOSS_REF source_48
69973 , l3.CM_LINE_ACCTD_AMT source_49
69974 , l4.CM_TAX_LINE_ID source_52
69975 , l4.CM_LINE_DIST_ACCOUNT_CLASS source_53
69976 , l4.CM_LINE_DIST_AMT source_54
69977 FROM xla_events_gt xet
69978 , AR_CM_LINES_BASE_V l3
69979 , AR_CM_LINES_L_V l4
69980 , AR_DISTRIBUTIONS_L_V l6
69981 , AR_RECEIVABLES_TRX_ACT_S_V l7
69982 , AR_TRANSACTIONS_S_V l9
69983 WHERE xet.event_id between x_first_event_id and x_last_event_id
69984 and xet.event_date between p_pad_start_date and p_pad_end_date
69985 and xet.event_class_code = C_EVENT_CLASS_CODE
69986 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
69987 AND l4.event_id (+) = l3.event_id
69988 AND l4.line_number (+) = l3.line_number
69989 AND l6.event_id (+) = l3.event_id
69990 AND l6.line_number (+) = l3.line_number
69991 AND l7.event_id (+) = l3.event_id
69992 AND l7.line_number (+) = l3.line_number
69993 AND l9.event_id (+) = l3.event_id
69994 AND l9.line_number (+) = l3.line_number
69995 ;
69996
69997 --
69998 BEGIN
69999 IF g_log_enabled THEN
70000 l_log_module := C_DEFAULT_MODULE||'.EventClass_136';
70001 END IF;
70002 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
70003 trace
70004 (p_msg => 'BEGIN of EventClass_136'
70005 ,p_level => C_LEVEL_PROCEDURE
70006 ,p_module => l_log_module);
70007 END IF;
70008
70009 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70010 trace
70011 (p_msg => 'p_application_id = '||p_application_id||
70012 ' - p_base_ledger_id = '||p_base_ledger_id||
70013 ' - p_target_ledger_id = '||p_target_ledger_id||
70014 ' - p_language = '||p_language||
70015 ' - p_currency_code = '||p_currency_code||
70016 ' - p_sla_ledger_id = '||p_sla_ledger_id
70017 ,p_level => C_LEVEL_STATEMENT
70018 ,p_module => l_log_module);
70019 END IF;
70020 --
70021 -- initialze arrays
70022 --
70023 g_array_event.DELETE;
70024 l_rec_array_event := l_null_rec_array_event;
70025 --
70026 --------------------------------------
70027 -- 4262811 Initialze MPA Line Number
70028 --------------------------------------
70029 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
70030
70031 --
70032
70033 --
70034 OPEN header_cur;
70035 --
70036 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70037 trace
70038 (p_msg => 'SQL - FETCH header_cur'
70039 ,p_level => C_LEVEL_STATEMENT
70040 ,p_module => l_log_module);
70041 END IF;
70042 --
70043 LOOP
70044 FETCH header_cur BULK COLLECT INTO
70045 l_array_entity_id
70049 , l_array_event_id
70046 , l_array_legal_entity_id
70047 , l_array_entity_code
70048 , l_array_transaction_num
70050 , l_array_class_code
70051 , l_array_event_type
70052 , l_array_event_number
70053 , l_array_event_date
70054 , l_array_transaction_date
70055 , l_array_reference_num_1
70056 , l_array_reference_num_2
70057 , l_array_reference_num_3
70058 , l_array_reference_num_4
70059 , l_array_reference_char_1
70060 , l_array_reference_char_2
70061 , l_array_reference_char_3
70062 , l_array_reference_char_4
70063 , l_array_reference_date_1
70064 , l_array_reference_date_2
70065 , l_array_reference_date_3
70066 , l_array_reference_date_4
70067 , l_array_event_created_by
70068 , l_array_budgetary_control_flag
70069 , l_array_source_7
70070 , l_array_source_8
70071 , l_array_source_32
70072 , l_array_source_44
70073 , l_array_source_50
70074 , l_array_source_51
70075 LIMIT l_rows;
70076 --
70077 IF (C_LEVEL_EVENT >= g_log_level) THEN
70078 trace
70079 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
70080 ,p_level => C_LEVEL_EVENT
70081 ,p_module => l_log_module);
70082 END IF;
70083 --
70084 EXIT WHEN l_array_entity_id.COUNT = 0;
70085
70086 -- initialize arrays
70087 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
70088 XLA_AE_LINES_PKG.g_rec_lines := NULL;
70089
70090 --
70091 -- Bug 4458708
70092 --
70093 XLA_AE_LINES_PKG.g_LineNumber := 0;
70094
70095
70096 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
70097 g_last_hdr_idx := l_array_event_id.LAST;
70098 --
70099 -- loop for the headers. Each iteration is for each header extract row
70100 -- fetched in header cursor
70101 --
70102 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
70103
70104 --
70105 -- set event info as cache for other routines to refer event attributes
70106 --
70107 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
70108 (p_application_id => p_application_id
70109 ,p_primary_ledger_id => p_primary_ledger_id
70110 ,p_base_ledger_id => p_base_ledger_id
70111 ,p_target_ledger_id => p_target_ledger_id
70112 ,p_entity_id => l_array_entity_id(hdr_idx)
70113 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
70114 ,p_entity_code => l_array_entity_code(hdr_idx)
70115 ,p_transaction_num => l_array_transaction_num(hdr_idx)
70116 ,p_event_id => l_array_event_id(hdr_idx)
70117 ,p_event_class_code => l_array_class_code(hdr_idx)
70118 ,p_event_type_code => l_array_event_type(hdr_idx)
70119 ,p_event_number => l_array_event_number(hdr_idx)
70120 ,p_event_date => l_array_event_date(hdr_idx)
70121 ,p_transaction_date => l_array_transaction_date(hdr_idx)
70122 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
70123 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
70124 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
70125 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
70126 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
70127 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
70128 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
70132 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
70129 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
70130 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
70131 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
70133 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
70134 ,p_event_created_by => l_array_event_created_by(hdr_idx)
70135 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
70136
70137 --
70138 -- set the status of entry to C_VALID (0)
70139 --
70140 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
70141
70142 --
70143 -- initialize a row for ae header
70144 --
70145 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
70146
70147 l_event_id := l_array_event_id(hdr_idx);
70148
70149 --
70150 -- storing the hdr_idx for event. May be used by line cursor.
70151 --
70152 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
70153
70154 --
70155 -- store sources from header extract. This can be improved to
70156 -- store only those sources from header extract that may be used in lines
70157 --
70158
70159 g_array_event(l_event_id).array_value_num('source_7') := l_array_source_7(hdr_idx);
70160 g_array_event(l_event_id).array_value_num('source_8') := l_array_source_8(hdr_idx);
70161 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
70162 g_array_event(l_event_id).array_value_char('source_44') := l_array_source_44(hdr_idx);
70163 g_array_event(l_event_id).array_value_num('source_50') := l_array_source_50(hdr_idx);
70164 g_array_event(l_event_id).array_value_num('source_51') := l_array_source_51(hdr_idx);
70165
70166 --
70167 -- initilaize the status of ae headers for diffrent balance types
70168 -- the status is initialised to C_NOT_CREATED (2)
70169 --
70170 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
70171 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
70172 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
70173
70174 --
70175 -- call api to validate and store accounting attributes for header
70176 --
70177
70178 ------------------------------------------------------------
70179 -- Accrual Reversal : to get date for Standard Source (NONE)
70180 ------------------------------------------------------------
70181 l_acc_rev_gl_date_source := NULL;
70182
70183 l_rec_acct_attrs.array_acct_attr_code(1) := 'GL_DATE';
70184 l_rec_acct_attrs.array_date_value(1) :=
70185 xla_ae_sources_pkg.GetSystemSourceDate(
70186 p_source_code => 'XLA_EVENT_DATE'
70187 , p_source_type_code => 'Y'
70188 , p_source_application_id => 602
70189 );
70190
70191
70192 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
70193
70194 XLA_AE_HEADER_PKG.SetJeCategoryName;
70195
70196 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
70197 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
70198 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
70199 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
70200 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
70201
70202
70203 -- No header level analytical criteria
70204
70205 --
70206 --accounting attribute enhancement, bug 3612931
70207 --
70208 l_trx_reversal_source := SUBSTR(NULL, 1,30);
70209
70210 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
70211 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
70212
70213 xla_accounting_err_pkg.build_message
70214 (p_appli_s_name => 'XLA'
70215 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
70216 ,p_token_1 => 'ACCT_ATTR_NAME'
70217 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
70218 ,p_token_2 => 'PRODUCT_NAME'
70219 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
70220 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
70221 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
70222 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
70223
70224 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
70225 --
70226 -- following sets the accounting attributes needed to reverse
70227 -- accounting for a distributeion
70228 --
70229 xla_ae_lines_pkg.SetTrxReversalAttrs
70230 (p_event_id => l_event_id
70231 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
70232 ,p_trx_reversal_source => l_trx_reversal_source);
70233
70234 END IF;
70235
70236
70237 ----------------------------------------------------------------
70238 -- 4262811 - update the header statuses to invalid in need be
70239 ----------------------------------------------------------------
70240 --
70241 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
70242
70243
70244 -----------------------------------------------
70245 -- No accrual reversal for the event class/type
70246 -----------------------------------------------
70247 ----------------------------------------------------------------
70248
70249 --
70250 -- this ends the header loop iteration for one bulk fetch
70251 --
70252 END LOOP;
70253
70254 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
70255 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
70256
70257 --
70258 -- insert dummy rows into lines gt table that were created due to
70259 -- transaction reversals
70260 --
70261 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
70262 l_result := XLA_AE_LINES_PKG.InsertLines;
70263 END IF;
70264
70265 --
70266 -- reset the temp_line_num for each set of events fetched from header
70267 -- cursor rather than doing it for each new event in line cursor
70268 -- Bug 3939231
70269 --
70270 xla_ae_lines_pkg.g_temp_line_num := 0;
70271
70272
70273
70274 --
70275 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
70276 --
70277 --
70278 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70279
70280 trace
70281 (p_msg => 'SQL - FETCH line_cur'
70282 ,p_level => C_LEVEL_STATEMENT
70283 ,p_module => l_log_module);
70284
70285 END IF;
70286 --
70287 --
70288 LOOP
70289 --
70290 FETCH line_cur BULK COLLECT INTO
70291 l_array_entity_id
70292 , l_array_legal_entity_id
70293 , l_array_entity_code
70294 , l_array_transaction_num
70295 , l_array_event_id
70296 , l_array_class_code
70297 , l_array_event_type
70298 , l_array_event_number
70299 , l_array_event_date
70300 , l_array_transaction_date
70301 , l_array_reference_num_1
70302 , l_array_reference_num_2
70303 , l_array_reference_num_3
70304 , l_array_reference_num_4
70305 , l_array_reference_char_1
70306 , l_array_reference_char_2
70307 , l_array_reference_char_3
70308 , l_array_reference_char_4
70309 , l_array_reference_date_1
70310 , l_array_reference_date_2
70311 , l_array_reference_date_3
70312 , l_array_reference_date_4
70313 , l_array_event_created_by
70314 , l_array_budgetary_control_flag
70315 , l_array_extract_line_num
70316 , l_array_source_1
70317 , l_array_source_2
70318 , l_array_source_3
70319 , l_array_source_4
70320 , l_array_source_5
70321 , l_array_source_20
70322 , l_array_source_21
70323 , l_array_source_24
70324 , l_array_source_42
70325 , l_array_source_43
70326 , l_array_source_45
70327 , l_array_source_46
70328 , l_array_source_47
70329 , l_array_source_48
70330 , l_array_source_49
70331 , l_array_source_52
70332 , l_array_source_53
70333 , l_array_source_54
70334 LIMIT l_rows;
70335
70336 --
70337 IF (C_LEVEL_EVENT >= g_log_level) THEN
70338 trace
70339 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
70340 ,p_level => C_LEVEL_EVENT
70341 ,p_module => l_log_module);
70342 END IF;
70343 --
70344 EXIT WHEN l_array_entity_id.count = 0;
70345
70346 XLA_AE_LINES_PKG.g_rec_lines := null;
70347
70348 --
70349 -- Bug 4458708
70350 --
70351 XLA_AE_LINES_PKG.g_LineNumber := 0;
70352 --
70353 --
70354
70355 FOR Idx IN 1..l_array_event_id.count LOOP
70356 --
70357 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
70358 --
70359 l_event_id := l_array_event_id(idx); -- 5648433
70360
70361 --
70362 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
70363 --
70364
70365 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
70366 (g_array_event(l_event_id).array_value_num('header_index'))
70367 ,'N'
70368 ) <> 'Y'
70369 THEN
70370 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70371 trace
70372 (p_msg => 'Trancaction revesal option is not Y '
70373 ,p_level => C_LEVEL_STATEMENT
70374 ,p_module => l_log_module);
70375 END IF;
70376
70377 --
70378 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
70379 --
70380 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
70381 --
70382 -- set event info as cache for other routines to refer event attributes
70383 --
70384
70385 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
70386 l_previous_event_id := l_event_id;
70387
70388 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
70389 (p_application_id => p_application_id
70390 ,p_primary_ledger_id => p_primary_ledger_id
70391 ,p_base_ledger_id => p_base_ledger_id
70392 ,p_target_ledger_id => p_target_ledger_id
70393 ,p_entity_id => l_array_entity_id(Idx)
70394 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
70395 ,p_entity_code => l_array_entity_code(Idx)
70396 ,p_transaction_num => l_array_transaction_num(Idx)
70397 ,p_event_id => l_array_event_id(Idx)
70398 ,p_event_class_code => l_array_class_code(Idx)
70399 ,p_event_type_code => l_array_event_type(Idx)
70400 ,p_event_number => l_array_event_number(Idx)
70401 ,p_event_date => l_array_event_date(Idx)
70402 ,p_transaction_date => l_array_transaction_date(Idx)
70403 ,p_reference_num_1 => l_array_reference_num_1(Idx)
70404 ,p_reference_num_2 => l_array_reference_num_2(Idx)
70405 ,p_reference_num_3 => l_array_reference_num_3(Idx)
70406 ,p_reference_num_4 => l_array_reference_num_4(Idx)
70407 ,p_reference_char_1 => l_array_reference_char_1(Idx)
70408 ,p_reference_char_2 => l_array_reference_char_2(Idx)
70409 ,p_reference_char_3 => l_array_reference_char_3(Idx)
70410 ,p_reference_char_4 => l_array_reference_char_4(Idx)
70411 ,p_reference_date_1 => l_array_reference_date_1(Idx)
70412 ,p_reference_date_2 => l_array_reference_date_2(Idx)
70413 ,p_reference_date_3 => l_array_reference_date_3(Idx)
70414 ,p_reference_date_4 => l_array_reference_date_4(Idx)
70415 ,p_event_created_by => l_array_event_created_by(Idx)
70416 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
70417 --
70418 END IF;
70419
70420
70421
70422 --
70423 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
70424
70425 l_acct_reversal_source := SUBSTR(NULL, 1,30);
70426
70427 IF l_continue_with_lines THEN
70428 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
70429 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
70430
70431 xla_accounting_err_pkg.build_message
70432 (p_appli_s_name => 'XLA'
70433 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
70434 ,p_token_1 => 'LINE_NUMBER'
70435 ,p_value_1 => l_array_extract_line_num(Idx)
70436 ,p_token_2 => 'PRODUCT_NAME'
70437 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
70438 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
70439 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
70440 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
70441
70442 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
70443 --
70444 -- following sets the accounting attributes needed to reverse
70445 -- accounting for a distributeion
70446 --
70447
70448 --
70449 -- 5217187
70450 --
70451 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
70452 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
70453 g_array_event(l_event_id).array_value_num('header_index'));
70454 --
70455 --
70456
70457 -- No reversal code generated
70458
70459 xla_ae_lines_pkg.SetAcctReversalAttrs
70460 (p_event_id => l_event_id
70461 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
70462 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70463 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
70464 END IF;
70465
70466 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
70467 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
70468
70469 --
70470 AcctLineType_39 (
70471 p_application_id => p_application_id
70472 ,p_event_id => l_event_id
70473 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70474 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70475 ,p_actual_flag => l_actual_flag
70476 ,p_balance_type_code => l_balance_type_code
70477 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70478
70479 , p_source_5 => l_array_source_5(Idx)
70480 , p_source_20 => l_array_source_20(Idx)
70481 , p_source_24 => l_array_source_24(Idx)
70482 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70483 , p_source_42 => l_array_source_42(Idx)
70484 , p_source_43 => l_array_source_43(Idx)
70485 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70486 , p_source_45 => l_array_source_45(Idx)
70487 , p_source_46 => l_array_source_46(Idx)
70488 , p_source_47 => l_array_source_47(Idx)
70489 , p_source_48 => l_array_source_48(Idx)
70490 , p_source_49 => l_array_source_49(Idx)
70491 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70492 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70493 , p_source_52 => l_array_source_52(Idx)
70494 );
70495 If(l_balance_type_code = 'A') THEN
70496 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70497 END IF;
70498
70499 --
70500
70501
70502 --
70503 AcctLineType_40 (
70504 p_application_id => p_application_id
70505 ,p_event_id => l_event_id
70506 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70507 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70508 ,p_actual_flag => l_actual_flag
70509 ,p_balance_type_code => l_balance_type_code
70510 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70511
70512 , p_source_1 => l_array_source_1(Idx)
70513 , p_source_2 => l_array_source_2(Idx)
70514 , p_source_3 => l_array_source_3(Idx)
70515 , p_source_5 => l_array_source_5(Idx)
70516 , p_source_20 => l_array_source_20(Idx)
70517 , p_source_24 => l_array_source_24(Idx)
70518 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70519 , p_source_42 => l_array_source_42(Idx)
70520 , p_source_43 => l_array_source_43(Idx)
70521 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70522 , p_source_45 => l_array_source_45(Idx)
70523 , p_source_46 => l_array_source_46(Idx)
70524 , p_source_47 => l_array_source_47(Idx)
70525 , p_source_48 => l_array_source_48(Idx)
70526 , p_source_49 => l_array_source_49(Idx)
70527 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70528 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70529 , p_source_52 => l_array_source_52(Idx)
70530 );
70531 If(l_balance_type_code = 'A') THEN
70532 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70533 END IF;
70534
70535 --
70536
70537
70538 --
70539 AcctLineType_41 (
70540 p_application_id => p_application_id
70541 ,p_event_id => l_event_id
70542 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70543 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70544 ,p_actual_flag => l_actual_flag
70545 ,p_balance_type_code => l_balance_type_code
70546 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70547
70548 , p_source_5 => l_array_source_5(Idx)
70549 , p_source_20 => l_array_source_20(Idx)
70550 , p_source_24 => l_array_source_24(Idx)
70551 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70552 , p_source_42 => l_array_source_42(Idx)
70553 , p_source_43 => l_array_source_43(Idx)
70554 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70555 , p_source_45 => l_array_source_45(Idx)
70556 , p_source_46 => l_array_source_46(Idx)
70557 , p_source_47 => l_array_source_47(Idx)
70558 , p_source_48 => l_array_source_48(Idx)
70559 , p_source_49 => l_array_source_49(Idx)
70560 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70561 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70562 , p_source_52 => l_array_source_52(Idx)
70563 );
70564 If(l_balance_type_code = 'A') THEN
70565 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70566 END IF;
70567
70568 --
70569
70570
70571 --
70572 AcctLineType_42 (
70573 p_application_id => p_application_id
70574 ,p_event_id => l_event_id
70575 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70576 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70577 ,p_actual_flag => l_actual_flag
70578 ,p_balance_type_code => l_balance_type_code
70579 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70580
70581 , p_source_5 => l_array_source_5(Idx)
70582 , p_source_20 => l_array_source_20(Idx)
70583 , p_source_21 => l_array_source_21(Idx)
70584 , p_source_24 => l_array_source_24(Idx)
70585 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70586 , p_source_42 => l_array_source_42(Idx)
70587 , p_source_43 => l_array_source_43(Idx)
70588 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70589 , p_source_45 => l_array_source_45(Idx)
70590 , p_source_46 => l_array_source_46(Idx)
70591 , p_source_47 => l_array_source_47(Idx)
70592 , p_source_48 => l_array_source_48(Idx)
70593 , p_source_49 => l_array_source_49(Idx)
70594 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70595 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70596 , p_source_52 => l_array_source_52(Idx)
70597 );
70598 If(l_balance_type_code = 'A') THEN
70599 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70600 END IF;
70601
70602 --
70603
70604
70605 --
70606 AcctLineType_43 (
70607 p_application_id => p_application_id
70608 ,p_event_id => l_event_id
70609 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70610 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70611 ,p_actual_flag => l_actual_flag
70612 ,p_balance_type_code => l_balance_type_code
70613 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70614
70615 , p_source_4 => l_array_source_4(Idx)
70616 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70617 , p_source_42 => l_array_source_42(Idx)
70618 , p_source_43 => l_array_source_43(Idx)
70619 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70620 , p_source_45 => l_array_source_45(Idx)
70621 , p_source_46 => l_array_source_46(Idx)
70622 , p_source_47 => l_array_source_47(Idx)
70623 , p_source_48 => l_array_source_48(Idx)
70624 , p_source_49 => l_array_source_49(Idx)
70625 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70629 , p_source_54 => l_array_source_54(Idx)
70626 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70627 , p_source_52 => l_array_source_52(Idx)
70628 , p_source_53 => l_array_source_53(Idx)
70630 );
70631 If(l_balance_type_code = 'A') THEN
70632 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70633 END IF;
70634
70635 --
70636
70637
70638 --
70639 AcctLineType_44 (
70640 p_application_id => p_application_id
70641 ,p_event_id => l_event_id
70642 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70643 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70644 ,p_actual_flag => l_actual_flag
70645 ,p_balance_type_code => l_balance_type_code
70646 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70647
70648 , p_source_4 => l_array_source_4(Idx)
70649 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70650 , p_source_42 => l_array_source_42(Idx)
70651 , p_source_43 => l_array_source_43(Idx)
70652 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70653 , p_source_45 => l_array_source_45(Idx)
70654 , p_source_46 => l_array_source_46(Idx)
70655 , p_source_47 => l_array_source_47(Idx)
70656 , p_source_48 => l_array_source_48(Idx)
70657 , p_source_49 => l_array_source_49(Idx)
70658 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70659 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70660 , p_source_52 => l_array_source_52(Idx)
70661 , p_source_53 => l_array_source_53(Idx)
70662 , p_source_54 => l_array_source_54(Idx)
70663 );
70664 If(l_balance_type_code = 'A') THEN
70665 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70666 END IF;
70667
70668 --
70669
70670
70671 --
70672 AcctLineType_45 (
70673 p_application_id => p_application_id
70674 ,p_event_id => l_event_id
70675 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70676 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70677 ,p_actual_flag => l_actual_flag
70678 ,p_balance_type_code => l_balance_type_code
70679 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70680
70681 , p_source_4 => l_array_source_4(Idx)
70682 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70683 , p_source_42 => l_array_source_42(Idx)
70684 , p_source_43 => l_array_source_43(Idx)
70685 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70686 , p_source_45 => l_array_source_45(Idx)
70687 , p_source_46 => l_array_source_46(Idx)
70688 , p_source_47 => l_array_source_47(Idx)
70689 , p_source_48 => l_array_source_48(Idx)
70690 , p_source_49 => l_array_source_49(Idx)
70691 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70692 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70693 , p_source_52 => l_array_source_52(Idx)
70694 , p_source_53 => l_array_source_53(Idx)
70695 , p_source_54 => l_array_source_54(Idx)
70696 );
70697 If(l_balance_type_code = 'A') THEN
70698 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70699 END IF;
70700
70701 --
70702
70703
70704 --
70705 AcctLineType_46 (
70706 p_application_id => p_application_id
70707 ,p_event_id => l_event_id
70708 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70709 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70710 ,p_actual_flag => l_actual_flag
70711 ,p_balance_type_code => l_balance_type_code
70712 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70713
70714 , p_source_4 => l_array_source_4(Idx)
70715 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70716 , p_source_42 => l_array_source_42(Idx)
70717 , p_source_43 => l_array_source_43(Idx)
70718 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70719 , p_source_45 => l_array_source_45(Idx)
70720 , p_source_46 => l_array_source_46(Idx)
70721 , p_source_47 => l_array_source_47(Idx)
70722 , p_source_48 => l_array_source_48(Idx)
70723 , p_source_49 => l_array_source_49(Idx)
70724 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70725 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70726 , p_source_52 => l_array_source_52(Idx)
70727 , p_source_53 => l_array_source_53(Idx)
70728 , p_source_54 => l_array_source_54(Idx)
70729 );
70730 If(l_balance_type_code = 'A') THEN
70731 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70732 END IF;
70733
70734 --
70735
70736
70737 --
70738 AcctLineType_47 (
70739 p_application_id => p_application_id
70740 ,p_event_id => l_event_id
70741 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70742 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70743 ,p_actual_flag => l_actual_flag
70744 ,p_balance_type_code => l_balance_type_code
70745 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70746
70747 , p_source_4 => l_array_source_4(Idx)
70748 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70749 , p_source_42 => l_array_source_42(Idx)
70750 , p_source_43 => l_array_source_43(Idx)
70751 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70752 , p_source_45 => l_array_source_45(Idx)
70753 , p_source_46 => l_array_source_46(Idx)
70754 , p_source_47 => l_array_source_47(Idx)
70755 , p_source_48 => l_array_source_48(Idx)
70756 , p_source_49 => l_array_source_49(Idx)
70757 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70758 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70759 , p_source_52 => l_array_source_52(Idx)
70760 , p_source_53 => l_array_source_53(Idx)
70761 , p_source_54 => l_array_source_54(Idx)
70762 );
70763 If(l_balance_type_code = 'A') THEN
70764 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70765 END IF;
70766
70767 --
70768
70769
70770 --
70771 AcctLineType_48 (
70772 p_application_id => p_application_id
70773 ,p_event_id => l_event_id
70774 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70775 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70776 ,p_actual_flag => l_actual_flag
70777 ,p_balance_type_code => l_balance_type_code
70778 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70779
70780 , p_source_4 => l_array_source_4(Idx)
70781 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70782 , p_source_42 => l_array_source_42(Idx)
70783 , p_source_43 => l_array_source_43(Idx)
70784 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70785 , p_source_45 => l_array_source_45(Idx)
70786 , p_source_46 => l_array_source_46(Idx)
70787 , p_source_47 => l_array_source_47(Idx)
70788 , p_source_48 => l_array_source_48(Idx)
70789 , p_source_49 => l_array_source_49(Idx)
70790 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70791 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70792 , p_source_52 => l_array_source_52(Idx)
70793 , p_source_53 => l_array_source_53(Idx)
70794 , p_source_54 => l_array_source_54(Idx)
70795 );
70796 If(l_balance_type_code = 'A') THEN
70797 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70798 END IF;
70799
70800 --
70801
70802
70803 --
70804 AcctLineType_49 (
70805 p_application_id => p_application_id
70806 ,p_event_id => l_event_id
70807 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70808 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70809 ,p_actual_flag => l_actual_flag
70810 ,p_balance_type_code => l_balance_type_code
70811 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70812
70813 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
70814 , p_source_8 => g_array_event(l_event_id).array_value_num('source_8')
70815 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70816 , p_source_42 => l_array_source_42(Idx)
70817 , p_source_43 => l_array_source_43(Idx)
70818 , p_source_48 => l_array_source_48(Idx)
70819 , p_source_49 => l_array_source_49(Idx)
70820 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70821 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70822 , p_source_52 => l_array_source_52(Idx)
70823 );
70824 If(l_balance_type_code = 'A') THEN
70825 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70826 END IF;
70827
70828 --
70829
70830
70831 --
70832 AcctLineType_50 (
70833 p_application_id => p_application_id
70834 ,p_event_id => l_event_id
70835 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70836 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70837 ,p_actual_flag => l_actual_flag
70838 ,p_balance_type_code => l_balance_type_code
70839 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70840
70841 , p_source_4 => l_array_source_4(Idx)
70842 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70843 , p_source_42 => l_array_source_42(Idx)
70844 , p_source_43 => l_array_source_43(Idx)
70845 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70846 , p_source_45 => l_array_source_45(Idx)
70847 , p_source_46 => l_array_source_46(Idx)
70848 , p_source_47 => l_array_source_47(Idx)
70849 , p_source_48 => l_array_source_48(Idx)
70850 , p_source_49 => l_array_source_49(Idx)
70851 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70852 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70853 , p_source_52 => l_array_source_52(Idx)
70854 , p_source_53 => l_array_source_53(Idx)
70855 , p_source_54 => l_array_source_54(Idx)
70856 );
70857 If(l_balance_type_code = 'A') THEN
70858 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70859 END IF;
70860
70861 --
70862
70863
70864 --
70865 AcctLineType_51 (
70866 p_application_id => p_application_id
70867 ,p_event_id => l_event_id
70868 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70869 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70870 ,p_actual_flag => l_actual_flag
70871 ,p_balance_type_code => l_balance_type_code
70872 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70873
70874 , p_source_4 => l_array_source_4(Idx)
70875 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70876 , p_source_42 => l_array_source_42(Idx)
70877 , p_source_43 => l_array_source_43(Idx)
70878 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70879 , p_source_45 => l_array_source_45(Idx)
70880 , p_source_46 => l_array_source_46(Idx)
70884 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70881 , p_source_47 => l_array_source_47(Idx)
70882 , p_source_48 => l_array_source_48(Idx)
70883 , p_source_49 => l_array_source_49(Idx)
70885 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70886 , p_source_52 => l_array_source_52(Idx)
70887 , p_source_53 => l_array_source_53(Idx)
70888 , p_source_54 => l_array_source_54(Idx)
70889 );
70890 If(l_balance_type_code = 'A') THEN
70891 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70892 END IF;
70893
70894 --
70895
70896
70897 --
70898 AcctLineType_52 (
70899 p_application_id => p_application_id
70900 ,p_event_id => l_event_id
70901 ,p_calculate_acctd_flag => l_calculate_acctd_flag
70902 ,p_calculate_g_l_flag => l_calculate_g_l_flag
70903 ,p_actual_flag => l_actual_flag
70904 ,p_balance_type_code => l_balance_type_code
70905 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
70906
70907 , p_source_4 => l_array_source_4(Idx)
70908 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
70909 , p_source_42 => l_array_source_42(Idx)
70910 , p_source_43 => l_array_source_43(Idx)
70911 , p_source_44 => g_array_event(l_event_id).array_value_char('source_44')
70912 , p_source_45 => l_array_source_45(Idx)
70913 , p_source_46 => l_array_source_46(Idx)
70914 , p_source_47 => l_array_source_47(Idx)
70915 , p_source_48 => l_array_source_48(Idx)
70916 , p_source_49 => l_array_source_49(Idx)
70917 , p_source_50 => g_array_event(l_event_id).array_value_num('source_50')
70918 , p_source_51 => g_array_event(l_event_id).array_value_num('source_51')
70919 , p_source_52 => l_array_source_52(Idx)
70920 , p_source_53 => l_array_source_53(Idx)
70921 , p_source_54 => l_array_source_54(Idx)
70922 );
70923 If(l_balance_type_code = 'A') THEN
70924 l_actual_gain_loss_ref := l_gain_or_loss_ref;
70925 END IF;
70926
70927 --
70928
70929 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
70930 -- or secondary ledger that has different currency with primary
70931 -- or alc that is calculated by sla
70932 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
70933 (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'))
70934
70935 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
70936 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
70937 AND (l_actual_flag = 'A')) THEN
70938 XLA_AE_LINES_PKG.CreateGainOrLossLines(
70939 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
70940 ,p_application_id => p_application_id
70941 ,p_amb_context_code => 'DEFAULT'
70942 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
70943 ,p_event_class_code => C_EVENT_CLASS_CODE
70944 ,p_event_type_code => C_EVENT_TYPE_CODE
70945
70946 ,p_gain_ccid => -1
70947 ,p_loss_ccid => -1
70948
70949 ,p_actual_flag => l_actual_flag
70950 ,p_enc_flag => null
70951 ,p_actual_g_l_ref => l_actual_gain_loss_ref
70952 ,p_enc_g_l_ref => null
70953 );
70954 END IF;
70955 END IF;
70956 END IF;
70957
70958 ELSE
70959 --
70960 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
70961 --
70962 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70963 trace
70964 (p_msg => 'Trancaction revesal option is Y'
70965 ,p_level => C_LEVEL_STATEMENT
70966 ,p_module => l_log_module);
70967 END IF;
70968 END IF;
70969
70970 END LOOP;
70971 l_result := XLA_AE_LINES_PKG.InsertLines ;
70972 end loop;
70973 close line_cur;
70974
70975
70976 --
70977 -- insert headers into xla_ae_headers_gt table
70978 --
70979 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
70980
70981 -- insert into errors table here.
70982
70983 END LOOP;
70984
70985 --
70986 -- 4865292
70987 --
70988 -- Compare g_hdr_extract_count with event count in
70989 -- CreateHeadersAndLines.
70990 --
70991 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
70992
70993 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
70994 trace (p_msg => '# rows extracted from header extract objects '
70995 || ' (running total): '
70996 || g_hdr_extract_count
70997 ,p_level => C_LEVEL_STATEMENT
70998 ,p_module => l_log_module);
70999 END IF;
71000
71001 CLOSE header_cur;
71002 --
71003
71004 --
71005 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
71006 trace
71007 (p_msg => 'END of EventClass_136'
71008 ,p_level => C_LEVEL_PROCEDURE
71009 ,p_module => l_log_module);
71010 END IF;
71011 --
71012 RETURN l_result;
71013 EXCEPTION
71014 WHEN xla_exceptions_pkg.application_exception THEN
71015
71016 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
71017
71018
71019 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
71020
71021 RAISE;
71022
71023 WHEN NO_DATA_FOUND THEN
71024
71025 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
71026 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
71027
71028 FOR header_record IN header_cur
71029 LOOP
71030 l_array_header_events(header_record.event_id) := header_record.event_id;
71031 END LOOP;
71032
71033 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
71034 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
71035
71036 fnd_file.put_line(fnd_file.LOG, ' ');
71037 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
71038 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
71039 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
71040
71041 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
71042 LOOP
71043 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
71044 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
71045 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
71046 END IF;
71047 END LOOP;
71048
71049 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
71050 fnd_file.put_line(fnd_file.LOG, ' ');
71051
71052
71053 xla_exceptions_pkg.raise_message
71054 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_136');
71055
71056
71057 WHEN OTHERS THEN
71058 xla_exceptions_pkg.raise_message
71059 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_136');
71060 END EventClass_136;
71061 --
71062
71063 ---------------------------------------
71064 --
71065 -- PRIVATE PROCEDURE
71066 -- insert_sources_137
71067 --
71068 ----------------------------------------
71069 --
71070 PROCEDURE insert_sources_137(
71071 p_target_ledger_id IN NUMBER
71072 , p_language IN VARCHAR2
71073 , p_sla_ledger_id IN NUMBER
71074 , p_pad_start_date IN DATE
71075 , p_pad_end_date IN DATE
71076 )
71077 IS
71078
71079 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO_ALL';
71080 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO';
71081 p_apps_owner VARCHAR2(30);
71082 l_log_module VARCHAR2(240);
71083 BEGIN
71084 IF g_log_enabled THEN
71085 l_log_module := C_DEFAULT_MODULE||'.insert_sources_137';
71086 END IF;
71087 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
71088
71089 trace
71090 (p_msg => 'BEGIN of insert_sources_137'
71091 ,p_level => C_LEVEL_PROCEDURE
71092 ,p_module => l_log_module);
71093
71094 END IF;
71095
71096 -- select APPS owner
71097 SELECT oracle_username
71098 INTO p_apps_owner
71099 FROM fnd_oracle_userid
71100 WHERE read_only_flag = 'U'
71101 ;
71102
71106 ' - p_language = '||p_language||
71103 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
71104 trace
71105 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
71107 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
71108 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
71109 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
71110 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
71111 ,p_level => C_LEVEL_STATEMENT
71112 ,p_module => l_log_module);
71113 END IF;
71114
71115
71116 --
71117 INSERT INTO xla_diag_sources --hdr2
71118 (
71119 event_id
71120 , ledger_id
71121 , sla_ledger_id
71122 , description_language
71123 , object_name
71124 , object_type_code
71125 , line_number
71126 , source_application_id
71127 , source_type_code
71128 , source_code
71129 , source_value
71130 , source_meaning
71131 , created_by
71132 , creation_date
71133 , last_update_date
71134 , last_updated_by
71135 , last_update_login
71136 , program_update_date
71137 , program_application_id
71138 , program_id
71139 , request_id
71140 )
71141 SELECT
71142 event_id
71143 , p_target_ledger_id
71144 , p_sla_ledger_id
71145 , p_language
71146 , object_name
71147 , object_type_code
71148 , line_number
71149 , source_application_id
71150 , source_type_code
71151 , source_code
71152 , SUBSTR(source_value ,1,1996)
71153 , SUBSTR(source_meaning ,1,200)
71154 , xla_environment_pkg.g_Usr_Id
71155 , TRUNC(SYSDATE)
71156 , TRUNC(SYSDATE)
71157 , xla_environment_pkg.g_Usr_Id
71158 , xla_environment_pkg.g_Login_Id
71159 , TRUNC(SYSDATE)
71160 , xla_environment_pkg.g_Prog_Appl_Id
71161 , xla_environment_pkg.g_Prog_Id
71162 , xla_environment_pkg.g_Req_Id
71163 FROM (
71164 SELECT xet.event_id event_id
71165 , 0 line_number
71166 , CASE r
71167 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
71168 WHEN 2 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
71169 WHEN 3 THEN 'AR_BILL_TO_SITE_USES_S_V'
71170 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
71171 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
71172 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
71173 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
71174
71175 ELSE null
71176 END object_name
71177 , CASE r
71178 WHEN 1 THEN 'HEADER'
71179 WHEN 2 THEN 'HEADER'
71180 WHEN 3 THEN 'HEADER'
71181 WHEN 4 THEN 'HEADER'
71182 WHEN 5 THEN 'HEADER'
71183 WHEN 6 THEN 'HEADER'
71184 WHEN 7 THEN 'HEADER'
71185
71186 ELSE null
71187 END object_type_code
71188 , CASE r
71189 WHEN 1 THEN '222'
71190 WHEN 2 THEN '222'
71191 WHEN 3 THEN '222'
71192 WHEN 4 THEN '222'
71193 WHEN 5 THEN '222'
71194 WHEN 6 THEN '222'
71195 WHEN 7 THEN '222'
71196
71197 ELSE null
71198 END source_application_id
71199 , 'S' source_type_code
71200 , CASE r
71201 WHEN 1 THEN 'TRX_DOC_SEQUENCE_VALUE'
71202 WHEN 2 THEN 'BILL_CUST_ACCOUNT_ID'
71203 WHEN 3 THEN 'BILL_USES_SITE_USE_ID'
71204 WHEN 4 THEN 'XLA_PARTY_TYPE'
71205 WHEN 5 THEN 'TRX_INVOICE_CURRENCY_CODE'
71206 WHEN 6 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
71207 WHEN 7 THEN 'TRX_DOC_SEQUENCE_ID'
71208
71209 ELSE null
71210 END source_code
71211 , CASE r
71212 WHEN 1 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
71213 WHEN 2 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
71214 WHEN 3 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
71215 WHEN 4 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
71219
71216 WHEN 5 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
71217 WHEN 6 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
71218 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
71220 ELSE null
71221 END source_value
71222 , null source_meaning
71223 FROM xla_events_gt xet
71224 , AR_BILL_TO_CUSTOMERS_S_V h1
71225 , AR_BILL_TO_SITE_USES_S_V h2
71226 , AR_TRANSACTIONS_S_V h5
71227 ,(select rownum r from all_objects where rownum <= 7 and owner = p_apps_owner)
71228 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
71229 AND xet.event_class_code = C_EVENT_CLASS_CODE
71230 AND h1.event_id = xet.event_id
71231 AND h2.event_id = h1.event_id
71232 AND h5.event_id = h1.event_id
71233
71234 )
71235 ;
71236 --
71237 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
71238
71239 trace
71240 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
71241 ,p_level => C_LEVEL_STATEMENT
71242 ,p_module => l_log_module);
71243
71244 END IF;
71245 --
71246
71247
71248
71249 --
71250 INSERT INTO xla_diag_sources --line2
71251 (
71252 event_id
71253 , ledger_id
71254 , sla_ledger_id
71255 , description_language
71256 , object_name
71257 , object_type_code
71258 , line_number
71259 , source_application_id
71260 , source_type_code
71261 , source_code
71262 , source_value
71263 , source_meaning
71264 , created_by
71265 , creation_date
71266 , last_update_date
71267 , last_updated_by
71268 , last_update_login
71269 , program_update_date
71270 , program_application_id
71271 , program_id
71272 , request_id
71273 )
71274 SELECT event_id
71275 , p_target_ledger_id
71276 , p_sla_ledger_id
71277 , p_language
71278 , object_name
71279 , object_type_code
71280 , line_number
71281 , source_application_id
71282 , source_type_code
71283 , source_code
71284 , SUBSTR(source_value,1,1996)
71285 , SUBSTR(source_meaning ,1,200)
71286 , xla_environment_pkg.g_Usr_Id
71287 , TRUNC(SYSDATE)
71288 , TRUNC(SYSDATE)
71289 , xla_environment_pkg.g_Usr_Id
71290 , xla_environment_pkg.g_Login_Id
71291 , TRUNC(SYSDATE)
71292 , xla_environment_pkg.g_Prog_Appl_Id
71293 , xla_environment_pkg.g_Prog_Id
71294 , xla_environment_pkg.g_Req_Id
71295 FROM (
71296 SELECT xet.event_id event_id
71297 , l4.line_number line_number
71298 , CASE r
71299 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
71300 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
71301 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
71302 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
71303 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
71304 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
71305 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
71306 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
71307 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
71308 WHEN 10 THEN 'AR_CUST_TRX_LINES_L_V'
71309
71310 ELSE null
71311 END object_name
71312 , CASE r
71313 WHEN 1 THEN 'LINE'
71314 WHEN 2 THEN 'LINE'
71315 WHEN 3 THEN 'LINE'
71316 WHEN 4 THEN 'LINE'
71317 WHEN 5 THEN 'LINE'
71318 WHEN 6 THEN 'LINE'
71319 WHEN 7 THEN 'LINE'
71320 WHEN 8 THEN 'LINE'
71321 WHEN 9 THEN 'LINE'
71322 WHEN 10 THEN 'LINE'
71323
71324 ELSE null
71325 END object_type_code
71326 , CASE r
71327 WHEN 1 THEN '222'
71328 WHEN 2 THEN '222'
71329 WHEN 3 THEN '222'
71330 WHEN 4 THEN '222'
71331 WHEN 5 THEN '222'
71332 WHEN 6 THEN '222'
71333 WHEN 7 THEN '222'
71334 WHEN 8 THEN '222'
71335 WHEN 9 THEN '222'
71336 WHEN 10 THEN '222'
71337
71338 ELSE null
71339 END source_application_id
71340 , 'S' source_type_code
71341 , CASE r
71342 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
71343 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
71344 WHEN 3 THEN 'TRX_LINE_DIST_ID'
71345 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
71346 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
71347 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
71348 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
71349 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
71350 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
71351 WHEN 10 THEN 'TRX_TAX_LINE_ID'
71352
71353 ELSE null
71354 END source_code
71355 , CASE r
71359 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
71356 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
71357 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
71358 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
71360 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
71361 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
71362 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
71363 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
71364 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
71365 WHEN 10 THEN TO_CHAR(l4.TRX_TAX_LINE_ID)
71366
71367 ELSE null
71368 END source_value
71369 , null source_meaning
71370 FROM xla_events_gt xet
71371 , AR_CUST_TRX_LINES_BASE_V l3
71372 , AR_CUST_TRX_LINES_L_V l4
71373 , (select rownum r from all_objects where rownum <= 10 and owner = p_apps_owner)
71374 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
71375 AND xet.event_class_code = C_EVENT_CLASS_CODE
71376 AND l3.event_id = xet.event_id
71377 AND l4.event_id = l3.event_id
71378 AND l4.line_number = l3.line_number
71379
71380 )
71381 ;
71382 --
71383 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
71384
71385 trace
71386 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
71387 ,p_level => C_LEVEL_STATEMENT
71388 ,p_module => l_log_module);
71389
71390 END IF;
71391
71392
71393 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
71394 trace
71395 (p_msg => 'END of insert_sources_137'
71396 ,p_level => C_LEVEL_PROCEDURE
71397 ,p_module => l_log_module);
71398 END IF;
71399 EXCEPTION
71400 WHEN xla_exceptions_pkg.application_exception THEN
71401 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
71402 trace
71403 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
71404 ,p_level => C_LEVEL_EXCEPTION
71405 ,p_module => l_log_module);
71406 END IF;
71407 RAISE;
71408 WHEN OTHERS THEN
71409 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
71410 trace
71411 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
71412 ,p_level => C_LEVEL_EXCEPTION
71413 ,p_module => l_log_module);
71414 END IF;
71415 xla_exceptions_pkg.raise_message
71416 (p_location => 'XLA_00222_AAD_S_000005_PKG.insert_sources_137');
71417 END insert_sources_137;
71418 --
71419
71420 ---------------------------------------
71421 --
71422 -- PRIVATE FUNCTION
71423 -- EventClass_137
71424 --
71425 ----------------------------------------
71426 --
71427 FUNCTION EventClass_137
71428 (p_application_id IN NUMBER
71429 ,p_base_ledger_id IN NUMBER
71430 ,p_target_ledger_id IN NUMBER
71431 ,p_language IN VARCHAR2
71432 ,p_currency_code IN VARCHAR2
71433 ,p_sla_ledger_id IN NUMBER
71434 ,p_pad_start_date IN DATE
71435 ,p_pad_end_date IN DATE
71436 ,p_primary_ledger_id IN NUMBER)
71437 RETURN BOOLEAN IS
71438 --
71439 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO_ALL';
71440 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEBIT_MEMO';
71441
71442 l_calculate_acctd_flag VARCHAR2(1) :='N';
71443 l_calculate_g_l_flag VARCHAR2(1) :='N';
71444 --
71445 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
71446 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
71447 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
71448 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
71449 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
71450 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
71451 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
71452 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
71453 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
71454 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
71455 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
71456 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
71457 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
71458 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
71459 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
71460 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
71461 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
71462 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
71463 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
71464 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
71465 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
71466 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
71467 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
71468 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
71472 l_event_id NUMBER;
71469 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
71470 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
71471
71473 l_previous_event_id NUMBER;
71474 l_first_event_id NUMBER;
71475 l_last_event_id NUMBER;
71476
71477 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
71478 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
71479 --
71480 --
71481 l_result BOOLEAN := TRUE;
71482 l_rows NUMBER := 1000;
71483 l_event_type_name VARCHAR2(80) := 'All';
71484 l_event_class_name VARCHAR2(80) := 'Debit Memo';
71485 l_description VARCHAR2(4000);
71486 l_transaction_reversal NUMBER;
71487 l_ae_header_id NUMBER;
71488 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
71489 l_log_module VARCHAR2(240);
71490 --
71491 l_acct_reversal_source VARCHAR2(30);
71492 l_trx_reversal_source VARCHAR2(30);
71493
71494 l_continue_with_lines BOOLEAN := TRUE;
71495 --
71496 l_acc_rev_gl_date_source DATE; -- 4262811
71497 --
71498 type t_array_event_id is table of number index by binary_integer;
71499
71500 l_rec_array_event t_rec_array_event;
71501 l_null_rec_array_event t_rec_array_event;
71502 l_array_ae_header_id xla_number_array_type;
71503 l_actual_flag VARCHAR2(1) := NULL;
71504 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
71505 l_balance_type_code VARCHAR2(1) :=NULL;
71506 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
71507
71508 --
71509 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
71510 --
71511
71512 TYPE t_array_source_3 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
71513 TYPE t_array_source_30 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
71514 TYPE t_array_source_31 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
71515 TYPE t_array_source_32 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
71516 TYPE t_array_source_37 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
71517 TYPE t_array_source_81 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
71518 TYPE t_array_source_82 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
71519
71520 TYPE t_array_source_19 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
71521 TYPE t_array_source_33 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
71522 TYPE t_array_source_34 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
71523 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
71524 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
71525 TYPE t_array_source_38 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
71526 TYPE t_array_source_39 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
71527 TYPE t_array_source_40 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
71528 TYPE t_array_source_41 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
71529 TYPE t_array_source_55 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_TAX_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
71530
71531 l_array_source_3 t_array_source_3;
71532 l_array_source_30 t_array_source_30;
71533 l_array_source_31 t_array_source_31;
71534 l_array_source_32 t_array_source_32;
71535 l_array_source_37 t_array_source_37;
71536 l_array_source_81 t_array_source_81;
71537 l_array_source_82 t_array_source_82;
71538
71539 l_array_source_19 t_array_source_19;
71540 l_array_source_33 t_array_source_33;
71541 l_array_source_34 t_array_source_34;
71542 l_array_source_35 t_array_source_35;
71543 l_array_source_36 t_array_source_36;
71544 l_array_source_38 t_array_source_38;
71545 l_array_source_39 t_array_source_39;
71546 l_array_source_40 t_array_source_40;
71547 l_array_source_41 t_array_source_41;
71548 l_array_source_55 t_array_source_55;
71549
71550 --
71551 CURSOR header_cur
71552 IS
71553 SELECT /*+ leading(xet) cardinality(xet,1) */
71554 -- Event Class Code: DEBIT_MEMO
71555 xet.entity_id
71556 ,xet.legal_entity_id
71557 ,xet.entity_code
71558 ,xet.transaction_number
71559 ,xet.event_id
71560 ,xet.event_class_code
71561 ,xet.event_type_code
71562 ,xet.event_number
71563 ,xet.event_date
71564 ,xet.transaction_date
71565 ,xet.reference_num_1
71566 ,xet.reference_num_2
71567 ,xet.reference_num_3
71568 ,xet.reference_num_4
71569 ,xet.reference_char_1
71570 ,xet.reference_char_2
71571 ,xet.reference_char_3
71572 ,xet.reference_char_4
71573 ,xet.reference_date_1
71574 ,xet.reference_date_2
71575 ,xet.reference_date_3
71576 ,xet.reference_date_4
71577 ,xet.event_created_by
71578 ,xet.budgetary_control_flag
71579 , h5.TRX_DOC_SEQUENCE_VALUE source_3
71580 , h1.BILL_CUST_ACCOUNT_ID source_30
71581 , h2.BILL_USES_SITE_USE_ID source_31
71582 , h5.XLA_PARTY_TYPE source_32
71583 , h5.TRX_INVOICE_CURRENCY_CODE source_37
71587 , AR_BILL_TO_CUSTOMERS_S_V h1
71584 , h5.TRX_DOC_SEQUENCE_CATEGORY source_81
71585 , h5.TRX_DOC_SEQUENCE_ID source_82
71586 FROM xla_events_gt xet
71588 , AR_BILL_TO_SITE_USES_S_V h2
71589 , AR_TRANSACTIONS_S_V h5
71590 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
71591 and xet.event_class_code = C_EVENT_CLASS_CODE
71592 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
71593 AND h2.event_id = h1.event_id
71594 AND h5.event_id = h1.event_id
71595
71596 ORDER BY event_id
71597 ;
71598
71599
71600 --
71601 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
71602 IS
71603 SELECT /*+ leading(xet) cardinality(xet,1) */
71604 -- Event Class Code: DEBIT_MEMO
71605 xet.entity_id
71606 ,xet.legal_entity_id
71607 ,xet.entity_code
71608 ,xet.transaction_number
71609 ,xet.event_id
71610 ,xet.event_class_code
71611 ,xet.event_type_code
71612 ,xet.event_number
71613 ,xet.event_date
71614 ,xet.transaction_date
71615 ,xet.reference_num_1
71616 ,xet.reference_num_2
71617 ,xet.reference_num_3
71618 ,xet.reference_num_4
71619 ,xet.reference_char_1
71620 ,xet.reference_char_2
71621 ,xet.reference_char_3
71622 ,xet.reference_char_4
71623 ,xet.reference_date_1
71624 ,xet.reference_date_2
71625 ,xet.reference_date_3
71626 ,xet.reference_date_4
71627 ,xet.event_created_by
71628 ,xet.budgetary_control_flag
71629 , l3.LINE_NUMBER
71630 , l4.TRX_LINE_DIST_CCID source_19
71631 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_33
71632 , l4.TRX_LINE_DIST_ID source_34
71633 , l4.TRX_DISTRIBUTION_TYPE source_35
71634 , l4.TRX_LINE_DIST_AMT source_36
71635 , l3.TRX_LINE_CUR_CONVERSION_DATE source_38
71636 , l3.TRX_LINE_CUR_CONVERSION_RATE source_39
71637 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_40
71638 , l3.TRX_LINE_ACCTD_AMT source_41
71639 , l4.TRX_TAX_LINE_ID source_55
71640 FROM xla_events_gt xet
71641 , AR_CUST_TRX_LINES_BASE_V l3
71642 , AR_CUST_TRX_LINES_L_V l4
71643 WHERE xet.event_id between x_first_event_id and x_last_event_id
71644 and xet.event_date between p_pad_start_date and p_pad_end_date
71645 and xet.event_class_code = C_EVENT_CLASS_CODE
71646 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
71647 AND l4.event_id = l3.event_id
71648 AND l4.line_number = l3.line_number
71649 ;
71650
71651 --
71652 BEGIN
71653 IF g_log_enabled THEN
71654 l_log_module := C_DEFAULT_MODULE||'.EventClass_137';
71655 END IF;
71656 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
71657 trace
71658 (p_msg => 'BEGIN of EventClass_137'
71659 ,p_level => C_LEVEL_PROCEDURE
71660 ,p_module => l_log_module);
71661 END IF;
71662
71663 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
71664 trace
71665 (p_msg => 'p_application_id = '||p_application_id||
71666 ' - p_base_ledger_id = '||p_base_ledger_id||
71667 ' - p_target_ledger_id = '||p_target_ledger_id||
71668 ' - p_language = '||p_language||
71669 ' - p_currency_code = '||p_currency_code||
71670 ' - p_sla_ledger_id = '||p_sla_ledger_id
71671 ,p_level => C_LEVEL_STATEMENT
71672 ,p_module => l_log_module);
71673 END IF;
71674 --
71675 -- initialze arrays
71676 --
71677 g_array_event.DELETE;
71678 l_rec_array_event := l_null_rec_array_event;
71679 --
71680 --------------------------------------
71681 -- 4262811 Initialze MPA Line Number
71682 --------------------------------------
71683 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
71684
71685 --
71686
71687 --
71688 OPEN header_cur;
71689 --
71690 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
71691 trace
71692 (p_msg => 'SQL - FETCH header_cur'
71693 ,p_level => C_LEVEL_STATEMENT
71694 ,p_module => l_log_module);
71695 END IF;
71696 --
71697 LOOP
71698 FETCH header_cur BULK COLLECT INTO
71699 l_array_entity_id
71700 , l_array_legal_entity_id
71701 , l_array_entity_code
71702 , l_array_transaction_num
71703 , l_array_event_id
71704 , l_array_class_code
71705 , l_array_event_type
71706 , l_array_event_number
71707 , l_array_event_date
71708 , l_array_transaction_date
71709 , l_array_reference_num_1
71710 , l_array_reference_num_2
71711 , l_array_reference_num_3
71712 , l_array_reference_num_4
71713 , l_array_reference_char_1
71714 , l_array_reference_char_2
71715 , l_array_reference_char_3
71716 , l_array_reference_char_4
71717 , l_array_reference_date_1
71718 , l_array_reference_date_2
71719 , l_array_reference_date_3
71720 , l_array_reference_date_4
71721 , l_array_event_created_by
71722 , l_array_budgetary_control_flag
71723 , l_array_source_3
71724 , l_array_source_30
71725 , l_array_source_31
71726 , l_array_source_32
71727 , l_array_source_37
71728 , l_array_source_81
71729 , l_array_source_82
71730 LIMIT l_rows;
71731 --
71732 IF (C_LEVEL_EVENT >= g_log_level) THEN
71733 trace
71734 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
71738 --
71735 ,p_level => C_LEVEL_EVENT
71736 ,p_module => l_log_module);
71737 END IF;
71739 EXIT WHEN l_array_entity_id.COUNT = 0;
71740
71741 -- initialize arrays
71742 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
71743 XLA_AE_LINES_PKG.g_rec_lines := NULL;
71744
71745 --
71746 -- Bug 4458708
71747 --
71748 XLA_AE_LINES_PKG.g_LineNumber := 0;
71749
71750
71751 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
71752 g_last_hdr_idx := l_array_event_id.LAST;
71753 --
71754 -- loop for the headers. Each iteration is for each header extract row
71755 -- fetched in header cursor
71756 --
71757 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
71758
71759 --
71760 -- set event info as cache for other routines to refer event attributes
71761 --
71762 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
71763 (p_application_id => p_application_id
71764 ,p_primary_ledger_id => p_primary_ledger_id
71765 ,p_base_ledger_id => p_base_ledger_id
71766 ,p_target_ledger_id => p_target_ledger_id
71767 ,p_entity_id => l_array_entity_id(hdr_idx)
71768 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
71769 ,p_entity_code => l_array_entity_code(hdr_idx)
71770 ,p_transaction_num => l_array_transaction_num(hdr_idx)
71771 ,p_event_id => l_array_event_id(hdr_idx)
71772 ,p_event_class_code => l_array_class_code(hdr_idx)
71773 ,p_event_type_code => l_array_event_type(hdr_idx)
71774 ,p_event_number => l_array_event_number(hdr_idx)
71775 ,p_event_date => l_array_event_date(hdr_idx)
71776 ,p_transaction_date => l_array_transaction_date(hdr_idx)
71777 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
71778 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
71779 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
71780 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
71781 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
71782 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
71783 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
71784 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
71785 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
71786 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
71787 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
71788 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
71789 ,p_event_created_by => l_array_event_created_by(hdr_idx)
71790 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
71791
71792 --
71793 -- set the status of entry to C_VALID (0)
71794 --
71795 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
71796
71797 --
71798 -- initialize a row for ae header
71799 --
71800 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
71801
71802 l_event_id := l_array_event_id(hdr_idx);
71803
71804 --
71805 -- storing the hdr_idx for event. May be used by line cursor.
71806 --
71807 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
71808
71809 --
71810 -- store sources from header extract. This can be improved to
71811 -- store only those sources from header extract that may be used in lines
71812 --
71813
71814 g_array_event(l_event_id).array_value_num('source_3') := l_array_source_3(hdr_idx);
71815 g_array_event(l_event_id).array_value_num('source_30') := l_array_source_30(hdr_idx);
71816 g_array_event(l_event_id).array_value_num('source_31') := l_array_source_31(hdr_idx);
71817 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
71818 g_array_event(l_event_id).array_value_char('source_37') := l_array_source_37(hdr_idx);
71819 g_array_event(l_event_id).array_value_char('source_81') := l_array_source_81(hdr_idx);
71820 g_array_event(l_event_id).array_value_num('source_82') := l_array_source_82(hdr_idx);
71821
71822 --
71823 -- initilaize the status of ae headers for diffrent balance types
71824 -- the status is initialised to C_NOT_CREATED (2)
71825 --
71826 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
71827 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
71828 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
71829
71830 --
71831 -- call api to validate and store accounting attributes for header
71832 --
71833
71834 ------------------------------------------------------------
71835 -- Accrual Reversal : to get date for Standard Source (NONE)
71836 ------------------------------------------------------------
71837 l_acc_rev_gl_date_source := NULL;
71838
71839 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
71840 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_81');
71841 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
71842 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_82');
71843 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
71844 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_3');
71845 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
71846 l_rec_acct_attrs.array_date_value(4) :=
71850 , p_source_application_id => 602
71847 xla_ae_sources_pkg.GetSystemSourceDate(
71848 p_source_code => 'XLA_EVENT_DATE'
71849 , p_source_type_code => 'Y'
71851 );
71852
71853
71854 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
71855
71856 XLA_AE_HEADER_PKG.SetJeCategoryName;
71857
71858 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
71859 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
71860 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
71861 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
71862 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
71863
71864
71865 -- No header level analytical criteria
71866
71867 --
71868 --accounting attribute enhancement, bug 3612931
71869 --
71870 l_trx_reversal_source := SUBSTR(NULL, 1,30);
71871
71872 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
71873 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
71874
71875 xla_accounting_err_pkg.build_message
71876 (p_appli_s_name => 'XLA'
71877 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
71878 ,p_token_1 => 'ACCT_ATTR_NAME'
71879 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
71880 ,p_token_2 => 'PRODUCT_NAME'
71881 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
71882 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
71883 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
71884 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
71885
71886 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
71887 --
71888 -- following sets the accounting attributes needed to reverse
71889 -- accounting for a distributeion
71890 --
71891 xla_ae_lines_pkg.SetTrxReversalAttrs
71892 (p_event_id => l_event_id
71893 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
71894 ,p_trx_reversal_source => l_trx_reversal_source);
71895
71896 END IF;
71897
71898
71899 ----------------------------------------------------------------
71900 -- 4262811 - update the header statuses to invalid in need be
71901 ----------------------------------------------------------------
71902 --
71903 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
71904
71905
71906 -----------------------------------------------
71907 -- No accrual reversal for the event class/type
71908 -----------------------------------------------
71909 ----------------------------------------------------------------
71910
71911 --
71912 -- this ends the header loop iteration for one bulk fetch
71913 --
71914 END LOOP;
71915
71916 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
71917 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
71918
71919 --
71920 -- insert dummy rows into lines gt table that were created due to
71921 -- transaction reversals
71922 --
71923 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
71924 l_result := XLA_AE_LINES_PKG.InsertLines;
71925 END IF;
71926
71927 --
71928 -- reset the temp_line_num for each set of events fetched from header
71929 -- cursor rather than doing it for each new event in line cursor
71930 -- Bug 3939231
71931 --
71932 xla_ae_lines_pkg.g_temp_line_num := 0;
71933
71934
71935
71936 --
71937 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
71938 --
71939 --
71940 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
71941
71942 trace
71943 (p_msg => 'SQL - FETCH line_cur'
71944 ,p_level => C_LEVEL_STATEMENT
71945 ,p_module => l_log_module);
71946
71947 END IF;
71948 --
71949 --
71950 LOOP
71951 --
71952 FETCH line_cur BULK COLLECT INTO
71953 l_array_entity_id
71954 , l_array_legal_entity_id
71955 , l_array_entity_code
71956 , l_array_transaction_num
71957 , l_array_event_id
71958 , l_array_class_code
71959 , l_array_event_type
71960 , l_array_event_number
71961 , l_array_event_date
71962 , l_array_transaction_date
71963 , l_array_reference_num_1
71964 , l_array_reference_num_2
71965 , l_array_reference_num_3
71966 , l_array_reference_num_4
71967 , l_array_reference_char_1
71968 , l_array_reference_char_2
71969 , l_array_reference_char_3
71970 , l_array_reference_char_4
71971 , l_array_reference_date_1
71972 , l_array_reference_date_2
71973 , l_array_reference_date_3
71974 , l_array_reference_date_4
71975 , l_array_event_created_by
71976 , l_array_budgetary_control_flag
71977 , l_array_extract_line_num
71978 , l_array_source_19
71979 , l_array_source_33
71980 , l_array_source_34
71981 , l_array_source_35
71982 , l_array_source_36
71983 , l_array_source_38
71984 , l_array_source_39
71985 , l_array_source_40
71986 , l_array_source_41
71987 , l_array_source_55
71988 LIMIT l_rows;
71989
71990 --
71991 IF (C_LEVEL_EVENT >= g_log_level) THEN
71992 trace
71996 END IF;
71993 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
71994 ,p_level => C_LEVEL_EVENT
71995 ,p_module => l_log_module);
71997 --
71998 EXIT WHEN l_array_entity_id.count = 0;
71999
72000 XLA_AE_LINES_PKG.g_rec_lines := null;
72001
72002 --
72003 -- Bug 4458708
72004 --
72005 XLA_AE_LINES_PKG.g_LineNumber := 0;
72006 --
72007 --
72008
72009 FOR Idx IN 1..l_array_event_id.count LOOP
72010 --
72011 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
72012 --
72013 l_event_id := l_array_event_id(idx); -- 5648433
72014
72015 --
72016 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
72017 --
72018
72019 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
72020 (g_array_event(l_event_id).array_value_num('header_index'))
72021 ,'N'
72022 ) <> 'Y'
72023 THEN
72024 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72025 trace
72026 (p_msg => 'Trancaction revesal option is not Y '
72027 ,p_level => C_LEVEL_STATEMENT
72028 ,p_module => l_log_module);
72029 END IF;
72030
72031 --
72032 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
72033 --
72034 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
72035 --
72036 -- set event info as cache for other routines to refer event attributes
72037 --
72038
72039 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
72040 l_previous_event_id := l_event_id;
72041
72042 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
72043 (p_application_id => p_application_id
72044 ,p_primary_ledger_id => p_primary_ledger_id
72045 ,p_base_ledger_id => p_base_ledger_id
72046 ,p_target_ledger_id => p_target_ledger_id
72047 ,p_entity_id => l_array_entity_id(Idx)
72048 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
72049 ,p_entity_code => l_array_entity_code(Idx)
72050 ,p_transaction_num => l_array_transaction_num(Idx)
72051 ,p_event_id => l_array_event_id(Idx)
72052 ,p_event_class_code => l_array_class_code(Idx)
72053 ,p_event_type_code => l_array_event_type(Idx)
72054 ,p_event_number => l_array_event_number(Idx)
72055 ,p_event_date => l_array_event_date(Idx)
72056 ,p_transaction_date => l_array_transaction_date(Idx)
72057 ,p_reference_num_1 => l_array_reference_num_1(Idx)
72058 ,p_reference_num_2 => l_array_reference_num_2(Idx)
72059 ,p_reference_num_3 => l_array_reference_num_3(Idx)
72060 ,p_reference_num_4 => l_array_reference_num_4(Idx)
72061 ,p_reference_char_1 => l_array_reference_char_1(Idx)
72062 ,p_reference_char_2 => l_array_reference_char_2(Idx)
72063 ,p_reference_char_3 => l_array_reference_char_3(Idx)
72064 ,p_reference_char_4 => l_array_reference_char_4(Idx)
72065 ,p_reference_date_1 => l_array_reference_date_1(Idx)
72066 ,p_reference_date_2 => l_array_reference_date_2(Idx)
72067 ,p_reference_date_3 => l_array_reference_date_3(Idx)
72068 ,p_reference_date_4 => l_array_reference_date_4(Idx)
72069 ,p_event_created_by => l_array_event_created_by(Idx)
72070 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
72071 --
72072 END IF;
72073
72074
72075
72076 --
72077 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
72078
72079 l_acct_reversal_source := SUBSTR(NULL, 1,30);
72080
72081 IF l_continue_with_lines THEN
72082 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
72083 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
72084
72085 xla_accounting_err_pkg.build_message
72086 (p_appli_s_name => 'XLA'
72087 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
72088 ,p_token_1 => 'LINE_NUMBER'
72089 ,p_value_1 => l_array_extract_line_num(Idx)
72090 ,p_token_2 => 'PRODUCT_NAME'
72091 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
72092 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
72093 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
72094 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
72095
72096 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
72097 --
72098 -- following sets the accounting attributes needed to reverse
72099 -- accounting for a distributeion
72100 --
72101
72102 --
72103 -- 5217187
72104 --
72105 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
72106 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
72107 g_array_event(l_event_id).array_value_num('header_index'));
72108 --
72109 --
72110
72111 -- No reversal code generated
72112
72113 xla_ae_lines_pkg.SetAcctReversalAttrs
72114 (p_event_id => l_event_id
72115 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
72116 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72117 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
72118 END IF;
72119
72120 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
72121 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
72122
72123 --
72124 AcctLineType_55 (
72125 p_application_id => p_application_id
72126 ,p_event_id => l_event_id
72127 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72128 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72129 ,p_actual_flag => l_actual_flag
72130 ,p_balance_type_code => l_balance_type_code
72131 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72132
72133 , p_source_19 => l_array_source_19(Idx)
72134 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
72135 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
72136 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
72137 , p_source_33 => l_array_source_33(Idx)
72138 , p_source_34 => l_array_source_34(Idx)
72139 , p_source_35 => l_array_source_35(Idx)
72140 , p_source_36 => l_array_source_36(Idx)
72141 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
72142 , p_source_38 => l_array_source_38(Idx)
72143 , p_source_39 => l_array_source_39(Idx)
72144 , p_source_40 => l_array_source_40(Idx)
72145 , p_source_41 => l_array_source_41(Idx)
72146 , p_source_55 => l_array_source_55(Idx)
72147 );
72148 If(l_balance_type_code = 'A') THEN
72149 l_actual_gain_loss_ref := l_gain_or_loss_ref;
72150 END IF;
72151
72152 --
72153
72154
72155 --
72156 AcctLineType_56 (
72157 p_application_id => p_application_id
72158 ,p_event_id => l_event_id
72159 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72160 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72161 ,p_actual_flag => l_actual_flag
72162 ,p_balance_type_code => l_balance_type_code
72163 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72164
72165 , p_source_19 => l_array_source_19(Idx)
72166 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
72167 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
72168 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
72169 , p_source_33 => l_array_source_33(Idx)
72170 , p_source_34 => l_array_source_34(Idx)
72171 , p_source_35 => l_array_source_35(Idx)
72172 , p_source_36 => l_array_source_36(Idx)
72173 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
72174 , p_source_38 => l_array_source_38(Idx)
72175 , p_source_39 => l_array_source_39(Idx)
72176 , p_source_40 => l_array_source_40(Idx)
72177 , p_source_41 => l_array_source_41(Idx)
72178 , p_source_55 => l_array_source_55(Idx)
72179 );
72180 If(l_balance_type_code = 'A') THEN
72181 l_actual_gain_loss_ref := l_gain_or_loss_ref;
72182 END IF;
72183
72184 --
72185
72186
72187 --
72188 AcctLineType_57 (
72189 p_application_id => p_application_id
72190 ,p_event_id => l_event_id
72191 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72192 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72193 ,p_actual_flag => l_actual_flag
72194 ,p_balance_type_code => l_balance_type_code
72195 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72196
72197 , p_source_19 => l_array_source_19(Idx)
72198 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
72199 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
72200 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
72201 , p_source_33 => l_array_source_33(Idx)
72202 , p_source_34 => l_array_source_34(Idx)
72203 , p_source_35 => l_array_source_35(Idx)
72204 , p_source_36 => l_array_source_36(Idx)
72205 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
72206 , p_source_38 => l_array_source_38(Idx)
72207 , p_source_39 => l_array_source_39(Idx)
72208 , p_source_40 => l_array_source_40(Idx)
72209 , p_source_41 => l_array_source_41(Idx)
72210 , p_source_55 => l_array_source_55(Idx)
72211 );
72212 If(l_balance_type_code = 'A') THEN
72213 l_actual_gain_loss_ref := l_gain_or_loss_ref;
72214 END IF;
72215
72216 --
72217
72218
72219 --
72220 AcctLineType_58 (
72221 p_application_id => p_application_id
72222 ,p_event_id => l_event_id
72223 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72224 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72225 ,p_actual_flag => l_actual_flag
72226 ,p_balance_type_code => l_balance_type_code
72227 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72228
72229 , p_source_19 => l_array_source_19(Idx)
72230 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
72231 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
72232 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
72233 , p_source_33 => l_array_source_33(Idx)
72234 , p_source_34 => l_array_source_34(Idx)
72235 , p_source_35 => l_array_source_35(Idx)
72236 , p_source_36 => l_array_source_36(Idx)
72237 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
72238 , p_source_38 => l_array_source_38(Idx)
72239 , p_source_39 => l_array_source_39(Idx)
72240 , p_source_40 => l_array_source_40(Idx)
72241 , p_source_41 => l_array_source_41(Idx)
72242 , p_source_55 => l_array_source_55(Idx)
72243 );
72244 If(l_balance_type_code = 'A') THEN
72245 l_actual_gain_loss_ref := l_gain_or_loss_ref;
72246 END IF;
72247
72248 --
72249
72250
72251 --
72252 AcctLineType_59 (
72253 p_application_id => p_application_id
72254 ,p_event_id => l_event_id
72255 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72256 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72257 ,p_actual_flag => l_actual_flag
72258 ,p_balance_type_code => l_balance_type_code
72259 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72260
72261 , p_source_19 => l_array_source_19(Idx)
72262 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
72263 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
72264 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
72265 , p_source_33 => l_array_source_33(Idx)
72266 , p_source_34 => l_array_source_34(Idx)
72267 , p_source_35 => l_array_source_35(Idx)
72268 , p_source_36 => l_array_source_36(Idx)
72269 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
72270 , p_source_38 => l_array_source_38(Idx)
72271 , p_source_39 => l_array_source_39(Idx)
72272 , p_source_40 => l_array_source_40(Idx)
72273 , p_source_41 => l_array_source_41(Idx)
72274 , p_source_55 => l_array_source_55(Idx)
72275 );
72276 If(l_balance_type_code = 'A') THEN
72277 l_actual_gain_loss_ref := l_gain_or_loss_ref;
72278 END IF;
72279
72280 --
72281
72282
72283 --
72284 AcctLineType_60 (
72285 p_application_id => p_application_id
72286 ,p_event_id => l_event_id
72287 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72288 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72289 ,p_actual_flag => l_actual_flag
72290 ,p_balance_type_code => l_balance_type_code
72291 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72292
72293 , p_source_19 => l_array_source_19(Idx)
72294 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
72295 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
72296 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
72297 , p_source_33 => l_array_source_33(Idx)
72298 , p_source_34 => l_array_source_34(Idx)
72299 , p_source_35 => l_array_source_35(Idx)
72300 , p_source_36 => l_array_source_36(Idx)
72301 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
72302 , p_source_38 => l_array_source_38(Idx)
72303 , p_source_39 => l_array_source_39(Idx)
72304 , p_source_40 => l_array_source_40(Idx)
72305 , p_source_41 => l_array_source_41(Idx)
72306 , p_source_55 => l_array_source_55(Idx)
72307 );
72308 If(l_balance_type_code = 'A') THEN
72309 l_actual_gain_loss_ref := l_gain_or_loss_ref;
72310 END IF;
72311
72312 --
72313
72314
72315 --
72316 AcctLineType_61 (
72317 p_application_id => p_application_id
72318 ,p_event_id => l_event_id
72319 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72320 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72321 ,p_actual_flag => l_actual_flag
72322 ,p_balance_type_code => l_balance_type_code
72323 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72324
72325 , p_source_19 => l_array_source_19(Idx)
72326 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
72327 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
72328 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
72329 , p_source_33 => l_array_source_33(Idx)
72330 , p_source_34 => l_array_source_34(Idx)
72331 , p_source_35 => l_array_source_35(Idx)
72332 , p_source_36 => l_array_source_36(Idx)
72333 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
72334 , p_source_38 => l_array_source_38(Idx)
72335 , p_source_39 => l_array_source_39(Idx)
72336 , p_source_40 => l_array_source_40(Idx)
72337 , p_source_41 => l_array_source_41(Idx)
72338 , p_source_55 => l_array_source_55(Idx)
72339 );
72340 If(l_balance_type_code = 'A') THEN
72341 l_actual_gain_loss_ref := l_gain_or_loss_ref;
72342 END IF;
72343
72344 --
72345
72346
72347 --
72348 AcctLineType_62 (
72349 p_application_id => p_application_id
72350 ,p_event_id => l_event_id
72351 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72352 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72353 ,p_actual_flag => l_actual_flag
72354 ,p_balance_type_code => l_balance_type_code
72355 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72356
72357 , p_source_19 => l_array_source_19(Idx)
72358 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
72359 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
72360 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
72361 , p_source_33 => l_array_source_33(Idx)
72362 , p_source_34 => l_array_source_34(Idx)
72363 , p_source_35 => l_array_source_35(Idx)
72364 , p_source_36 => l_array_source_36(Idx)
72365 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
72366 , p_source_38 => l_array_source_38(Idx)
72367 , p_source_39 => l_array_source_39(Idx)
72368 , p_source_40 => l_array_source_40(Idx)
72369 , p_source_41 => l_array_source_41(Idx)
72370 , p_source_55 => l_array_source_55(Idx)
72371 );
72372 If(l_balance_type_code = 'A') THEN
72373 l_actual_gain_loss_ref := l_gain_or_loss_ref;
72374 END IF;
72375
72376 --
72377
72378
72379 --
72380 AcctLineType_63 (
72381 p_application_id => p_application_id
72382 ,p_event_id => l_event_id
72383 ,p_calculate_acctd_flag => l_calculate_acctd_flag
72384 ,p_calculate_g_l_flag => l_calculate_g_l_flag
72385 ,p_actual_flag => l_actual_flag
72386 ,p_balance_type_code => l_balance_type_code
72387 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
72388
72389 , p_source_19 => l_array_source_19(Idx)
72390 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
72391 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
72392 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
72393 , p_source_33 => l_array_source_33(Idx)
72394 , p_source_34 => l_array_source_34(Idx)
72395 , p_source_35 => l_array_source_35(Idx)
72396 , p_source_36 => l_array_source_36(Idx)
72397 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
72398 , p_source_38 => l_array_source_38(Idx)
72399 , p_source_39 => l_array_source_39(Idx)
72400 , p_source_40 => l_array_source_40(Idx)
72401 , p_source_41 => l_array_source_41(Idx)
72402 , p_source_55 => l_array_source_55(Idx)
72403 );
72404 If(l_balance_type_code = 'A') THEN
72405 l_actual_gain_loss_ref := l_gain_or_loss_ref;
72406 END IF;
72407
72408 --
72409
72410 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
72411 -- or secondary ledger that has different currency with primary
72412 -- or alc that is calculated by sla
72413 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
72414 (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'))
72415
72416 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
72417 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
72418 AND (l_actual_flag = 'A')) THEN
72419 XLA_AE_LINES_PKG.CreateGainOrLossLines(
72420 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
72421 ,p_application_id => p_application_id
72422 ,p_amb_context_code => 'DEFAULT'
72423 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
72424 ,p_event_class_code => C_EVENT_CLASS_CODE
72425 ,p_event_type_code => C_EVENT_TYPE_CODE
72426
72427 ,p_gain_ccid => -1
72428 ,p_loss_ccid => -1
72429
72430 ,p_actual_flag => l_actual_flag
72431 ,p_enc_flag => null
72432 ,p_actual_g_l_ref => l_actual_gain_loss_ref
72433 ,p_enc_g_l_ref => null
72434 );
72435 END IF;
72436 END IF;
72437 END IF;
72438
72439 ELSE
72440 --
72441 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
72442 --
72443 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72444 trace
72445 (p_msg => 'Trancaction revesal option is Y'
72446 ,p_level => C_LEVEL_STATEMENT
72447 ,p_module => l_log_module);
72448 END IF;
72449 END IF;
72450
72451 END LOOP;
72452 l_result := XLA_AE_LINES_PKG.InsertLines ;
72453 end loop;
72454 close line_cur;
72455
72456
72457 --
72458 -- insert headers into xla_ae_headers_gt table
72459 --
72460 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
72461
72462 -- insert into errors table here.
72463
72464 END LOOP;
72465
72466 --
72467 -- 4865292
72468 --
72469 -- Compare g_hdr_extract_count with event count in
72470 -- CreateHeadersAndLines.
72471 --
72472 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
72473
72474 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72475 trace (p_msg => '# rows extracted from header extract objects '
72476 || ' (running total): '
72477 || g_hdr_extract_count
72478 ,p_level => C_LEVEL_STATEMENT
72479 ,p_module => l_log_module);
72480 END IF;
72481
72482 CLOSE header_cur;
72483 --
72484
72485 --
72486 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
72487 trace
72488 (p_msg => 'END of EventClass_137'
72489 ,p_level => C_LEVEL_PROCEDURE
72490 ,p_module => l_log_module);
72491 END IF;
72492 --
72493 RETURN l_result;
72494 EXCEPTION
72495 WHEN xla_exceptions_pkg.application_exception THEN
72496
72497 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
72498
72499
72500 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
72501
72502 RAISE;
72503
72504 WHEN NO_DATA_FOUND THEN
72505
72506 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
72507 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
72508
72509 FOR header_record IN header_cur
72510 LOOP
72511 l_array_header_events(header_record.event_id) := header_record.event_id;
72512 END LOOP;
72513
72514 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
72515 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
72516
72517 fnd_file.put_line(fnd_file.LOG, ' ');
72518 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
72519 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
72520 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
72521
72522 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
72523 LOOP
72524 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
72525 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
72526 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
72527 END IF;
72528 END LOOP;
72529
72530 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
72531 fnd_file.put_line(fnd_file.LOG, ' ');
72532
72533
72534 xla_exceptions_pkg.raise_message
72535 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_137');
72536
72537
72538 WHEN OTHERS THEN
72539 xla_exceptions_pkg.raise_message
72540 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_137');
72541 END EventClass_137;
72542 --
72543
72544 ---------------------------------------
72545 --
72546 -- PRIVATE PROCEDURE
72547 -- insert_sources_138
72548 --
72549 ----------------------------------------
72550 --
72551 PROCEDURE insert_sources_138(
72552 p_target_ledger_id IN NUMBER
72553 , p_language IN VARCHAR2
72554 , p_sla_ledger_id IN NUMBER
72555 , p_pad_start_date IN DATE
72556 , p_pad_end_date IN DATE
72557 )
72558 IS
72559
72560 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT_ALL';
72561 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT';
72562 p_apps_owner VARCHAR2(30);
72563 l_log_module VARCHAR2(240);
72564 BEGIN
72565 IF g_log_enabled THEN
72566 l_log_module := C_DEFAULT_MODULE||'.insert_sources_138';
72567 END IF;
72568 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
72569
72570 trace
72571 (p_msg => 'BEGIN of insert_sources_138'
72572 ,p_level => C_LEVEL_PROCEDURE
72573 ,p_module => l_log_module);
72574
72575 END IF;
72576
72577 -- select APPS owner
72578 SELECT oracle_username
72579 INTO p_apps_owner
72580 FROM fnd_oracle_userid
72581 WHERE read_only_flag = 'U'
72582 ;
72583
72584 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72585 trace
72586 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
72587 ' - p_language = '||p_language||
72588 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
72589 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
72590 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
72591 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
72592 ,p_level => C_LEVEL_STATEMENT
72593 ,p_module => l_log_module);
72594 END IF;
72595
72596
72597 --
72598 INSERT INTO xla_diag_sources --hdr2
72599 (
72600 event_id
72601 , ledger_id
72602 , sla_ledger_id
72603 , description_language
72604 , object_name
72605 , object_type_code
72606 , line_number
72607 , source_application_id
72608 , source_type_code
72609 , source_code
72610 , source_value
72611 , source_meaning
72612 , created_by
72613 , creation_date
72614 , last_update_date
72615 , last_updated_by
72616 , last_update_login
72617 , program_update_date
72618 , program_application_id
72619 , program_id
72620 , request_id
72621 )
72622 SELECT
72623 event_id
72624 , p_target_ledger_id
72625 , p_sla_ledger_id
72626 , p_language
72627 , object_name
72628 , object_type_code
72629 , line_number
72630 , source_application_id
72631 , source_type_code
72632 , source_code
72633 , SUBSTR(source_value ,1,1996)
72634 , SUBSTR(source_meaning ,1,200)
72635 , xla_environment_pkg.g_Usr_Id
72636 , TRUNC(SYSDATE)
72637 , TRUNC(SYSDATE)
72638 , xla_environment_pkg.g_Usr_Id
72639 , xla_environment_pkg.g_Login_Id
72640 , TRUNC(SYSDATE)
72641 , xla_environment_pkg.g_Prog_Appl_Id
72642 , xla_environment_pkg.g_Prog_Id
72643 , xla_environment_pkg.g_Req_Id
72644 FROM (
72645 SELECT xet.event_id event_id
72646 , 0 line_number
72647 , CASE r
72648 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
72649 WHEN 2 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
72650 WHEN 3 THEN 'AR_BILL_TO_SITE_USES_S_V'
72651 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
72652 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
72653 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
72654 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
72655
72656 ELSE null
72657 END object_name
72658 , CASE r
72659 WHEN 1 THEN 'HEADER'
72660 WHEN 2 THEN 'HEADER'
72661 WHEN 3 THEN 'HEADER'
72662 WHEN 4 THEN 'HEADER'
72663 WHEN 5 THEN 'HEADER'
72664 WHEN 6 THEN 'HEADER'
72665 WHEN 7 THEN 'HEADER'
72666
72667 ELSE null
72668 END object_type_code
72669 , CASE r
72670 WHEN 1 THEN '222'
72671 WHEN 2 THEN '222'
72672 WHEN 3 THEN '222'
72673 WHEN 4 THEN '222'
72674 WHEN 5 THEN '222'
72675 WHEN 6 THEN '222'
72676 WHEN 7 THEN '222'
72677
72678 ELSE null
72679 END source_application_id
72680 , 'S' source_type_code
72681 , CASE r
72682 WHEN 1 THEN 'TRX_DOC_SEQUENCE_VALUE'
72683 WHEN 2 THEN 'BILL_CUST_ACCOUNT_ID'
72684 WHEN 3 THEN 'BILL_USES_SITE_USE_ID'
72685 WHEN 4 THEN 'XLA_PARTY_TYPE'
72686 WHEN 5 THEN 'TRX_INVOICE_CURRENCY_CODE'
72687 WHEN 6 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
72688 WHEN 7 THEN 'TRX_DOC_SEQUENCE_ID'
72689
72690 ELSE null
72691 END source_code
72692 , CASE r
72696 WHEN 4 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
72693 WHEN 1 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
72694 WHEN 2 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
72695 WHEN 3 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
72697 WHEN 5 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
72698 WHEN 6 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
72699 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
72700
72701 ELSE null
72702 END source_value
72703 , null source_meaning
72704 FROM xla_events_gt xet
72705 , AR_BILL_TO_CUSTOMERS_S_V h1
72706 , AR_BILL_TO_SITE_USES_S_V h2
72707 , AR_TRANSACTIONS_S_V h5
72708 ,(select rownum r from all_objects where rownum <= 7 and owner = p_apps_owner)
72709 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
72710 AND xet.event_class_code = C_EVENT_CLASS_CODE
72711 AND h1.event_id = xet.event_id
72712 AND h2.event_id = h1.event_id
72713 AND h5.event_id = h1.event_id
72714
72715 )
72716 ;
72717 --
72718 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72719
72720 trace
72721 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
72722 ,p_level => C_LEVEL_STATEMENT
72723 ,p_module => l_log_module);
72724
72725 END IF;
72726 --
72727
72728
72729
72730 --
72731 INSERT INTO xla_diag_sources --line2
72732 (
72733 event_id
72734 , ledger_id
72735 , sla_ledger_id
72736 , description_language
72737 , object_name
72738 , object_type_code
72739 , line_number
72740 , source_application_id
72741 , source_type_code
72742 , source_code
72743 , source_value
72744 , source_meaning
72745 , created_by
72746 , creation_date
72747 , last_update_date
72748 , last_updated_by
72749 , last_update_login
72750 , program_update_date
72751 , program_application_id
72752 , program_id
72753 , request_id
72754 )
72755 SELECT event_id
72756 , p_target_ledger_id
72757 , p_sla_ledger_id
72758 , p_language
72759 , object_name
72760 , object_type_code
72761 , line_number
72762 , source_application_id
72763 , source_type_code
72764 , source_code
72765 , SUBSTR(source_value,1,1996)
72766 , SUBSTR(source_meaning ,1,200)
72767 , xla_environment_pkg.g_Usr_Id
72768 , TRUNC(SYSDATE)
72769 , TRUNC(SYSDATE)
72770 , xla_environment_pkg.g_Usr_Id
72771 , xla_environment_pkg.g_Login_Id
72772 , TRUNC(SYSDATE)
72773 , xla_environment_pkg.g_Prog_Appl_Id
72774 , xla_environment_pkg.g_Prog_Id
72775 , xla_environment_pkg.g_Req_Id
72776 FROM (
72777 SELECT xet.event_id event_id
72778 , l4.line_number line_number
72779 , CASE r
72780 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
72781 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
72782 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
72783 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
72784 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
72785 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
72786 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
72787 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
72788 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
72789
72790 ELSE null
72791 END object_name
72792 , CASE r
72793 WHEN 1 THEN 'LINE'
72794 WHEN 2 THEN 'LINE'
72795 WHEN 3 THEN 'LINE'
72796 WHEN 4 THEN 'LINE'
72797 WHEN 5 THEN 'LINE'
72798 WHEN 6 THEN 'LINE'
72799 WHEN 7 THEN 'LINE'
72800 WHEN 8 THEN 'LINE'
72801 WHEN 9 THEN 'LINE'
72802
72803 ELSE null
72804 END object_type_code
72805 , CASE r
72806 WHEN 1 THEN '222'
72807 WHEN 2 THEN '222'
72808 WHEN 3 THEN '222'
72809 WHEN 4 THEN '222'
72810 WHEN 5 THEN '222'
72811 WHEN 6 THEN '222'
72812 WHEN 7 THEN '222'
72813 WHEN 8 THEN '222'
72814 WHEN 9 THEN '222'
72815
72816 ELSE null
72817 END source_application_id
72818 , 'S' source_type_code
72819 , CASE r
72820 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
72821 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
72822 WHEN 3 THEN 'TRX_LINE_DIST_ID'
72823 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
72824 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
72825 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
72826 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
72827 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
72828 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
72829
72830 ELSE null
72831 END source_code
72832 , CASE r
72833 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
72834 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
72835 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
72836 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
72837 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
72838 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
72839 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
72840 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
72841 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
72842
72843 ELSE null
72844 END source_value
72845 , null source_meaning
72846 FROM xla_events_gt xet
72847 , AR_CUST_TRX_LINES_BASE_V l3
72848 , AR_CUST_TRX_LINES_L_V l4
72849 , (select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
72850 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
72851 AND xet.event_class_code = C_EVENT_CLASS_CODE
72852 AND l3.event_id = xet.event_id
72853 AND l4.event_id = l3.event_id
72854 AND l4.line_number = l3.line_number
72855
72856 )
72857 ;
72858 --
72859 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
72860
72861 trace
72862 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
72863 ,p_level => C_LEVEL_STATEMENT
72864 ,p_module => l_log_module);
72865
72866 END IF;
72867
72868
72869 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
72870 trace
72874 END IF;
72871 (p_msg => 'END of insert_sources_138'
72872 ,p_level => C_LEVEL_PROCEDURE
72873 ,p_module => l_log_module);
72875 EXCEPTION
72876 WHEN xla_exceptions_pkg.application_exception THEN
72877 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
72878 trace
72879 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
72880 ,p_level => C_LEVEL_EXCEPTION
72881 ,p_module => l_log_module);
72882 END IF;
72883 RAISE;
72884 WHEN OTHERS THEN
72885 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
72886 trace
72887 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
72888 ,p_level => C_LEVEL_EXCEPTION
72889 ,p_module => l_log_module);
72890 END IF;
72891 xla_exceptions_pkg.raise_message
72892 (p_location => 'XLA_00222_AAD_S_000005_PKG.insert_sources_138');
72893 END insert_sources_138;
72894 --
72895
72896 ---------------------------------------
72897 --
72898 -- PRIVATE FUNCTION
72899 -- EventClass_138
72900 --
72901 ----------------------------------------
72902 --
72903 FUNCTION EventClass_138
72904 (p_application_id IN NUMBER
72905 ,p_base_ledger_id IN NUMBER
72906 ,p_target_ledger_id IN NUMBER
72907 ,p_language IN VARCHAR2
72908 ,p_currency_code IN VARCHAR2
72909 ,p_sla_ledger_id IN NUMBER
72910 ,p_pad_start_date IN DATE
72911 ,p_pad_end_date IN DATE
72912 ,p_primary_ledger_id IN NUMBER)
72913 RETURN BOOLEAN IS
72914 --
72915 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT_ALL';
72916 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'DEPOSIT';
72917
72918 l_calculate_acctd_flag VARCHAR2(1) :='N';
72919 l_calculate_g_l_flag VARCHAR2(1) :='N';
72920 --
72921 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72922 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72923 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
72924 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
72925 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72926 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
72927 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
72928 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72929 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72930 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72931 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72932 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72933 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72934 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
72935 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
72936 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
72937 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
72938 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
72939 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72940 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72941 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72942 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
72943 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
72944 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
72945 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
72946 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
72947
72948 l_event_id NUMBER;
72949 l_previous_event_id NUMBER;
72950 l_first_event_id NUMBER;
72951 l_last_event_id NUMBER;
72952
72953 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
72954 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
72955 --
72956 --
72957 l_result BOOLEAN := TRUE;
72958 l_rows NUMBER := 1000;
72959 l_event_type_name VARCHAR2(80) := 'All';
72960 l_event_class_name VARCHAR2(80) := 'Deposit';
72961 l_description VARCHAR2(4000);
72962 l_transaction_reversal NUMBER;
72963 l_ae_header_id NUMBER;
72964 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
72965 l_log_module VARCHAR2(240);
72966 --
72967 l_acct_reversal_source VARCHAR2(30);
72968 l_trx_reversal_source VARCHAR2(30);
72969
72970 l_continue_with_lines BOOLEAN := TRUE;
72971 --
72972 l_acc_rev_gl_date_source DATE; -- 4262811
72973 --
72974 type t_array_event_id is table of number index by binary_integer;
72975
72976 l_rec_array_event t_rec_array_event;
72977 l_null_rec_array_event t_rec_array_event;
72978 l_array_ae_header_id xla_number_array_type;
72979 l_actual_flag VARCHAR2(1) := NULL;
72980 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
72981 l_balance_type_code VARCHAR2(1) :=NULL;
72982 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
72983
72984 --
72985 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
72986 --
72987
72988 TYPE t_array_source_3 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
72989 TYPE t_array_source_30 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
72990 TYPE t_array_source_31 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
72991 TYPE t_array_source_32 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
72992 TYPE t_array_source_37 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
72993 TYPE t_array_source_81 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
72994 TYPE t_array_source_82 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
72995
72996 TYPE t_array_source_19 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
72997 TYPE t_array_source_33 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
72998 TYPE t_array_source_34 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
72999 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
73000 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
73001 TYPE t_array_source_38 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
73002 TYPE t_array_source_39 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
73003 TYPE t_array_source_40 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
73004 TYPE t_array_source_41 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
73005
73006 l_array_source_3 t_array_source_3;
73007 l_array_source_30 t_array_source_30;
73008 l_array_source_31 t_array_source_31;
73009 l_array_source_32 t_array_source_32;
73010 l_array_source_37 t_array_source_37;
73011 l_array_source_81 t_array_source_81;
73012 l_array_source_82 t_array_source_82;
73013
73014 l_array_source_19 t_array_source_19;
73015 l_array_source_33 t_array_source_33;
73016 l_array_source_34 t_array_source_34;
73017 l_array_source_35 t_array_source_35;
73018 l_array_source_36 t_array_source_36;
73019 l_array_source_38 t_array_source_38;
73020 l_array_source_39 t_array_source_39;
73021 l_array_source_40 t_array_source_40;
73022 l_array_source_41 t_array_source_41;
73023
73024 --
73025 CURSOR header_cur
73026 IS
73027 SELECT /*+ leading(xet) cardinality(xet,1) */
73028 -- Event Class Code: DEPOSIT
73029 xet.entity_id
73030 ,xet.legal_entity_id
73031 ,xet.entity_code
73032 ,xet.transaction_number
73033 ,xet.event_id
73034 ,xet.event_class_code
73035 ,xet.event_type_code
73036 ,xet.event_number
73037 ,xet.event_date
73038 ,xet.transaction_date
73039 ,xet.reference_num_1
73040 ,xet.reference_num_2
73041 ,xet.reference_num_3
73042 ,xet.reference_num_4
73043 ,xet.reference_char_1
73044 ,xet.reference_char_2
73045 ,xet.reference_char_3
73046 ,xet.reference_char_4
73047 ,xet.reference_date_1
73048 ,xet.reference_date_2
73049 ,xet.reference_date_3
73050 ,xet.reference_date_4
73051 ,xet.event_created_by
73052 ,xet.budgetary_control_flag
73053 , h5.TRX_DOC_SEQUENCE_VALUE source_3
73054 , h1.BILL_CUST_ACCOUNT_ID source_30
73055 , h2.BILL_USES_SITE_USE_ID source_31
73056 , h5.XLA_PARTY_TYPE source_32
73057 , h5.TRX_INVOICE_CURRENCY_CODE source_37
73058 , h5.TRX_DOC_SEQUENCE_CATEGORY source_81
73059 , h5.TRX_DOC_SEQUENCE_ID source_82
73060 FROM xla_events_gt xet
73061 , AR_BILL_TO_CUSTOMERS_S_V h1
73062 , AR_BILL_TO_SITE_USES_S_V h2
73063 , AR_TRANSACTIONS_S_V h5
73064 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
73065 and xet.event_class_code = C_EVENT_CLASS_CODE
73066 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
73067 AND h2.event_id = h1.event_id
73068 AND h5.event_id = h1.event_id
73069
73070 ORDER BY event_id
73071 ;
73072
73073
73074 --
73075 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
73076 IS
73077 SELECT /*+ leading(xet) cardinality(xet,1) */
73078 -- Event Class Code: DEPOSIT
73079 xet.entity_id
73080 ,xet.legal_entity_id
73081 ,xet.entity_code
73082 ,xet.transaction_number
73083 ,xet.event_id
73084 ,xet.event_class_code
73085 ,xet.event_type_code
73086 ,xet.event_number
73087 ,xet.event_date
73088 ,xet.transaction_date
73089 ,xet.reference_num_1
73090 ,xet.reference_num_2
73091 ,xet.reference_num_3
73092 ,xet.reference_num_4
73093 ,xet.reference_char_1
73094 ,xet.reference_char_2
73095 ,xet.reference_char_3
73096 ,xet.reference_char_4
73097 ,xet.reference_date_1
73098 ,xet.reference_date_2
73099 ,xet.reference_date_3
73100 ,xet.reference_date_4
73101 ,xet.event_created_by
73102 ,xet.budgetary_control_flag
73103 , l3.LINE_NUMBER
73104 , l4.TRX_LINE_DIST_CCID source_19
73105 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_33
73106 , l4.TRX_LINE_DIST_ID source_34
73107 , l4.TRX_DISTRIBUTION_TYPE source_35
73108 , l4.TRX_LINE_DIST_AMT source_36
73109 , l3.TRX_LINE_CUR_CONVERSION_DATE source_38
73110 , l3.TRX_LINE_CUR_CONVERSION_RATE source_39
73111 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_40
73112 , l3.TRX_LINE_ACCTD_AMT source_41
73113 FROM xla_events_gt xet
73114 , AR_CUST_TRX_LINES_BASE_V l3
73115 , AR_CUST_TRX_LINES_L_V l4
73116 WHERE xet.event_id between x_first_event_id and x_last_event_id
73117 and xet.event_date between p_pad_start_date and p_pad_end_date
73118 and xet.event_class_code = C_EVENT_CLASS_CODE
73119 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
73120 AND l4.event_id = l3.event_id
73121 AND l4.line_number = l3.line_number
73122 ;
73123
73124 --
73125 BEGIN
73126 IF g_log_enabled THEN
73127 l_log_module := C_DEFAULT_MODULE||'.EventClass_138';
73128 END IF;
73129 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
73130 trace
73131 (p_msg => 'BEGIN of EventClass_138'
73132 ,p_level => C_LEVEL_PROCEDURE
73133 ,p_module => l_log_module);
73134 END IF;
73135
73136 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73137 trace
73138 (p_msg => 'p_application_id = '||p_application_id||
73139 ' - p_base_ledger_id = '||p_base_ledger_id||
73140 ' - p_target_ledger_id = '||p_target_ledger_id||
73141 ' - p_language = '||p_language||
73142 ' - p_currency_code = '||p_currency_code||
73143 ' - p_sla_ledger_id = '||p_sla_ledger_id
73144 ,p_level => C_LEVEL_STATEMENT
73145 ,p_module => l_log_module);
73146 END IF;
73147 --
73148 -- initialze arrays
73149 --
73150 g_array_event.DELETE;
73151 l_rec_array_event := l_null_rec_array_event;
73152 --
73153 --------------------------------------
73154 -- 4262811 Initialze MPA Line Number
73155 --------------------------------------
73156 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
73157
73158 --
73159
73160 --
73161 OPEN header_cur;
73162 --
73163 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73164 trace
73165 (p_msg => 'SQL - FETCH header_cur'
73166 ,p_level => C_LEVEL_STATEMENT
73167 ,p_module => l_log_module);
73168 END IF;
73169 --
73170 LOOP
73171 FETCH header_cur BULK COLLECT INTO
73172 l_array_entity_id
73173 , l_array_legal_entity_id
73174 , l_array_entity_code
73175 , l_array_transaction_num
73176 , l_array_event_id
73177 , l_array_class_code
73178 , l_array_event_type
73179 , l_array_event_number
73180 , l_array_event_date
73181 , l_array_transaction_date
73182 , l_array_reference_num_1
73183 , l_array_reference_num_2
73184 , l_array_reference_num_3
73185 , l_array_reference_num_4
73186 , l_array_reference_char_1
73187 , l_array_reference_char_2
73188 , l_array_reference_char_3
73189 , l_array_reference_char_4
73190 , l_array_reference_date_1
73191 , l_array_reference_date_2
73192 , l_array_reference_date_3
73193 , l_array_reference_date_4
73194 , l_array_event_created_by
73195 , l_array_budgetary_control_flag
73196 , l_array_source_3
73197 , l_array_source_30
73198 , l_array_source_31
73199 , l_array_source_32
73200 , l_array_source_37
73201 , l_array_source_81
73202 , l_array_source_82
73203 LIMIT l_rows;
73204 --
73205 IF (C_LEVEL_EVENT >= g_log_level) THEN
73206 trace
73207 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
73208 ,p_level => C_LEVEL_EVENT
73209 ,p_module => l_log_module);
73210 END IF;
73211 --
73212 EXIT WHEN l_array_entity_id.COUNT = 0;
73213
73214 -- initialize arrays
73215 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
73216 XLA_AE_LINES_PKG.g_rec_lines := NULL;
73217
73218 --
73219 -- Bug 4458708
73220 --
73221 XLA_AE_LINES_PKG.g_LineNumber := 0;
73222
73223
73224 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
73225 g_last_hdr_idx := l_array_event_id.LAST;
73226 --
73227 -- loop for the headers. Each iteration is for each header extract row
73228 -- fetched in header cursor
73229 --
73230 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
73231
73232 --
73233 -- set event info as cache for other routines to refer event attributes
73234 --
73235 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
73236 (p_application_id => p_application_id
73237 ,p_primary_ledger_id => p_primary_ledger_id
73238 ,p_base_ledger_id => p_base_ledger_id
73239 ,p_target_ledger_id => p_target_ledger_id
73240 ,p_entity_id => l_array_entity_id(hdr_idx)
73241 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
73242 ,p_entity_code => l_array_entity_code(hdr_idx)
73243 ,p_transaction_num => l_array_transaction_num(hdr_idx)
73244 ,p_event_id => l_array_event_id(hdr_idx)
73245 ,p_event_class_code => l_array_class_code(hdr_idx)
73246 ,p_event_type_code => l_array_event_type(hdr_idx)
73247 ,p_event_number => l_array_event_number(hdr_idx)
73248 ,p_event_date => l_array_event_date(hdr_idx)
73249 ,p_transaction_date => l_array_transaction_date(hdr_idx)
73250 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
73251 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
73252 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
73253 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
73254 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
73255 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
73256 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
73257 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
73258 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
73259 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
73260 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
73261 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
73262 ,p_event_created_by => l_array_event_created_by(hdr_idx)
73263 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
73264
73265 --
73266 -- set the status of entry to C_VALID (0)
73267 --
73268 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
73269
73270 --
73271 -- initialize a row for ae header
73272 --
73273 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
73274
73275 l_event_id := l_array_event_id(hdr_idx);
73276
73277 --
73278 -- storing the hdr_idx for event. May be used by line cursor.
73279 --
73280 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
73281
73282 --
73283 -- store sources from header extract. This can be improved to
73284 -- store only those sources from header extract that may be used in lines
73285 --
73286
73287 g_array_event(l_event_id).array_value_num('source_3') := l_array_source_3(hdr_idx);
73288 g_array_event(l_event_id).array_value_num('source_30') := l_array_source_30(hdr_idx);
73289 g_array_event(l_event_id).array_value_num('source_31') := l_array_source_31(hdr_idx);
73290 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
73291 g_array_event(l_event_id).array_value_char('source_37') := l_array_source_37(hdr_idx);
73292 g_array_event(l_event_id).array_value_char('source_81') := l_array_source_81(hdr_idx);
73293 g_array_event(l_event_id).array_value_num('source_82') := l_array_source_82(hdr_idx);
73294
73295 --
73296 -- initilaize the status of ae headers for diffrent balance types
73297 -- the status is initialised to C_NOT_CREATED (2)
73298 --
73299 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
73300 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
73301 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
73302
73303 --
73304 -- call api to validate and store accounting attributes for header
73305 --
73306
73307 ------------------------------------------------------------
73308 -- Accrual Reversal : to get date for Standard Source (NONE)
73312 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
73309 ------------------------------------------------------------
73310 l_acc_rev_gl_date_source := NULL;
73311
73313 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_81');
73314 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
73315 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_82');
73316 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
73317 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_3');
73318 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
73319 l_rec_acct_attrs.array_date_value(4) :=
73320 xla_ae_sources_pkg.GetSystemSourceDate(
73321 p_source_code => 'XLA_EVENT_DATE'
73322 , p_source_type_code => 'Y'
73323 , p_source_application_id => 602
73324 );
73325
73326
73327 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
73328
73329 XLA_AE_HEADER_PKG.SetJeCategoryName;
73330
73331 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
73332 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
73333 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
73334 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
73335 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
73336
73337
73338 -- No header level analytical criteria
73339
73340 --
73341 --accounting attribute enhancement, bug 3612931
73342 --
73343 l_trx_reversal_source := SUBSTR(NULL, 1,30);
73344
73345 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
73346 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
73347
73348 xla_accounting_err_pkg.build_message
73349 (p_appli_s_name => 'XLA'
73350 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
73351 ,p_token_1 => 'ACCT_ATTR_NAME'
73352 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
73353 ,p_token_2 => 'PRODUCT_NAME'
73354 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
73355 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
73356 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
73357 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
73358
73359 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
73360 --
73361 -- following sets the accounting attributes needed to reverse
73362 -- accounting for a distributeion
73363 --
73364 xla_ae_lines_pkg.SetTrxReversalAttrs
73365 (p_event_id => l_event_id
73366 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
73367 ,p_trx_reversal_source => l_trx_reversal_source);
73368
73369 END IF;
73370
73371
73372 ----------------------------------------------------------------
73373 -- 4262811 - update the header statuses to invalid in need be
73374 ----------------------------------------------------------------
73375 --
73376 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
73377
73378
73379 -----------------------------------------------
73380 -- No accrual reversal for the event class/type
73381 -----------------------------------------------
73382 ----------------------------------------------------------------
73383
73384 --
73385 -- this ends the header loop iteration for one bulk fetch
73386 --
73387 END LOOP;
73388
73389 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
73390 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
73391
73392 --
73393 -- insert dummy rows into lines gt table that were created due to
73394 -- transaction reversals
73395 --
73396 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
73397 l_result := XLA_AE_LINES_PKG.InsertLines;
73398 END IF;
73399
73400 --
73401 -- reset the temp_line_num for each set of events fetched from header
73402 -- cursor rather than doing it for each new event in line cursor
73403 -- Bug 3939231
73404 --
73405 xla_ae_lines_pkg.g_temp_line_num := 0;
73406
73407
73408
73409 --
73410 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
73411 --
73412 --
73413 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73414
73415 trace
73416 (p_msg => 'SQL - FETCH line_cur'
73417 ,p_level => C_LEVEL_STATEMENT
73418 ,p_module => l_log_module);
73419
73420 END IF;
73421 --
73422 --
73423 LOOP
73424 --
73425 FETCH line_cur BULK COLLECT INTO
73426 l_array_entity_id
73427 , l_array_legal_entity_id
73428 , l_array_entity_code
73429 , l_array_transaction_num
73430 , l_array_event_id
73431 , l_array_class_code
73432 , l_array_event_type
73433 , l_array_event_number
73434 , l_array_event_date
73435 , l_array_transaction_date
73436 , l_array_reference_num_1
73437 , l_array_reference_num_2
73438 , l_array_reference_num_3
73439 , l_array_reference_num_4
73440 , l_array_reference_char_1
73441 , l_array_reference_char_2
73442 , l_array_reference_char_3
73443 , l_array_reference_char_4
73444 , l_array_reference_date_1
73445 , l_array_reference_date_2
73446 , l_array_reference_date_3
73447 , l_array_reference_date_4
73448 , l_array_event_created_by
73449 , l_array_budgetary_control_flag
73450 , l_array_extract_line_num
73451 , l_array_source_19
73452 , l_array_source_33
73453 , l_array_source_34
73454 , l_array_source_35
73455 , l_array_source_36
73456 , l_array_source_38
73457 , l_array_source_39
73458 , l_array_source_40
73459 , l_array_source_41
73460 LIMIT l_rows;
73461
73462 --
73463 IF (C_LEVEL_EVENT >= g_log_level) THEN
73464 trace
73465 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
73466 ,p_level => C_LEVEL_EVENT
73467 ,p_module => l_log_module);
73468 END IF;
73469 --
73470 EXIT WHEN l_array_entity_id.count = 0;
73471
73472 XLA_AE_LINES_PKG.g_rec_lines := null;
73473
73474 --
73475 -- Bug 4458708
73476 --
73477 XLA_AE_LINES_PKG.g_LineNumber := 0;
73478 --
73479 --
73480
73481 FOR Idx IN 1..l_array_event_id.count LOOP
73482 --
73483 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
73484 --
73485 l_event_id := l_array_event_id(idx); -- 5648433
73486
73487 --
73488 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
73489 --
73490
73491 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
73492 (g_array_event(l_event_id).array_value_num('header_index'))
73493 ,'N'
73494 ) <> 'Y'
73495 THEN
73496 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73497 trace
73498 (p_msg => 'Trancaction revesal option is not Y '
73499 ,p_level => C_LEVEL_STATEMENT
73500 ,p_module => l_log_module);
73501 END IF;
73502
73503 --
73504 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
73505 --
73506 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
73507 --
73508 -- set event info as cache for other routines to refer event attributes
73509 --
73510
73511 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
73512 l_previous_event_id := l_event_id;
73513
73514 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
73515 (p_application_id => p_application_id
73516 ,p_primary_ledger_id => p_primary_ledger_id
73517 ,p_base_ledger_id => p_base_ledger_id
73518 ,p_target_ledger_id => p_target_ledger_id
73519 ,p_entity_id => l_array_entity_id(Idx)
73520 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
73521 ,p_entity_code => l_array_entity_code(Idx)
73522 ,p_transaction_num => l_array_transaction_num(Idx)
73523 ,p_event_id => l_array_event_id(Idx)
73524 ,p_event_class_code => l_array_class_code(Idx)
73525 ,p_event_type_code => l_array_event_type(Idx)
73526 ,p_event_number => l_array_event_number(Idx)
73527 ,p_event_date => l_array_event_date(Idx)
73528 ,p_transaction_date => l_array_transaction_date(Idx)
73529 ,p_reference_num_1 => l_array_reference_num_1(Idx)
73530 ,p_reference_num_2 => l_array_reference_num_2(Idx)
73531 ,p_reference_num_3 => l_array_reference_num_3(Idx)
73532 ,p_reference_num_4 => l_array_reference_num_4(Idx)
73533 ,p_reference_char_1 => l_array_reference_char_1(Idx)
73534 ,p_reference_char_2 => l_array_reference_char_2(Idx)
73535 ,p_reference_char_3 => l_array_reference_char_3(Idx)
73536 ,p_reference_char_4 => l_array_reference_char_4(Idx)
73537 ,p_reference_date_1 => l_array_reference_date_1(Idx)
73538 ,p_reference_date_2 => l_array_reference_date_2(Idx)
73539 ,p_reference_date_3 => l_array_reference_date_3(Idx)
73540 ,p_reference_date_4 => l_array_reference_date_4(Idx)
73541 ,p_event_created_by => l_array_event_created_by(Idx)
73542 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
73543 --
73544 END IF;
73545
73546
73547
73548 --
73549 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
73550
73551 l_acct_reversal_source := SUBSTR(NULL, 1,30);
73552
73553 IF l_continue_with_lines THEN
73554 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
73555 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
73556
73557 xla_accounting_err_pkg.build_message
73558 (p_appli_s_name => 'XLA'
73559 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
73560 ,p_token_1 => 'LINE_NUMBER'
73561 ,p_value_1 => l_array_extract_line_num(Idx)
73562 ,p_token_2 => 'PRODUCT_NAME'
73563 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
73564 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
73565 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
73566 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
73567
73568 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
73569 --
73570 -- following sets the accounting attributes needed to reverse
73571 -- accounting for a distributeion
73572 --
73573
73574 --
73575 -- 5217187
73576 --
73577 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
73578 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
73579 g_array_event(l_event_id).array_value_num('header_index'));
73580 --
73581 --
73582
73583 -- No reversal code generated
73584
73585 xla_ae_lines_pkg.SetAcctReversalAttrs
73586 (p_event_id => l_event_id
73587 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
73588 ,p_calculate_acctd_flag => l_calculate_acctd_flag
73589 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
73590 END IF;
73591
73592 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
73593 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
73594
73595 --
73596 AcctLineType_53 (
73597 p_application_id => p_application_id
73598 ,p_event_id => l_event_id
73599 ,p_calculate_acctd_flag => l_calculate_acctd_flag
73600 ,p_calculate_g_l_flag => l_calculate_g_l_flag
73601 ,p_actual_flag => l_actual_flag
73602 ,p_balance_type_code => l_balance_type_code
73603 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
73604
73605 , p_source_19 => l_array_source_19(Idx)
73606 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
73607 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
73608 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
73609 , p_source_33 => l_array_source_33(Idx)
73610 , p_source_34 => l_array_source_34(Idx)
73611 , p_source_35 => l_array_source_35(Idx)
73612 , p_source_36 => l_array_source_36(Idx)
73613 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
73614 , p_source_38 => l_array_source_38(Idx)
73615 , p_source_39 => l_array_source_39(Idx)
73616 , p_source_40 => l_array_source_40(Idx)
73617 , p_source_41 => l_array_source_41(Idx)
73618 );
73619 If(l_balance_type_code = 'A') THEN
73620 l_actual_gain_loss_ref := l_gain_or_loss_ref;
73621 END IF;
73622
73623 --
73624
73625
73626 --
73627 AcctLineType_54 (
73628 p_application_id => p_application_id
73629 ,p_event_id => l_event_id
73630 ,p_calculate_acctd_flag => l_calculate_acctd_flag
73631 ,p_calculate_g_l_flag => l_calculate_g_l_flag
73632 ,p_actual_flag => l_actual_flag
73633 ,p_balance_type_code => l_balance_type_code
73634 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
73635
73636 , p_source_19 => l_array_source_19(Idx)
73637 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
73638 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
73639 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
73640 , p_source_33 => l_array_source_33(Idx)
73641 , p_source_34 => l_array_source_34(Idx)
73642 , p_source_35 => l_array_source_35(Idx)
73643 , p_source_36 => l_array_source_36(Idx)
73644 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
73645 , p_source_38 => l_array_source_38(Idx)
73646 , p_source_39 => l_array_source_39(Idx)
73647 , p_source_40 => l_array_source_40(Idx)
73648 , p_source_41 => l_array_source_41(Idx)
73649 );
73650 If(l_balance_type_code = 'A') THEN
73651 l_actual_gain_loss_ref := l_gain_or_loss_ref;
73652 END IF;
73653
73654 --
73655
73656 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
73657 -- or secondary ledger that has different currency with primary
73658 -- or alc that is calculated by sla
73659 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
73660 (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'))
73661
73662 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
73663 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
73664 AND (l_actual_flag = 'A')) THEN
73665 XLA_AE_LINES_PKG.CreateGainOrLossLines(
73666 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
73667 ,p_application_id => p_application_id
73668 ,p_amb_context_code => 'DEFAULT'
73669 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
73670 ,p_event_class_code => C_EVENT_CLASS_CODE
73671 ,p_event_type_code => C_EVENT_TYPE_CODE
73672
73673 ,p_gain_ccid => -1
73674 ,p_loss_ccid => -1
73675
73676 ,p_actual_flag => l_actual_flag
73677 ,p_enc_flag => null
73678 ,p_actual_g_l_ref => l_actual_gain_loss_ref
73679 ,p_enc_g_l_ref => null
73680 );
73681 END IF;
73682 END IF;
73683 END IF;
73684
73685 ELSE
73686 --
73687 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
73688 --
73689 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73690 trace
73691 (p_msg => 'Trancaction revesal option is Y'
73692 ,p_level => C_LEVEL_STATEMENT
73693 ,p_module => l_log_module);
73694 END IF;
73695 END IF;
73696
73697 END LOOP;
73698 l_result := XLA_AE_LINES_PKG.InsertLines ;
73699 end loop;
73700 close line_cur;
73701
73702
73703 --
73704 -- insert headers into xla_ae_headers_gt table
73705 --
73706 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
73707
73708 -- insert into errors table here.
73709
73710 END LOOP;
73711
73712 --
73713 -- 4865292
73714 --
73715 -- Compare g_hdr_extract_count with event count in
73716 -- CreateHeadersAndLines.
73717 --
73718 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
73719
73720 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73721 trace (p_msg => '# rows extracted from header extract objects '
73722 || ' (running total): '
73723 || g_hdr_extract_count
73724 ,p_level => C_LEVEL_STATEMENT
73725 ,p_module => l_log_module);
73726 END IF;
73727
73728 CLOSE header_cur;
73729 --
73730
73731 --
73732 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
73733 trace
73734 (p_msg => 'END of EventClass_138'
73735 ,p_level => C_LEVEL_PROCEDURE
73736 ,p_module => l_log_module);
73737 END IF;
73738 --
73739 RETURN l_result;
73740 EXCEPTION
73741 WHEN xla_exceptions_pkg.application_exception THEN
73742
73743 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
73744
73745
73746 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
73747
73748 RAISE;
73749
73750 WHEN NO_DATA_FOUND THEN
73751
73752 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
73753 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
73754
73755 FOR header_record IN header_cur
73756 LOOP
73757 l_array_header_events(header_record.event_id) := header_record.event_id;
73758 END LOOP;
73759
73760 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
73761 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
73762
73763 fnd_file.put_line(fnd_file.LOG, ' ');
73764 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
73765 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
73766 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
73767
73768 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
73769 LOOP
73770 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
73771 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
73772 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
73773 END IF;
73774 END LOOP;
73775
73776 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
73777 fnd_file.put_line(fnd_file.LOG, ' ');
73778
73779
73780 xla_exceptions_pkg.raise_message
73781 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_138');
73782
73783
73784 WHEN OTHERS THEN
73785 xla_exceptions_pkg.raise_message
73786 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_138');
73787 END EventClass_138;
73788 --
73789
73790 ---------------------------------------
73791 --
73792 -- PRIVATE PROCEDURE
73793 -- insert_sources_139
73794 --
73795 ----------------------------------------
73796 --
73797 PROCEDURE insert_sources_139(
73798 p_target_ledger_id IN NUMBER
73799 , p_language IN VARCHAR2
73800 , p_sla_ledger_id IN NUMBER
73801 , p_pad_start_date IN DATE
73802 , p_pad_end_date IN DATE
73803 )
73804 IS
73805
73806 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE_ALL';
73807 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE';
73808 p_apps_owner VARCHAR2(30);
73809 l_log_module VARCHAR2(240);
73810 BEGIN
73811 IF g_log_enabled THEN
73812 l_log_module := C_DEFAULT_MODULE||'.insert_sources_139';
73813 END IF;
73814 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
73815
73816 trace
73817 (p_msg => 'BEGIN of insert_sources_139'
73818 ,p_level => C_LEVEL_PROCEDURE
73819 ,p_module => l_log_module);
73820
73821 END IF;
73822
73823 -- select APPS owner
73824 SELECT oracle_username
73825 INTO p_apps_owner
73826 FROM fnd_oracle_userid
73827 WHERE read_only_flag = 'U'
73828 ;
73829
73830 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73831 trace
73832 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
73833 ' - p_language = '||p_language||
73834 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
73835 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
73836 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
73837 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
73838 ,p_level => C_LEVEL_STATEMENT
73839 ,p_module => l_log_module);
73840 END IF;
73841
73842
73843 --
73844 INSERT INTO xla_diag_sources --hdr2
73845 (
73846 event_id
73847 , ledger_id
73848 , sla_ledger_id
73849 , description_language
73850 , object_name
73851 , object_type_code
73852 , line_number
73853 , source_application_id
73854 , source_type_code
73855 , source_code
73856 , source_value
73857 , source_meaning
73858 , created_by
73859 , creation_date
73860 , last_update_date
73861 , last_updated_by
73862 , last_update_login
73863 , program_update_date
73864 , program_application_id
73865 , program_id
73866 , request_id
73867 )
73868 SELECT
73869 event_id
73870 , p_target_ledger_id
73871 , p_sla_ledger_id
73872 , p_language
73873 , object_name
73874 , object_type_code
73875 , line_number
73876 , source_application_id
73877 , source_type_code
73878 , source_code
73879 , SUBSTR(source_value ,1,1996)
73880 , SUBSTR(source_meaning ,1,200)
73881 , xla_environment_pkg.g_Usr_Id
73882 , TRUNC(SYSDATE)
73883 , TRUNC(SYSDATE)
73884 , xla_environment_pkg.g_Usr_Id
73885 , xla_environment_pkg.g_Login_Id
73886 , TRUNC(SYSDATE)
73887 , xla_environment_pkg.g_Prog_Appl_Id
73888 , xla_environment_pkg.g_Prog_Id
73889 , xla_environment_pkg.g_Req_Id
73890 FROM (
73891 SELECT xet.event_id event_id
73892 , 0 line_number
73893 , CASE r
73894 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
73895 WHEN 2 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
73896 WHEN 3 THEN 'AR_BILL_TO_SITE_USES_S_V'
73897 WHEN 4 THEN 'AR_TRANSACTIONS_S_V'
73898 WHEN 5 THEN 'AR_TRANSACTIONS_S_V'
73899 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
73900 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
73901
73902 ELSE null
73903 END object_name
73904 , CASE r
73905 WHEN 1 THEN 'HEADER'
73906 WHEN 2 THEN 'HEADER'
73907 WHEN 3 THEN 'HEADER'
73908 WHEN 4 THEN 'HEADER'
73909 WHEN 5 THEN 'HEADER'
73910 WHEN 6 THEN 'HEADER'
73911 WHEN 7 THEN 'HEADER'
73912
73913 ELSE null
73914 END object_type_code
73915 , CASE r
73916 WHEN 1 THEN '222'
73917 WHEN 2 THEN '222'
73918 WHEN 3 THEN '222'
73919 WHEN 4 THEN '222'
73920 WHEN 5 THEN '222'
73921 WHEN 6 THEN '222'
73922 WHEN 7 THEN '222'
73923
73924 ELSE null
73925 END source_application_id
73926 , 'S' source_type_code
73927 , CASE r
73928 WHEN 1 THEN 'TRX_DOC_SEQUENCE_VALUE'
73929 WHEN 2 THEN 'BILL_CUST_ACCOUNT_ID'
73930 WHEN 3 THEN 'BILL_USES_SITE_USE_ID'
73931 WHEN 4 THEN 'XLA_PARTY_TYPE'
73932 WHEN 5 THEN 'TRX_INVOICE_CURRENCY_CODE'
73933 WHEN 6 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
73934 WHEN 7 THEN 'TRX_DOC_SEQUENCE_ID'
73935
73936 ELSE null
73937 END source_code
73938 , CASE r
73939 WHEN 1 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
73940 WHEN 2 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
73941 WHEN 3 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
73942 WHEN 4 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
73943 WHEN 5 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
73944 WHEN 6 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
73945 WHEN 7 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
73946
73947 ELSE null
73948 END source_value
73949 , null source_meaning
73950 FROM xla_events_gt xet
73951 , AR_BILL_TO_CUSTOMERS_S_V h1
73952 , AR_BILL_TO_SITE_USES_S_V h2
73953 , AR_TRANSACTIONS_S_V h5
73954 ,(select rownum r from all_objects where rownum <= 7 and owner = p_apps_owner)
73955 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
73956 AND xet.event_class_code = C_EVENT_CLASS_CODE
73957 AND h1.event_id = xet.event_id
73958 AND h2.event_id = h1.event_id
73959 AND h5.event_id = h1.event_id
73960
73961 )
73962 ;
73963 --
73964 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
73965
73966 trace
73967 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
73968 ,p_level => C_LEVEL_STATEMENT
73969 ,p_module => l_log_module);
73970
73971 END IF;
73972 --
73973
73974
73975
73976 --
73977 INSERT INTO xla_diag_sources --line2
73978 (
73979 event_id
73980 , ledger_id
73981 , sla_ledger_id
73982 , description_language
73983 , object_name
73984 , object_type_code
73985 , line_number
73986 , source_application_id
73987 , source_type_code
73988 , source_code
73989 , source_value
73990 , source_meaning
73991 , created_by
73992 , creation_date
73993 , last_update_date
73994 , last_updated_by
73995 , last_update_login
73996 , program_update_date
73997 , program_application_id
73998 , program_id
73999 , request_id
74000 )
74001 SELECT event_id
74002 , p_target_ledger_id
74003 , p_sla_ledger_id
74004 , p_language
74005 , object_name
74006 , object_type_code
74007 , line_number
74008 , source_application_id
74009 , source_type_code
74010 , source_code
74011 , SUBSTR(source_value,1,1996)
74012 , SUBSTR(source_meaning ,1,200)
74013 , xla_environment_pkg.g_Usr_Id
74014 , TRUNC(SYSDATE)
74015 , TRUNC(SYSDATE)
74016 , xla_environment_pkg.g_Usr_Id
74017 , xla_environment_pkg.g_Login_Id
74018 , TRUNC(SYSDATE)
74019 , xla_environment_pkg.g_Prog_Appl_Id
74020 , xla_environment_pkg.g_Prog_Id
74021 , xla_environment_pkg.g_Req_Id
74022 FROM (
74023 SELECT xet.event_id event_id
74024 , l4.line_number line_number
74025 , CASE r
74026 WHEN 1 THEN 'AR_CUST_TRX_LINES_L_V'
74027 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
74028 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
74029 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
74030 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
74031 WHEN 6 THEN 'AR_CUST_TRX_LINES_BASE_V'
74032 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
74033 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
74034 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
74035
74036 ELSE null
74037 END object_name
74038 , CASE r
74039 WHEN 1 THEN 'LINE'
74040 WHEN 2 THEN 'LINE'
74041 WHEN 3 THEN 'LINE'
74042 WHEN 4 THEN 'LINE'
74043 WHEN 5 THEN 'LINE'
74044 WHEN 6 THEN 'LINE'
74045 WHEN 7 THEN 'LINE'
74046 WHEN 8 THEN 'LINE'
74047 WHEN 9 THEN 'LINE'
74048
74049 ELSE null
74050 END object_type_code
74051 , CASE r
74052 WHEN 1 THEN '222'
74053 WHEN 2 THEN '222'
74054 WHEN 3 THEN '222'
74055 WHEN 4 THEN '222'
74056 WHEN 5 THEN '222'
74057 WHEN 6 THEN '222'
74058 WHEN 7 THEN '222'
74059 WHEN 8 THEN '222'
74060 WHEN 9 THEN '222'
74061
74062 ELSE null
74063 END source_application_id
74064 , 'S' source_type_code
74065 , CASE r
74066 WHEN 1 THEN 'TRX_LINE_DIST_CCID'
74067 WHEN 2 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
74068 WHEN 3 THEN 'TRX_LINE_DIST_ID'
74069 WHEN 4 THEN 'TRX_DISTRIBUTION_TYPE'
74070 WHEN 5 THEN 'TRX_LINE_DIST_AMT'
74071 WHEN 6 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
74072 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
74073 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
74074 WHEN 9 THEN 'TRX_LINE_ACCTD_AMT'
74075
74076 ELSE null
74077 END source_code
74078 , CASE r
74079 WHEN 1 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
74080 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
74081 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
74082 WHEN 4 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
74083 WHEN 5 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
74084 WHEN 6 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
74085 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
74086 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
74087 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
74088
74089 ELSE null
74090 END source_value
74091 , null source_meaning
74092 FROM xla_events_gt xet
74093 , AR_CUST_TRX_LINES_BASE_V l3
74094 , AR_CUST_TRX_LINES_L_V l4
74095 , (select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
74096 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
74097 AND xet.event_class_code = C_EVENT_CLASS_CODE
74098 AND l3.event_id = xet.event_id
74099 AND l4.event_id = l3.event_id
74100 AND l4.line_number = l3.line_number
74101
74102 )
74103 ;
74104 --
74105 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74106
74107 trace
74108 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
74109 ,p_level => C_LEVEL_STATEMENT
74110 ,p_module => l_log_module);
74111
74112 END IF;
74113
74114
74115 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
74116 trace
74117 (p_msg => 'END of insert_sources_139'
74118 ,p_level => C_LEVEL_PROCEDURE
74119 ,p_module => l_log_module);
74120 END IF;
74121 EXCEPTION
74122 WHEN xla_exceptions_pkg.application_exception THEN
74123 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
74124 trace
74125 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
74126 ,p_level => C_LEVEL_EXCEPTION
74127 ,p_module => l_log_module);
74128 END IF;
74129 RAISE;
74130 WHEN OTHERS THEN
74131 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
74132 trace
74133 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
74134 ,p_level => C_LEVEL_EXCEPTION
74135 ,p_module => l_log_module);
74136 END IF;
74137 xla_exceptions_pkg.raise_message
74138 (p_location => 'XLA_00222_AAD_S_000005_PKG.insert_sources_139');
74139 END insert_sources_139;
74140 --
74141
74142 ---------------------------------------
74143 --
74144 -- PRIVATE FUNCTION
74145 -- EventClass_139
74146 --
74147 ----------------------------------------
74148 --
74149 FUNCTION EventClass_139
74150 (p_application_id IN NUMBER
74151 ,p_base_ledger_id IN NUMBER
74152 ,p_target_ledger_id IN NUMBER
74153 ,p_language IN VARCHAR2
74154 ,p_currency_code IN VARCHAR2
74155 ,p_sla_ledger_id IN NUMBER
74156 ,p_pad_start_date IN DATE
74157 ,p_pad_end_date IN DATE
74158 ,p_primary_ledger_id IN NUMBER)
74159 RETURN BOOLEAN IS
74160 --
74161 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE_ALL';
74162 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'GUARANTEE';
74163
74164 l_calculate_acctd_flag VARCHAR2(1) :='N';
74165 l_calculate_g_l_flag VARCHAR2(1) :='N';
74166 --
74167 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74168 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74169 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
74170 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
74171 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74172 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
74173 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
74174 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74175 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74176 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74177 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74178 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74179 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74180 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
74181 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
74182 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
74183 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
74184 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
74185 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74186 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74187 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74188 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
74189 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
74190 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
74191 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
74192 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
74193
74194 l_event_id NUMBER;
74195 l_previous_event_id NUMBER;
74196 l_first_event_id NUMBER;
74197 l_last_event_id NUMBER;
74198
74199 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
74200 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
74201 --
74202 --
74203 l_result BOOLEAN := TRUE;
74204 l_rows NUMBER := 1000;
74205 l_event_type_name VARCHAR2(80) := 'All';
74206 l_event_class_name VARCHAR2(80) := 'Guarantee';
74207 l_description VARCHAR2(4000);
74208 l_transaction_reversal NUMBER;
74209 l_ae_header_id NUMBER;
74210 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
74211 l_log_module VARCHAR2(240);
74212 --
74213 l_acct_reversal_source VARCHAR2(30);
74214 l_trx_reversal_source VARCHAR2(30);
74215
74216 l_continue_with_lines BOOLEAN := TRUE;
74217 --
74218 l_acc_rev_gl_date_source DATE; -- 4262811
74219 --
74220 type t_array_event_id is table of number index by binary_integer;
74221
74222 l_rec_array_event t_rec_array_event;
74223 l_null_rec_array_event t_rec_array_event;
74224 l_array_ae_header_id xla_number_array_type;
74225 l_actual_flag VARCHAR2(1) := NULL;
74226 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
74227 l_balance_type_code VARCHAR2(1) :=NULL;
74228 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
74229
74230 --
74231 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
74232 --
74233
74234 TYPE t_array_source_3 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
74235 TYPE t_array_source_30 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
74236 TYPE t_array_source_31 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
74237 TYPE t_array_source_32 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
74238 TYPE t_array_source_37 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
74239 TYPE t_array_source_81 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
74240 TYPE t_array_source_82 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
74241
74242 TYPE t_array_source_19 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
74243 TYPE t_array_source_33 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
74244 TYPE t_array_source_34 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
74245 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
74246 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
74247 TYPE t_array_source_38 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
74248 TYPE t_array_source_39 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
74249 TYPE t_array_source_40 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
74250 TYPE t_array_source_41 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
74251
74252 l_array_source_3 t_array_source_3;
74253 l_array_source_30 t_array_source_30;
74254 l_array_source_31 t_array_source_31;
74255 l_array_source_32 t_array_source_32;
74256 l_array_source_37 t_array_source_37;
74257 l_array_source_81 t_array_source_81;
74258 l_array_source_82 t_array_source_82;
74259
74260 l_array_source_19 t_array_source_19;
74261 l_array_source_33 t_array_source_33;
74262 l_array_source_34 t_array_source_34;
74263 l_array_source_35 t_array_source_35;
74264 l_array_source_36 t_array_source_36;
74265 l_array_source_38 t_array_source_38;
74266 l_array_source_39 t_array_source_39;
74267 l_array_source_40 t_array_source_40;
74268 l_array_source_41 t_array_source_41;
74269
74270 --
74271 CURSOR header_cur
74272 IS
74273 SELECT /*+ leading(xet) cardinality(xet,1) */
74274 -- Event Class Code: GUARANTEE
74275 xet.entity_id
74279 ,xet.event_id
74276 ,xet.legal_entity_id
74277 ,xet.entity_code
74278 ,xet.transaction_number
74280 ,xet.event_class_code
74281 ,xet.event_type_code
74282 ,xet.event_number
74283 ,xet.event_date
74284 ,xet.transaction_date
74285 ,xet.reference_num_1
74286 ,xet.reference_num_2
74287 ,xet.reference_num_3
74288 ,xet.reference_num_4
74289 ,xet.reference_char_1
74290 ,xet.reference_char_2
74291 ,xet.reference_char_3
74292 ,xet.reference_char_4
74293 ,xet.reference_date_1
74294 ,xet.reference_date_2
74295 ,xet.reference_date_3
74296 ,xet.reference_date_4
74297 ,xet.event_created_by
74298 ,xet.budgetary_control_flag
74299 , h5.TRX_DOC_SEQUENCE_VALUE source_3
74300 , h1.BILL_CUST_ACCOUNT_ID source_30
74301 , h2.BILL_USES_SITE_USE_ID source_31
74302 , h5.XLA_PARTY_TYPE source_32
74303 , h5.TRX_INVOICE_CURRENCY_CODE source_37
74304 , h5.TRX_DOC_SEQUENCE_CATEGORY source_81
74305 , h5.TRX_DOC_SEQUENCE_ID source_82
74306 FROM xla_events_gt xet
74307 , AR_BILL_TO_CUSTOMERS_S_V h1
74308 , AR_BILL_TO_SITE_USES_S_V h2
74309 , AR_TRANSACTIONS_S_V h5
74310 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
74311 and xet.event_class_code = C_EVENT_CLASS_CODE
74312 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
74313 AND h2.event_id = h1.event_id
74314 AND h5.event_id = h1.event_id
74315
74316 ORDER BY event_id
74317 ;
74318
74319
74320 --
74321 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
74322 IS
74323 SELECT /*+ leading(xet) cardinality(xet,1) */
74324 -- Event Class Code: GUARANTEE
74325 xet.entity_id
74326 ,xet.legal_entity_id
74327 ,xet.entity_code
74328 ,xet.transaction_number
74329 ,xet.event_id
74330 ,xet.event_class_code
74331 ,xet.event_type_code
74332 ,xet.event_number
74333 ,xet.event_date
74334 ,xet.transaction_date
74335 ,xet.reference_num_1
74336 ,xet.reference_num_2
74337 ,xet.reference_num_3
74338 ,xet.reference_num_4
74339 ,xet.reference_char_1
74340 ,xet.reference_char_2
74341 ,xet.reference_char_3
74342 ,xet.reference_char_4
74343 ,xet.reference_date_1
74344 ,xet.reference_date_2
74345 ,xet.reference_date_3
74346 ,xet.reference_date_4
74347 ,xet.event_created_by
74348 ,xet.budgetary_control_flag
74349 , l3.LINE_NUMBER
74350 , l4.TRX_LINE_DIST_CCID source_19
74351 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_33
74352 , l4.TRX_LINE_DIST_ID source_34
74353 , l4.TRX_DISTRIBUTION_TYPE source_35
74354 , l4.TRX_LINE_DIST_AMT source_36
74355 , l3.TRX_LINE_CUR_CONVERSION_DATE source_38
74356 , l3.TRX_LINE_CUR_CONVERSION_RATE source_39
74357 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_40
74358 , l3.TRX_LINE_ACCTD_AMT source_41
74359 FROM xla_events_gt xet
74360 , AR_CUST_TRX_LINES_BASE_V l3
74361 , AR_CUST_TRX_LINES_L_V l4
74362 WHERE xet.event_id between x_first_event_id and x_last_event_id
74363 and xet.event_date between p_pad_start_date and p_pad_end_date
74364 and xet.event_class_code = C_EVENT_CLASS_CODE
74365 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
74366 AND l4.event_id = l3.event_id
74367 AND l4.line_number = l3.line_number
74368 ;
74369
74370 --
74371 BEGIN
74372 IF g_log_enabled THEN
74373 l_log_module := C_DEFAULT_MODULE||'.EventClass_139';
74374 END IF;
74375 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
74376 trace
74377 (p_msg => 'BEGIN of EventClass_139'
74378 ,p_level => C_LEVEL_PROCEDURE
74379 ,p_module => l_log_module);
74380 END IF;
74381
74382 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74383 trace
74384 (p_msg => 'p_application_id = '||p_application_id||
74385 ' - p_base_ledger_id = '||p_base_ledger_id||
74386 ' - p_target_ledger_id = '||p_target_ledger_id||
74387 ' - p_language = '||p_language||
74388 ' - p_currency_code = '||p_currency_code||
74389 ' - p_sla_ledger_id = '||p_sla_ledger_id
74390 ,p_level => C_LEVEL_STATEMENT
74391 ,p_module => l_log_module);
74392 END IF;
74393 --
74394 -- initialze arrays
74395 --
74396 g_array_event.DELETE;
74397 l_rec_array_event := l_null_rec_array_event;
74398 --
74399 --------------------------------------
74400 -- 4262811 Initialze MPA Line Number
74401 --------------------------------------
74402 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
74403
74404 --
74405
74406 --
74407 OPEN header_cur;
74408 --
74409 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74410 trace
74411 (p_msg => 'SQL - FETCH header_cur'
74412 ,p_level => C_LEVEL_STATEMENT
74413 ,p_module => l_log_module);
74414 END IF;
74415 --
74416 LOOP
74417 FETCH header_cur BULK COLLECT INTO
74418 l_array_entity_id
74419 , l_array_legal_entity_id
74420 , l_array_entity_code
74421 , l_array_transaction_num
74422 , l_array_event_id
74423 , l_array_class_code
74424 , l_array_event_type
74425 , l_array_event_number
74426 , l_array_event_date
74427 , l_array_transaction_date
74431 , l_array_reference_num_4
74428 , l_array_reference_num_1
74429 , l_array_reference_num_2
74430 , l_array_reference_num_3
74432 , l_array_reference_char_1
74433 , l_array_reference_char_2
74434 , l_array_reference_char_3
74435 , l_array_reference_char_4
74436 , l_array_reference_date_1
74437 , l_array_reference_date_2
74438 , l_array_reference_date_3
74439 , l_array_reference_date_4
74440 , l_array_event_created_by
74441 , l_array_budgetary_control_flag
74442 , l_array_source_3
74443 , l_array_source_30
74444 , l_array_source_31
74445 , l_array_source_32
74446 , l_array_source_37
74447 , l_array_source_81
74448 , l_array_source_82
74449 LIMIT l_rows;
74450 --
74451 IF (C_LEVEL_EVENT >= g_log_level) THEN
74452 trace
74453 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
74454 ,p_level => C_LEVEL_EVENT
74455 ,p_module => l_log_module);
74456 END IF;
74457 --
74458 EXIT WHEN l_array_entity_id.COUNT = 0;
74459
74460 -- initialize arrays
74461 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
74462 XLA_AE_LINES_PKG.g_rec_lines := NULL;
74463
74464 --
74465 -- Bug 4458708
74466 --
74467 XLA_AE_LINES_PKG.g_LineNumber := 0;
74468
74469
74470 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
74471 g_last_hdr_idx := l_array_event_id.LAST;
74472 --
74473 -- loop for the headers. Each iteration is for each header extract row
74474 -- fetched in header cursor
74475 --
74476 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
74477
74478 --
74479 -- set event info as cache for other routines to refer event attributes
74480 --
74481 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
74482 (p_application_id => p_application_id
74483 ,p_primary_ledger_id => p_primary_ledger_id
74484 ,p_base_ledger_id => p_base_ledger_id
74485 ,p_target_ledger_id => p_target_ledger_id
74486 ,p_entity_id => l_array_entity_id(hdr_idx)
74487 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
74488 ,p_entity_code => l_array_entity_code(hdr_idx)
74489 ,p_transaction_num => l_array_transaction_num(hdr_idx)
74490 ,p_event_id => l_array_event_id(hdr_idx)
74491 ,p_event_class_code => l_array_class_code(hdr_idx)
74492 ,p_event_type_code => l_array_event_type(hdr_idx)
74493 ,p_event_number => l_array_event_number(hdr_idx)
74494 ,p_event_date => l_array_event_date(hdr_idx)
74495 ,p_transaction_date => l_array_transaction_date(hdr_idx)
74496 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
74497 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
74498 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
74499 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
74500 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
74501 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
74502 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
74503 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
74504 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
74505 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
74506 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
74507 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
74508 ,p_event_created_by => l_array_event_created_by(hdr_idx)
74509 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
74510
74511 --
74512 -- set the status of entry to C_VALID (0)
74513 --
74514 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
74515
74516 --
74517 -- initialize a row for ae header
74518 --
74519 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
74520
74521 l_event_id := l_array_event_id(hdr_idx);
74522
74523 --
74524 -- storing the hdr_idx for event. May be used by line cursor.
74525 --
74526 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
74527
74528 --
74529 -- store sources from header extract. This can be improved to
74530 -- store only those sources from header extract that may be used in lines
74531 --
74532
74533 g_array_event(l_event_id).array_value_num('source_3') := l_array_source_3(hdr_idx);
74534 g_array_event(l_event_id).array_value_num('source_30') := l_array_source_30(hdr_idx);
74535 g_array_event(l_event_id).array_value_num('source_31') := l_array_source_31(hdr_idx);
74536 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
74537 g_array_event(l_event_id).array_value_char('source_37') := l_array_source_37(hdr_idx);
74538 g_array_event(l_event_id).array_value_char('source_81') := l_array_source_81(hdr_idx);
74539 g_array_event(l_event_id).array_value_num('source_82') := l_array_source_82(hdr_idx);
74540
74541 --
74542 -- initilaize the status of ae headers for diffrent balance types
74543 -- the status is initialised to C_NOT_CREATED (2)
74544 --
74545 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
74546 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
74550 -- call api to validate and store accounting attributes for header
74547 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
74548
74549 --
74551 --
74552
74553 ------------------------------------------------------------
74554 -- Accrual Reversal : to get date for Standard Source (NONE)
74555 ------------------------------------------------------------
74556 l_acc_rev_gl_date_source := NULL;
74557
74558 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
74559 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_81');
74560 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
74561 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_82');
74562 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
74563 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_3');
74564 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
74565 l_rec_acct_attrs.array_date_value(4) :=
74566 xla_ae_sources_pkg.GetSystemSourceDate(
74567 p_source_code => 'XLA_EVENT_DATE'
74568 , p_source_type_code => 'Y'
74569 , p_source_application_id => 602
74570 );
74571
74572
74573 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
74574
74575 XLA_AE_HEADER_PKG.SetJeCategoryName;
74576
74577 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
74578 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
74579 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
74580 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
74581 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
74582
74583
74584 -- No header level analytical criteria
74585
74586 --
74587 --accounting attribute enhancement, bug 3612931
74588 --
74589 l_trx_reversal_source := SUBSTR(NULL, 1,30);
74590
74591 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
74592 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
74593
74594 xla_accounting_err_pkg.build_message
74595 (p_appli_s_name => 'XLA'
74596 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
74597 ,p_token_1 => 'ACCT_ATTR_NAME'
74598 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
74599 ,p_token_2 => 'PRODUCT_NAME'
74600 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
74601 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
74602 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
74603 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
74604
74605 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
74606 --
74607 -- following sets the accounting attributes needed to reverse
74608 -- accounting for a distributeion
74609 --
74610 xla_ae_lines_pkg.SetTrxReversalAttrs
74611 (p_event_id => l_event_id
74612 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
74613 ,p_trx_reversal_source => l_trx_reversal_source);
74614
74615 END IF;
74616
74617
74618 ----------------------------------------------------------------
74619 -- 4262811 - update the header statuses to invalid in need be
74620 ----------------------------------------------------------------
74621 --
74622 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
74623
74624
74625 -----------------------------------------------
74626 -- No accrual reversal for the event class/type
74627 -----------------------------------------------
74628 ----------------------------------------------------------------
74629
74630 --
74631 -- this ends the header loop iteration for one bulk fetch
74632 --
74633 END LOOP;
74634
74635 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
74636 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
74637
74638 --
74639 -- insert dummy rows into lines gt table that were created due to
74640 -- transaction reversals
74641 --
74642 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
74643 l_result := XLA_AE_LINES_PKG.InsertLines;
74644 END IF;
74645
74646 --
74647 -- reset the temp_line_num for each set of events fetched from header
74648 -- cursor rather than doing it for each new event in line cursor
74649 -- Bug 3939231
74650 --
74651 xla_ae_lines_pkg.g_temp_line_num := 0;
74652
74653
74654
74655 --
74656 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
74657 --
74658 --
74659 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74660
74661 trace
74662 (p_msg => 'SQL - FETCH line_cur'
74663 ,p_level => C_LEVEL_STATEMENT
74664 ,p_module => l_log_module);
74665
74666 END IF;
74667 --
74668 --
74669 LOOP
74670 --
74671 FETCH line_cur BULK COLLECT INTO
74672 l_array_entity_id
74673 , l_array_legal_entity_id
74674 , l_array_entity_code
74675 , l_array_transaction_num
74676 , l_array_event_id
74677 , l_array_class_code
74678 , l_array_event_type
74679 , l_array_event_number
74680 , l_array_event_date
74681 , l_array_transaction_date
74682 , l_array_reference_num_1
74683 , l_array_reference_num_2
74684 , l_array_reference_num_3
74685 , l_array_reference_num_4
74686 , l_array_reference_char_1
74687 , l_array_reference_char_2
74688 , l_array_reference_char_3
74689 , l_array_reference_char_4
74690 , l_array_reference_date_1
74691 , l_array_reference_date_2
74692 , l_array_reference_date_3
74693 , l_array_reference_date_4
74694 , l_array_event_created_by
74695 , l_array_budgetary_control_flag
74696 , l_array_extract_line_num
74697 , l_array_source_19
74698 , l_array_source_33
74699 , l_array_source_34
74700 , l_array_source_35
74701 , l_array_source_36
74702 , l_array_source_38
74703 , l_array_source_39
74704 , l_array_source_40
74705 , l_array_source_41
74706 LIMIT l_rows;
74707
74708 --
74709 IF (C_LEVEL_EVENT >= g_log_level) THEN
74710 trace
74711 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
74712 ,p_level => C_LEVEL_EVENT
74713 ,p_module => l_log_module);
74714 END IF;
74715 --
74716 EXIT WHEN l_array_entity_id.count = 0;
74717
74718 XLA_AE_LINES_PKG.g_rec_lines := null;
74719
74720 --
74721 -- Bug 4458708
74722 --
74723 XLA_AE_LINES_PKG.g_LineNumber := 0;
74724 --
74725 --
74726
74727 FOR Idx IN 1..l_array_event_id.count LOOP
74728 --
74729 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
74730 --
74731 l_event_id := l_array_event_id(idx); -- 5648433
74732
74733 --
74734 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
74735 --
74736
74737 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
74738 (g_array_event(l_event_id).array_value_num('header_index'))
74739 ,'N'
74740 ) <> 'Y'
74741 THEN
74742 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74743 trace
74744 (p_msg => 'Trancaction revesal option is not Y '
74745 ,p_level => C_LEVEL_STATEMENT
74746 ,p_module => l_log_module);
74747 END IF;
74748
74749 --
74750 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
74751 --
74752 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
74753 --
74754 -- set event info as cache for other routines to refer event attributes
74755 --
74756
74757 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
74758 l_previous_event_id := l_event_id;
74759
74760 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
74761 (p_application_id => p_application_id
74762 ,p_primary_ledger_id => p_primary_ledger_id
74763 ,p_base_ledger_id => p_base_ledger_id
74764 ,p_target_ledger_id => p_target_ledger_id
74765 ,p_entity_id => l_array_entity_id(Idx)
74766 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
74767 ,p_entity_code => l_array_entity_code(Idx)
74768 ,p_transaction_num => l_array_transaction_num(Idx)
74769 ,p_event_id => l_array_event_id(Idx)
74770 ,p_event_class_code => l_array_class_code(Idx)
74771 ,p_event_type_code => l_array_event_type(Idx)
74772 ,p_event_number => l_array_event_number(Idx)
74773 ,p_event_date => l_array_event_date(Idx)
74774 ,p_transaction_date => l_array_transaction_date(Idx)
74775 ,p_reference_num_1 => l_array_reference_num_1(Idx)
74776 ,p_reference_num_2 => l_array_reference_num_2(Idx)
74777 ,p_reference_num_3 => l_array_reference_num_3(Idx)
74778 ,p_reference_num_4 => l_array_reference_num_4(Idx)
74779 ,p_reference_char_1 => l_array_reference_char_1(Idx)
74780 ,p_reference_char_2 => l_array_reference_char_2(Idx)
74781 ,p_reference_char_3 => l_array_reference_char_3(Idx)
74782 ,p_reference_char_4 => l_array_reference_char_4(Idx)
74783 ,p_reference_date_1 => l_array_reference_date_1(Idx)
74784 ,p_reference_date_2 => l_array_reference_date_2(Idx)
74785 ,p_reference_date_3 => l_array_reference_date_3(Idx)
74786 ,p_reference_date_4 => l_array_reference_date_4(Idx)
74787 ,p_event_created_by => l_array_event_created_by(Idx)
74788 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
74789 --
74790 END IF;
74791
74792
74793
74794 --
74795 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
74796
74797 l_acct_reversal_source := SUBSTR(NULL, 1,30);
74798
74799 IF l_continue_with_lines THEN
74800 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
74801 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
74802
74803 xla_accounting_err_pkg.build_message
74804 (p_appli_s_name => 'XLA'
74805 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
74806 ,p_token_1 => 'LINE_NUMBER'
74807 ,p_value_1 => l_array_extract_line_num(Idx)
74808 ,p_token_2 => 'PRODUCT_NAME'
74809 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
74810 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
74811 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
74812 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
74813
74814 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
74815 --
74816 -- following sets the accounting attributes needed to reverse
74817 -- accounting for a distributeion
74818 --
74819
74820 --
74821 -- 5217187
74822 --
74823 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
74824 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
74825 g_array_event(l_event_id).array_value_num('header_index'));
74826 --
74827 --
74828
74829 -- No reversal code generated
74830
74831 xla_ae_lines_pkg.SetAcctReversalAttrs
74832 (p_event_id => l_event_id
74833 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
74834 ,p_calculate_acctd_flag => l_calculate_acctd_flag
74835 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
74836 END IF;
74837
74838 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
74839 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
74840
74841 --
74842 AcctLineType_82 (
74843 p_application_id => p_application_id
74844 ,p_event_id => l_event_id
74845 ,p_calculate_acctd_flag => l_calculate_acctd_flag
74846 ,p_calculate_g_l_flag => l_calculate_g_l_flag
74847 ,p_actual_flag => l_actual_flag
74848 ,p_balance_type_code => l_balance_type_code
74849 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
74850
74851 , p_source_19 => l_array_source_19(Idx)
74852 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
74853 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
74854 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
74855 , p_source_33 => l_array_source_33(Idx)
74856 , p_source_34 => l_array_source_34(Idx)
74857 , p_source_35 => l_array_source_35(Idx)
74858 , p_source_36 => l_array_source_36(Idx)
74859 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
74860 , p_source_38 => l_array_source_38(Idx)
74861 , p_source_39 => l_array_source_39(Idx)
74862 , p_source_40 => l_array_source_40(Idx)
74863 , p_source_41 => l_array_source_41(Idx)
74864 );
74865 If(l_balance_type_code = 'A') THEN
74866 l_actual_gain_loss_ref := l_gain_or_loss_ref;
74867 END IF;
74868
74869 --
74870
74871
74872 --
74873 AcctLineType_83 (
74874 p_application_id => p_application_id
74875 ,p_event_id => l_event_id
74876 ,p_calculate_acctd_flag => l_calculate_acctd_flag
74877 ,p_calculate_g_l_flag => l_calculate_g_l_flag
74878 ,p_actual_flag => l_actual_flag
74879 ,p_balance_type_code => l_balance_type_code
74880 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
74881
74882 , p_source_19 => l_array_source_19(Idx)
74883 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
74884 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
74885 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
74886 , p_source_33 => l_array_source_33(Idx)
74887 , p_source_34 => l_array_source_34(Idx)
74888 , p_source_35 => l_array_source_35(Idx)
74889 , p_source_36 => l_array_source_36(Idx)
74890 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
74891 , p_source_38 => l_array_source_38(Idx)
74892 , p_source_39 => l_array_source_39(Idx)
74893 , p_source_40 => l_array_source_40(Idx)
74894 , p_source_41 => l_array_source_41(Idx)
74895 );
74896 If(l_balance_type_code = 'A') THEN
74897 l_actual_gain_loss_ref := l_gain_or_loss_ref;
74898 END IF;
74899
74900 --
74901
74902 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
74906 (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'))
74903 -- or secondary ledger that has different currency with primary
74904 -- or alc that is calculated by sla
74905 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
74907
74908 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
74909 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
74910 AND (l_actual_flag = 'A')) THEN
74911 XLA_AE_LINES_PKG.CreateGainOrLossLines(
74912 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
74913 ,p_application_id => p_application_id
74914 ,p_amb_context_code => 'DEFAULT'
74915 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
74916 ,p_event_class_code => C_EVENT_CLASS_CODE
74917 ,p_event_type_code => C_EVENT_TYPE_CODE
74918
74919 ,p_gain_ccid => -1
74920 ,p_loss_ccid => -1
74921
74922 ,p_actual_flag => l_actual_flag
74923 ,p_enc_flag => null
74924 ,p_actual_g_l_ref => l_actual_gain_loss_ref
74925 ,p_enc_g_l_ref => null
74926 );
74927 END IF;
74928 END IF;
74929 END IF;
74930
74931 ELSE
74932 --
74933 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
74934 --
74935 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74936 trace
74937 (p_msg => 'Trancaction revesal option is Y'
74938 ,p_level => C_LEVEL_STATEMENT
74939 ,p_module => l_log_module);
74940 END IF;
74941 END IF;
74942
74943 END LOOP;
74944 l_result := XLA_AE_LINES_PKG.InsertLines ;
74945 end loop;
74946 close line_cur;
74947
74948
74949 --
74950 -- insert headers into xla_ae_headers_gt table
74951 --
74952 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
74953
74954 -- insert into errors table here.
74955
74956 END LOOP;
74957
74958 --
74959 -- 4865292
74960 --
74961 -- Compare g_hdr_extract_count with event count in
74962 -- CreateHeadersAndLines.
74963 --
74964 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
74965
74966 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
74967 trace (p_msg => '# rows extracted from header extract objects '
74968 || ' (running total): '
74969 || g_hdr_extract_count
74970 ,p_level => C_LEVEL_STATEMENT
74971 ,p_module => l_log_module);
74972 END IF;
74973
74974 CLOSE header_cur;
74975 --
74976
74977 --
74978 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
74979 trace
74980 (p_msg => 'END of EventClass_139'
74981 ,p_level => C_LEVEL_PROCEDURE
74982 ,p_module => l_log_module);
74983 END IF;
74984 --
74985 RETURN l_result;
74986 EXCEPTION
74987 WHEN xla_exceptions_pkg.application_exception THEN
74988
74989 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
74990
74991
74992 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
74993
74994 RAISE;
74995
74996 WHEN NO_DATA_FOUND THEN
74997
74998 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
74999 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
75000
75001 FOR header_record IN header_cur
75002 LOOP
75003 l_array_header_events(header_record.event_id) := header_record.event_id;
75004 END LOOP;
75005
75006 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
75007 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
75008
75009 fnd_file.put_line(fnd_file.LOG, ' ');
75010 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
75011 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
75012 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
75013
75014 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
75015 LOOP
75016 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
75017 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
75018 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
75019 END IF;
75020 END LOOP;
75021
75022 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
75023 fnd_file.put_line(fnd_file.LOG, ' ');
75024
75025
75026 xla_exceptions_pkg.raise_message
75027 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_139');
75028
75029
75030 WHEN OTHERS THEN
75031 xla_exceptions_pkg.raise_message
75032 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_139');
75033 END EventClass_139;
75034 --
75035
75036 ---------------------------------------
75037 --
75038 -- PRIVATE PROCEDURE
75039 -- insert_sources_140
75040 --
75041 ----------------------------------------
75042 --
75043 PROCEDURE insert_sources_140(
75044 p_target_ledger_id IN NUMBER
75045 , p_language IN VARCHAR2
75046 , p_sla_ledger_id IN NUMBER
75047 , p_pad_start_date IN DATE
75048 , p_pad_end_date IN DATE
75049 )
75050 IS
75051
75052 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'INVOICE_ALL';
75053 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'INVOICE';
75054 p_apps_owner VARCHAR2(30);
75055 l_log_module VARCHAR2(240);
75056 BEGIN
75057 IF g_log_enabled THEN
75058 l_log_module := C_DEFAULT_MODULE||'.insert_sources_140';
75059 END IF;
75060 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
75061
75062 trace
75063 (p_msg => 'BEGIN of insert_sources_140'
75064 ,p_level => C_LEVEL_PROCEDURE
75065 ,p_module => l_log_module);
75066
75067 END IF;
75068
75069 -- select APPS owner
75070 SELECT oracle_username
75071 INTO p_apps_owner
75072 FROM fnd_oracle_userid
75073 WHERE read_only_flag = 'U'
75074 ;
75075
75076 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75077 trace
75078 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
75079 ' - p_language = '||p_language||
75080 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
75081 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
75082 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
75083 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
75084 ,p_level => C_LEVEL_STATEMENT
75085 ,p_module => l_log_module);
75086 END IF;
75087
75088
75089 --
75090 INSERT INTO xla_diag_sources --hdr2
75091 (
75092 event_id
75093 , ledger_id
75094 , sla_ledger_id
75095 , description_language
75096 , object_name
75097 , object_type_code
75098 , line_number
75099 , source_application_id
75100 , source_type_code
75101 , source_code
75102 , source_value
75103 , source_meaning
75104 , created_by
75105 , creation_date
75106 , last_update_date
75107 , last_updated_by
75108 , last_update_login
75109 , program_update_date
75110 , program_application_id
75111 , program_id
75112 , request_id
75113 )
75114 SELECT
75115 event_id
75116 , p_target_ledger_id
75117 , p_sla_ledger_id
75118 , p_language
75119 , object_name
75120 , object_type_code
75121 , line_number
75122 , source_application_id
75123 , source_type_code
75124 , source_code
75125 , SUBSTR(source_value ,1,1996)
75126 , SUBSTR(source_meaning ,1,200)
75127 , xla_environment_pkg.g_Usr_Id
75128 , TRUNC(SYSDATE)
75129 , TRUNC(SYSDATE)
75130 , xla_environment_pkg.g_Usr_Id
75131 , xla_environment_pkg.g_Login_Id
75132 , TRUNC(SYSDATE)
75133 , xla_environment_pkg.g_Prog_Appl_Id
75134 , xla_environment_pkg.g_Prog_Id
75135 , xla_environment_pkg.g_Req_Id
75136 FROM (
75137 SELECT xet.event_id event_id
75138 , 0 line_number
75139 , CASE r
75140 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
75141 WHEN 2 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
75142 WHEN 3 THEN 'AR_TRANSACTIONS_S_V'
75143 WHEN 4 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
75144 WHEN 5 THEN 'AR_BILL_TO_SITE_USES_S_V'
75145 WHEN 6 THEN 'AR_TRANSACTIONS_S_V'
75146 WHEN 7 THEN 'AR_TRANSACTIONS_S_V'
75147 WHEN 8 THEN 'AR_TRANSACTIONS_S_V'
75148 WHEN 9 THEN 'AR_TRANSACTIONS_S_V'
75149
75150 ELSE null
75151 END object_name
75152 , CASE r
75153 WHEN 1 THEN 'HEADER'
75154 WHEN 2 THEN 'HEADER'
75155 WHEN 3 THEN 'HEADER'
75156 WHEN 4 THEN 'HEADER'
75157 WHEN 5 THEN 'HEADER'
75158 WHEN 6 THEN 'HEADER'
75159 WHEN 7 THEN 'HEADER'
75160 WHEN 8 THEN 'HEADER'
75161 WHEN 9 THEN 'HEADER'
75162
75163 ELSE null
75164 END object_type_code
75165 , CASE r
75169 WHEN 4 THEN '222'
75166 WHEN 1 THEN '222'
75167 WHEN 2 THEN '222'
75168 WHEN 3 THEN '222'
75170 WHEN 5 THEN '222'
75171 WHEN 6 THEN '222'
75172 WHEN 7 THEN '222'
75173 WHEN 8 THEN '222'
75174 WHEN 9 THEN '222'
75175
75176 ELSE null
75177 END source_application_id
75178 , 'S' source_type_code
75179 , CASE r
75180 WHEN 1 THEN 'TRX_DOC_SEQUENCE_VALUE'
75181 WHEN 2 THEN 'BILL_CUSTOMER_CLASS_CODE'
75182 WHEN 3 THEN 'TRX_RECEIVABLE_CCID'
75183 WHEN 4 THEN 'BILL_CUST_ACCOUNT_ID'
75184 WHEN 5 THEN 'BILL_USES_SITE_USE_ID'
75185 WHEN 6 THEN 'XLA_PARTY_TYPE'
75186 WHEN 7 THEN 'TRX_INVOICE_CURRENCY_CODE'
75187 WHEN 8 THEN 'TRX_DOC_SEQUENCE_CATEGORY'
75188 WHEN 9 THEN 'TRX_DOC_SEQUENCE_ID'
75189
75190 ELSE null
75191 END source_code
75192 , CASE r
75193 WHEN 1 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_VALUE)
75194 WHEN 2 THEN TO_CHAR(h1.BILL_CUSTOMER_CLASS_CODE)
75195 WHEN 3 THEN TO_CHAR(h5.TRX_RECEIVABLE_CCID)
75196 WHEN 4 THEN TO_CHAR(h1.BILL_CUST_ACCOUNT_ID)
75197 WHEN 5 THEN TO_CHAR(h2.BILL_USES_SITE_USE_ID)
75198 WHEN 6 THEN TO_CHAR(h5.XLA_PARTY_TYPE)
75199 WHEN 7 THEN TO_CHAR(h5.TRX_INVOICE_CURRENCY_CODE)
75200 WHEN 8 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_CATEGORY)
75201 WHEN 9 THEN TO_CHAR(h5.TRX_DOC_SEQUENCE_ID)
75202
75203 ELSE null
75204 END source_value
75205 , null source_meaning
75206 FROM xla_events_gt xet
75207 , AR_BILL_TO_CUSTOMERS_S_V h1
75208 , AR_BILL_TO_SITE_USES_S_V h2
75209 , AR_TRANSACTIONS_S_V h5
75210 ,(select rownum r from all_objects where rownum <= 9 and owner = p_apps_owner)
75211 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
75212 AND xet.event_class_code = C_EVENT_CLASS_CODE
75213 AND h1.event_id = xet.event_id
75214 AND h2.event_id = h1.event_id
75215 AND h5.event_id = h1.event_id
75216
75217 )
75218 ;
75219 --
75220 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75221
75222 trace
75223 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
75224 ,p_level => C_LEVEL_STATEMENT
75225 ,p_module => l_log_module);
75226
75227 END IF;
75228 --
75229
75230
75231
75232 --
75233 INSERT INTO xla_diag_sources --line2
75234 (
75235 event_id
75236 , ledger_id
75237 , sla_ledger_id
75238 , description_language
75239 , object_name
75240 , object_type_code
75241 , line_number
75242 , source_application_id
75243 , source_type_code
75244 , source_code
75245 , source_value
75246 , source_meaning
75247 , created_by
75248 , creation_date
75249 , last_update_date
75250 , last_updated_by
75251 , last_update_login
75252 , program_update_date
75253 , program_application_id
75254 , program_id
75255 , request_id
75256 )
75257 SELECT event_id
75258 , p_target_ledger_id
75259 , p_sla_ledger_id
75260 , p_language
75261 , object_name
75262 , object_type_code
75263 , line_number
75264 , source_application_id
75265 , source_type_code
75266 , source_code
75267 , SUBSTR(source_value,1,1996)
75268 , SUBSTR(source_meaning ,1,200)
75269 , xla_environment_pkg.g_Usr_Id
75270 , TRUNC(SYSDATE)
75271 , TRUNC(SYSDATE)
75272 , xla_environment_pkg.g_Usr_Id
75273 , xla_environment_pkg.g_Login_Id
75274 , TRUNC(SYSDATE)
75275 , xla_environment_pkg.g_Prog_Appl_Id
75276 , xla_environment_pkg.g_Prog_Id
75277 , xla_environment_pkg.g_Req_Id
75278 FROM (
75279 SELECT xet.event_id event_id
75280 , l4.line_number line_number
75281 , CASE r
75282 WHEN 1 THEN 'FV_XLA_AR_REF_V'
75283 WHEN 2 THEN 'AR_CUST_TRX_LINES_L_V'
75284 WHEN 3 THEN 'AR_CUST_TRX_LINES_L_V'
75285 WHEN 4 THEN 'AR_CUST_TRX_LINES_L_V'
75286 WHEN 5 THEN 'AR_CUST_TRX_LINES_L_V'
75287 WHEN 6 THEN 'AR_CUST_TRX_LINES_L_V'
75288 WHEN 7 THEN 'AR_CUST_TRX_LINES_BASE_V'
75289 WHEN 8 THEN 'AR_CUST_TRX_LINES_BASE_V'
75290 WHEN 9 THEN 'AR_CUST_TRX_LINES_BASE_V'
75291 WHEN 10 THEN 'AR_CUST_TRX_LINES_BASE_V'
75292 WHEN 11 THEN 'AR_CUST_TRX_LINES_L_V'
75293 WHEN 12 THEN 'FV_XLA_AR_REF_V'
75294 WHEN 13 THEN 'AR_CUST_TRX_LINES_BASE_V'
75295
75296 ELSE null
75297 END object_name
75298 , CASE r
75299 WHEN 1 THEN 'LINE'
75300 WHEN 2 THEN 'LINE'
75301 WHEN 3 THEN 'LINE'
75302 WHEN 4 THEN 'LINE'
75303 WHEN 5 THEN 'LINE'
75304 WHEN 6 THEN 'LINE'
75305 WHEN 7 THEN 'LINE'
75309 WHEN 11 THEN 'LINE'
75306 WHEN 8 THEN 'LINE'
75307 WHEN 9 THEN 'LINE'
75308 WHEN 10 THEN 'LINE'
75310 WHEN 12 THEN 'LINE'
75311 WHEN 13 THEN 'LINE'
75312
75313 ELSE null
75314 END object_type_code
75315 , CASE r
75316 WHEN 1 THEN '8901'
75317 WHEN 2 THEN '222'
75318 WHEN 3 THEN '222'
75319 WHEN 4 THEN '222'
75320 WHEN 5 THEN '222'
75321 WHEN 6 THEN '222'
75322 WHEN 7 THEN '222'
75323 WHEN 8 THEN '222'
75324 WHEN 9 THEN '222'
75325 WHEN 10 THEN '222'
75326 WHEN 11 THEN '222'
75327 WHEN 12 THEN '8901'
75328 WHEN 13 THEN '222'
75329
75330 ELSE null
75331 END source_application_id
75332 , 'S' source_type_code
75333 , CASE r
75334 WHEN 1 THEN 'FEDERAL_FUND_CATEGORY'
75335 WHEN 2 THEN 'TRX_LINE_DIST_CCID'
75336 WHEN 3 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
75337 WHEN 4 THEN 'TRX_LINE_DIST_ID'
75338 WHEN 5 THEN 'TRX_DISTRIBUTION_TYPE'
75339 WHEN 6 THEN 'TRX_LINE_DIST_AMT'
75340 WHEN 7 THEN 'TRX_LINE_CUR_CONVERSION_DATE'
75341 WHEN 8 THEN 'TRX_LINE_CUR_CONVERSION_RATE'
75342 WHEN 9 THEN 'TRX_LINE_CUR_CONVERSION_TYPE'
75343 WHEN 10 THEN 'TRX_LINE_ACCTD_AMT'
75344 WHEN 11 THEN 'TRX_TAX_LINE_ID'
75345 WHEN 12 THEN 'FEDERAL_ACCOUNT_VALID_FLAG'
75346 WHEN 13 THEN 'ROUNDING_CORRECTION_FLAG'
75347
75348 ELSE null
75349 END source_code
75350 , CASE r
75351 WHEN 1 THEN TO_CHAR(l6.FEDERAL_FUND_CATEGORY)
75352 WHEN 2 THEN TO_CHAR(l4.TRX_LINE_DIST_CCID)
75353 WHEN 3 THEN TO_CHAR(l4.TRX_LINE_DIST_ACCOUNT_CLASS)
75354 WHEN 4 THEN TO_CHAR(l4.TRX_LINE_DIST_ID)
75355 WHEN 5 THEN TO_CHAR(l4.TRX_DISTRIBUTION_TYPE)
75356 WHEN 6 THEN TO_CHAR(l4.TRX_LINE_DIST_AMT)
75357 WHEN 7 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_DATE)
75358 WHEN 8 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_RATE)
75359 WHEN 9 THEN TO_CHAR(l3.TRX_LINE_CUR_CONVERSION_TYPE)
75360 WHEN 10 THEN TO_CHAR(l3.TRX_LINE_ACCTD_AMT)
75361 WHEN 11 THEN TO_CHAR(l4.TRX_TAX_LINE_ID)
75362 WHEN 12 THEN TO_CHAR(l6.FEDERAL_ACCOUNT_VALID_FLAG)
75363 WHEN 13 THEN TO_CHAR(l3.ROUNDING_CORRECTION_FLAG)
75364
75365 ELSE null
75366 END source_value
75367 , null source_meaning
75368 FROM xla_events_gt xet
75369 , AR_CUST_TRX_LINES_BASE_V l3
75370 , AR_CUST_TRX_LINES_L_V l4
75371 , FV_XLA_AR_REF_V l6
75375 AND l3.event_id = xet.event_id
75372 , (select rownum r from all_objects where rownum <= 13 and owner = p_apps_owner)
75373 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
75374 AND xet.event_class_code = C_EVENT_CLASS_CODE
75376 AND l4.event_id = l3.event_id
75377 AND l4.line_number = l3.line_number
75378 AND l6.federal_event_id (+) = l4.event_id and l6.federal_line_number (+) = l4.line_number
75379 )
75380 ;
75381 --
75382 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75383
75384 trace
75385 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
75386 ,p_level => C_LEVEL_STATEMENT
75387 ,p_module => l_log_module);
75388
75389 END IF;
75390
75391
75392 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
75393 trace
75394 (p_msg => 'END of insert_sources_140'
75395 ,p_level => C_LEVEL_PROCEDURE
75396 ,p_module => l_log_module);
75397 END IF;
75398 EXCEPTION
75399 WHEN xla_exceptions_pkg.application_exception THEN
75400 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
75401 trace
75402 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
75403 ,p_level => C_LEVEL_EXCEPTION
75404 ,p_module => l_log_module);
75405 END IF;
75406 RAISE;
75407 WHEN OTHERS THEN
75408 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
75409 trace
75410 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
75411 ,p_level => C_LEVEL_EXCEPTION
75412 ,p_module => l_log_module);
75413 END IF;
75414 xla_exceptions_pkg.raise_message
75415 (p_location => 'XLA_00222_AAD_S_000005_PKG.insert_sources_140');
75419 ---------------------------------------
75416 END insert_sources_140;
75417 --
75418
75420 --
75421 -- PRIVATE FUNCTION
75422 -- EventClass_140
75423 --
75424 ----------------------------------------
75425 --
75426 FUNCTION EventClass_140
75427 (p_application_id IN NUMBER
75428 ,p_base_ledger_id IN NUMBER
75429 ,p_target_ledger_id IN NUMBER
75430 ,p_language IN VARCHAR2
75431 ,p_currency_code IN VARCHAR2
75432 ,p_sla_ledger_id IN NUMBER
75433 ,p_pad_start_date IN DATE
75434 ,p_pad_end_date IN DATE
75435 ,p_primary_ledger_id IN NUMBER)
75436 RETURN BOOLEAN IS
75437 --
75438 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'INVOICE_ALL';
75439 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'INVOICE';
75440
75441 l_calculate_acctd_flag VARCHAR2(1) :='N';
75442 l_calculate_g_l_flag VARCHAR2(1) :='N';
75443 --
75444 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
75445 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
75446 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
75447 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
75448 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
75449 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
75450 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
75451 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
75452 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
75453 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
75454 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
75455 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
75456 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
75457 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
75458 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
75459 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
75460 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
75461 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
75462 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
75463 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
75464 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
75465 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
75466 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
75467 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
75468 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
75469 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
75470
75471 l_event_id NUMBER;
75472 l_previous_event_id NUMBER;
75473 l_first_event_id NUMBER;
75474 l_last_event_id NUMBER;
75475
75476 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
75477 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
75478 --
75479 --
75480 l_result BOOLEAN := TRUE;
75481 l_rows NUMBER := 1000;
75482 l_event_type_name VARCHAR2(80) := 'All';
75483 l_event_class_name VARCHAR2(80) := 'Invoice';
75484 l_description VARCHAR2(4000);
75485 l_transaction_reversal NUMBER;
75486 l_ae_header_id NUMBER;
75487 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
75488 l_log_module VARCHAR2(240);
75489 --
75490 l_acct_reversal_source VARCHAR2(30);
75491 l_trx_reversal_source VARCHAR2(30);
75492
75493 l_continue_with_lines BOOLEAN := TRUE;
75494 --
75495 l_acc_rev_gl_date_source DATE; -- 4262811
75496 --
75497 type t_array_event_id is table of number index by binary_integer;
75498
75499 l_rec_array_event t_rec_array_event;
75500 l_null_rec_array_event t_rec_array_event;
75501 l_array_ae_header_id xla_number_array_type;
75502 l_actual_flag VARCHAR2(1) := NULL;
75503 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
75504 l_balance_type_code VARCHAR2(1) :=NULL;
75505 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
75506
75507 --
75508 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
75509 --
75510
75511 TYPE t_array_source_3 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
75512 TYPE t_array_source_10 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUSTOMER_CLASS_CODE%TYPE INDEX BY BINARY_INTEGER;
75513 TYPE t_array_source_16 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_RECEIVABLE_CCID%TYPE INDEX BY BINARY_INTEGER;
75514 TYPE t_array_source_30 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUST_ACCOUNT_ID%TYPE INDEX BY BINARY_INTEGER;
75515 TYPE t_array_source_31 IS TABLE OF AR_BILL_TO_SITE_USES_S_V.BILL_USES_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
75516 TYPE t_array_source_32 IS TABLE OF AR_TRANSACTIONS_S_V.XLA_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
75517 TYPE t_array_source_37 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_INVOICE_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
75518 TYPE t_array_source_81 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
75519 TYPE t_array_source_82 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
75520
75521 TYPE t_array_source_9 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
75522 TYPE t_array_source_19 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_CCID%TYPE INDEX BY BINARY_INTEGER;
75523 TYPE t_array_source_33 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
75524 TYPE t_array_source_34 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
75525 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
75526 TYPE t_array_source_36 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_AMT%TYPE INDEX BY BINARY_INTEGER;
75527 TYPE t_array_source_38 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
75528 TYPE t_array_source_39 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
75529 TYPE t_array_source_40 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
75530 TYPE t_array_source_41 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.TRX_LINE_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
75531 TYPE t_array_source_55 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_TAX_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
75532 TYPE t_array_source_56 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_ACCOUNT_VALID_FLAG%TYPE INDEX BY BINARY_INTEGER;
75533 TYPE t_array_source_66 IS TABLE OF AR_CUST_TRX_LINES_BASE_V.ROUNDING_CORRECTION_FLAG%TYPE INDEX BY BINARY_INTEGER;
75534
75535 l_array_source_3 t_array_source_3;
75536 l_array_source_10 t_array_source_10;
75537 l_array_source_16 t_array_source_16;
75538 l_array_source_30 t_array_source_30;
75539 l_array_source_31 t_array_source_31;
75540 l_array_source_32 t_array_source_32;
75541 l_array_source_37 t_array_source_37;
75542 l_array_source_81 t_array_source_81;
75543 l_array_source_82 t_array_source_82;
75544
75545 l_array_source_9 t_array_source_9;
75546 l_array_source_19 t_array_source_19;
75547 l_array_source_33 t_array_source_33;
75548 l_array_source_34 t_array_source_34;
75549 l_array_source_35 t_array_source_35;
75550 l_array_source_36 t_array_source_36;
75551 l_array_source_38 t_array_source_38;
75552 l_array_source_39 t_array_source_39;
75553 l_array_source_40 t_array_source_40;
75554 l_array_source_41 t_array_source_41;
75555 l_array_source_55 t_array_source_55;
75556 l_array_source_56 t_array_source_56;
75557 l_array_source_66 t_array_source_66;
75558
75559 --
75560 CURSOR header_cur
75561 IS
75562 SELECT /*+ leading(xet) cardinality(xet,1) */
75563 -- Event Class Code: INVOICE
75564 xet.entity_id
75565 ,xet.legal_entity_id
75566 ,xet.entity_code
75567 ,xet.transaction_number
75568 ,xet.event_id
75569 ,xet.event_class_code
75570 ,xet.event_type_code
75571 ,xet.event_number
75572 ,xet.event_date
75573 ,xet.transaction_date
75574 ,xet.reference_num_1
75575 ,xet.reference_num_2
75576 ,xet.reference_num_3
75577 ,xet.reference_num_4
75578 ,xet.reference_char_1
75579 ,xet.reference_char_2
75580 ,xet.reference_char_3
75581 ,xet.reference_char_4
75582 ,xet.reference_date_1
75583 ,xet.reference_date_2
75584 ,xet.reference_date_3
75585 ,xet.reference_date_4
75586 ,xet.event_created_by
75587 ,xet.budgetary_control_flag
75588 , h5.TRX_DOC_SEQUENCE_VALUE source_3
75589 , h1.BILL_CUSTOMER_CLASS_CODE source_10
75590 , h5.TRX_RECEIVABLE_CCID source_16
75591 , h1.BILL_CUST_ACCOUNT_ID source_30
75592 , h2.BILL_USES_SITE_USE_ID source_31
75593 , h5.XLA_PARTY_TYPE source_32
75594 , h5.TRX_INVOICE_CURRENCY_CODE source_37
75595 , h5.TRX_DOC_SEQUENCE_CATEGORY source_81
75599 , AR_BILL_TO_SITE_USES_S_V h2
75596 , h5.TRX_DOC_SEQUENCE_ID source_82
75597 FROM xla_events_gt xet
75598 , AR_BILL_TO_CUSTOMERS_S_V h1
75600 , AR_TRANSACTIONS_S_V h5
75601 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
75602 and xet.event_class_code = C_EVENT_CLASS_CODE
75603 and xet.event_status_code <> 'N' AND h1.event_id = xet.event_id
75604 AND h2.event_id = h1.event_id
75605 AND h5.event_id = h1.event_id
75606
75607 ORDER BY event_id
75608 ;
75609
75610
75611 --
75612 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
75613 IS
75614 SELECT /*+ leading(xet) cardinality(xet,1) */
75615 -- Event Class Code: INVOICE
75616 xet.entity_id
75617 ,xet.legal_entity_id
75618 ,xet.entity_code
75619 ,xet.transaction_number
75620 ,xet.event_id
75621 ,xet.event_class_code
75622 ,xet.event_type_code
75623 ,xet.event_number
75624 ,xet.event_date
75625 ,xet.transaction_date
75626 ,xet.reference_num_1
75627 ,xet.reference_num_2
75628 ,xet.reference_num_3
75629 ,xet.reference_num_4
75630 ,xet.reference_char_1
75631 ,xet.reference_char_2
75632 ,xet.reference_char_3
75633 ,xet.reference_char_4
75634 ,xet.reference_date_1
75635 ,xet.reference_date_2
75636 ,xet.reference_date_3
75637 ,xet.reference_date_4
75638 ,xet.event_created_by
75639 ,xet.budgetary_control_flag
75640 , l3.LINE_NUMBER
75641 , l6.FEDERAL_FUND_CATEGORY source_9
75642 , l4.TRX_LINE_DIST_CCID source_19
75643 , l4.TRX_LINE_DIST_ACCOUNT_CLASS source_33
75644 , l4.TRX_LINE_DIST_ID source_34
75645 , l4.TRX_DISTRIBUTION_TYPE source_35
75646 , l4.TRX_LINE_DIST_AMT source_36
75647 , l3.TRX_LINE_CUR_CONVERSION_DATE source_38
75648 , l3.TRX_LINE_CUR_CONVERSION_RATE source_39
75649 , l3.TRX_LINE_CUR_CONVERSION_TYPE source_40
75650 , l3.TRX_LINE_ACCTD_AMT source_41
75651 , l4.TRX_TAX_LINE_ID source_55
75652 , l6.FEDERAL_ACCOUNT_VALID_FLAG source_56
75656 , AR_CUST_TRX_LINES_L_V l4
75653 , l3.ROUNDING_CORRECTION_FLAG source_66
75654 FROM xla_events_gt xet
75655 , AR_CUST_TRX_LINES_BASE_V l3
75657 , FV_XLA_AR_REF_V l6
75658 WHERE xet.event_id between x_first_event_id and x_last_event_id
75659 and xet.event_date between p_pad_start_date and p_pad_end_date
75660 and xet.event_class_code = C_EVENT_CLASS_CODE
75661 and xet.event_status_code <> 'N' AND l3.event_id = xet.event_id
75662 AND l4.event_id = l3.event_id
75663 AND l4.line_number = l3.line_number
75664 AND l6.federal_event_id (+) = l4.event_id AND l6.federal_line_number (+) = l4.line_number;
75665
75666 --
75667 BEGIN
75668 IF g_log_enabled THEN
75669 l_log_module := C_DEFAULT_MODULE||'.EventClass_140';
75670 END IF;
75671 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
75672 trace
75676 END IF;
75673 (p_msg => 'BEGIN of EventClass_140'
75674 ,p_level => C_LEVEL_PROCEDURE
75675 ,p_module => l_log_module);
75677
75678 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75679 trace
75680 (p_msg => 'p_application_id = '||p_application_id||
75681 ' - p_base_ledger_id = '||p_base_ledger_id||
75682 ' - p_target_ledger_id = '||p_target_ledger_id||
75683 ' - p_language = '||p_language||
75684 ' - p_currency_code = '||p_currency_code||
75685 ' - p_sla_ledger_id = '||p_sla_ledger_id
75686 ,p_level => C_LEVEL_STATEMENT
75687 ,p_module => l_log_module);
75688 END IF;
75689 --
75690 -- initialze arrays
75691 --
75692 g_array_event.DELETE;
75693 l_rec_array_event := l_null_rec_array_event;
75694 --
75695 --------------------------------------
75696 -- 4262811 Initialze MPA Line Number
75697 --------------------------------------
75698 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
75699
75700 --
75701
75702 --
75703 OPEN header_cur;
75704 --
75705 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75706 trace
75707 (p_msg => 'SQL - FETCH header_cur'
75708 ,p_level => C_LEVEL_STATEMENT
75709 ,p_module => l_log_module);
75710 END IF;
75711 --
75712 LOOP
75713 FETCH header_cur BULK COLLECT INTO
75714 l_array_entity_id
75715 , l_array_legal_entity_id
75716 , l_array_entity_code
75717 , l_array_transaction_num
75718 , l_array_event_id
75719 , l_array_class_code
75720 , l_array_event_type
75721 , l_array_event_number
75722 , l_array_event_date
75723 , l_array_transaction_date
75724 , l_array_reference_num_1
75725 , l_array_reference_num_2
75726 , l_array_reference_num_3
75727 , l_array_reference_num_4
75728 , l_array_reference_char_1
75729 , l_array_reference_char_2
75730 , l_array_reference_char_3
75731 , l_array_reference_char_4
75732 , l_array_reference_date_1
75733 , l_array_reference_date_2
75734 , l_array_reference_date_3
75735 , l_array_reference_date_4
75736 , l_array_event_created_by
75737 , l_array_budgetary_control_flag
75738 , l_array_source_3
75739 , l_array_source_10
75740 , l_array_source_16
75741 , l_array_source_30
75742 , l_array_source_31
75743 , l_array_source_32
75744 , l_array_source_37
75745 , l_array_source_81
75746 , l_array_source_82
75747 LIMIT l_rows;
75748 --
75749 IF (C_LEVEL_EVENT >= g_log_level) THEN
75750 trace
75751 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
75752 ,p_level => C_LEVEL_EVENT
75753 ,p_module => l_log_module);
75754 END IF;
75755 --
75756 EXIT WHEN l_array_entity_id.COUNT = 0;
75757
75758 -- initialize arrays
75759 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
75760 XLA_AE_LINES_PKG.g_rec_lines := NULL;
75761
75762 --
75763 -- Bug 4458708
75764 --
75765 XLA_AE_LINES_PKG.g_LineNumber := 0;
75766
75767
75768 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
75769 g_last_hdr_idx := l_array_event_id.LAST;
75770 --
75771 -- loop for the headers. Each iteration is for each header extract row
75772 -- fetched in header cursor
75773 --
75774 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
75775
75776 --
75777 -- set event info as cache for other routines to refer event attributes
75778 --
75779 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
75780 (p_application_id => p_application_id
75781 ,p_primary_ledger_id => p_primary_ledger_id
75782 ,p_base_ledger_id => p_base_ledger_id
75783 ,p_target_ledger_id => p_target_ledger_id
75784 ,p_entity_id => l_array_entity_id(hdr_idx)
75785 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
75786 ,p_entity_code => l_array_entity_code(hdr_idx)
75787 ,p_transaction_num => l_array_transaction_num(hdr_idx)
75788 ,p_event_id => l_array_event_id(hdr_idx)
75789 ,p_event_class_code => l_array_class_code(hdr_idx)
75790 ,p_event_type_code => l_array_event_type(hdr_idx)
75791 ,p_event_number => l_array_event_number(hdr_idx)
75792 ,p_event_date => l_array_event_date(hdr_idx)
75793 ,p_transaction_date => l_array_transaction_date(hdr_idx)
75794 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
75795 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
75796 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
75797 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
75798 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
75799 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
75800 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
75801 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
75802 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
75803 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
75804 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
75805 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
75806 ,p_event_created_by => l_array_event_created_by(hdr_idx)
75807 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
75808
75809 --
75810 -- set the status of entry to C_VALID (0)
75811 --
75812 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
75813
75814 --
75815 -- initialize a row for ae header
75816 --
75817 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
75818
75819 l_event_id := l_array_event_id(hdr_idx);
75820
75821 --
75822 -- storing the hdr_idx for event. May be used by line cursor.
75823 --
75824 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
75825
75826 --
75827 -- store sources from header extract. This can be improved to
75828 -- store only those sources from header extract that may be used in lines
75829 --
75830
75831 g_array_event(l_event_id).array_value_num('source_3') := l_array_source_3(hdr_idx);
75832 g_array_event(l_event_id).array_value_char('source_10') := l_array_source_10(hdr_idx);
75833 g_array_event(l_event_id).array_value_num('source_16') := l_array_source_16(hdr_idx);
75834 g_array_event(l_event_id).array_value_num('source_30') := l_array_source_30(hdr_idx);
75835 g_array_event(l_event_id).array_value_num('source_31') := l_array_source_31(hdr_idx);
75836 g_array_event(l_event_id).array_value_char('source_32') := l_array_source_32(hdr_idx);
75837 g_array_event(l_event_id).array_value_char('source_37') := l_array_source_37(hdr_idx);
75838 g_array_event(l_event_id).array_value_char('source_81') := l_array_source_81(hdr_idx);
75839 g_array_event(l_event_id).array_value_num('source_82') := l_array_source_82(hdr_idx);
75840
75841 --
75842 -- initilaize the status of ae headers for diffrent balance types
75843 -- the status is initialised to C_NOT_CREATED (2)
75844 --
75845 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
75846 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
75847 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
75848
75849 --
75850 -- call api to validate and store accounting attributes for header
75851 --
75852
75853 ------------------------------------------------------------
75854 -- Accrual Reversal : to get date for Standard Source (NONE)
75855 ------------------------------------------------------------
75856 l_acc_rev_gl_date_source := NULL;
75857
75858 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
75859 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_81');
75860 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
75861 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_82');
75862 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
75863 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_3');
75864 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
75865 l_rec_acct_attrs.array_date_value(4) :=
75866 xla_ae_sources_pkg.GetSystemSourceDate(
75867 p_source_code => 'XLA_EVENT_DATE'
75868 , p_source_type_code => 'Y'
75869 , p_source_application_id => 602
75870 );
75871
75872
75873 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
75874
75875 XLA_AE_HEADER_PKG.SetJeCategoryName;
75876
75877 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
75878 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
75879 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
75880 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
75881 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
75882
75883
75884 -- No header level analytical criteria
75885
75886 --
75887 --accounting attribute enhancement, bug 3612931
75888 --
75889 l_trx_reversal_source := SUBSTR(NULL, 1,30);
75890
75891 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
75892 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
75893
75894 xla_accounting_err_pkg.build_message
75895 (p_appli_s_name => 'XLA'
75896 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
75897 ,p_token_1 => 'ACCT_ATTR_NAME'
75898 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
75899 ,p_token_2 => 'PRODUCT_NAME'
75900 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
75901 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
75902 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
75903 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
75904
75908 -- accounting for a distributeion
75905 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
75906 --
75907 -- following sets the accounting attributes needed to reverse
75909 --
75910 xla_ae_lines_pkg.SetTrxReversalAttrs
75911 (p_event_id => l_event_id
75912 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
75913 ,p_trx_reversal_source => l_trx_reversal_source);
75914
75915 END IF;
75916
75917
75918 ----------------------------------------------------------------
75919 -- 4262811 - update the header statuses to invalid in need be
75920 ----------------------------------------------------------------
75921 --
75922 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
75923
75924
75925 -----------------------------------------------
75926 -- No accrual reversal for the event class/type
75927 -----------------------------------------------
75928 ----------------------------------------------------------------
75929
75930 --
75931 -- this ends the header loop iteration for one bulk fetch
75932 --
75933 END LOOP;
75934
75935 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
75936 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
75937
75938 --
75939 -- insert dummy rows into lines gt table that were created due to
75940 -- transaction reversals
75941 --
75942 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
75943 l_result := XLA_AE_LINES_PKG.InsertLines;
75944 END IF;
75945
75946 --
75947 -- reset the temp_line_num for each set of events fetched from header
75948 -- cursor rather than doing it for each new event in line cursor
75949 -- Bug 3939231
75950 --
75951 xla_ae_lines_pkg.g_temp_line_num := 0;
75952
75953
75954
75955 --
75956 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
75957 --
75958 --
75959 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
75960
75961 trace
75962 (p_msg => 'SQL - FETCH line_cur'
75963 ,p_level => C_LEVEL_STATEMENT
75964 ,p_module => l_log_module);
75965
75966 END IF;
75967 --
75968 --
75969 LOOP
75970 --
75971 FETCH line_cur BULK COLLECT INTO
75972 l_array_entity_id
75973 , l_array_legal_entity_id
75974 , l_array_entity_code
75975 , l_array_transaction_num
75976 , l_array_event_id
75977 , l_array_class_code
75978 , l_array_event_type
75979 , l_array_event_number
75980 , l_array_event_date
75981 , l_array_transaction_date
75982 , l_array_reference_num_1
75983 , l_array_reference_num_2
75984 , l_array_reference_num_3
75985 , l_array_reference_num_4
75986 , l_array_reference_char_1
75987 , l_array_reference_char_2
75988 , l_array_reference_char_3
75989 , l_array_reference_char_4
75990 , l_array_reference_date_1
75991 , l_array_reference_date_2
75992 , l_array_reference_date_3
75993 , l_array_reference_date_4
75994 , l_array_event_created_by
75995 , l_array_budgetary_control_flag
75996 , l_array_extract_line_num
75997 , l_array_source_9
75998 , l_array_source_19
75999 , l_array_source_33
76000 , l_array_source_34
76001 , l_array_source_35
76002 , l_array_source_36
76003 , l_array_source_38
76004 , l_array_source_39
76005 , l_array_source_40
76006 , l_array_source_41
76007 , l_array_source_55
76008 , l_array_source_56
76009 , l_array_source_66
76010 LIMIT l_rows;
76011
76012 --
76013 IF (C_LEVEL_EVENT >= g_log_level) THEN
76014 trace
76015 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
76016 ,p_level => C_LEVEL_EVENT
76017 ,p_module => l_log_module);
76018 END IF;
76019 --
76020 EXIT WHEN l_array_entity_id.count = 0;
76021
76022 XLA_AE_LINES_PKG.g_rec_lines := null;
76023
76024 --
76025 -- Bug 4458708
76026 --
76027 XLA_AE_LINES_PKG.g_LineNumber := 0;
76028 --
76029 --
76030
76031 FOR Idx IN 1..l_array_event_id.count LOOP
76032 --
76033 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
76034 --
76035 l_event_id := l_array_event_id(idx); -- 5648433
76036
76037 --
76038 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
76039 --
76040
76041 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
76042 (g_array_event(l_event_id).array_value_num('header_index'))
76043 ,'N'
76044 ) <> 'Y'
76045 THEN
76046 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
76047 trace
76048 (p_msg => 'Trancaction revesal option is not Y '
76049 ,p_level => C_LEVEL_STATEMENT
76050 ,p_module => l_log_module);
76051 END IF;
76052
76053 --
76054 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
76055 --
76056 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
76057 --
76058 -- set event info as cache for other routines to refer event attributes
76059 --
76060
76061 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
76062 l_previous_event_id := l_event_id;
76063
76064 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
76068 ,p_target_ledger_id => p_target_ledger_id
76065 (p_application_id => p_application_id
76066 ,p_primary_ledger_id => p_primary_ledger_id
76067 ,p_base_ledger_id => p_base_ledger_id
76069 ,p_entity_id => l_array_entity_id(Idx)
76070 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
76071 ,p_entity_code => l_array_entity_code(Idx)
76072 ,p_transaction_num => l_array_transaction_num(Idx)
76073 ,p_event_id => l_array_event_id(Idx)
76074 ,p_event_class_code => l_array_class_code(Idx)
76075 ,p_event_type_code => l_array_event_type(Idx)
76076 ,p_event_number => l_array_event_number(Idx)
76077 ,p_event_date => l_array_event_date(Idx)
76078 ,p_transaction_date => l_array_transaction_date(Idx)
76079 ,p_reference_num_1 => l_array_reference_num_1(Idx)
76080 ,p_reference_num_2 => l_array_reference_num_2(Idx)
76081 ,p_reference_num_3 => l_array_reference_num_3(Idx)
76082 ,p_reference_num_4 => l_array_reference_num_4(Idx)
76083 ,p_reference_char_1 => l_array_reference_char_1(Idx)
76084 ,p_reference_char_2 => l_array_reference_char_2(Idx)
76085 ,p_reference_char_3 => l_array_reference_char_3(Idx)
76086 ,p_reference_char_4 => l_array_reference_char_4(Idx)
76087 ,p_reference_date_1 => l_array_reference_date_1(Idx)
76088 ,p_reference_date_2 => l_array_reference_date_2(Idx)
76089 ,p_reference_date_3 => l_array_reference_date_3(Idx)
76090 ,p_reference_date_4 => l_array_reference_date_4(Idx)
76091 ,p_event_created_by => l_array_event_created_by(Idx)
76092 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
76093 --
76094 END IF;
76095
76096
76097
76098 --
76099 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
76100
76101 l_acct_reversal_source := SUBSTR(NULL, 1,30);
76102
76103 IF l_continue_with_lines THEN
76104 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
76105 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
76106
76107 xla_accounting_err_pkg.build_message
76108 (p_appli_s_name => 'XLA'
76109 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
76110 ,p_token_1 => 'LINE_NUMBER'
76111 ,p_value_1 => l_array_extract_line_num(Idx)
76112 ,p_token_2 => 'PRODUCT_NAME'
76113 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
76114 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
76115 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
76116 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
76117
76121 -- accounting for a distributeion
76118 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
76119 --
76120 -- following sets the accounting attributes needed to reverse
76122 --
76123
76124 --
76125 -- 5217187
76126 --
76127 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
76128 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
76129 g_array_event(l_event_id).array_value_num('header_index'));
76130 --
76131 --
76132
76133 -- No reversal code generated
76134
76135 xla_ae_lines_pkg.SetAcctReversalAttrs
76136 (p_event_id => l_event_id
76137 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
76138 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76139 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
76140 END IF;
76141
76142 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
76143 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
76144
76145 --
76146 AcctLineType_64 (
76147 p_application_id => p_application_id
76148 ,p_event_id => l_event_id
76149 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76150 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76151 ,p_actual_flag => l_actual_flag
76152 ,p_balance_type_code => l_balance_type_code
76153 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76154
76155 , p_source_9 => l_array_source_9(Idx)
76156 , p_source_10 => g_array_event(l_event_id).array_value_char('source_10')
76157 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
76158 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76159 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76163 , p_source_35 => l_array_source_35(Idx)
76160 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76161 , p_source_33 => l_array_source_33(Idx)
76162 , p_source_34 => l_array_source_34(Idx)
76164 , p_source_36 => l_array_source_36(Idx)
76165 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76166 , p_source_38 => l_array_source_38(Idx)
76167 , p_source_39 => l_array_source_39(Idx)
76168 , p_source_40 => l_array_source_40(Idx)
76169 , p_source_41 => l_array_source_41(Idx)
76170 , p_source_55 => l_array_source_55(Idx)
76171 , p_source_56 => l_array_source_56(Idx)
76172 );
76173 If(l_balance_type_code = 'A') THEN
76174 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76175 END IF;
76176
76177 --
76178
76179
76180 --
76181 AcctLineType_65 (
76182 p_application_id => p_application_id
76183 ,p_event_id => l_event_id
76184 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76185 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76186 ,p_actual_flag => l_actual_flag
76187 ,p_balance_type_code => l_balance_type_code
76188 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76189
76190 , p_source_9 => l_array_source_9(Idx)
76191 , p_source_10 => g_array_event(l_event_id).array_value_char('source_10')
76192 , p_source_16 => g_array_event(l_event_id).array_value_num('source_16')
76193 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76194 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76195 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76196 , p_source_33 => l_array_source_33(Idx)
76197 , p_source_34 => l_array_source_34(Idx)
76198 , p_source_35 => l_array_source_35(Idx)
76199 , p_source_36 => l_array_source_36(Idx)
76200 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76201 , p_source_38 => l_array_source_38(Idx)
76202 , p_source_39 => l_array_source_39(Idx)
76203 , p_source_40 => l_array_source_40(Idx)
76204 , p_source_41 => l_array_source_41(Idx)
76205 , p_source_55 => l_array_source_55(Idx)
76206 , p_source_56 => l_array_source_56(Idx)
76207 );
76208 If(l_balance_type_code = 'A') THEN
76209 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76210 END IF;
76211
76212 --
76213
76214
76215 --
76216 AcctLineType_84 (
76217 p_application_id => p_application_id
76218 ,p_event_id => l_event_id
76219 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76220 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76221 ,p_actual_flag => l_actual_flag
76222 ,p_balance_type_code => l_balance_type_code
76223 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76224
76225 , p_source_19 => l_array_source_19(Idx)
76226 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76227 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76228 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76229 , p_source_33 => l_array_source_33(Idx)
76230 , p_source_34 => l_array_source_34(Idx)
76231 , p_source_35 => l_array_source_35(Idx)
76232 , p_source_36 => l_array_source_36(Idx)
76233 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76234 , p_source_38 => l_array_source_38(Idx)
76235 , p_source_39 => l_array_source_39(Idx)
76236 , p_source_40 => l_array_source_40(Idx)
76237 , p_source_41 => l_array_source_41(Idx)
76238 , p_source_55 => l_array_source_55(Idx)
76239 );
76240 If(l_balance_type_code = 'A') THEN
76241 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76242 END IF;
76243
76244 --
76245
76246
76247 --
76248 AcctLineType_85 (
76249 p_application_id => p_application_id
76250 ,p_event_id => l_event_id
76251 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76252 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76253 ,p_actual_flag => l_actual_flag
76254 ,p_balance_type_code => l_balance_type_code
76255 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76256
76257 , p_source_19 => l_array_source_19(Idx)
76258 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76259 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76260 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76261 , p_source_33 => l_array_source_33(Idx)
76262 , p_source_34 => l_array_source_34(Idx)
76263 , p_source_35 => l_array_source_35(Idx)
76264 , p_source_36 => l_array_source_36(Idx)
76265 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76266 , p_source_38 => l_array_source_38(Idx)
76267 , p_source_39 => l_array_source_39(Idx)
76268 , p_source_40 => l_array_source_40(Idx)
76269 , p_source_41 => l_array_source_41(Idx)
76270 , p_source_55 => l_array_source_55(Idx)
76271 );
76272 If(l_balance_type_code = 'A') THEN
76273 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76274 END IF;
76275
76276 --
76277
76278
76284 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76279 --
76280 AcctLineType_86 (
76281 p_application_id => p_application_id
76282 ,p_event_id => l_event_id
76283 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76285 ,p_actual_flag => l_actual_flag
76286 ,p_balance_type_code => l_balance_type_code
76287 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76288
76289 , p_source_19 => l_array_source_19(Idx)
76290 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76291 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76292 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76293 , p_source_33 => l_array_source_33(Idx)
76294 , p_source_34 => l_array_source_34(Idx)
76295 , p_source_35 => l_array_source_35(Idx)
76296 , p_source_36 => l_array_source_36(Idx)
76297 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76298 , p_source_38 => l_array_source_38(Idx)
76299 , p_source_39 => l_array_source_39(Idx)
76300 , p_source_40 => l_array_source_40(Idx)
76301 , p_source_41 => l_array_source_41(Idx)
76302 , p_source_55 => l_array_source_55(Idx)
76303 );
76304 If(l_balance_type_code = 'A') THEN
76305 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76306 END IF;
76307
76308 --
76309
76310
76311 --
76312 AcctLineType_87 (
76313 p_application_id => p_application_id
76314 ,p_event_id => l_event_id
76315 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76316 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76317 ,p_actual_flag => l_actual_flag
76318 ,p_balance_type_code => l_balance_type_code
76319 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76320
76321 , p_source_19 => l_array_source_19(Idx)
76322 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76323 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76324 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76325 , p_source_33 => l_array_source_33(Idx)
76326 , p_source_34 => l_array_source_34(Idx)
76327 , p_source_35 => l_array_source_35(Idx)
76328 , p_source_36 => l_array_source_36(Idx)
76329 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76330 , p_source_38 => l_array_source_38(Idx)
76331 , p_source_39 => l_array_source_39(Idx)
76332 , p_source_40 => l_array_source_40(Idx)
76333 , p_source_41 => l_array_source_41(Idx)
76334 , p_source_55 => l_array_source_55(Idx)
76335 , p_source_66 => l_array_source_66(Idx)
76336 );
76337 If(l_balance_type_code = 'A') THEN
76338 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76339 END IF;
76340
76341 --
76342
76343
76344 --
76345 AcctLineType_88 (
76346 p_application_id => p_application_id
76347 ,p_event_id => l_event_id
76348 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76349 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76350 ,p_actual_flag => l_actual_flag
76351 ,p_balance_type_code => l_balance_type_code
76352 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76353
76354 , p_source_19 => l_array_source_19(Idx)
76355 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76356 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76357 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76358 , p_source_33 => l_array_source_33(Idx)
76359 , p_source_34 => l_array_source_34(Idx)
76360 , p_source_35 => l_array_source_35(Idx)
76361 , p_source_36 => l_array_source_36(Idx)
76362 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76363 , p_source_38 => l_array_source_38(Idx)
76364 , p_source_39 => l_array_source_39(Idx)
76365 , p_source_40 => l_array_source_40(Idx)
76366 , p_source_41 => l_array_source_41(Idx)
76367 , p_source_55 => l_array_source_55(Idx)
76368 , p_source_66 => l_array_source_66(Idx)
76369 );
76370 If(l_balance_type_code = 'A') THEN
76371 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76372 END IF;
76373
76374 --
76375
76376
76377 --
76378 AcctLineType_89 (
76379 p_application_id => p_application_id
76380 ,p_event_id => l_event_id
76381 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76382 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76383 ,p_actual_flag => l_actual_flag
76384 ,p_balance_type_code => l_balance_type_code
76385 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76386
76387 , p_source_19 => l_array_source_19(Idx)
76388 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76389 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76390 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76391 , p_source_33 => l_array_source_33(Idx)
76392 , p_source_34 => l_array_source_34(Idx)
76393 , p_source_35 => l_array_source_35(Idx)
76394 , p_source_36 => l_array_source_36(Idx)
76395 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76396 , p_source_38 => l_array_source_38(Idx)
76397 , p_source_39 => l_array_source_39(Idx)
76398 , p_source_40 => l_array_source_40(Idx)
76399 , p_source_41 => l_array_source_41(Idx)
76400 , p_source_55 => l_array_source_55(Idx)
76401 );
76402 If(l_balance_type_code = 'A') THEN
76403 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76404 END IF;
76405
76406 --
76407
76408
76409 --
76410 AcctLineType_90 (
76411 p_application_id => p_application_id
76412 ,p_event_id => l_event_id
76413 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76414 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76415 ,p_actual_flag => l_actual_flag
76419 , p_source_19 => l_array_source_19(Idx)
76416 ,p_balance_type_code => l_balance_type_code
76417 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76418
76420 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76421 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76422 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76423 , p_source_33 => l_array_source_33(Idx)
76424 , p_source_34 => l_array_source_34(Idx)
76425 , p_source_35 => l_array_source_35(Idx)
76426 , p_source_36 => l_array_source_36(Idx)
76427 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76428 , p_source_38 => l_array_source_38(Idx)
76429 , p_source_39 => l_array_source_39(Idx)
76430 , p_source_40 => l_array_source_40(Idx)
76431 , p_source_41 => l_array_source_41(Idx)
76432 , p_source_55 => l_array_source_55(Idx)
76433 );
76434 If(l_balance_type_code = 'A') THEN
76435 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76436 END IF;
76437
76438 --
76439
76440
76441 --
76445 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76442 AcctLineType_91 (
76443 p_application_id => p_application_id
76444 ,p_event_id => l_event_id
76446 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76447 ,p_actual_flag => l_actual_flag
76448 ,p_balance_type_code => l_balance_type_code
76449 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76450
76451 , p_source_19 => l_array_source_19(Idx)
76452 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76453 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76454 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76455 , p_source_33 => l_array_source_33(Idx)
76456 , p_source_34 => l_array_source_34(Idx)
76457 , p_source_35 => l_array_source_35(Idx)
76458 , p_source_36 => l_array_source_36(Idx)
76459 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76460 , p_source_38 => l_array_source_38(Idx)
76461 , p_source_39 => l_array_source_39(Idx)
76462 , p_source_40 => l_array_source_40(Idx)
76463 , p_source_41 => l_array_source_41(Idx)
76464 , p_source_55 => l_array_source_55(Idx)
76465 );
76466 If(l_balance_type_code = 'A') THEN
76467 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76468 END IF;
76469
76470 --
76471
76472
76473 --
76474 AcctLineType_92 (
76475 p_application_id => p_application_id
76476 ,p_event_id => l_event_id
76477 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76478 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76479 ,p_actual_flag => l_actual_flag
76480 ,p_balance_type_code => l_balance_type_code
76481 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76482
76483 , p_source_19 => l_array_source_19(Idx)
76484 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76485 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76486 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76487 , p_source_33 => l_array_source_33(Idx)
76488 , p_source_34 => l_array_source_34(Idx)
76489 , p_source_35 => l_array_source_35(Idx)
76490 , p_source_36 => l_array_source_36(Idx)
76491 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76492 , p_source_38 => l_array_source_38(Idx)
76493 , p_source_39 => l_array_source_39(Idx)
76494 , p_source_40 => l_array_source_40(Idx)
76495 , p_source_41 => l_array_source_41(Idx)
76496 , p_source_55 => l_array_source_55(Idx)
76497 , p_source_66 => l_array_source_66(Idx)
76498 );
76499 If(l_balance_type_code = 'A') THEN
76500 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76501 END IF;
76502
76503 --
76504
76505
76506 --
76507 AcctLineType_93 (
76508 p_application_id => p_application_id
76509 ,p_event_id => l_event_id
76510 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76511 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76512 ,p_actual_flag => l_actual_flag
76513 ,p_balance_type_code => l_balance_type_code
76514 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76515
76516 , p_source_19 => l_array_source_19(Idx)
76517 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76518 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76519 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76520 , p_source_33 => l_array_source_33(Idx)
76521 , p_source_34 => l_array_source_34(Idx)
76522 , p_source_35 => l_array_source_35(Idx)
76523 , p_source_36 => l_array_source_36(Idx)
76524 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76525 , p_source_38 => l_array_source_38(Idx)
76526 , p_source_39 => l_array_source_39(Idx)
76527 , p_source_40 => l_array_source_40(Idx)
76531 );
76528 , p_source_41 => l_array_source_41(Idx)
76529 , p_source_55 => l_array_source_55(Idx)
76530 , p_source_66 => l_array_source_66(Idx)
76532 If(l_balance_type_code = 'A') THEN
76533 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76534 END IF;
76535
76536 --
76537
76538
76539 --
76540 AcctLineType_94 (
76541 p_application_id => p_application_id
76542 ,p_event_id => l_event_id
76543 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76544 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76545 ,p_actual_flag => l_actual_flag
76546 ,p_balance_type_code => l_balance_type_code
76547 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76548
76549 , p_source_19 => l_array_source_19(Idx)
76550 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76551 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76552 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76553 , p_source_33 => l_array_source_33(Idx)
76554 , p_source_34 => l_array_source_34(Idx)
76555 , p_source_35 => l_array_source_35(Idx)
76556 , p_source_36 => l_array_source_36(Idx)
76557 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76558 , p_source_38 => l_array_source_38(Idx)
76559 , p_source_39 => l_array_source_39(Idx)
76560 , p_source_40 => l_array_source_40(Idx)
76561 , p_source_41 => l_array_source_41(Idx)
76562 , p_source_55 => l_array_source_55(Idx)
76563 , p_source_66 => l_array_source_66(Idx)
76564 );
76565 If(l_balance_type_code = 'A') THEN
76566 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76567 END IF;
76568
76569 --
76570
76571
76572 --
76573 AcctLineType_95 (
76574 p_application_id => p_application_id
76575 ,p_event_id => l_event_id
76576 ,p_calculate_acctd_flag => l_calculate_acctd_flag
76577 ,p_calculate_g_l_flag => l_calculate_g_l_flag
76578 ,p_actual_flag => l_actual_flag
76579 ,p_balance_type_code => l_balance_type_code
76580 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
76581
76582 , p_source_19 => l_array_source_19(Idx)
76583 , p_source_30 => g_array_event(l_event_id).array_value_num('source_30')
76584 , p_source_31 => g_array_event(l_event_id).array_value_num('source_31')
76585 , p_source_32 => g_array_event(l_event_id).array_value_char('source_32')
76586 , p_source_33 => l_array_source_33(Idx)
76587 , p_source_34 => l_array_source_34(Idx)
76588 , p_source_35 => l_array_source_35(Idx)
76589 , p_source_36 => l_array_source_36(Idx)
76590 , p_source_37 => g_array_event(l_event_id).array_value_char('source_37')
76591 , p_source_38 => l_array_source_38(Idx)
76592 , p_source_39 => l_array_source_39(Idx)
76593 , p_source_40 => l_array_source_40(Idx)
76594 , p_source_41 => l_array_source_41(Idx)
76595 , p_source_55 => l_array_source_55(Idx)
76596 , p_source_66 => l_array_source_66(Idx)
76597 );
76598 If(l_balance_type_code = 'A') THEN
76599 l_actual_gain_loss_ref := l_gain_or_loss_ref;
76600 END IF;
76601
76602 --
76603
76607 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
76604 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
76605 -- or secondary ledger that has different currency with primary
76606 -- or alc that is calculated by sla
76608 (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'))
76609
76610 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
76611 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
76612 AND (l_actual_flag = 'A')) THEN
76613 XLA_AE_LINES_PKG.CreateGainOrLossLines(
76614 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
76615 ,p_application_id => p_application_id
76616 ,p_amb_context_code => 'DEFAULT'
76617 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
76618 ,p_event_class_code => C_EVENT_CLASS_CODE
76619 ,p_event_type_code => C_EVENT_TYPE_CODE
76620
76621 ,p_gain_ccid => -1
76622 ,p_loss_ccid => -1
76623
76624 ,p_actual_flag => l_actual_flag
76625 ,p_enc_flag => null
76626 ,p_actual_g_l_ref => l_actual_gain_loss_ref
76627 ,p_enc_g_l_ref => null
76628 );
76629 END IF;
76630 END IF;
76631 END IF;
76632
76633 ELSE
76634 --
76635 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
76636 --
76637 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
76638 trace
76639 (p_msg => 'Trancaction revesal option is Y'
76640 ,p_level => C_LEVEL_STATEMENT
76641 ,p_module => l_log_module);
76642 END IF;
76643 END IF;
76644
76645 END LOOP;
76646 l_result := XLA_AE_LINES_PKG.InsertLines ;
76647 end loop;
76648 close line_cur;
76649
76650
76651 --
76652 -- insert headers into xla_ae_headers_gt table
76653 --
76654 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
76655
76656 -- insert into errors table here.
76657
76658 END LOOP;
76659
76660 --
76661 -- 4865292
76662 --
76663 -- Compare g_hdr_extract_count with event count in
76664 -- CreateHeadersAndLines.
76665 --
76666 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
76667
76668 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
76669 trace (p_msg => '# rows extracted from header extract objects '
76670 || ' (running total): '
76671 || g_hdr_extract_count
76672 ,p_level => C_LEVEL_STATEMENT
76673 ,p_module => l_log_module);
76674 END IF;
76675
76676 CLOSE header_cur;
76677 --
76678
76679 --
76680 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
76681 trace
76682 (p_msg => 'END of EventClass_140'
76683 ,p_level => C_LEVEL_PROCEDURE
76684 ,p_module => l_log_module);
76685 END IF;
76686 --
76687 RETURN l_result;
76688 EXCEPTION
76689 WHEN xla_exceptions_pkg.application_exception THEN
76690
76691 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
76692
76693
76694 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
76695
76696 RAISE;
76697
76698 WHEN NO_DATA_FOUND THEN
76699
76700 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
76701 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
76702
76703 FOR header_record IN header_cur
76704 LOOP
76705 l_array_header_events(header_record.event_id) := header_record.event_id;
76706 END LOOP;
76707
76708 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
76709 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
76710
76711 fnd_file.put_line(fnd_file.LOG, ' ');
76712 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
76713 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
76714 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
76715
76716 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
76717 LOOP
76718 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
76719 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
76720 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
76721 END IF;
76722 END LOOP;
76723
76724 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
76725 fnd_file.put_line(fnd_file.LOG, ' ');
76726
76727
76728 xla_exceptions_pkg.raise_message
76729 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_140');
76730
76731
76732 WHEN OTHERS THEN
76733 xla_exceptions_pkg.raise_message
76734 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_140');
76735 END EventClass_140;
76736 --
76737
76738 ---------------------------------------
76739 --
76740 -- PRIVATE PROCEDURE
76741 -- insert_sources_141
76742 --
76743 ----------------------------------------
76744 --
76745 PROCEDURE insert_sources_141(
76746 p_target_ledger_id IN NUMBER
76747 , p_language IN VARCHAR2
76748 , p_sla_ledger_id IN NUMBER
76749 , p_pad_start_date IN DATE
76750 , p_pad_end_date IN DATE
76751 )
76752 IS
76753
76754 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT_ALL';
76755 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT';
76756 p_apps_owner VARCHAR2(30);
76757 l_log_module VARCHAR2(240);
76758 BEGIN
76759 IF g_log_enabled THEN
76760 l_log_module := C_DEFAULT_MODULE||'.insert_sources_141';
76761 END IF;
76762 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
76763
76764 trace
76765 (p_msg => 'BEGIN of insert_sources_141'
76766 ,p_level => C_LEVEL_PROCEDURE
76767 ,p_module => l_log_module);
76768
76769 END IF;
76770
76771 -- select APPS owner
76772 SELECT oracle_username
76773 INTO p_apps_owner
76774 FROM fnd_oracle_userid
76778 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
76775 WHERE read_only_flag = 'U'
76776 ;
76777
76779 trace
76780 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
76781 ' - p_language = '||p_language||
76782 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
76783 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
76784 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
76785 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
76786 ,p_level => C_LEVEL_STATEMENT
76787 ,p_module => l_log_module);
76788 END IF;
76789
76790
76791 --
76792 INSERT INTO xla_diag_sources --hdr2
76793 (
76794 event_id
76795 , ledger_id
76796 , sla_ledger_id
76797 , description_language
76798 , object_name
76799 , object_type_code
76800 , line_number
76801 , source_application_id
76802 , source_type_code
76803 , source_code
76804 , source_value
76805 , source_meaning
76806 , created_by
76807 , creation_date
76808 , last_update_date
76809 , last_updated_by
76810 , last_update_login
76811 , program_update_date
76812 , program_application_id
76813 , program_id
76814 , request_id
76815 )
76816 SELECT
76817 event_id
76818 , p_target_ledger_id
76819 , p_sla_ledger_id
76820 , p_language
76821 , object_name
76822 , object_type_code
76823 , line_number
76824 , source_application_id
76825 , source_type_code
76826 , source_code
76827 , SUBSTR(source_value ,1,1996)
76828 , SUBSTR(source_meaning ,1,200)
76829 , xla_environment_pkg.g_Usr_Id
76830 , TRUNC(SYSDATE)
76831 , TRUNC(SYSDATE)
76832 , xla_environment_pkg.g_Usr_Id
76833 , xla_environment_pkg.g_Login_Id
76834 , TRUNC(SYSDATE)
76835 , xla_environment_pkg.g_Prog_Appl_Id
76836 , xla_environment_pkg.g_Prog_Id
76837 , xla_environment_pkg.g_Req_Id
76838 FROM (
76839 SELECT xet.event_id event_id
76840 , 0 line_number
76841 , CASE r
76842 WHEN 1 THEN 'AR_CASH_RECEIPTS_H_V'
76843 WHEN 2 THEN 'AR_CASH_RECEIPTS_H_V'
76844 WHEN 3 THEN 'AR_CASH_RECEIPTS_H_V'
76845 WHEN 4 THEN 'AR_CASH_RECEIPTS_H_V'
76846
76847 ELSE null
76848 END object_name
76849 , CASE r
76850 WHEN 1 THEN 'HEADER'
76851 WHEN 2 THEN 'HEADER'
76852 WHEN 3 THEN 'HEADER'
76853 WHEN 4 THEN 'HEADER'
76854
76855 ELSE null
76856 END object_type_code
76857 , CASE r
76858 WHEN 1 THEN '222'
76859 WHEN 2 THEN '222'
76860 WHEN 3 THEN '222'
76861 WHEN 4 THEN '222'
76862
76863 ELSE null
76864 END source_application_id
76865 , 'S' source_type_code
76866 , CASE r
76867 WHEN 1 THEN 'RCT_DOC_SEQUENCE_CATEGORY'
76868 WHEN 2 THEN 'RCT_DOC_SEQUENCE_ID'
76869 WHEN 3 THEN 'RCT_DOC_SEQUENCE_VALUE'
76870 WHEN 4 THEN 'RCT_TRX_ACCT_REVERSAL'
76871
76872 ELSE null
76873 END source_code
76874 , CASE r
76875 WHEN 1 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_CATEGORY)
76876 WHEN 2 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_ID)
76877 WHEN 3 THEN TO_CHAR(h1.RCT_DOC_SEQUENCE_VALUE)
76878 WHEN 4 THEN TO_CHAR(h1.RCT_TRX_ACCT_REVERSAL)
76879
76880 ELSE null
76881 END source_value
76882 , null source_meaning
76883 FROM xla_events_gt xet
76884 , AR_CASH_RECEIPTS_H_V h1
76885 ,(select rownum r from all_objects where rownum <= 4 and owner = p_apps_owner)
76886 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
76887 AND xet.event_class_code = C_EVENT_CLASS_CODE
76888
76889 )
76890 ;
76891 --
76892 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
76893
76894 trace
76898
76895 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
76896 ,p_level => C_LEVEL_STATEMENT
76897 ,p_module => l_log_module);
76899 END IF;
76900 --
76901
76902
76903
76904 --
76905 INSERT INTO xla_diag_sources --line2
76906 (
76907 event_id
76908 , ledger_id
76909 , sla_ledger_id
76910 , description_language
76911 , object_name
76912 , object_type_code
76913 , line_number
76914 , source_application_id
76915 , source_type_code
76916 , source_code
76917 , source_value
76918 , source_meaning
76919 , created_by
76920 , creation_date
76921 , last_update_date
76922 , last_updated_by
76923 , last_update_login
76924 , program_update_date
76925 , program_application_id
76926 , program_id
76927 , request_id
76928 )
76929 SELECT event_id
76930 , p_target_ledger_id
76931 , p_sla_ledger_id
76932 , p_language
76933 , object_name
76934 , object_type_code
76935 , line_number
76936 , source_application_id
76937 , source_type_code
76938 , source_code
76939 , SUBSTR(source_value,1,1996)
76940 , SUBSTR(source_meaning ,1,200)
76941 , xla_environment_pkg.g_Usr_Id
76942 , TRUNC(SYSDATE)
76943 , TRUNC(SYSDATE)
76944 , xla_environment_pkg.g_Usr_Id
76945 , xla_environment_pkg.g_Login_Id
76946 , TRUNC(SYSDATE)
76947 , xla_environment_pkg.g_Prog_Appl_Id
76948 , xla_environment_pkg.g_Prog_Id
76949 , xla_environment_pkg.g_Req_Id
76950 FROM (
76951 SELECT xet.event_id event_id
76952 , l3.line_number line_number
76953 , CASE r
76954 WHEN 1 THEN 'AR_DISTRIBUTIONS_L_V'
76955 WHEN 2 THEN 'FV_XLA_AR_REF_V'
76956 WHEN 3 THEN 'FV_XLA_AR_REF_V'
76957 WHEN 4 THEN 'FV_XLA_AR_REF_V'
76958 WHEN 5 THEN 'FV_XLA_AR_REF_V'
76959 WHEN 6 THEN 'FV_XLA_AR_REF_V'
76960 WHEN 7 THEN 'AR_DISTRIBUTIONS_L_V'
76961 WHEN 8 THEN 'AR_DISTRIBUTIONS_L_V'
76962 WHEN 9 THEN 'AR_DISTRIBUTIONS_L_V'
76963 WHEN 10 THEN 'AR_DISTRIBUTIONS_L_V'
76964 WHEN 11 THEN 'AR_DISTRIBUTIONS_L_V'
76965 WHEN 12 THEN 'AR_DISTRIBUTIONS_BASE_V'
76966 WHEN 13 THEN 'AR_DISTRIBUTIONS_BASE_V'
76967 WHEN 14 THEN 'AR_DISTRIBUTIONS_BASE_V'
76968 WHEN 15 THEN 'FV_XLA_AR_REF_V'
76969 WHEN 16 THEN 'AR_DISTRIBUTIONS_BASE_V'
76970 WHEN 17 THEN 'AR_DISTRIBUTIONS_L_V'
76971
76972 ELSE null
76973 END object_name
76974 , CASE r
76975 WHEN 1 THEN 'LINE'
76976 WHEN 2 THEN 'LINE'
76977 WHEN 3 THEN 'LINE'
76978 WHEN 4 THEN 'LINE'
76979 WHEN 5 THEN 'LINE'
76980 WHEN 6 THEN 'LINE'
76981 WHEN 7 THEN 'LINE'
76982 WHEN 8 THEN 'LINE'
76983 WHEN 9 THEN 'LINE'
76984 WHEN 10 THEN 'LINE'
76985 WHEN 11 THEN 'LINE'
76986 WHEN 12 THEN 'LINE'
76987 WHEN 13 THEN 'LINE'
76988 WHEN 14 THEN 'LINE'
76989 WHEN 15 THEN 'LINE'
76990 WHEN 16 THEN 'LINE'
76991 WHEN 17 THEN 'LINE'
76992
76993 ELSE null
76994 END object_type_code
76995 , CASE r
76996 WHEN 1 THEN '222'
76997 WHEN 2 THEN '8901'
76998 WHEN 3 THEN '8901'
76999 WHEN 4 THEN '8901'
77000 WHEN 5 THEN '8901'
77001 WHEN 6 THEN '8901'
77002 WHEN 7 THEN '222'
77003 WHEN 8 THEN '222'
77004 WHEN 9 THEN '222'
77005 WHEN 10 THEN '222'
77006 WHEN 11 THEN '222'
77007 WHEN 12 THEN '222'
77008 WHEN 13 THEN '222'
77009 WHEN 14 THEN '222'
77010 WHEN 15 THEN '8901'
77011 WHEN 16 THEN '222'
77012 WHEN 17 THEN '222'
77013
77014 ELSE null
77015 END source_application_id
77016 , 'S' source_type_code
77017 , CASE r
77018 WHEN 1 THEN 'DIST_CODE_COMBINATION_ID'
77019 WHEN 2 THEN 'FEDERAL_FUND_CATEGORY'
77020 WHEN 3 THEN 'FEDERAL_FUND_EXPIRED_STATUS'
77021 WHEN 4 THEN 'FEDERAL_PRIOR_YEAR_FLAG'
77022 WHEN 5 THEN 'FEDERAL_FUND_TIME_FRAME'
77023 WHEN 6 THEN 'FEDERAL_APPORTIONMENT_CATEGORY'
77024 WHEN 7 THEN 'DIST_SOURCE_TYPE'
77025 WHEN 8 THEN 'DIST_LINE_ID'
77026 WHEN 9 THEN 'DISTRIBUTION_TYPE'
77027 WHEN 10 THEN 'DIST_ENT_AMT'
77028 WHEN 11 THEN 'DIST_CURRENCY_CODE'
77029 WHEN 12 THEN 'DIST_CUR_CONVERSION_RATE'
77030 WHEN 13 THEN 'DIST_CUR_CONVERSION_TYPE'
77031 WHEN 14 THEN 'DIST_TO_ACCTD_AMT'
77032 WHEN 15 THEN 'FEDERAL_ACCOUNT_VALID_FLAG'
77033 WHEN 16 THEN 'DIST_TO_CUR_CONVERSION_DATE'
77034 WHEN 17 THEN 'DIST_MFAR_ADDITIONAL_ENTRY'
77035
77036 ELSE null
77037 END source_code
77038 , CASE r
77039 WHEN 1 THEN TO_CHAR(l3.DIST_CODE_COMBINATION_ID)
77040 WHEN 2 THEN TO_CHAR(l4.FEDERAL_FUND_CATEGORY)
77041 WHEN 3 THEN TO_CHAR(l4.FEDERAL_FUND_EXPIRED_STATUS)
77042 WHEN 4 THEN TO_CHAR(l4.FEDERAL_PRIOR_YEAR_FLAG)
77043 WHEN 5 THEN TO_CHAR(l4.FEDERAL_FUND_TIME_FRAME)
77044 WHEN 6 THEN TO_CHAR(l4.FEDERAL_APPORTIONMENT_CATEGORY)
77045 WHEN 7 THEN TO_CHAR(l3.DIST_SOURCE_TYPE)
77046 WHEN 8 THEN TO_CHAR(l3.DIST_LINE_ID)
77047 WHEN 9 THEN TO_CHAR(l3.DISTRIBUTION_TYPE)
77048 WHEN 10 THEN TO_CHAR(l3.DIST_ENT_AMT)
77049 WHEN 11 THEN TO_CHAR(l3.DIST_CURRENCY_CODE)
77050 WHEN 12 THEN TO_CHAR(l2.DIST_CUR_CONVERSION_RATE)
77051 WHEN 13 THEN TO_CHAR(l2.DIST_CUR_CONVERSION_TYPE)
77052 WHEN 14 THEN TO_CHAR(l2.DIST_TO_ACCTD_AMT)
77053 WHEN 15 THEN TO_CHAR(l4.FEDERAL_ACCOUNT_VALID_FLAG)
77054 WHEN 16 THEN TO_CHAR(l2.DIST_TO_CUR_CONVERSION_DATE)
77055 WHEN 17 THEN TO_CHAR(l3.DIST_MFAR_ADDITIONAL_ENTRY)
77056
77057 ELSE null
77058 END source_value
77059 , null source_meaning
77060 FROM xla_events_gt xet
77061 , AR_DISTRIBUTIONS_BASE_V l2
77062 , AR_DISTRIBUTIONS_L_V l3
77063 , FV_XLA_AR_REF_V l4
77064 , (select rownum r from all_objects where rownum <= 17 and owner = p_apps_owner)
77065 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
77066 AND xet.event_class_code = C_EVENT_CLASS_CODE
77067 AND l2.event_id = xet.event_id
77068 AND l3.event_id = l2.event_id
77069 AND l3.line_number = l2.line_number
77070 AND l4.federal_event_id (+) = l3.event_id and l4.federal_line_number (+) = l3.line_number
77071 )
77072 ;
77073 --
77074 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
77075
77076 trace
77077 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
77078 ,p_level => C_LEVEL_STATEMENT
77079 ,p_module => l_log_module);
77080
77081 END IF;
77082
77083
77084 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
77085 trace
77086 (p_msg => 'END of insert_sources_141'
77087 ,p_level => C_LEVEL_PROCEDURE
77088 ,p_module => l_log_module);
77089 END IF;
77090 EXCEPTION
77091 WHEN xla_exceptions_pkg.application_exception THEN
77092 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
77093 trace
77094 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
77095 ,p_level => C_LEVEL_EXCEPTION
77096 ,p_module => l_log_module);
77097 END IF;
77098 RAISE;
77099 WHEN OTHERS THEN
77100 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
77101 trace
77102 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
77103 ,p_level => C_LEVEL_EXCEPTION
77104 ,p_module => l_log_module);
77105 END IF;
77106 xla_exceptions_pkg.raise_message
77107 (p_location => 'XLA_00222_AAD_S_000005_PKG.insert_sources_141');
77108 END insert_sources_141;
77109 --
77110
77111 ---------------------------------------
77112 --
77113 -- PRIVATE FUNCTION
77114 -- EventClass_141
77115 --
77116 ----------------------------------------
77117 --
77118 FUNCTION EventClass_141
77119 (p_application_id IN NUMBER
77120 ,p_base_ledger_id IN NUMBER
77121 ,p_target_ledger_id IN NUMBER
77122 ,p_language IN VARCHAR2
77123 ,p_currency_code IN VARCHAR2
77124 ,p_sla_ledger_id IN NUMBER
77125 ,p_pad_start_date IN DATE
77126 ,p_pad_end_date IN DATE
77127 ,p_primary_ledger_id IN NUMBER)
77128 RETURN BOOLEAN IS
77129 --
77130 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT_ALL';
77131 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'MISC_RECEIPT';
77132
77133 l_calculate_acctd_flag VARCHAR2(1) :='N';
77134 l_calculate_g_l_flag VARCHAR2(1) :='N';
77135 --
77136 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77137 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77138 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
77139 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
77140 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77141 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
77145 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77142 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
77143 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77144 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77146 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77147 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77148 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77149 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
77150 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
77151 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
77152 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
77153 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
77154 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77155 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77156 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77157 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
77158 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
77159 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
77160 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
77161 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
77162
77163 l_event_id NUMBER;
77164 l_previous_event_id NUMBER;
77165 l_first_event_id NUMBER;
77166 l_last_event_id NUMBER;
77167
77168 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
77169 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
77170 --
77171 --
77172 l_result BOOLEAN := TRUE;
77173 l_rows NUMBER := 1000;
77174 l_event_type_name VARCHAR2(80) := 'All';
77175 l_event_class_name VARCHAR2(80) := 'Miscellaneous Receipt';
77176 l_description VARCHAR2(4000);
77177 l_transaction_reversal NUMBER;
77178 l_ae_header_id NUMBER;
77179 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
77180 l_log_module VARCHAR2(240);
77181 --
77182 l_acct_reversal_source VARCHAR2(30);
77183 l_trx_reversal_source VARCHAR2(30);
77184
77185 l_continue_with_lines BOOLEAN := TRUE;
77186 --
77187 l_acc_rev_gl_date_source DATE; -- 4262811
77188 --
77189 type t_array_event_id is table of number index by binary_integer;
77190
77191 l_rec_array_event t_rec_array_event;
77192 l_null_rec_array_event t_rec_array_event;
77193 l_array_ae_header_id xla_number_array_type;
77194 l_actual_flag VARCHAR2(1) := NULL;
77195 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
77196 l_balance_type_code VARCHAR2(1) :=NULL;
77197 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
77198
77199 --
77200 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
77201 --
77202
77203 TYPE t_array_source_83 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
77204 TYPE t_array_source_84 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
77205 TYPE t_array_source_85 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
77206 TYPE t_array_source_86 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_TRX_ACCT_REVERSAL%TYPE INDEX BY BINARY_INTEGER;
77207
77208 TYPE t_array_source_5 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
77209 TYPE t_array_source_9 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
77210 TYPE t_array_source_12 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_EXPIRED_STATUS%TYPE INDEX BY BINARY_INTEGER;
77211 TYPE t_array_source_13 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_PRIOR_YEAR_FLAG%TYPE INDEX BY BINARY_INTEGER;
77212 TYPE t_array_source_14 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_TIME_FRAME%TYPE INDEX BY BINARY_INTEGER;
77213 TYPE t_array_source_15 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_APPORTIONMENT_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
77214 TYPE t_array_source_20 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
77215 TYPE t_array_source_22 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
77216 TYPE t_array_source_23 IS TABLE OF AR_DISTRIBUTIONS_L_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
77217 TYPE t_array_source_24 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
77218 TYPE t_array_source_25 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
77219 TYPE t_array_source_27 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
77220 TYPE t_array_source_28 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
77221 TYPE t_array_source_29 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
77222 TYPE t_array_source_56 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_ACCOUNT_VALID_FLAG%TYPE INDEX BY BINARY_INTEGER;
77223 TYPE t_array_source_57 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
77224 TYPE t_array_source_67 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_MFAR_ADDITIONAL_ENTRY%TYPE INDEX BY BINARY_INTEGER;
77225
77226 l_array_source_83 t_array_source_83;
77227 l_array_source_84 t_array_source_84;
77228 l_array_source_85 t_array_source_85;
77229 l_array_source_86 t_array_source_86;
77230
77234 l_array_source_13 t_array_source_13;
77231 l_array_source_5 t_array_source_5;
77232 l_array_source_9 t_array_source_9;
77233 l_array_source_12 t_array_source_12;
77235 l_array_source_14 t_array_source_14;
77236 l_array_source_15 t_array_source_15;
77237 l_array_source_20 t_array_source_20;
77238 l_array_source_22 t_array_source_22;
77239 l_array_source_23 t_array_source_23;
77240 l_array_source_24 t_array_source_24;
77241 l_array_source_25 t_array_source_25;
77242 l_array_source_27 t_array_source_27;
77243 l_array_source_28 t_array_source_28;
77244 l_array_source_29 t_array_source_29;
77245 l_array_source_56 t_array_source_56;
77246 l_array_source_57 t_array_source_57;
77247 l_array_source_67 t_array_source_67;
77248
77249 --
77250 CURSOR header_cur
77251 IS
77252 SELECT /*+ leading(xet) cardinality(xet,1) */
77253 -- Event Class Code: MISC_RECEIPT
77254 xet.entity_id
77255 ,xet.legal_entity_id
77256 ,xet.entity_code
77257 ,xet.transaction_number
77258 ,xet.event_id
77259 ,xet.event_class_code
77260 ,xet.event_type_code
77261 ,xet.event_number
77262 ,xet.event_date
77263 ,xet.transaction_date
77264 ,xet.reference_num_1
77265 ,xet.reference_num_2
77266 ,xet.reference_num_3
77267 ,xet.reference_num_4
77268 ,xet.reference_char_1
77269 ,xet.reference_char_2
77270 ,xet.reference_char_3
77271 ,xet.reference_char_4
77272 ,xet.reference_date_1
77273 ,xet.reference_date_2
77274 ,xet.reference_date_3
77275 ,xet.reference_date_4
77276 ,xet.event_created_by
77277 ,xet.budgetary_control_flag
77278 , h1.RCT_DOC_SEQUENCE_CATEGORY source_83
77279 , h1.RCT_DOC_SEQUENCE_ID source_84
77280 , h1.RCT_DOC_SEQUENCE_VALUE source_85
77281 , h1.RCT_TRX_ACCT_REVERSAL source_86
77282 FROM xla_events_gt xet
77283 , AR_CASH_RECEIPTS_H_V h1
77284 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
77285 and xet.event_class_code = C_EVENT_CLASS_CODE
77286 and xet.event_status_code <> 'N' AND h1.event_id (+) = xet.event_id
77287
77288 ORDER BY event_id
77289 ;
77290
77291
77292 --
77293 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
77294 IS
77295 SELECT /*+ leading(xet) cardinality(xet,1) */
77296 -- Event Class Code: MISC_RECEIPT
77297 xet.entity_id
77298 ,xet.legal_entity_id
77299 ,xet.entity_code
77300 ,xet.transaction_number
77301 ,xet.event_id
77302 ,xet.event_class_code
77303 ,xet.event_type_code
77304 ,xet.event_number
77305 ,xet.event_date
77306 ,xet.transaction_date
77307 ,xet.reference_num_1
77308 ,xet.reference_num_2
77309 ,xet.reference_num_3
77310 ,xet.reference_num_4
77311 ,xet.reference_char_1
77312 ,xet.reference_char_2
77313 ,xet.reference_char_3
77314 ,xet.reference_char_4
77315 ,xet.reference_date_1
77316 ,xet.reference_date_2
77317 ,xet.reference_date_3
77318 ,xet.reference_date_4
77319 ,xet.event_created_by
77320 ,xet.budgetary_control_flag
77321 , l2.LINE_NUMBER
77322 , l3.DIST_CODE_COMBINATION_ID source_5
77323 , l4.FEDERAL_FUND_CATEGORY source_9
77324 , l4.FEDERAL_FUND_EXPIRED_STATUS source_12
77325 , l4.FEDERAL_PRIOR_YEAR_FLAG source_13
77326 , l4.FEDERAL_FUND_TIME_FRAME source_14
77327 , l4.FEDERAL_APPORTIONMENT_CATEGORY source_15
77328 , l3.DIST_SOURCE_TYPE source_20
77329 , l3.DIST_LINE_ID source_22
77330 , l3.DISTRIBUTION_TYPE source_23
77331 , l3.DIST_ENT_AMT source_24
77332 , l3.DIST_CURRENCY_CODE source_25
77333 , l2.DIST_CUR_CONVERSION_RATE source_27
77334 , l2.DIST_CUR_CONVERSION_TYPE source_28
77335 , l2.DIST_TO_ACCTD_AMT source_29
77336 , l4.FEDERAL_ACCOUNT_VALID_FLAG source_56
77337 , l2.DIST_TO_CUR_CONVERSION_DATE source_57
77338 , l3.DIST_MFAR_ADDITIONAL_ENTRY source_67
77339 FROM xla_events_gt xet
77340 , AR_DISTRIBUTIONS_BASE_V l2
77341 , AR_DISTRIBUTIONS_L_V l3
77342 , FV_XLA_AR_REF_V l4
77343 WHERE xet.event_id between x_first_event_id and x_last_event_id
77344 and xet.event_date between p_pad_start_date and p_pad_end_date
77345 and xet.event_class_code = C_EVENT_CLASS_CODE
77346 and xet.event_status_code <> 'N' AND l2.event_id = xet.event_id
77347 AND l3.event_id = l2.event_id
77348 AND l3.line_number = l2.line_number
77349 AND l4.federal_event_id (+) = l3.event_id AND l4.federal_line_number (+) = l3.line_number;
77350
77351 --
77352 BEGIN
77353 IF g_log_enabled THEN
77354 l_log_module := C_DEFAULT_MODULE||'.EventClass_141';
77355 END IF;
77356 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
77357 trace
77358 (p_msg => 'BEGIN of EventClass_141'
77359 ,p_level => C_LEVEL_PROCEDURE
77360 ,p_module => l_log_module);
77361 END IF;
77362
77363 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
77364 trace
77365 (p_msg => 'p_application_id = '||p_application_id||
77366 ' - p_base_ledger_id = '||p_base_ledger_id||
77367 ' - p_target_ledger_id = '||p_target_ledger_id||
77368 ' - p_language = '||p_language||
77369 ' - p_currency_code = '||p_currency_code||
77370 ' - p_sla_ledger_id = '||p_sla_ledger_id
77371 ,p_level => C_LEVEL_STATEMENT
77372 ,p_module => l_log_module);
77376 --
77373 END IF;
77374 --
77375 -- initialze arrays
77377 g_array_event.DELETE;
77378 l_rec_array_event := l_null_rec_array_event;
77379 --
77380 --------------------------------------
77381 -- 4262811 Initialze MPA Line Number
77382 --------------------------------------
77383 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
77384
77385 --
77386
77387 --
77388 OPEN header_cur;
77389 --
77390 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
77391 trace
77392 (p_msg => 'SQL - FETCH header_cur'
77393 ,p_level => C_LEVEL_STATEMENT
77394 ,p_module => l_log_module);
77395 END IF;
77396 --
77397 LOOP
77398 FETCH header_cur BULK COLLECT INTO
77399 l_array_entity_id
77400 , l_array_legal_entity_id
77401 , l_array_entity_code
77402 , l_array_transaction_num
77403 , l_array_event_id
77404 , l_array_class_code
77405 , l_array_event_type
77406 , l_array_event_number
77407 , l_array_event_date
77408 , l_array_transaction_date
77409 , l_array_reference_num_1
77410 , l_array_reference_num_2
77411 , l_array_reference_num_3
77412 , l_array_reference_num_4
77413 , l_array_reference_char_1
77414 , l_array_reference_char_2
77415 , l_array_reference_char_3
77416 , l_array_reference_char_4
77417 , l_array_reference_date_1
77418 , l_array_reference_date_2
77419 , l_array_reference_date_3
77420 , l_array_reference_date_4
77421 , l_array_event_created_by
77422 , l_array_budgetary_control_flag
77423 , l_array_source_83
77424 , l_array_source_84
77425 , l_array_source_85
77426 , l_array_source_86
77427 LIMIT l_rows;
77428 --
77429 IF (C_LEVEL_EVENT >= g_log_level) THEN
77430 trace
77431 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
77432 ,p_level => C_LEVEL_EVENT
77433 ,p_module => l_log_module);
77434 END IF;
77435 --
77436 EXIT WHEN l_array_entity_id.COUNT = 0;
77437
77438 -- initialize arrays
77439 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
77440 XLA_AE_LINES_PKG.g_rec_lines := NULL;
77441
77442 --
77443 -- Bug 4458708
77444 --
77445 XLA_AE_LINES_PKG.g_LineNumber := 0;
77446
77447
77448 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
77449 g_last_hdr_idx := l_array_event_id.LAST;
77450 --
77451 -- loop for the headers. Each iteration is for each header extract row
77452 -- fetched in header cursor
77453 --
77454 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
77455
77456 --
77457 -- set event info as cache for other routines to refer event attributes
77458 --
77459 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
77460 (p_application_id => p_application_id
77461 ,p_primary_ledger_id => p_primary_ledger_id
77462 ,p_base_ledger_id => p_base_ledger_id
77463 ,p_target_ledger_id => p_target_ledger_id
77464 ,p_entity_id => l_array_entity_id(hdr_idx)
77465 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
77466 ,p_entity_code => l_array_entity_code(hdr_idx)
77467 ,p_transaction_num => l_array_transaction_num(hdr_idx)
77468 ,p_event_id => l_array_event_id(hdr_idx)
77469 ,p_event_class_code => l_array_class_code(hdr_idx)
77470 ,p_event_type_code => l_array_event_type(hdr_idx)
77471 ,p_event_number => l_array_event_number(hdr_idx)
77472 ,p_event_date => l_array_event_date(hdr_idx)
77473 ,p_transaction_date => l_array_transaction_date(hdr_idx)
77474 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
77475 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
77476 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
77477 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
77478 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
77479 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
77480 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
77481 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
77482 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
77483 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
77484 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
77485 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
77486 ,p_event_created_by => l_array_event_created_by(hdr_idx)
77487 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
77488
77489 --
77490 -- set the status of entry to C_VALID (0)
77491 --
77492 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
77493
77494 --
77495 -- initialize a row for ae header
77496 --
77497 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
77498
77499 l_event_id := l_array_event_id(hdr_idx);
77500
77501 --
77502 -- storing the hdr_idx for event. May be used by line cursor.
77503 --
77504 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
77505
77506 --
77507 -- store sources from header extract. This can be improved to
77508 -- store only those sources from header extract that may be used in lines
77509 --
77510
77511 g_array_event(l_event_id).array_value_char('source_83') := l_array_source_83(hdr_idx);
77512 g_array_event(l_event_id).array_value_num('source_84') := l_array_source_84(hdr_idx);
77513 g_array_event(l_event_id).array_value_num('source_85') := l_array_source_85(hdr_idx);
77517 -- initilaize the status of ae headers for diffrent balance types
77514 g_array_event(l_event_id).array_value_char('source_86') := l_array_source_86(hdr_idx);
77515
77516 --
77518 -- the status is initialised to C_NOT_CREATED (2)
77519 --
77520 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
77521 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
77522 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
77523
77524 --
77525 -- call api to validate and store accounting attributes for header
77526 --
77527
77528 ------------------------------------------------------------
77529 -- Accrual Reversal : to get date for Standard Source (NONE)
77530 ------------------------------------------------------------
77531 l_acc_rev_gl_date_source := NULL;
77532
77533 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
77534 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_83');
77535 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
77536 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_84');
77537 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
77538 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_85');
77539 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
77540 l_rec_acct_attrs.array_date_value(4) :=
77541 xla_ae_sources_pkg.GetSystemSourceDate(
77542 p_source_code => 'XLA_EVENT_DATE'
77543 , p_source_type_code => 'Y'
77544 , p_source_application_id => 602
77545 );
77546 l_rec_acct_attrs.array_acct_attr_code(5) := 'TRX_ACCT_REVERSAL_OPTION';
77547 l_rec_acct_attrs.array_char_value(5) := g_array_event(l_event_id).array_value_char('source_86');
77548
77549
77550 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
77551
77552 XLA_AE_HEADER_PKG.SetJeCategoryName;
77553
77554 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
77555 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
77556 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
77557 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
77558 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
77559
77560
77561 -- No header level analytical criteria
77562
77563 --
77564 --accounting attribute enhancement, bug 3612931
77565 --
77566 l_trx_reversal_source := SUBSTR(g_array_event(l_event_id).array_value_char('source_86'), 1,30);
77567
77568 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
77569 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
77570
77571 xla_accounting_err_pkg.build_message
77572 (p_appli_s_name => 'XLA'
77573 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
77574 ,p_token_1 => 'ACCT_ATTR_NAME'
77575 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
77576 ,p_token_2 => 'PRODUCT_NAME'
77577 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
77578 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
77579 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
77580 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
77581
77582 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
77583 --
77584 -- following sets the accounting attributes needed to reverse
77585 -- accounting for a distributeion
77586 --
77587 xla_ae_lines_pkg.SetTrxReversalAttrs
77588 (p_event_id => l_event_id
77589 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
77590 ,p_trx_reversal_source => l_trx_reversal_source);
77591
77592 END IF;
77593
77594
77595 ----------------------------------------------------------------
77596 -- 4262811 - update the header statuses to invalid in need be
77597 ----------------------------------------------------------------
77598 --
77599 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
77600
77601
77602 -----------------------------------------------
77603 -- No accrual reversal for the event class/type
77604 -----------------------------------------------
77605 ----------------------------------------------------------------
77606
77607 --
77608 -- this ends the header loop iteration for one bulk fetch
77609 --
77610 END LOOP;
77611
77612 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
77613 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
77614
77615 --
77616 -- insert dummy rows into lines gt table that were created due to
77617 -- transaction reversals
77618 --
77619 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
77620 l_result := XLA_AE_LINES_PKG.InsertLines;
77621 END IF;
77622
77623 --
77624 -- reset the temp_line_num for each set of events fetched from header
77625 -- cursor rather than doing it for each new event in line cursor
77626 -- Bug 3939231
77627 --
77628 xla_ae_lines_pkg.g_temp_line_num := 0;
77629
77630
77631
77632 --
77633 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
77634 --
77635 --
77636 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
77637
77638 trace
77642
77639 (p_msg => 'SQL - FETCH line_cur'
77640 ,p_level => C_LEVEL_STATEMENT
77641 ,p_module => l_log_module);
77643 END IF;
77644 --
77645 --
77646 LOOP
77647 --
77648 FETCH line_cur BULK COLLECT INTO
77649 l_array_entity_id
77650 , l_array_legal_entity_id
77651 , l_array_entity_code
77652 , l_array_transaction_num
77653 , l_array_event_id
77654 , l_array_class_code
77655 , l_array_event_type
77656 , l_array_event_number
77657 , l_array_event_date
77658 , l_array_transaction_date
77659 , l_array_reference_num_1
77660 , l_array_reference_num_2
77661 , l_array_reference_num_3
77662 , l_array_reference_num_4
77663 , l_array_reference_char_1
77664 , l_array_reference_char_2
77665 , l_array_reference_char_3
77666 , l_array_reference_char_4
77667 , l_array_reference_date_1
77668 , l_array_reference_date_2
77669 , l_array_reference_date_3
77670 , l_array_reference_date_4
77671 , l_array_event_created_by
77672 , l_array_budgetary_control_flag
77673 , l_array_extract_line_num
77674 , l_array_source_5
77675 , l_array_source_9
77676 , l_array_source_12
77677 , l_array_source_13
77678 , l_array_source_14
77679 , l_array_source_15
77680 , l_array_source_20
77681 , l_array_source_22
77682 , l_array_source_23
77683 , l_array_source_24
77684 , l_array_source_25
77685 , l_array_source_27
77686 , l_array_source_28
77687 , l_array_source_29
77688 , l_array_source_56
77689 , l_array_source_57
77690 , l_array_source_67
77691 LIMIT l_rows;
77692
77693 --
77694 IF (C_LEVEL_EVENT >= g_log_level) THEN
77695 trace
77696 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
77697 ,p_level => C_LEVEL_EVENT
77698 ,p_module => l_log_module);
77699 END IF;
77700 --
77701 EXIT WHEN l_array_entity_id.count = 0;
77702
77703 XLA_AE_LINES_PKG.g_rec_lines := null;
77704
77705 --
77706 -- Bug 4458708
77707 --
77708 XLA_AE_LINES_PKG.g_LineNumber := 0;
77709 --
77710 --
77711
77712 FOR Idx IN 1..l_array_event_id.count LOOP
77713 --
77714 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
77715 --
77716 l_event_id := l_array_event_id(idx); -- 5648433
77717
77718 --
77719 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
77720 --
77721
77722 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
77723 (g_array_event(l_event_id).array_value_num('header_index'))
77724 ,'N'
77725 ) <> 'Y'
77726 THEN
77727 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
77728 trace
77729 (p_msg => 'Trancaction revesal option is not Y '
77730 ,p_level => C_LEVEL_STATEMENT
77731 ,p_module => l_log_module);
77732 END IF;
77733
77734 --
77735 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
77736 --
77737 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
77738 --
77739 -- set event info as cache for other routines to refer event attributes
77740 --
77741
77742 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
77743 l_previous_event_id := l_event_id;
77744
77745 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
77746 (p_application_id => p_application_id
77747 ,p_primary_ledger_id => p_primary_ledger_id
77748 ,p_base_ledger_id => p_base_ledger_id
77749 ,p_target_ledger_id => p_target_ledger_id
77750 ,p_entity_id => l_array_entity_id(Idx)
77751 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
77752 ,p_entity_code => l_array_entity_code(Idx)
77753 ,p_transaction_num => l_array_transaction_num(Idx)
77754 ,p_event_id => l_array_event_id(Idx)
77755 ,p_event_class_code => l_array_class_code(Idx)
77756 ,p_event_type_code => l_array_event_type(Idx)
77757 ,p_event_number => l_array_event_number(Idx)
77758 ,p_event_date => l_array_event_date(Idx)
77759 ,p_transaction_date => l_array_transaction_date(Idx)
77760 ,p_reference_num_1 => l_array_reference_num_1(Idx)
77761 ,p_reference_num_2 => l_array_reference_num_2(Idx)
77762 ,p_reference_num_3 => l_array_reference_num_3(Idx)
77763 ,p_reference_num_4 => l_array_reference_num_4(Idx)
77764 ,p_reference_char_1 => l_array_reference_char_1(Idx)
77765 ,p_reference_char_2 => l_array_reference_char_2(Idx)
77766 ,p_reference_char_3 => l_array_reference_char_3(Idx)
77767 ,p_reference_char_4 => l_array_reference_char_4(Idx)
77768 ,p_reference_date_1 => l_array_reference_date_1(Idx)
77769 ,p_reference_date_2 => l_array_reference_date_2(Idx)
77770 ,p_reference_date_3 => l_array_reference_date_3(Idx)
77771 ,p_reference_date_4 => l_array_reference_date_4(Idx)
77772 ,p_event_created_by => l_array_event_created_by(Idx)
77773 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
77774 --
77775 END IF;
77776
77777
77778
77779 --
77783
77780 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
77781
77782 l_acct_reversal_source := SUBSTR(NULL, 1,30);
77784 IF l_continue_with_lines THEN
77785 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
77786 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
77787
77788 xla_accounting_err_pkg.build_message
77789 (p_appli_s_name => 'XLA'
77790 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
77791 ,p_token_1 => 'LINE_NUMBER'
77792 ,p_value_1 => l_array_extract_line_num(Idx)
77793 ,p_token_2 => 'PRODUCT_NAME'
77794 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
77795 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
77796 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
77797 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
77798
77799 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
77800 --
77801 -- following sets the accounting attributes needed to reverse
77802 -- accounting for a distributeion
77803 --
77804
77805 --
77806 -- 5217187
77807 --
77808 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
77809 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
77810 g_array_event(l_event_id).array_value_num('header_index'));
77811 --
77812 --
77813
77814 -- No reversal code generated
77815
77816 xla_ae_lines_pkg.SetAcctReversalAttrs
77817 (p_event_id => l_event_id
77818 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
77819 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77820 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
77821 END IF;
77822
77823 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
77824 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
77825
77826 --
77827 AcctLineType_66 (
77828 p_application_id => p_application_id
77829 ,p_event_id => l_event_id
77830 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77831 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77832 ,p_actual_flag => l_actual_flag
77833 ,p_balance_type_code => l_balance_type_code
77834 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77835
77836 , p_source_5 => l_array_source_5(Idx)
77837 , p_source_12 => l_array_source_12(Idx)
77838 , p_source_13 => l_array_source_13(Idx)
77839 , p_source_14 => l_array_source_14(Idx)
77840 , p_source_20 => l_array_source_20(Idx)
77841 , p_source_22 => l_array_source_22(Idx)
77842 , p_source_23 => l_array_source_23(Idx)
77843 , p_source_24 => l_array_source_24(Idx)
77844 , p_source_25 => l_array_source_25(Idx)
77845 , p_source_27 => l_array_source_27(Idx)
77846 , p_source_28 => l_array_source_28(Idx)
77847 , p_source_29 => l_array_source_29(Idx)
77848 , p_source_56 => l_array_source_56(Idx)
77849 , p_source_57 => l_array_source_57(Idx)
77850 );
77851 If(l_balance_type_code = 'A') THEN
77852 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77853 END IF;
77854
77855 --
77856
77857
77858 --
77859 AcctLineType_67 (
77860 p_application_id => p_application_id
77861 ,p_event_id => l_event_id
77862 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77863 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77864 ,p_actual_flag => l_actual_flag
77865 ,p_balance_type_code => l_balance_type_code
77866 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77867
77868 , p_source_5 => l_array_source_5(Idx)
77869 , p_source_12 => l_array_source_12(Idx)
77870 , p_source_13 => l_array_source_13(Idx)
77871 , p_source_14 => l_array_source_14(Idx)
77872 , p_source_20 => l_array_source_20(Idx)
77873 , p_source_22 => l_array_source_22(Idx)
77874 , p_source_23 => l_array_source_23(Idx)
77875 , p_source_24 => l_array_source_24(Idx)
77876 , p_source_25 => l_array_source_25(Idx)
77877 , p_source_27 => l_array_source_27(Idx)
77878 , p_source_28 => l_array_source_28(Idx)
77879 , p_source_29 => l_array_source_29(Idx)
77880 , p_source_56 => l_array_source_56(Idx)
77881 , p_source_57 => l_array_source_57(Idx)
77882 );
77883 If(l_balance_type_code = 'A') THEN
77884 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77885 END IF;
77886
77887 --
77888
77889
77890 --
77891 AcctLineType_68 (
77892 p_application_id => p_application_id
77893 ,p_event_id => l_event_id
77894 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77895 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77896 ,p_actual_flag => l_actual_flag
77897 ,p_balance_type_code => l_balance_type_code
77898 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77899
77900 , p_source_5 => l_array_source_5(Idx)
77901 , p_source_12 => l_array_source_12(Idx)
77902 , p_source_13 => l_array_source_13(Idx)
77903 , p_source_14 => l_array_source_14(Idx)
77904 , p_source_15 => l_array_source_15(Idx)
77905 , p_source_20 => l_array_source_20(Idx)
77906 , p_source_22 => l_array_source_22(Idx)
77907 , p_source_23 => l_array_source_23(Idx)
77908 , p_source_24 => l_array_source_24(Idx)
77909 , p_source_25 => l_array_source_25(Idx)
77910 , p_source_27 => l_array_source_27(Idx)
77911 , p_source_28 => l_array_source_28(Idx)
77912 , p_source_29 => l_array_source_29(Idx)
77913 , p_source_56 => l_array_source_56(Idx)
77914 , p_source_57 => l_array_source_57(Idx)
77915 );
77916 If(l_balance_type_code = 'A') THEN
77917 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77918 END IF;
77919
77920 --
77921
77922
77923 --
77924 AcctLineType_69 (
77925 p_application_id => p_application_id
77926 ,p_event_id => l_event_id
77927 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77928 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77929 ,p_actual_flag => l_actual_flag
77930 ,p_balance_type_code => l_balance_type_code
77931 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77932
77933 , p_source_5 => l_array_source_5(Idx)
77934 , p_source_12 => l_array_source_12(Idx)
77935 , p_source_13 => l_array_source_13(Idx)
77936 , p_source_14 => l_array_source_14(Idx)
77937 , p_source_15 => l_array_source_15(Idx)
77938 , p_source_20 => l_array_source_20(Idx)
77939 , p_source_22 => l_array_source_22(Idx)
77940 , p_source_23 => l_array_source_23(Idx)
77941 , p_source_24 => l_array_source_24(Idx)
77942 , p_source_25 => l_array_source_25(Idx)
77943 , p_source_27 => l_array_source_27(Idx)
77944 , p_source_28 => l_array_source_28(Idx)
77945 , p_source_29 => l_array_source_29(Idx)
77946 , p_source_56 => l_array_source_56(Idx)
77947 , p_source_57 => l_array_source_57(Idx)
77948 );
77949 If(l_balance_type_code = 'A') THEN
77950 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77951 END IF;
77952
77953 --
77954
77955
77956 --
77957 AcctLineType_70 (
77958 p_application_id => p_application_id
77959 ,p_event_id => l_event_id
77960 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77961 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77962 ,p_actual_flag => l_actual_flag
77963 ,p_balance_type_code => l_balance_type_code
77964 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77965
77966 , p_source_5 => l_array_source_5(Idx)
77967 , p_source_12 => l_array_source_12(Idx)
77968 , p_source_13 => l_array_source_13(Idx)
77969 , p_source_14 => l_array_source_14(Idx)
77970 , p_source_20 => l_array_source_20(Idx)
77971 , p_source_22 => l_array_source_22(Idx)
77972 , p_source_23 => l_array_source_23(Idx)
77973 , p_source_24 => l_array_source_24(Idx)
77974 , p_source_25 => l_array_source_25(Idx)
77975 , p_source_27 => l_array_source_27(Idx)
77976 , p_source_28 => l_array_source_28(Idx)
77977 , p_source_29 => l_array_source_29(Idx)
77978 , p_source_56 => l_array_source_56(Idx)
77979 , p_source_57 => l_array_source_57(Idx)
77980 );
77981 If(l_balance_type_code = 'A') THEN
77982 l_actual_gain_loss_ref := l_gain_or_loss_ref;
77983 END IF;
77984
77985 --
77986
77987
77988 --
77989 AcctLineType_71 (
77990 p_application_id => p_application_id
77991 ,p_event_id => l_event_id
77992 ,p_calculate_acctd_flag => l_calculate_acctd_flag
77993 ,p_calculate_g_l_flag => l_calculate_g_l_flag
77994 ,p_actual_flag => l_actual_flag
77995 ,p_balance_type_code => l_balance_type_code
77996 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
77997
77998 , p_source_5 => l_array_source_5(Idx)
77999 , p_source_12 => l_array_source_12(Idx)
78000 , p_source_13 => l_array_source_13(Idx)
78001 , p_source_14 => l_array_source_14(Idx)
78002 , p_source_20 => l_array_source_20(Idx)
78003 , p_source_22 => l_array_source_22(Idx)
78004 , p_source_23 => l_array_source_23(Idx)
78005 , p_source_24 => l_array_source_24(Idx)
78006 , p_source_25 => l_array_source_25(Idx)
78007 , p_source_27 => l_array_source_27(Idx)
78008 , p_source_28 => l_array_source_28(Idx)
78009 , p_source_29 => l_array_source_29(Idx)
78010 , p_source_56 => l_array_source_56(Idx)
78011 , p_source_57 => l_array_source_57(Idx)
78012 );
78013 If(l_balance_type_code = 'A') THEN
78014 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78015 END IF;
78016
78017 --
78018
78019
78020 --
78021 AcctLineType_72 (
78022 p_application_id => p_application_id
78023 ,p_event_id => l_event_id
78024 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78025 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78026 ,p_actual_flag => l_actual_flag
78027 ,p_balance_type_code => l_balance_type_code
78028 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78029
78030 , p_source_5 => l_array_source_5(Idx)
78031 , p_source_9 => l_array_source_9(Idx)
78032 , p_source_20 => l_array_source_20(Idx)
78033 , p_source_22 => l_array_source_22(Idx)
78034 , p_source_23 => l_array_source_23(Idx)
78035 , p_source_24 => l_array_source_24(Idx)
78036 , p_source_25 => l_array_source_25(Idx)
78037 , p_source_27 => l_array_source_27(Idx)
78038 , p_source_28 => l_array_source_28(Idx)
78039 , p_source_29 => l_array_source_29(Idx)
78040 , p_source_56 => l_array_source_56(Idx)
78041 , p_source_57 => l_array_source_57(Idx)
78042 );
78043 If(l_balance_type_code = 'A') THEN
78044 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78045 END IF;
78049
78046
78047 --
78048
78050 --
78051 AcctLineType_73 (
78052 p_application_id => p_application_id
78053 ,p_event_id => l_event_id
78054 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78055 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78056 ,p_actual_flag => l_actual_flag
78057 ,p_balance_type_code => l_balance_type_code
78058 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78059
78060 , p_source_5 => l_array_source_5(Idx)
78061 , p_source_9 => l_array_source_9(Idx)
78062 , p_source_20 => l_array_source_20(Idx)
78063 , p_source_22 => l_array_source_22(Idx)
78064 , p_source_23 => l_array_source_23(Idx)
78065 , p_source_24 => l_array_source_24(Idx)
78066 , p_source_25 => l_array_source_25(Idx)
78067 , p_source_27 => l_array_source_27(Idx)
78068 , p_source_28 => l_array_source_28(Idx)
78069 , p_source_29 => l_array_source_29(Idx)
78070 , p_source_56 => l_array_source_56(Idx)
78071 , p_source_57 => l_array_source_57(Idx)
78072 );
78073 If(l_balance_type_code = 'A') THEN
78074 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78075 END IF;
78076
78077 --
78078
78079
78080 --
78081 AcctLineType_96 (
78082 p_application_id => p_application_id
78083 ,p_event_id => l_event_id
78084 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78085 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78086 ,p_actual_flag => l_actual_flag
78087 ,p_balance_type_code => l_balance_type_code
78088 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78089
78090 , p_source_5 => l_array_source_5(Idx)
78091 , p_source_20 => l_array_source_20(Idx)
78092 , p_source_22 => l_array_source_22(Idx)
78093 , p_source_23 => l_array_source_23(Idx)
78094 , p_source_24 => l_array_source_24(Idx)
78095 , p_source_25 => l_array_source_25(Idx)
78096 , p_source_27 => l_array_source_27(Idx)
78097 , p_source_28 => l_array_source_28(Idx)
78098 , p_source_29 => l_array_source_29(Idx)
78099 , p_source_57 => l_array_source_57(Idx)
78100 , p_source_67 => l_array_source_67(Idx)
78101 );
78102 If(l_balance_type_code = 'A') THEN
78103 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78104 END IF;
78105
78106 --
78107
78108
78109 --
78110 AcctLineType_97 (
78111 p_application_id => p_application_id
78112 ,p_event_id => l_event_id
78113 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78114 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78115 ,p_actual_flag => l_actual_flag
78116 ,p_balance_type_code => l_balance_type_code
78117 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78118
78119 , p_source_5 => l_array_source_5(Idx)
78120 , p_source_20 => l_array_source_20(Idx)
78121 , p_source_22 => l_array_source_22(Idx)
78122 , p_source_23 => l_array_source_23(Idx)
78123 , p_source_24 => l_array_source_24(Idx)
78124 , p_source_25 => l_array_source_25(Idx)
78125 , p_source_27 => l_array_source_27(Idx)
78126 , p_source_28 => l_array_source_28(Idx)
78127 , p_source_29 => l_array_source_29(Idx)
78128 , p_source_57 => l_array_source_57(Idx)
78129 , p_source_67 => l_array_source_67(Idx)
78130 );
78131 If(l_balance_type_code = 'A') THEN
78132 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78133 END IF;
78134
78135 --
78136
78137
78138 --
78139 AcctLineType_98 (
78140 p_application_id => p_application_id
78141 ,p_event_id => l_event_id
78142 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78143 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78144 ,p_actual_flag => l_actual_flag
78145 ,p_balance_type_code => l_balance_type_code
78146 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78147
78148 , p_source_5 => l_array_source_5(Idx)
78149 , p_source_20 => l_array_source_20(Idx)
78150 , p_source_22 => l_array_source_22(Idx)
78151 , p_source_23 => l_array_source_23(Idx)
78152 , p_source_24 => l_array_source_24(Idx)
78153 , p_source_25 => l_array_source_25(Idx)
78154 , p_source_27 => l_array_source_27(Idx)
78155 , p_source_28 => l_array_source_28(Idx)
78156 , p_source_29 => l_array_source_29(Idx)
78157 , p_source_57 => l_array_source_57(Idx)
78158 , p_source_67 => l_array_source_67(Idx)
78159 );
78160 If(l_balance_type_code = 'A') THEN
78161 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78162 END IF;
78163
78164 --
78165
78166
78167 --
78168 AcctLineType_99 (
78169 p_application_id => p_application_id
78170 ,p_event_id => l_event_id
78171 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78172 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78173 ,p_actual_flag => l_actual_flag
78174 ,p_balance_type_code => l_balance_type_code
78175 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78176
78177 , p_source_5 => l_array_source_5(Idx)
78178 , p_source_20 => l_array_source_20(Idx)
78179 , p_source_22 => l_array_source_22(Idx)
78180 , p_source_23 => l_array_source_23(Idx)
78181 , p_source_24 => l_array_source_24(Idx)
78182 , p_source_25 => l_array_source_25(Idx)
78183 , p_source_27 => l_array_source_27(Idx)
78184 , p_source_28 => l_array_source_28(Idx)
78185 , p_source_29 => l_array_source_29(Idx)
78186 , p_source_57 => l_array_source_57(Idx)
78187 , p_source_67 => l_array_source_67(Idx)
78188 );
78189 If(l_balance_type_code = 'A') THEN
78190 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78191 END IF;
78192
78193 --
78194
78195
78196 --
78197 AcctLineType_100 (
78198 p_application_id => p_application_id
78199 ,p_event_id => l_event_id
78203 ,p_balance_type_code => l_balance_type_code
78200 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78201 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78202 ,p_actual_flag => l_actual_flag
78204 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78205
78206 , p_source_5 => l_array_source_5(Idx)
78207 , p_source_20 => l_array_source_20(Idx)
78208 , p_source_22 => l_array_source_22(Idx)
78209 , p_source_23 => l_array_source_23(Idx)
78210 , p_source_24 => l_array_source_24(Idx)
78211 , p_source_25 => l_array_source_25(Idx)
78212 , p_source_27 => l_array_source_27(Idx)
78213 , p_source_28 => l_array_source_28(Idx)
78214 , p_source_29 => l_array_source_29(Idx)
78215 , p_source_57 => l_array_source_57(Idx)
78216 , p_source_67 => l_array_source_67(Idx)
78217 );
78218 If(l_balance_type_code = 'A') THEN
78219 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78220 END IF;
78221
78222 --
78223
78224
78225 --
78226 AcctLineType_101 (
78227 p_application_id => p_application_id
78228 ,p_event_id => l_event_id
78229 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78230 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78231 ,p_actual_flag => l_actual_flag
78232 ,p_balance_type_code => l_balance_type_code
78233 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78234
78235 , p_source_5 => l_array_source_5(Idx)
78236 , p_source_20 => l_array_source_20(Idx)
78237 , p_source_22 => l_array_source_22(Idx)
78238 , p_source_23 => l_array_source_23(Idx)
78239 , p_source_24 => l_array_source_24(Idx)
78240 , p_source_25 => l_array_source_25(Idx)
78241 , p_source_27 => l_array_source_27(Idx)
78242 , p_source_28 => l_array_source_28(Idx)
78243 , p_source_29 => l_array_source_29(Idx)
78244 , p_source_57 => l_array_source_57(Idx)
78245 , p_source_67 => l_array_source_67(Idx)
78246 );
78247 If(l_balance_type_code = 'A') THEN
78248 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78249 END IF;
78250
78251 --
78252
78253
78254 --
78255 AcctLineType_102 (
78256 p_application_id => p_application_id
78257 ,p_event_id => l_event_id
78258 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78259 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78260 ,p_actual_flag => l_actual_flag
78261 ,p_balance_type_code => l_balance_type_code
78262 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78263
78264 , p_source_5 => l_array_source_5(Idx)
78265 , p_source_20 => l_array_source_20(Idx)
78266 , p_source_22 => l_array_source_22(Idx)
78267 , p_source_23 => l_array_source_23(Idx)
78268 , p_source_24 => l_array_source_24(Idx)
78269 , p_source_25 => l_array_source_25(Idx)
78270 , p_source_27 => l_array_source_27(Idx)
78271 , p_source_28 => l_array_source_28(Idx)
78272 , p_source_29 => l_array_source_29(Idx)
78273 , p_source_57 => l_array_source_57(Idx)
78274 , p_source_67 => l_array_source_67(Idx)
78275 );
78276 If(l_balance_type_code = 'A') THEN
78277 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78278 END IF;
78279
78280 --
78281
78282
78283 --
78284 AcctLineType_103 (
78285 p_application_id => p_application_id
78286 ,p_event_id => l_event_id
78287 ,p_calculate_acctd_flag => l_calculate_acctd_flag
78288 ,p_calculate_g_l_flag => l_calculate_g_l_flag
78289 ,p_actual_flag => l_actual_flag
78290 ,p_balance_type_code => l_balance_type_code
78291 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
78292
78293 , p_source_5 => l_array_source_5(Idx)
78294 , p_source_20 => l_array_source_20(Idx)
78295 , p_source_22 => l_array_source_22(Idx)
78296 , p_source_23 => l_array_source_23(Idx)
78297 , p_source_24 => l_array_source_24(Idx)
78298 , p_source_25 => l_array_source_25(Idx)
78299 , p_source_27 => l_array_source_27(Idx)
78300 , p_source_28 => l_array_source_28(Idx)
78301 , p_source_29 => l_array_source_29(Idx)
78302 , p_source_57 => l_array_source_57(Idx)
78303 , p_source_67 => l_array_source_67(Idx)
78304 );
78305 If(l_balance_type_code = 'A') THEN
78306 l_actual_gain_loss_ref := l_gain_or_loss_ref;
78307 END IF;
78308
78309 --
78310
78311 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
78312 -- or secondary ledger that has different currency with primary
78313 -- or alc that is calculated by sla
78314 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
78315 (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'))
78316
78317 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
78318 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
78319 AND (l_actual_flag = 'A')) THEN
78320 XLA_AE_LINES_PKG.CreateGainOrLossLines(
78321 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
78322 ,p_application_id => p_application_id
78323 ,p_amb_context_code => 'DEFAULT'
78324 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
78325 ,p_event_class_code => C_EVENT_CLASS_CODE
78326 ,p_event_type_code => C_EVENT_TYPE_CODE
78327
78328 ,p_gain_ccid => -1
78329 ,p_loss_ccid => -1
78330
78331 ,p_actual_flag => l_actual_flag
78332 ,p_enc_flag => null
78333 ,p_actual_g_l_ref => l_actual_gain_loss_ref
78334 ,p_enc_g_l_ref => null
78335 );
78336 END IF;
78337 END IF;
78338 END IF;
78339
78340 ELSE
78341 --
78342 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
78343 --
78344 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
78345 trace
78346 (p_msg => 'Trancaction revesal option is Y'
78347 ,p_level => C_LEVEL_STATEMENT
78348 ,p_module => l_log_module);
78349 END IF;
78350 END IF;
78351
78352 END LOOP;
78353 l_result := XLA_AE_LINES_PKG.InsertLines ;
78354 end loop;
78355 close line_cur;
78356
78357
78358 --
78359 -- insert headers into xla_ae_headers_gt table
78360 --
78361 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
78362
78363 -- insert into errors table here.
78364
78365 END LOOP;
78366
78367 --
78368 -- 4865292
78369 --
78370 -- Compare g_hdr_extract_count with event count in
78371 -- CreateHeadersAndLines.
78372 --
78373 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
78374
78375 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
78376 trace (p_msg => '# rows extracted from header extract objects '
78377 || ' (running total): '
78378 || g_hdr_extract_count
78379 ,p_level => C_LEVEL_STATEMENT
78380 ,p_module => l_log_module);
78381 END IF;
78382
78383 CLOSE header_cur;
78384 --
78385
78386 --
78387 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
78388 trace
78389 (p_msg => 'END of EventClass_141'
78390 ,p_level => C_LEVEL_PROCEDURE
78391 ,p_module => l_log_module);
78392 END IF;
78393 --
78394 RETURN l_result;
78395 EXCEPTION
78396 WHEN xla_exceptions_pkg.application_exception THEN
78397
78398 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
78399
78400
78401 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
78402
78403 RAISE;
78404
78405 WHEN NO_DATA_FOUND THEN
78406
78407 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
78408 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
78409
78410 FOR header_record IN header_cur
78411 LOOP
78412 l_array_header_events(header_record.event_id) := header_record.event_id;
78413 END LOOP;
78414
78415 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
78416 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
78417
78418 fnd_file.put_line(fnd_file.LOG, ' ');
78419 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
78420 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
78421 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
78422
78423 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
78424 LOOP
78425 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
78426 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
78427 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
78428 END IF;
78429 END LOOP;
78430
78431 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
78432 fnd_file.put_line(fnd_file.LOG, ' ');
78433
78434
78435 xla_exceptions_pkg.raise_message
78436 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_141');
78437
78438
78439 WHEN OTHERS THEN
78440 xla_exceptions_pkg.raise_message
78441 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_141');
78442 END EventClass_141;
78443 --
78444
78445 ---------------------------------------
78446 --
78447 -- PRIVATE PROCEDURE
78448 -- insert_sources_142
78449 --
78450 ----------------------------------------
78451 --
78452 PROCEDURE insert_sources_142(
78453 p_target_ledger_id IN NUMBER
78454 , p_language IN VARCHAR2
78455 , p_sla_ledger_id IN NUMBER
78456 , p_pad_start_date IN DATE
78457 , p_pad_end_date IN DATE
78458 )
78459 IS
78460
78461 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'RECEIPT_ALL';
78462 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'RECEIPT';
78463 p_apps_owner VARCHAR2(30);
78464 l_log_module VARCHAR2(240);
78465 BEGIN
78466 IF g_log_enabled THEN
78467 l_log_module := C_DEFAULT_MODULE||'.insert_sources_142';
78468 END IF;
78469 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
78470
78471 trace
78472 (p_msg => 'BEGIN of insert_sources_142'
78473 ,p_level => C_LEVEL_PROCEDURE
78474 ,p_module => l_log_module);
78475
78476 END IF;
78477
78478 -- select APPS owner
78479 SELECT oracle_username
78480 INTO p_apps_owner
78481 FROM fnd_oracle_userid
78482 WHERE read_only_flag = 'U'
78483 ;
78484
78485 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
78486 trace
78487 (p_msg => 'p_target_ledger_id = '||p_target_ledger_id||
78488 ' - p_language = '||p_language||
78489 ' - p_sla_ledger_id = '||p_sla_ledger_id ||
78490 ' - p_pad_start_date = '||TO_CHAR(p_pad_start_date)||
78491 ' - p_pad_end_date = '||TO_CHAR(p_pad_end_date)||
78492 ' - p_apps_owner = '||TO_CHAR(p_apps_owner)
78493 ,p_level => C_LEVEL_STATEMENT
78494 ,p_module => l_log_module);
78495 END IF;
78496
78497
78498 --
78499 INSERT INTO xla_diag_sources --hdr2
78500 (
78501 event_id
78502 , ledger_id
78503 , sla_ledger_id
78504 , description_language
78505 , object_name
78506 , object_type_code
78507 , line_number
78508 , source_application_id
78509 , source_type_code
78510 , source_code
78511 , source_value
78512 , source_meaning
78513 , created_by
78514 , creation_date
78515 , last_update_date
78516 , last_updated_by
78517 , last_update_login
78518 , program_update_date
78519 , program_application_id
78520 , program_id
78521 , request_id
78522 )
78523 SELECT
78524 event_id
78525 , p_target_ledger_id
78526 , p_sla_ledger_id
78527 , p_language
78528 , object_name
78529 , object_type_code
78530 , line_number
78531 , source_application_id
78532 , source_type_code
78533 , source_code
78534 , SUBSTR(source_value ,1,1996)
78535 , SUBSTR(source_meaning ,1,200)
78536 , xla_environment_pkg.g_Usr_Id
78537 , TRUNC(SYSDATE)
78538 , TRUNC(SYSDATE)
78539 , xla_environment_pkg.g_Usr_Id
78540 , xla_environment_pkg.g_Login_Id
78541 , TRUNC(SYSDATE)
78542 , xla_environment_pkg.g_Prog_Appl_Id
78543 , xla_environment_pkg.g_Prog_Id
78544 , xla_environment_pkg.g_Req_Id
78545 FROM (
78546 SELECT xet.event_id event_id
78547 , 0 line_number
78548 , CASE r
78549 WHEN 1 THEN 'AR_SYSTEM_PARAM_H_V'
78550 WHEN 2 THEN 'AR_SYSTEM_PARAM_H_V'
78551 WHEN 3 THEN 'AR_REMIT_BANK_ACCT_H_V'
78552 WHEN 4 THEN 'AR_REMIT_BANK_ACCT_H_V'
78553 WHEN 5 THEN 'AR_CASH_RECEIPTS_H_V'
78554 WHEN 6 THEN 'AR_CASH_RECEIPTS_H_V'
78555 WHEN 7 THEN 'AR_RCT_SITE_USES_H_V'
78556 WHEN 8 THEN 'AR_CASH_RECEIPTS_H_V'
78557 WHEN 9 THEN 'AR_CASH_RECEIPTS_H_V'
78558 WHEN 10 THEN 'AR_CASH_RECEIPTS_H_V'
78559 WHEN 11 THEN 'AR_CASH_RECEIPTS_H_V'
78560 WHEN 12 THEN 'AR_CASH_RECEIPTS_H_V'
78561 WHEN 13 THEN 'AR_CASH_RECEIPTS_H_V'
78562 WHEN 14 THEN 'AR_CASH_RECEIPTS_H_V'
78563
78564 ELSE null
78565 END object_name
78566 , CASE r
78567 WHEN 1 THEN 'HEADER'
78568 WHEN 2 THEN 'HEADER'
78569 WHEN 3 THEN 'HEADER'
78570 WHEN 4 THEN 'HEADER'
78574 WHEN 8 THEN 'HEADER'
78571 WHEN 5 THEN 'HEADER'
78572 WHEN 6 THEN 'HEADER'
78573 WHEN 7 THEN 'HEADER'
78575 WHEN 9 THEN 'HEADER'
78576 WHEN 10 THEN 'HEADER'
78577 WHEN 11 THEN 'HEADER'
78578 WHEN 12 THEN 'HEADER'
78579 WHEN 13 THEN 'HEADER'
78580 WHEN 14 THEN 'HEADER'
78581
78582 ELSE null
78583 END object_type_code
78584 , CASE r
78585 WHEN 1 THEN '222'
78586 WHEN 2 THEN '222'
78587 WHEN 3 THEN '222'
78588 WHEN 4 THEN '222'
78589 WHEN 5 THEN '222'
78590 WHEN 6 THEN '222'
78591 WHEN 7 THEN '222'
78592 WHEN 8 THEN '222'
78593 WHEN 9 THEN '222'
78594 WHEN 10 THEN '222'
78595 WHEN 11 THEN '222'
78596 WHEN 12 THEN '222'
78597 WHEN 13 THEN '222'
78598 WHEN 14 THEN '222'
78599
78600 ELSE null
78601 END source_application_id
78602 , 'S' source_type_code
78603 , CASE r
78604 WHEN 1 THEN 'CODE_COMBINATION_ID_GAIN'
78605 WHEN 2 THEN 'CODE_COMBINATION_ID_LOSS'
78606 WHEN 3 THEN 'RMT_BNK_UNAPPLIED_CCID'
78607 WHEN 4 THEN 'RMT_BNK_UNIDENTIFIED_CCID'
78608 WHEN 5 THEN 'RCT_XLA_APPLIED_TO_APP_ID'
78609 WHEN 6 THEN 'RCT_PAY_FROM_CUSTOMER'
78610 WHEN 7 THEN 'RCT_SITE_SITE_USE_ID'
78611 WHEN 8 THEN 'RCT_APP_STATUS'
78612 WHEN 9 THEN 'RCT_PREV_PAY_FROM_CUSTOMER'
78613 WHEN 10 THEN 'RCT_PREV_CUSTOMER_SITE_USE_ID'
78614 WHEN 11 THEN 'RCT_DOC_SEQUENCE_CATEGORY'
78615 WHEN 12 THEN 'RCT_DOC_SEQUENCE_ID'
78616 WHEN 13 THEN 'RCT_DOC_SEQUENCE_VALUE'
78617 WHEN 14 THEN 'RCT_TRX_ACCT_REVERSAL'
78618
78619 ELSE null
78620 END source_code
78621 , CASE r
78622 WHEN 1 THEN TO_CHAR(h9.CODE_COMBINATION_ID_GAIN)
78623 WHEN 2 THEN TO_CHAR(h9.CODE_COMBINATION_ID_LOSS)
78624 WHEN 3 THEN TO_CHAR(h8.RMT_BNK_UNAPPLIED_CCID)
78625 WHEN 4 THEN TO_CHAR(h8.RMT_BNK_UNIDENTIFIED_CCID)
78626 WHEN 5 THEN TO_CHAR(h2.RCT_XLA_APPLIED_TO_APP_ID)
78627 WHEN 6 THEN TO_CHAR(h2.RCT_PAY_FROM_CUSTOMER)
78628 WHEN 7 THEN TO_CHAR(h6.RCT_SITE_SITE_USE_ID)
78629 WHEN 8 THEN TO_CHAR(h2.RCT_APP_STATUS)
78630 WHEN 9 THEN TO_CHAR(h2.RCT_PREV_PAY_FROM_CUSTOMER)
78631 WHEN 10 THEN TO_CHAR(h2.RCT_PREV_CUSTOMER_SITE_USE_ID)
78632 WHEN 11 THEN TO_CHAR(h2.RCT_DOC_SEQUENCE_CATEGORY)
78633 WHEN 12 THEN TO_CHAR(h2.RCT_DOC_SEQUENCE_ID)
78634 WHEN 13 THEN TO_CHAR(h2.RCT_DOC_SEQUENCE_VALUE)
78635 WHEN 14 THEN TO_CHAR(h2.RCT_TRX_ACCT_REVERSAL)
78636
78637 ELSE null
78638 END source_value
78639 , null source_meaning
78640 FROM xla_events_gt xet
78641 , AR_CASH_RECEIPTS_H_V h2
78642 , AR_RCT_SITE_USES_H_V h6
78643 , AR_REMIT_BANK_ACCT_H_V h8
78644 , AR_SYSTEM_PARAM_H_V h9
78645 ,(select rownum r from all_objects where rownum <= 14 and owner = p_apps_owner)
78646 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
78647 AND xet.event_class_code = C_EVENT_CLASS_CODE
78648 AND h2.event_id = xet.event_id
78649 AND h6.event_id (+) = h2.event_id
78650 AND h8.event_id (+) = h2.event_id
78651 AND h9.event_id (+) = h2.event_id
78652
78653 )
78654 ;
78655 --
78656 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
78657
78658 trace
78659 (p_msg => 'number of header sources inserted = '||SQL%ROWCOUNT
78660 ,p_level => C_LEVEL_STATEMENT
78661 ,p_module => l_log_module);
78662
78663 END IF;
78664 --
78665
78666
78667
78668 --
78669 INSERT INTO xla_diag_sources --line2
78670 (
78671 event_id
78672 , ledger_id
78673 , sla_ledger_id
78674 , description_language
78675 , object_name
78676 , object_type_code
78677 , line_number
78678 , source_application_id
78679 , source_type_code
78680 , source_code
78681 , source_value
78682 , source_meaning
78683 , created_by
78684 , creation_date
78685 , last_update_date
78686 , last_updated_by
78687 , last_update_login
78688 , program_update_date
78689 , program_application_id
78690 , program_id
78691 , request_id
78692 )
78693 SELECT event_id
78694 , p_target_ledger_id
78695 , p_sla_ledger_id
78696 , p_language
78697 , object_name
78698 , object_type_code
78699 , line_number
78700 , source_application_id
78701 , source_type_code
78702 , source_code
78703 , SUBSTR(source_value,1,1996)
78704 , SUBSTR(source_meaning ,1,200)
78705 , xla_environment_pkg.g_Usr_Id
78706 , TRUNC(SYSDATE)
78707 , TRUNC(SYSDATE)
78708 , xla_environment_pkg.g_Usr_Id
78709 , xla_environment_pkg.g_Login_Id
78710 , TRUNC(SYSDATE)
78711 , xla_environment_pkg.g_Prog_Appl_Id
78712 , xla_environment_pkg.g_Prog_Id
78713 , xla_environment_pkg.g_Req_Id
78714 FROM (
78715 SELECT xet.event_id event_id
78716 , l5.line_number line_number
78717 , CASE r
78718 WHEN 1 THEN 'AR_TRANSACTIONS_S_V'
78719 WHEN 2 THEN 'AR_TRANSACTIONS_S_V'
78720 WHEN 3 THEN 'AR_TRANSACTIONS_S_V'
78721 WHEN 4 THEN 'AR_DISTRIBUTIONS_L_V'
78722 WHEN 5 THEN 'AR_DISTRIBUTIONS_L_V'
78723 WHEN 6 THEN 'AR_BILL_TO_CUSTOMERS_S_V'
78724 WHEN 7 THEN 'FV_XLA_AR_REF_V'
78725 WHEN 8 THEN 'FV_XLA_AR_REF_V'
78726 WHEN 9 THEN 'FV_XLA_AR_REF_V'
78727 WHEN 10 THEN 'FV_XLA_AR_REF_V'
78728 WHEN 11 THEN 'FV_XLA_AR_REF_V'
78729 WHEN 12 THEN 'AR_DISTRIBUTIONS_L_V'
78730 WHEN 13 THEN 'AR_RECEIVABLES_TRX_ACT_S_V'
78731 WHEN 14 THEN 'AR_DISTRIBUTIONS_L_V'
78732 WHEN 15 THEN 'AR_DISTRIBUTIONS_L_V'
78733 WHEN 16 THEN 'AR_DISTRIBUTIONS_L_V'
78734 WHEN 17 THEN 'AR_DISTRIBUTIONS_L_V'
78735 WHEN 18 THEN 'AR_DISTRIBUTIONS_BASE_V'
78736 WHEN 19 THEN 'AR_DISTRIBUTIONS_BASE_V'
78737 WHEN 20 THEN 'AR_DISTRIBUTIONS_BASE_V'
78738 WHEN 21 THEN 'AR_DISTRIBUTIONS_BASE_V'
78739 WHEN 22 THEN 'AR_CUST_TRX_LINES_L_V'
78740 WHEN 23 THEN 'AR_CUST_TRX_LINES_L_V'
78741 WHEN 24 THEN 'AR_CUST_TRX_LINES_L_V'
78742 WHEN 25 THEN 'FV_XLA_AR_REF_V'
78743 WHEN 26 THEN 'AR_DISTRIBUTIONS_BASE_V'
78744 WHEN 27 THEN 'AR_TRANSACTIONS_S_V'
78745 WHEN 28 THEN 'AR_TRANSACTIONS_S_V'
78746 WHEN 29 THEN 'AR_DISTRIBUTIONS_L_V'
78747 WHEN 30 THEN 'AR_DISTRIBUTIONS_BASE_V'
78748 WHEN 31 THEN 'AR_DISTRIBUTIONS_L_V'
78749 WHEN 32 THEN 'AR_DISTRIBUTIONS_L_V'
78750 WHEN 33 THEN 'AR_DISTRIBUTIONS_L_V'
78751 WHEN 34 THEN 'AR_DISTRIBUTIONS_L_V'
78752 WHEN 35 THEN 'AR_DISTRIBUTIONS_L_V'
78753 WHEN 36 THEN 'AR_DISTRIBUTIONS_BASE_V'
78754 WHEN 37 THEN 'AR_DISTRIBUTIONS_BASE_V'
78755 WHEN 38 THEN 'AR_DISTRIBUTIONS_L_V'
78756
78757 ELSE null
78758 END object_name
78759 , CASE r
78760 WHEN 1 THEN 'LINE'
78761 WHEN 2 THEN 'LINE'
78762 WHEN 3 THEN 'LINE'
78763 WHEN 4 THEN 'LINE'
78764 WHEN 5 THEN 'LINE'
78765 WHEN 6 THEN 'LINE'
78766 WHEN 7 THEN 'LINE'
78767 WHEN 8 THEN 'LINE'
78768 WHEN 9 THEN 'LINE'
78769 WHEN 10 THEN 'LINE'
78770 WHEN 11 THEN 'LINE'
78771 WHEN 12 THEN 'LINE'
78772 WHEN 13 THEN 'LINE'
78773 WHEN 14 THEN 'LINE'
78774 WHEN 15 THEN 'LINE'
78775 WHEN 16 THEN 'LINE'
78776 WHEN 17 THEN 'LINE'
78777 WHEN 18 THEN 'LINE'
78778 WHEN 19 THEN 'LINE'
78779 WHEN 20 THEN 'LINE'
78780 WHEN 21 THEN 'LINE'
78781 WHEN 22 THEN 'LINE'
78782 WHEN 23 THEN 'LINE'
78783 WHEN 24 THEN 'LINE'
78784 WHEN 25 THEN 'LINE'
78785 WHEN 26 THEN 'LINE'
78786 WHEN 27 THEN 'LINE'
78787 WHEN 28 THEN 'LINE'
78788 WHEN 29 THEN 'LINE'
78789 WHEN 30 THEN 'LINE'
78790 WHEN 31 THEN 'LINE'
78791 WHEN 32 THEN 'LINE'
78792 WHEN 33 THEN 'LINE'
78793 WHEN 34 THEN 'LINE'
78794 WHEN 35 THEN 'LINE'
78795 WHEN 36 THEN 'LINE'
78796 WHEN 37 THEN 'LINE'
78797 WHEN 38 THEN 'LINE'
78798
78799 ELSE null
78800 END object_type_code
78801 , CASE r
78802 WHEN 1 THEN '222'
78803 WHEN 2 THEN '222'
78804 WHEN 3 THEN '222'
78805 WHEN 4 THEN '222'
78806 WHEN 5 THEN '222'
78807 WHEN 6 THEN '222'
78808 WHEN 7 THEN '8901'
78812 WHEN 11 THEN '8901'
78809 WHEN 8 THEN '8901'
78810 WHEN 9 THEN '8901'
78811 WHEN 10 THEN '8901'
78813 WHEN 12 THEN '222'
78814 WHEN 13 THEN '222'
78815 WHEN 14 THEN '222'
78816 WHEN 15 THEN '222'
78817 WHEN 16 THEN '222'
78818 WHEN 17 THEN '222'
78819 WHEN 18 THEN '222'
78820 WHEN 19 THEN '222'
78821 WHEN 20 THEN '222'
78822 WHEN 21 THEN '222'
78823 WHEN 22 THEN '222'
78824 WHEN 23 THEN '222'
78825 WHEN 24 THEN '222'
78826 WHEN 25 THEN '8901'
78827 WHEN 26 THEN '222'
78828 WHEN 27 THEN '222'
78829 WHEN 28 THEN '222'
78830 WHEN 29 THEN '222'
78831 WHEN 30 THEN '222'
78832 WHEN 31 THEN '222'
78833 WHEN 32 THEN '222'
78834 WHEN 33 THEN '222'
78835 WHEN 34 THEN '222'
78836 WHEN 35 THEN '222'
78837 WHEN 36 THEN '222'
78838 WHEN 37 THEN '222'
78839 WHEN 38 THEN '222'
78840
78841 ELSE null
78842 END source_application_id
78843 , 'S' source_type_code
78844 , CASE r
78845 WHEN 1 THEN 'TRX_TYPE_NAME'
78846 WHEN 2 THEN 'TRX_NUMBER'
78847 WHEN 3 THEN 'TRX_DOC_SEQUENCE_VALUE'
78848 WHEN 4 THEN 'DIST_CODE_COMBINATION_ID'
78849 WHEN 5 THEN 'GAIN_LOSS_CCID'
78850 WHEN 6 THEN 'BILL_CUSTOMER_CLASS_CODE'
78851 WHEN 7 THEN 'FEDERAL_ACCOUNT_RULE'
78852 WHEN 8 THEN 'FEDERAL_FUND_EXPIRED_STATUS'
78853 WHEN 9 THEN 'FEDERAL_PRIOR_YEAR_FLAG'
78854 WHEN 10 THEN 'FEDERAL_FUND_TIME_FRAME'
78855 WHEN 11 THEN 'FEDERAL_APPORTIONMENT_CATEGORY'
78856 WHEN 12 THEN 'DIST_SOURCE_TYPE'
78857 WHEN 13 THEN 'REC_ACT_TYPE'
78858 WHEN 14 THEN 'DIST_LINE_ID'
78859 WHEN 15 THEN 'DISTRIBUTION_TYPE'
78860 WHEN 16 THEN 'DIST_ENT_AMT'
78861 WHEN 17 THEN 'DIST_CURRENCY_CODE'
78862 WHEN 18 THEN 'DIST_CUR_CONVERSION_DATE'
78863 WHEN 19 THEN 'DIST_CUR_CONVERSION_RATE'
78864 WHEN 20 THEN 'DIST_CUR_CONVERSION_TYPE'
78865 WHEN 21 THEN 'DIST_TO_ACCTD_AMT'
78866 WHEN 22 THEN 'TRX_LINE_DIST_ACCOUNT_CLASS'
78867 WHEN 23 THEN 'TRX_LINE_DIST_ID'
78868 WHEN 24 THEN 'TRX_DISTRIBUTION_TYPE'
78869 WHEN 25 THEN 'FEDERAL_ACCOUNT_VALID_FLAG'
78870 WHEN 26 THEN 'DIST_TO_CUR_CONVERSION_DATE'
78871 WHEN 27 THEN 'TRX_ENTITY_CODE'
78872 WHEN 28 THEN 'TRX_CUSTOMER_TRX_ID'
78873 WHEN 29 THEN 'DIST_CURRENCY_CODE_FROM'
78874 WHEN 30 THEN 'DIST_TO_CUR_CONVERSION_RATE'
78875 WHEN 31 THEN 'DIST_PARTY_ID'
78876 WHEN 32 THEN 'DIST_PARTY_SITE_ID'
78877 WHEN 33 THEN 'DIST_PARTY_TYPE'
78878 WHEN 34 THEN 'DIST_MFAR_ADDITIONAL_ENTRY'
78879 WHEN 35 THEN 'DIST_ENT_AMT_FROM'
78880 WHEN 36 THEN 'DIST_ACCTD_AMT'
78881 WHEN 37 THEN 'DIST_TO_CUR_CONVERSION_TYPE'
78882 WHEN 38 THEN 'DIST_SOURCE_TABLE'
78883
78884 ELSE null
78885 END source_code
78886 , CASE r
78887 WHEN 1 THEN TO_CHAR(l10.TRX_TYPE_NAME)
78888 WHEN 2 THEN TO_CHAR(l10.TRX_NUMBER)
78889 WHEN 3 THEN TO_CHAR(l10.TRX_DOC_SEQUENCE_VALUE)
78890 WHEN 4 THEN TO_CHAR(l5.DIST_CODE_COMBINATION_ID)
78891 WHEN 5 THEN TO_CHAR(l5.GAIN_LOSS_CCID)
78892 WHEN 6 THEN TO_CHAR(l1.BILL_CUSTOMER_CLASS_CODE)
78893 WHEN 7 THEN TO_CHAR(l11.FEDERAL_ACCOUNT_RULE)
78894 WHEN 8 THEN TO_CHAR(l11.FEDERAL_FUND_EXPIRED_STATUS)
78895 WHEN 9 THEN TO_CHAR(l11.FEDERAL_PRIOR_YEAR_FLAG)
78896 WHEN 10 THEN TO_CHAR(l11.FEDERAL_FUND_TIME_FRAME)
78897 WHEN 11 THEN TO_CHAR(l11.FEDERAL_APPORTIONMENT_CATEGORY)
78898 WHEN 12 THEN TO_CHAR(l5.DIST_SOURCE_TYPE)
78899 WHEN 13 THEN TO_CHAR(l7.REC_ACT_TYPE)
78900 WHEN 14 THEN TO_CHAR(l5.DIST_LINE_ID)
78901 WHEN 15 THEN TO_CHAR(l5.DISTRIBUTION_TYPE)
78902 WHEN 16 THEN TO_CHAR(l5.DIST_ENT_AMT)
78903 WHEN 17 THEN TO_CHAR(l5.DIST_CURRENCY_CODE)
78904 WHEN 18 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_DATE)
78905 WHEN 19 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_RATE)
78906 WHEN 20 THEN TO_CHAR(l4.DIST_CUR_CONVERSION_TYPE)
78907 WHEN 21 THEN TO_CHAR(l4.DIST_TO_ACCTD_AMT)
78908 WHEN 22 THEN TO_CHAR(l3.TRX_LINE_DIST_ACCOUNT_CLASS)
78909 WHEN 23 THEN TO_CHAR(l3.TRX_LINE_DIST_ID)
78910 WHEN 24 THEN TO_CHAR(l3.TRX_DISTRIBUTION_TYPE)
78911 WHEN 25 THEN TO_CHAR(l11.FEDERAL_ACCOUNT_VALID_FLAG)
78912 WHEN 26 THEN TO_CHAR(l4.DIST_TO_CUR_CONVERSION_DATE)
78913 WHEN 27 THEN TO_CHAR(l10.TRX_ENTITY_CODE)
78914 WHEN 28 THEN TO_CHAR(l10.TRX_CUSTOMER_TRX_ID)
78915 WHEN 29 THEN TO_CHAR(l5.DIST_CURRENCY_CODE_FROM)
78916 WHEN 30 THEN TO_CHAR(l4.DIST_TO_CUR_CONVERSION_RATE)
78917 WHEN 31 THEN TO_CHAR(l5.DIST_PARTY_ID)
78918 WHEN 32 THEN TO_CHAR(l5.DIST_PARTY_SITE_ID)
78922 WHEN 36 THEN TO_CHAR(l4.DIST_ACCTD_AMT)
78919 WHEN 33 THEN TO_CHAR(l5.DIST_PARTY_TYPE)
78920 WHEN 34 THEN TO_CHAR(l5.DIST_MFAR_ADDITIONAL_ENTRY)
78921 WHEN 35 THEN TO_CHAR(l5.DIST_ENT_AMT_FROM)
78923 WHEN 37 THEN TO_CHAR(l4.DIST_TO_CUR_CONVERSION_TYPE)
78924 WHEN 38 THEN TO_CHAR(l5.DIST_SOURCE_TABLE)
78925
78926 ELSE null
78927 END source_value
78928 , null source_meaning
78929 FROM xla_events_gt xet
78930 , AR_BILL_TO_CUSTOMERS_S_V l1
78931 , AR_CUST_TRX_LINES_L_V l3
78932 , AR_DISTRIBUTIONS_BASE_V l4
78933 , AR_DISTRIBUTIONS_L_V l5
78934 , AR_RECEIVABLES_TRX_ACT_S_V l7
78935 , AR_TRANSACTIONS_S_V l10
78936 , FV_XLA_AR_REF_V l11
78937 , (select rownum r from all_objects where rownum <= 38 and owner = p_apps_owner)
78938 WHERE xet.event_date between p_pad_start_date AND p_pad_end_date
78939 AND xet.event_class_code = C_EVENT_CLASS_CODE
78940 AND l4.event_id = xet.event_id
78941 AND l1.event_id (+) = l4.event_id
78942 AND l1.line_number (+) = l4.line_number
78943 AND l3.event_id (+) = l4.event_id
78944 AND l3.line_number (+) = l4.line_number
78945 AND l5.event_id = l4.event_id
78946 AND l5.line_number = l4.line_number
78947 AND l7.event_id (+) = l4.event_id
78948 AND l7.line_number (+) = l4.line_number
78949 AND l10.event_id (+) = l4.event_id
78950 AND l10.line_number (+) = l4.line_number
78951 AND l11.federal_event_id (+) = l5.event_id and l11.federal_line_number (+) = l5.line_number
78952 )
78953 ;
78954 --
78955 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
78956
78957 trace
78958 (p_msg => 'number of line sources inserted = '||SQL%ROWCOUNT
78959 ,p_level => C_LEVEL_STATEMENT
78960 ,p_module => l_log_module);
78961
78962 END IF;
78963
78964
78965 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
78966 trace
78967 (p_msg => 'END of insert_sources_142'
78968 ,p_level => C_LEVEL_PROCEDURE
78969 ,p_module => l_log_module);
78970 END IF;
78971 EXCEPTION
78972 WHEN xla_exceptions_pkg.application_exception THEN
78973 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
78974 trace
78975 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
78976 ,p_level => C_LEVEL_EXCEPTION
78977 ,p_module => l_log_module);
78978 END IF;
78979 RAISE;
78980 WHEN OTHERS THEN
78981 IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
78982 trace
78983 (p_msg => 'ERROR: XLA_CMP_COMPILER_ERROR = '||sqlerrm
78984 ,p_level => C_LEVEL_EXCEPTION
78985 ,p_module => l_log_module);
78986 END IF;
78987 xla_exceptions_pkg.raise_message
78988 (p_location => 'XLA_00222_AAD_S_000005_PKG.insert_sources_142');
78989 END insert_sources_142;
78990 --
78991
78992 ---------------------------------------
78993 --
78994 -- PRIVATE FUNCTION
78995 -- EventClass_142
78996 --
78997 ----------------------------------------
78998 --
78999 FUNCTION EventClass_142
79000 (p_application_id IN NUMBER
79001 ,p_base_ledger_id IN NUMBER
79002 ,p_target_ledger_id IN NUMBER
79003 ,p_language IN VARCHAR2
79004 ,p_currency_code IN VARCHAR2
79005 ,p_sla_ledger_id IN NUMBER
79006 ,p_pad_start_date IN DATE
79007 ,p_pad_end_date IN DATE
79008 ,p_primary_ledger_id IN NUMBER)
79009 RETURN BOOLEAN IS
79010 --
79011 C_EVENT_TYPE_CODE CONSTANT VARCHAR2(30) := 'RECEIPT_ALL';
79012 C_EVENT_CLASS_CODE CONSTANT VARCHAR2(30) := 'RECEIPT';
79013
79014 l_calculate_acctd_flag VARCHAR2(1) :='N';
79015 l_calculate_g_l_flag VARCHAR2(1) :='Y';
79016 --
79017 l_array_legal_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79018 l_array_entity_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79019 l_array_entity_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
79020 l_array_transaction_num XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
79021 l_array_event_id XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79022 l_array_class_code XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
79023 l_array_event_type XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
79024 l_array_event_number XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79025 l_array_event_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79026 l_array_transaction_date XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79027 l_array_reference_num_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79028 l_array_reference_num_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79029 l_array_reference_num_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79030 l_array_reference_num_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num;
79031 l_array_reference_char_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
79032 l_array_reference_char_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
79033 l_array_reference_char_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
79034 l_array_reference_char_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_V240L;
79035 l_array_reference_date_1 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79036 l_array_reference_date_2 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79037 l_array_reference_date_3 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79038 l_array_reference_date_4 XLA_AE_JOURNAL_ENTRY_PKG.t_array_Date;
79039 l_array_event_created_by XLA_AE_JOURNAL_ENTRY_PKG.t_array_V100L;
79040 l_array_budgetary_control_flag XLA_AE_JOURNAL_ENTRY_PKG.t_array_V30L;
79041 l_array_header_events XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
79042 l_array_duplicate_checker XLA_AE_JOURNAL_ENTRY_PKG.t_array_Num; --added
79043
79044 l_event_id NUMBER;
79045 l_previous_event_id NUMBER;
79046 l_first_event_id NUMBER;
79047 l_last_event_id NUMBER;
79048
79049 l_rec_acct_attrs XLA_AE_HEADER_PKG.t_rec_acct_attrs;
79050 l_rec_rev_acct_attrs XLA_AE_LINES_PKG.t_rec_acct_attrs;
79051 --
79052 --
79053 l_result BOOLEAN := TRUE;
79054 l_rows NUMBER := 1000;
79055 l_event_type_name VARCHAR2(80) := 'All';
79056 l_event_class_name VARCHAR2(80) := 'Receipt';
79057 l_description VARCHAR2(4000);
79058 l_transaction_reversal NUMBER;
79059 l_ae_header_id NUMBER;
79060 l_array_extract_line_num xla_ae_journal_entry_pkg.t_array_Num;
79061 l_log_module VARCHAR2(240);
79062 --
79063 l_acct_reversal_source VARCHAR2(30);
79064 l_trx_reversal_source VARCHAR2(30);
79065
79066 l_continue_with_lines BOOLEAN := TRUE;
79067 --
79068 l_acc_rev_gl_date_source DATE; -- 4262811
79069 --
79070 type t_array_event_id is table of number index by binary_integer;
79071
79072 l_rec_array_event t_rec_array_event;
79073 l_null_rec_array_event t_rec_array_event;
79074 l_array_ae_header_id xla_number_array_type;
79075 l_actual_flag VARCHAR2(1) := NULL;
79076 l_actual_gain_loss_ref VARCHAR2(30) := '#####';
79077 l_balance_type_code VARCHAR2(1) :=NULL;
79078 l_gain_or_loss_ref VARCHAR2(30) :=NULL;
79079
79080 --
79081 TYPE t_array_lookup_meaning IS TABLE OF fnd_lookup_values.meaning%TYPE INDEX BY BINARY_INTEGER;
79082 --
79083
79084 TYPE t_array_source_7 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_GAIN%TYPE INDEX BY BINARY_INTEGER;
79085 TYPE t_array_source_8 IS TABLE OF AR_SYSTEM_PARAM_H_V.CODE_COMBINATION_ID_LOSS%TYPE INDEX BY BINARY_INTEGER;
79086 TYPE t_array_source_17 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_UNAPPLIED_CCID%TYPE INDEX BY BINARY_INTEGER;
79087 TYPE t_array_source_18 IS TABLE OF AR_REMIT_BANK_ACCT_H_V.RMT_BNK_UNIDENTIFIED_CCID%TYPE INDEX BY BINARY_INTEGER;
79088 TYPE t_array_source_58 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_XLA_APPLIED_TO_APP_ID%TYPE INDEX BY BINARY_INTEGER;
79089 TYPE t_array_source_72 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_PAY_FROM_CUSTOMER%TYPE INDEX BY BINARY_INTEGER;
79090 TYPE t_array_source_73 IS TABLE OF AR_RCT_SITE_USES_H_V.RCT_SITE_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
79091 TYPE t_array_source_74 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_APP_STATUS%TYPE INDEX BY BINARY_INTEGER;
79092 TYPE t_array_source_75 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_PREV_PAY_FROM_CUSTOMER%TYPE INDEX BY BINARY_INTEGER;
79093 TYPE t_array_source_76 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_PREV_CUSTOMER_SITE_USE_ID%TYPE INDEX BY BINARY_INTEGER;
79094 TYPE t_array_source_83 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
79095 TYPE t_array_source_84 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_ID%TYPE INDEX BY BINARY_INTEGER;
79096 TYPE t_array_source_85 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
79097 TYPE t_array_source_86 IS TABLE OF AR_CASH_RECEIPTS_H_V.RCT_TRX_ACCT_REVERSAL%TYPE INDEX BY BINARY_INTEGER;
79098
79099 TYPE t_array_source_1 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_TYPE_NAME%TYPE INDEX BY BINARY_INTEGER;
79100 TYPE t_array_source_2 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_NUMBER%TYPE INDEX BY BINARY_INTEGER;
79101 TYPE t_array_source_3 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_DOC_SEQUENCE_VALUE%TYPE INDEX BY BINARY_INTEGER;
79102 TYPE t_array_source_5 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CODE_COMBINATION_ID%TYPE INDEX BY BINARY_INTEGER;
79103 TYPE t_array_source_6 IS TABLE OF AR_DISTRIBUTIONS_L_V.GAIN_LOSS_CCID%TYPE INDEX BY BINARY_INTEGER;
79104 TYPE t_array_source_10 IS TABLE OF AR_BILL_TO_CUSTOMERS_S_V.BILL_CUSTOMER_CLASS_CODE%TYPE INDEX BY BINARY_INTEGER;
79105 TYPE t_array_source_11 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_ACCOUNT_RULE%TYPE INDEX BY BINARY_INTEGER;
79106 TYPE t_array_source_12 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_EXPIRED_STATUS%TYPE INDEX BY BINARY_INTEGER;
79107 TYPE t_array_source_13 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_PRIOR_YEAR_FLAG%TYPE INDEX BY BINARY_INTEGER;
79108 TYPE t_array_source_14 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_FUND_TIME_FRAME%TYPE INDEX BY BINARY_INTEGER;
79109 TYPE t_array_source_15 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_APPORTIONMENT_CATEGORY%TYPE INDEX BY BINARY_INTEGER;
79110 TYPE t_array_source_20 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TYPE%TYPE INDEX BY BINARY_INTEGER;
79114 TYPE t_array_source_24 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT%TYPE INDEX BY BINARY_INTEGER;
79111 TYPE t_array_source_21 IS TABLE OF AR_RECEIVABLES_TRX_ACT_S_V.REC_ACT_TYPE%TYPE INDEX BY BINARY_INTEGER;
79112 TYPE t_array_source_22 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_LINE_ID%TYPE INDEX BY BINARY_INTEGER;
79113 TYPE t_array_source_23 IS TABLE OF AR_DISTRIBUTIONS_L_V.DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
79115 TYPE t_array_source_25 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER;
79116 TYPE t_array_source_26 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
79117 TYPE t_array_source_27 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
79118 TYPE t_array_source_28 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
79119 TYPE t_array_source_29 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
79120 TYPE t_array_source_33 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ACCOUNT_CLASS%TYPE INDEX BY BINARY_INTEGER;
79121 TYPE t_array_source_34 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_LINE_DIST_ID%TYPE INDEX BY BINARY_INTEGER;
79122 TYPE t_array_source_35 IS TABLE OF AR_CUST_TRX_LINES_L_V.TRX_DISTRIBUTION_TYPE%TYPE INDEX BY BINARY_INTEGER;
79123 TYPE t_array_source_56 IS TABLE OF FV_XLA_AR_REF_V.FEDERAL_ACCOUNT_VALID_FLAG%TYPE INDEX BY BINARY_INTEGER;
79124 TYPE t_array_source_57 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_DATE%TYPE INDEX BY BINARY_INTEGER;
79125 TYPE t_array_source_59 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_ENTITY_CODE%TYPE INDEX BY BINARY_INTEGER;
79126 TYPE t_array_source_60 IS TABLE OF AR_TRANSACTIONS_S_V.TRX_CUSTOMER_TRX_ID%TYPE INDEX BY BINARY_INTEGER;
79127 TYPE t_array_source_61 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_CURRENCY_CODE_FROM%TYPE INDEX BY BINARY_INTEGER;
79128 TYPE t_array_source_62 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_RATE%TYPE INDEX BY BINARY_INTEGER;
79129 TYPE t_array_source_63 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_PARTY_ID%TYPE INDEX BY BINARY_INTEGER;
79130 TYPE t_array_source_64 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_PARTY_SITE_ID%TYPE INDEX BY BINARY_INTEGER;
79131 TYPE t_array_source_65 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_PARTY_TYPE%TYPE INDEX BY BINARY_INTEGER;
79132 TYPE t_array_source_67 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_MFAR_ADDITIONAL_ENTRY%TYPE INDEX BY BINARY_INTEGER;
79133 TYPE t_array_source_68 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_ENT_AMT_FROM%TYPE INDEX BY BINARY_INTEGER;
79134 TYPE t_array_source_69 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_ACCTD_AMT%TYPE INDEX BY BINARY_INTEGER;
79135 TYPE t_array_source_70 IS TABLE OF AR_DISTRIBUTIONS_BASE_V.DIST_TO_CUR_CONVERSION_TYPE%TYPE INDEX BY BINARY_INTEGER;
79136 TYPE t_array_source_71 IS TABLE OF AR_DISTRIBUTIONS_L_V.DIST_SOURCE_TABLE%TYPE INDEX BY BINARY_INTEGER;
79137
79138 l_array_source_7 t_array_source_7;
79139 l_array_source_8 t_array_source_8;
79140 l_array_source_17 t_array_source_17;
79141 l_array_source_18 t_array_source_18;
79142 l_array_source_58 t_array_source_58;
79143 l_array_source_72 t_array_source_72;
79144 l_array_source_73 t_array_source_73;
79145 l_array_source_74 t_array_source_74;
79146 l_array_source_75 t_array_source_75;
79147 l_array_source_76 t_array_source_76;
79148 l_array_source_83 t_array_source_83;
79149 l_array_source_84 t_array_source_84;
79150 l_array_source_85 t_array_source_85;
79151 l_array_source_86 t_array_source_86;
79152
79153 l_array_source_1 t_array_source_1;
79154 l_array_source_2 t_array_source_2;
79155 l_array_source_3 t_array_source_3;
79156 l_array_source_5 t_array_source_5;
79157 l_array_source_6 t_array_source_6;
79158 l_array_source_10 t_array_source_10;
79159 l_array_source_11 t_array_source_11;
79160 l_array_source_12 t_array_source_12;
79161 l_array_source_13 t_array_source_13;
79162 l_array_source_14 t_array_source_14;
79163 l_array_source_15 t_array_source_15;
79164 l_array_source_20 t_array_source_20;
79165 l_array_source_21 t_array_source_21;
79166 l_array_source_22 t_array_source_22;
79167 l_array_source_23 t_array_source_23;
79168 l_array_source_24 t_array_source_24;
79169 l_array_source_25 t_array_source_25;
79170 l_array_source_26 t_array_source_26;
79171 l_array_source_27 t_array_source_27;
79172 l_array_source_28 t_array_source_28;
79173 l_array_source_29 t_array_source_29;
79174 l_array_source_33 t_array_source_33;
79175 l_array_source_34 t_array_source_34;
79176 l_array_source_35 t_array_source_35;
79177 l_array_source_56 t_array_source_56;
79178 l_array_source_57 t_array_source_57;
79179 l_array_source_59 t_array_source_59;
79180 l_array_source_60 t_array_source_60;
79181 l_array_source_61 t_array_source_61;
79182 l_array_source_62 t_array_source_62;
79183 l_array_source_63 t_array_source_63;
79184 l_array_source_64 t_array_source_64;
79185 l_array_source_65 t_array_source_65;
79186 l_array_source_67 t_array_source_67;
79187 l_array_source_68 t_array_source_68;
79188 l_array_source_69 t_array_source_69;
79189 l_array_source_70 t_array_source_70;
79190 l_array_source_71 t_array_source_71;
79191
79192 --
79193 CURSOR header_cur
79194 IS
79195 SELECT /*+ leading(xet) cardinality(xet,1) */
79196 -- Event Class Code: RECEIPT
79197 xet.entity_id
79198 ,xet.legal_entity_id
79199 ,xet.entity_code
79200 ,xet.transaction_number
79201 ,xet.event_id
79202 ,xet.event_class_code
79203 ,xet.event_type_code
79204 ,xet.event_number
79205 ,xet.event_date
79206 ,xet.transaction_date
79207 ,xet.reference_num_1
79208 ,xet.reference_num_2
79209 ,xet.reference_num_3
79210 ,xet.reference_num_4
79211 ,xet.reference_char_1
79212 ,xet.reference_char_2
79213 ,xet.reference_char_3
79214 ,xet.reference_char_4
79215 ,xet.reference_date_1
79216 ,xet.reference_date_2
79217 ,xet.reference_date_3
79218 ,xet.reference_date_4
79219 ,xet.event_created_by
79220 ,xet.budgetary_control_flag
79221 , h9.CODE_COMBINATION_ID_GAIN source_7
79222 , h9.CODE_COMBINATION_ID_LOSS source_8
79223 , h8.RMT_BNK_UNAPPLIED_CCID source_17
79224 , h8.RMT_BNK_UNIDENTIFIED_CCID source_18
79225 , h2.RCT_XLA_APPLIED_TO_APP_ID source_58
79226 , h2.RCT_PAY_FROM_CUSTOMER source_72
79227 , h6.RCT_SITE_SITE_USE_ID source_73
79228 , h2.RCT_APP_STATUS source_74
79229 , h2.RCT_PREV_PAY_FROM_CUSTOMER source_75
79230 , h2.RCT_PREV_CUSTOMER_SITE_USE_ID source_76
79231 , h2.RCT_DOC_SEQUENCE_CATEGORY source_83
79232 , h2.RCT_DOC_SEQUENCE_ID source_84
79233 , h2.RCT_DOC_SEQUENCE_VALUE source_85
79234 , h2.RCT_TRX_ACCT_REVERSAL source_86
79235 FROM xla_events_gt xet
79236 , AR_CASH_RECEIPTS_H_V h2
79237 , AR_RCT_SITE_USES_H_V h6
79238 , AR_REMIT_BANK_ACCT_H_V h8
79239 , AR_SYSTEM_PARAM_H_V h9
79240 WHERE xet.event_date between p_pad_start_date and p_pad_end_date
79241 and xet.event_class_code = C_EVENT_CLASS_CODE
79242 and xet.event_status_code <> 'N' AND h2.event_id = xet.event_id
79243 AND h6.event_id (+) = h2.event_id
79244 AND h8.event_id (+) = h2.event_id
79245 AND h9.event_id (+) = h2.event_id
79246
79247 ORDER BY event_id
79248 ;
79249
79250
79251 --
79252 CURSOR line_cur (x_first_event_id in number, x_last_event_id in number)
79253 IS
79254 SELECT /*+ leading(xet) cardinality(xet,1) */
79255 -- Event Class Code: RECEIPT
79256 xet.entity_id
79257 ,xet.legal_entity_id
79258 ,xet.entity_code
79259 ,xet.transaction_number
79260 ,xet.event_id
79261 ,xet.event_class_code
79262 ,xet.event_type_code
79263 ,xet.event_number
79264 ,xet.event_date
79265 ,xet.transaction_date
79266 ,xet.reference_num_1
79267 ,xet.reference_num_2
79268 ,xet.reference_num_3
79269 ,xet.reference_num_4
79270 ,xet.reference_char_1
79271 ,xet.reference_char_2
79272 ,xet.reference_char_3
79273 ,xet.reference_char_4
79274 ,xet.reference_date_1
79275 ,xet.reference_date_2
79276 ,xet.reference_date_3
79277 ,xet.reference_date_4
79278 ,xet.event_created_by
79279 ,xet.budgetary_control_flag
79280 , l4.LINE_NUMBER
79281 , l10.TRX_TYPE_NAME source_1
79282 , l10.TRX_NUMBER source_2
79283 , l10.TRX_DOC_SEQUENCE_VALUE source_3
79284 , l5.DIST_CODE_COMBINATION_ID source_5
79285 , l5.GAIN_LOSS_CCID source_6
79286 , l1.BILL_CUSTOMER_CLASS_CODE source_10
79287 , l11.FEDERAL_ACCOUNT_RULE source_11
79288 , l11.FEDERAL_FUND_EXPIRED_STATUS source_12
79289 , l11.FEDERAL_PRIOR_YEAR_FLAG source_13
79290 , l11.FEDERAL_FUND_TIME_FRAME source_14
79291 , l11.FEDERAL_APPORTIONMENT_CATEGORY source_15
79292 , l5.DIST_SOURCE_TYPE source_20
79293 , l7.REC_ACT_TYPE source_21
79294 , l5.DIST_LINE_ID source_22
79295 , l5.DISTRIBUTION_TYPE source_23
79296 , l5.DIST_ENT_AMT source_24
79297 , l5.DIST_CURRENCY_CODE source_25
79298 , l4.DIST_CUR_CONVERSION_DATE source_26
79299 , l4.DIST_CUR_CONVERSION_RATE source_27
79300 , l4.DIST_CUR_CONVERSION_TYPE source_28
79301 , l4.DIST_TO_ACCTD_AMT source_29
79302 , l3.TRX_LINE_DIST_ACCOUNT_CLASS source_33
79303 , l3.TRX_LINE_DIST_ID source_34
79304 , l3.TRX_DISTRIBUTION_TYPE source_35
79305 , l11.FEDERAL_ACCOUNT_VALID_FLAG source_56
79306 , l4.DIST_TO_CUR_CONVERSION_DATE source_57
79307 , l10.TRX_ENTITY_CODE source_59
79308 , l10.TRX_CUSTOMER_TRX_ID source_60
79309 , l5.DIST_CURRENCY_CODE_FROM source_61
79310 , l4.DIST_TO_CUR_CONVERSION_RATE source_62
79311 , l5.DIST_PARTY_ID source_63
79312 , l5.DIST_PARTY_SITE_ID source_64
79316 , l4.DIST_ACCTD_AMT source_69
79313 , l5.DIST_PARTY_TYPE source_65
79314 , l5.DIST_MFAR_ADDITIONAL_ENTRY source_67
79315 , l5.DIST_ENT_AMT_FROM source_68
79317 , l4.DIST_TO_CUR_CONVERSION_TYPE source_70
79318 , l5.DIST_SOURCE_TABLE source_71
79319 FROM xla_events_gt xet
79320 , AR_BILL_TO_CUSTOMERS_S_V l1
79321 , AR_CUST_TRX_LINES_L_V l3
79322 , AR_DISTRIBUTIONS_BASE_V l4
79323 , AR_DISTRIBUTIONS_L_V l5
79324 , AR_RECEIVABLES_TRX_ACT_S_V l7
79325 , AR_TRANSACTIONS_S_V l10
79326 , FV_XLA_AR_REF_V l11
79327 WHERE xet.event_id between x_first_event_id and x_last_event_id
79328 and xet.event_date between p_pad_start_date and p_pad_end_date
79329 and xet.event_class_code = C_EVENT_CLASS_CODE
79330 and xet.event_status_code <> 'N' AND l4.event_id = xet.event_id
79331 AND l1.event_id (+) = l4.event_id
79332 AND l1.line_number (+) = l4.line_number
79333 AND l3.event_id (+) = l4.event_id
79334 AND l3.line_number (+) = l4.line_number
79335 AND l5.event_id = l4.event_id
79336 AND l5.line_number = l4.line_number
79337 AND l7.event_id (+) = l4.event_id
79338 AND l7.line_number (+) = l4.line_number
79339 AND l10.event_id (+) = l4.event_id
79340 AND l10.line_number (+) = l4.line_number
79341 AND l11.federal_event_id (+) = l5.event_id AND l11.federal_line_number (+) = l5.line_number;
79342
79343 --
79344 BEGIN
79345 IF g_log_enabled THEN
79346 l_log_module := C_DEFAULT_MODULE||'.EventClass_142';
79347 END IF;
79348 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
79349 trace
79350 (p_msg => 'BEGIN of EventClass_142'
79351 ,p_level => C_LEVEL_PROCEDURE
79352 ,p_module => l_log_module);
79353 END IF;
79354
79355 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
79356 trace
79357 (p_msg => 'p_application_id = '||p_application_id||
79358 ' - p_base_ledger_id = '||p_base_ledger_id||
79359 ' - p_target_ledger_id = '||p_target_ledger_id||
79360 ' - p_language = '||p_language||
79361 ' - p_currency_code = '||p_currency_code||
79362 ' - p_sla_ledger_id = '||p_sla_ledger_id
79363 ,p_level => C_LEVEL_STATEMENT
79364 ,p_module => l_log_module);
79365 END IF;
79366 --
79367 -- initialze arrays
79368 --
79369 g_array_event.DELETE;
79370 l_rec_array_event := l_null_rec_array_event;
79371 --
79372 --------------------------------------
79373 -- 4262811 Initialze MPA Line Number
79374 --------------------------------------
79375 XLA_AE_HEADER_PKG.g_mpa_line_num := 0;
79376
79377 --
79378
79379 --
79380 OPEN header_cur;
79381 --
79382 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
79383 trace
79384 (p_msg => 'SQL - FETCH header_cur'
79385 ,p_level => C_LEVEL_STATEMENT
79386 ,p_module => l_log_module);
79387 END IF;
79388 --
79389 LOOP
79390 FETCH header_cur BULK COLLECT INTO
79391 l_array_entity_id
79392 , l_array_legal_entity_id
79393 , l_array_entity_code
79394 , l_array_transaction_num
79395 , l_array_event_id
79396 , l_array_class_code
79397 , l_array_event_type
79398 , l_array_event_number
79399 , l_array_event_date
79400 , l_array_transaction_date
79401 , l_array_reference_num_1
79402 , l_array_reference_num_2
79403 , l_array_reference_num_3
79404 , l_array_reference_num_4
79405 , l_array_reference_char_1
79406 , l_array_reference_char_2
79407 , l_array_reference_char_3
79408 , l_array_reference_char_4
79409 , l_array_reference_date_1
79410 , l_array_reference_date_2
79411 , l_array_reference_date_3
79412 , l_array_reference_date_4
79413 , l_array_event_created_by
79414 , l_array_budgetary_control_flag
79415 , l_array_source_7
79416 , l_array_source_8
79417 , l_array_source_17
79418 , l_array_source_18
79419 , l_array_source_58
79420 , l_array_source_72
79421 , l_array_source_73
79422 , l_array_source_74
79423 , l_array_source_75
79424 , l_array_source_76
79425 , l_array_source_83
79426 , l_array_source_84
79427 , l_array_source_85
79428 , l_array_source_86
79429 LIMIT l_rows;
79430 --
79431 IF (C_LEVEL_EVENT >= g_log_level) THEN
79432 trace
79433 (p_msg => '# rows extracted from header extract objects = '||TO_CHAR(header_cur%ROWCOUNT)
79434 ,p_level => C_LEVEL_EVENT
79435 ,p_module => l_log_module);
79436 END IF;
79437 --
79438 EXIT WHEN l_array_entity_id.COUNT = 0;
79439
79440 -- initialize arrays
79441 XLA_AE_HEADER_PKG.g_rec_header_new := NULL;
79442 XLA_AE_LINES_PKG.g_rec_lines := NULL;
79443
79444 --
79445 -- Bug 4458708
79446 --
79447 XLA_AE_LINES_PKG.g_LineNumber := 0;
79448
79449
79450 -- 4262811 - when creating Accrual Reversal or MPA, use g_last_hdr_idx to increment for next header id
79451 g_last_hdr_idx := l_array_event_id.LAST;
79452 --
79453 -- loop for the headers. Each iteration is for each header extract row
79454 -- fetched in header cursor
79455 --
79456 FOR hdr_idx IN l_array_event_id.FIRST .. l_array_event_id.LAST LOOP
79457
79458 --
79459 -- set event info as cache for other routines to refer event attributes
79460 --
79461 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
79462 (p_application_id => p_application_id
79463 ,p_primary_ledger_id => p_primary_ledger_id
79464 ,p_base_ledger_id => p_base_ledger_id
79468 ,p_entity_code => l_array_entity_code(hdr_idx)
79465 ,p_target_ledger_id => p_target_ledger_id
79466 ,p_entity_id => l_array_entity_id(hdr_idx)
79467 ,p_legal_entity_id => l_array_legal_entity_id(hdr_idx)
79469 ,p_transaction_num => l_array_transaction_num(hdr_idx)
79470 ,p_event_id => l_array_event_id(hdr_idx)
79471 ,p_event_class_code => l_array_class_code(hdr_idx)
79472 ,p_event_type_code => l_array_event_type(hdr_idx)
79473 ,p_event_number => l_array_event_number(hdr_idx)
79474 ,p_event_date => l_array_event_date(hdr_idx)
79475 ,p_transaction_date => l_array_transaction_date(hdr_idx)
79476 ,p_reference_num_1 => l_array_reference_num_1(hdr_idx)
79477 ,p_reference_num_2 => l_array_reference_num_2(hdr_idx)
79478 ,p_reference_num_3 => l_array_reference_num_3(hdr_idx)
79479 ,p_reference_num_4 => l_array_reference_num_4(hdr_idx)
79480 ,p_reference_char_1 => l_array_reference_char_1(hdr_idx)
79481 ,p_reference_char_2 => l_array_reference_char_2(hdr_idx)
79482 ,p_reference_char_3 => l_array_reference_char_3(hdr_idx)
79483 ,p_reference_char_4 => l_array_reference_char_4(hdr_idx)
79484 ,p_reference_date_1 => l_array_reference_date_1(hdr_idx)
79485 ,p_reference_date_2 => l_array_reference_date_2(hdr_idx)
79486 ,p_reference_date_3 => l_array_reference_date_3(hdr_idx)
79487 ,p_reference_date_4 => l_array_reference_date_4(hdr_idx)
79488 ,p_event_created_by => l_array_event_created_by(hdr_idx)
79489 ,p_budgetary_control_flag => l_array_budgetary_control_flag(hdr_idx));
79490
79491 --
79492 -- set the status of entry to C_VALID (0)
79493 --
79494 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
79495
79496 --
79497 -- initialize a row for ae header
79498 --
79499 XLA_AE_HEADER_PKG.InitHeader(hdr_idx);
79500
79501 l_event_id := l_array_event_id(hdr_idx);
79502
79503 --
79504 -- storing the hdr_idx for event. May be used by line cursor.
79505 --
79506 g_array_event(l_event_id).array_value_num('header_index') := hdr_idx;
79507
79508 --
79509 -- store sources from header extract. This can be improved to
79510 -- store only those sources from header extract that may be used in lines
79511 --
79512
79513 g_array_event(l_event_id).array_value_num('source_7') := l_array_source_7(hdr_idx);
79514 g_array_event(l_event_id).array_value_num('source_8') := l_array_source_8(hdr_idx);
79515 g_array_event(l_event_id).array_value_num('source_17') := l_array_source_17(hdr_idx);
79516 g_array_event(l_event_id).array_value_num('source_18') := l_array_source_18(hdr_idx);
79517 g_array_event(l_event_id).array_value_num('source_58') := l_array_source_58(hdr_idx);
79518 g_array_event(l_event_id).array_value_num('source_72') := l_array_source_72(hdr_idx);
79519 g_array_event(l_event_id).array_value_num('source_73') := l_array_source_73(hdr_idx);
79520 g_array_event(l_event_id).array_value_char('source_74') := l_array_source_74(hdr_idx);
79521 g_array_event(l_event_id).array_value_num('source_75') := l_array_source_75(hdr_idx);
79522 g_array_event(l_event_id).array_value_num('source_76') := l_array_source_76(hdr_idx);
79523 g_array_event(l_event_id).array_value_char('source_83') := l_array_source_83(hdr_idx);
79524 g_array_event(l_event_id).array_value_num('source_84') := l_array_source_84(hdr_idx);
79525 g_array_event(l_event_id).array_value_num('source_85') := l_array_source_85(hdr_idx);
79526 g_array_event(l_event_id).array_value_char('source_86') := l_array_source_86(hdr_idx);
79527
79528 --
79529 -- initilaize the status of ae headers for diffrent balance types
79530 -- the status is initialised to C_NOT_CREATED (2)
79531 --
79532 --g_array_event(l_event_id).array_value_num('actual_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
79533 --g_array_event(l_event_id).array_value_num('budget_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
79534 --g_array_event(l_event_id).array_value_num('encumbrance_je_status') := XLA_AE_JOURNAL_ENTRY_PKG.C_NOT_CREATED;
79535
79536 --
79537 -- call api to validate and store accounting attributes for header
79538 --
79539
79540 ------------------------------------------------------------
79541 -- Accrual Reversal : to get date for Standard Source (NONE)
79542 ------------------------------------------------------------
79543 l_acc_rev_gl_date_source := NULL;
79544
79545 l_rec_acct_attrs.array_acct_attr_code(1) := 'DOC_CATEGORY_CODE';
79546 l_rec_acct_attrs.array_char_value(1) := g_array_event(l_event_id).array_value_char('source_83');
79547 l_rec_acct_attrs.array_acct_attr_code(2) := 'DOC_SEQUENCE_ID';
79548 l_rec_acct_attrs.array_num_value(2) := g_array_event(l_event_id).array_value_num('source_84');
79549 l_rec_acct_attrs.array_acct_attr_code(3) := 'DOC_SEQUENCE_VALUE';
79550 l_rec_acct_attrs.array_num_value(3) := g_array_event(l_event_id).array_value_num('source_85');
79551 l_rec_acct_attrs.array_acct_attr_code(4) := 'GL_DATE';
79552 l_rec_acct_attrs.array_date_value(4) :=
79553 xla_ae_sources_pkg.GetSystemSourceDate(
79554 p_source_code => 'XLA_EVENT_DATE'
79555 , p_source_type_code => 'Y'
79556 , p_source_application_id => 602
79557 );
79558 l_rec_acct_attrs.array_acct_attr_code(5) := 'TRX_ACCT_REVERSAL_OPTION';
79559 l_rec_acct_attrs.array_char_value(5) := g_array_event(l_event_id).array_value_char('source_86');
79560
79561
79562 XLA_AE_HEADER_PKG.SetHdrAcctAttrs(l_rec_acct_attrs);
79563
79564 XLA_AE_HEADER_PKG.SetJeCategoryName;
79565
79566 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_type_code(hdr_idx) := l_array_event_type(hdr_idx);
79567 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_id(hdr_idx) := l_array_event_id(hdr_idx);
79568 XLA_AE_HEADER_PKG.g_rec_header_new.array_entity_id(hdr_idx) := l_array_entity_id(hdr_idx);
79572
79569 XLA_AE_HEADER_PKG.g_rec_header_new.array_event_number(hdr_idx) := l_array_event_number(hdr_idx);
79570 XLA_AE_HEADER_PKG.g_rec_header_new.array_target_ledger_id(hdr_idx) := p_target_ledger_id;
79571
79573 -- No header level analytical criteria
79574
79575 --
79576 --accounting attribute enhancement, bug 3612931
79577 --
79578 l_trx_reversal_source := SUBSTR(g_array_event(l_event_id).array_value_char('source_86'), 1,30);
79579
79580 IF NVL(l_trx_reversal_source, 'N') NOT IN ('N','Y') THEN
79581 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
79582
79583 xla_accounting_err_pkg.build_message
79584 (p_appli_s_name => 'XLA'
79585 ,p_msg_name => 'XLA_AP_INVALID_HDR_ATTR'
79586 ,p_token_1 => 'ACCT_ATTR_NAME'
79587 ,p_value_1 => xla_ae_sources_pkg.GetAccountingSourceName('TRX_ACCT_REVERSAL_OPTION')
79588 ,p_token_2 => 'PRODUCT_NAME'
79589 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
79590 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
79591 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
79592 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
79593
79594 ELSIF NVL(l_trx_reversal_source, 'N') = 'Y' THEN
79595 --
79596 -- following sets the accounting attributes needed to reverse
79597 -- accounting for a distributeion
79598 --
79599 xla_ae_lines_pkg.SetTrxReversalAttrs
79600 (p_event_id => l_event_id
79601 ,p_gl_date => XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(hdr_idx)
79602 ,p_trx_reversal_source => l_trx_reversal_source);
79603
79604 END IF;
79605
79606
79607 ----------------------------------------------------------------
79608 -- 4262811 - update the header statuses to invalid in need be
79609 ----------------------------------------------------------------
79610 --
79611 XLA_AE_JOURNAL_ENTRY_PKG.UpdateJournalEntryStatus (p_hdr_idx => hdr_idx);
79612
79613
79614 -----------------------------------------------
79615 -- No accrual reversal for the event class/type
79616 -----------------------------------------------
79617 ----------------------------------------------------------------
79618
79619 --
79620 -- this ends the header loop iteration for one bulk fetch
79621 --
79622 END LOOP;
79623
79624 l_first_event_id := l_array_event_id(l_array_event_id.FIRST);
79625 l_last_event_id := l_array_event_id(l_array_event_id.LAST);
79626
79627 --
79628 -- insert dummy rows into lines gt table that were created due to
79629 -- transaction reversals
79630 --
79631 IF XLA_AE_LINES_PKG.g_rec_lines.array_ae_header_id.COUNT > 0 THEN
79632 l_result := XLA_AE_LINES_PKG.InsertLines;
79633 END IF;
79634
79635 --
79636 -- reset the temp_line_num for each set of events fetched from header
79637 -- cursor rather than doing it for each new event in line cursor
79638 -- Bug 3939231
79639 --
79640 xla_ae_lines_pkg.g_temp_line_num := 0;
79641
79642
79643
79644 --
79645 OPEN line_cur(x_first_event_id => l_first_event_id, x_last_event_id => l_last_event_id);
79646 --
79647 --
79648 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
79649
79650 trace
79651 (p_msg => 'SQL - FETCH line_cur'
79652 ,p_level => C_LEVEL_STATEMENT
79653 ,p_module => l_log_module);
79654
79655 END IF;
79656 --
79657 --
79658 LOOP
79659 --
79660 FETCH line_cur BULK COLLECT INTO
79661 l_array_entity_id
79662 , l_array_legal_entity_id
79663 , l_array_entity_code
79664 , l_array_transaction_num
79665 , l_array_event_id
79666 , l_array_class_code
79667 , l_array_event_type
79668 , l_array_event_number
79669 , l_array_event_date
79670 , l_array_transaction_date
79671 , l_array_reference_num_1
79672 , l_array_reference_num_2
79673 , l_array_reference_num_3
79674 , l_array_reference_num_4
79675 , l_array_reference_char_1
79676 , l_array_reference_char_2
79677 , l_array_reference_char_3
79678 , l_array_reference_char_4
79679 , l_array_reference_date_1
79680 , l_array_reference_date_2
79681 , l_array_reference_date_3
79682 , l_array_reference_date_4
79683 , l_array_event_created_by
79684 , l_array_budgetary_control_flag
79685 , l_array_extract_line_num
79686 , l_array_source_1
79687 , l_array_source_2
79688 , l_array_source_3
79689 , l_array_source_5
79690 , l_array_source_6
79691 , l_array_source_10
79692 , l_array_source_11
79693 , l_array_source_12
79694 , l_array_source_13
79695 , l_array_source_14
79696 , l_array_source_15
79697 , l_array_source_20
79698 , l_array_source_21
79699 , l_array_source_22
79700 , l_array_source_23
79701 , l_array_source_24
79702 , l_array_source_25
79703 , l_array_source_26
79704 , l_array_source_27
79705 , l_array_source_28
79706 , l_array_source_29
79707 , l_array_source_33
79708 , l_array_source_34
79709 , l_array_source_35
79710 , l_array_source_56
79711 , l_array_source_57
79712 , l_array_source_59
79716 , l_array_source_63
79713 , l_array_source_60
79714 , l_array_source_61
79715 , l_array_source_62
79717 , l_array_source_64
79718 , l_array_source_65
79719 , l_array_source_67
79720 , l_array_source_68
79721 , l_array_source_69
79722 , l_array_source_70
79723 , l_array_source_71
79724 LIMIT l_rows;
79725
79726 --
79727 IF (C_LEVEL_EVENT >= g_log_level) THEN
79728 trace
79729 (p_msg => '# rows extracted from line extract objects = '||TO_CHAR(line_cur%ROWCOUNT)
79730 ,p_level => C_LEVEL_EVENT
79731 ,p_module => l_log_module);
79732 END IF;
79733 --
79734 EXIT WHEN l_array_entity_id.count = 0;
79735
79736 XLA_AE_LINES_PKG.g_rec_lines := null;
79737
79738 --
79739 -- Bug 4458708
79740 --
79741 XLA_AE_LINES_PKG.g_LineNumber := 0;
79742 --
79743 --
79744
79745 FOR Idx IN 1..l_array_event_id.count LOOP
79746 --
79747 -- 5648433 (move l_event_id out of IF statement) set l_event_id to be used inside IF condition
79748 --
79749 l_event_id := l_array_event_id(idx); -- 5648433
79750
79751 --
79752 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
79753 --
79754
79755 IF NVL(xla_ae_header_pkg.g_rec_header_new.array_trx_acct_reversal_option
79756 (g_array_event(l_event_id).array_value_num('header_index'))
79757 ,'N'
79758 ) <> 'Y'
79759 THEN
79760 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
79761 trace
79762 (p_msg => 'Trancaction revesal option is not Y '
79763 ,p_level => C_LEVEL_STATEMENT
79764 ,p_module => l_log_module);
79765 END IF;
79766
79767 --
79768 -- set the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
79769 --
79770 XLA_AE_JOURNAL_ENTRY_PKG.g_global_status := XLA_AE_JOURNAL_ENTRY_PKG.C_VALID;
79771 --
79772 -- set event info as cache for other routines to refer event attributes
79773 --
79774
79775 IF l_event_id <> NVL(l_previous_event_id, -1) THEN
79776 l_previous_event_id := l_event_id;
79777
79778 XLA_AE_JOURNAL_ENTRY_PKG.set_event_info
79779 (p_application_id => p_application_id
79780 ,p_primary_ledger_id => p_primary_ledger_id
79781 ,p_base_ledger_id => p_base_ledger_id
79782 ,p_target_ledger_id => p_target_ledger_id
79783 ,p_entity_id => l_array_entity_id(Idx)
79784 ,p_legal_entity_id => l_array_legal_entity_id(Idx)
79785 ,p_entity_code => l_array_entity_code(Idx)
79786 ,p_transaction_num => l_array_transaction_num(Idx)
79787 ,p_event_id => l_array_event_id(Idx)
79788 ,p_event_class_code => l_array_class_code(Idx)
79789 ,p_event_type_code => l_array_event_type(Idx)
79790 ,p_event_number => l_array_event_number(Idx)
79791 ,p_event_date => l_array_event_date(Idx)
79792 ,p_transaction_date => l_array_transaction_date(Idx)
79793 ,p_reference_num_1 => l_array_reference_num_1(Idx)
79794 ,p_reference_num_2 => l_array_reference_num_2(Idx)
79795 ,p_reference_num_3 => l_array_reference_num_3(Idx)
79796 ,p_reference_num_4 => l_array_reference_num_4(Idx)
79797 ,p_reference_char_1 => l_array_reference_char_1(Idx)
79798 ,p_reference_char_2 => l_array_reference_char_2(Idx)
79799 ,p_reference_char_3 => l_array_reference_char_3(Idx)
79800 ,p_reference_char_4 => l_array_reference_char_4(Idx)
79801 ,p_reference_date_1 => l_array_reference_date_1(Idx)
79802 ,p_reference_date_2 => l_array_reference_date_2(Idx)
79803 ,p_reference_date_3 => l_array_reference_date_3(Idx)
79804 ,p_reference_date_4 => l_array_reference_date_4(Idx)
79805 ,p_event_created_by => l_array_event_created_by(Idx)
79806 ,p_budgetary_control_flag => l_array_budgetary_control_flag(Idx));
79807 --
79808 END IF;
79809
79810
79811
79812 --
79813 xla_ae_lines_pkg.SetExtractLine(p_extract_line => l_array_extract_line_num(Idx));
79814
79815 l_acct_reversal_source := SUBSTR(NULL, 1,30);
79816
79817 IF l_continue_with_lines THEN
79818 IF NVL(l_acct_reversal_source, 'N') NOT IN ('N','Y','B') THEN
79819 xla_ae_journal_entry_pkg.g_global_status := xla_ae_journal_entry_pkg.C_INVALID;
79820
79821 xla_accounting_err_pkg.build_message
79822 (p_appli_s_name => 'XLA'
79823 ,p_msg_name => 'XLA_AP_INVALID_REVERSAL_OPTION'
79824 ,p_token_1 => 'LINE_NUMBER'
79825 ,p_value_1 => l_array_extract_line_num(Idx)
79826 ,p_token_2 => 'PRODUCT_NAME'
79827 ,p_value_2 => xla_ae_journal_entry_pkg.g_cache_event.application_name
79828 ,p_entity_id => xla_ae_journal_entry_pkg.g_cache_event.entity_id
79829 ,p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
79830 ,p_ledger_id => xla_ae_journal_entry_pkg.g_cache_event.target_ledger_id);
79831
79832 ELSIF NVL(l_acct_reversal_source, 'N') IN ('Y','B') THEN
79833 --
79834 -- following sets the accounting attributes needed to reverse
79835 -- accounting for a distributeion
79836 --
79837
79838 --
79839 -- 5217187
79840 --
79841 l_rec_rev_acct_attrs.array_acct_attr_code(1):= 'GL_DATE';
79842 l_rec_rev_acct_attrs.array_date_value(1) := XLA_AE_HEADER_PKG.g_rec_header_new.array_gl_date(
79843 g_array_event(l_event_id).array_value_num('header_index'));
79844 --
79845 --
79846
79847 -- No reversal code generated
79848
79849 xla_ae_lines_pkg.SetAcctReversalAttrs
79850 (p_event_id => l_event_id
79851 ,p_rec_acct_attrs => l_rec_rev_acct_attrs
79852 ,p_calculate_acctd_flag => l_calculate_acctd_flag
79853 ,p_calculate_g_l_flag => l_calculate_g_l_flag);
79854 END IF;
79855
79856 IF NVL(l_acct_reversal_source, 'N') IN ('N','B') THEN
79857 l_actual_flag := NULL; l_actual_gain_loss_ref := '#####';
79858
79859 --
79860 AcctLineType_74 (
79861 p_application_id => p_application_id
79862 ,p_event_id => l_event_id
79863 ,p_calculate_acctd_flag => l_calculate_acctd_flag
79864 ,p_calculate_g_l_flag => l_calculate_g_l_flag
79865 ,p_actual_flag => l_actual_flag
79866 ,p_balance_type_code => l_balance_type_code
79867 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
79868
79869 , p_source_5 => l_array_source_5(Idx)
79870 , p_source_11 => l_array_source_11(Idx)
79871 , p_source_12 => l_array_source_12(Idx)
79872 , p_source_13 => l_array_source_13(Idx)
79873 , p_source_14 => l_array_source_14(Idx)
79874 , p_source_20 => l_array_source_20(Idx)
79875 , p_source_22 => l_array_source_22(Idx)
79876 , p_source_23 => l_array_source_23(Idx)
79877 , p_source_24 => l_array_source_24(Idx)
79878 , p_source_28 => l_array_source_28(Idx)
79879 , p_source_29 => l_array_source_29(Idx)
79880 , p_source_33 => l_array_source_33(Idx)
79881 , p_source_34 => l_array_source_34(Idx)
79882 , p_source_35 => l_array_source_35(Idx)
79883 , p_source_56 => l_array_source_56(Idx)
79884 , p_source_57 => l_array_source_57(Idx)
79885 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
79886 , p_source_59 => l_array_source_59(Idx)
79887 , p_source_60 => l_array_source_60(Idx)
79888 , p_source_61 => l_array_source_61(Idx)
79889 , p_source_62 => l_array_source_62(Idx)
79890 , p_source_63 => l_array_source_63(Idx)
79891 , p_source_64 => l_array_source_64(Idx)
79892 , p_source_65 => l_array_source_65(Idx)
79893 );
79894 If(l_balance_type_code = 'A') THEN
79895 l_actual_gain_loss_ref := l_gain_or_loss_ref;
79896 END IF;
79897
79898 --
79899
79900
79901 --
79902 AcctLineType_75 (
79903 p_application_id => p_application_id
79904 ,p_event_id => l_event_id
79905 ,p_calculate_acctd_flag => l_calculate_acctd_flag
79906 ,p_calculate_g_l_flag => l_calculate_g_l_flag
79907 ,p_actual_flag => l_actual_flag
79908 ,p_balance_type_code => l_balance_type_code
79909 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
79910
79911 , p_source_5 => l_array_source_5(Idx)
79912 , p_source_11 => l_array_source_11(Idx)
79913 , p_source_12 => l_array_source_12(Idx)
79914 , p_source_13 => l_array_source_13(Idx)
79915 , p_source_14 => l_array_source_14(Idx)
79916 , p_source_20 => l_array_source_20(Idx)
79917 , p_source_22 => l_array_source_22(Idx)
79918 , p_source_23 => l_array_source_23(Idx)
79919 , p_source_24 => l_array_source_24(Idx)
79920 , p_source_28 => l_array_source_28(Idx)
79921 , p_source_29 => l_array_source_29(Idx)
79922 , p_source_33 => l_array_source_33(Idx)
79923 , p_source_34 => l_array_source_34(Idx)
79924 , p_source_35 => l_array_source_35(Idx)
79925 , p_source_56 => l_array_source_56(Idx)
79926 , p_source_57 => l_array_source_57(Idx)
79927 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
79928 , p_source_59 => l_array_source_59(Idx)
79929 , p_source_60 => l_array_source_60(Idx)
79930 , p_source_61 => l_array_source_61(Idx)
79931 , p_source_62 => l_array_source_62(Idx)
79932 , p_source_63 => l_array_source_63(Idx)
79933 , p_source_64 => l_array_source_64(Idx)
79934 , p_source_65 => l_array_source_65(Idx)
79935 );
79936 If(l_balance_type_code = 'A') THEN
79937 l_actual_gain_loss_ref := l_gain_or_loss_ref;
79938 END IF;
79939
79940 --
79941
79942
79943 --
79944 AcctLineType_76 (
79945 p_application_id => p_application_id
79946 ,p_event_id => l_event_id
79947 ,p_calculate_acctd_flag => l_calculate_acctd_flag
79948 ,p_calculate_g_l_flag => l_calculate_g_l_flag
79949 ,p_actual_flag => l_actual_flag
79950 ,p_balance_type_code => l_balance_type_code
79951 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
79952
79953 , p_source_5 => l_array_source_5(Idx)
79954 , p_source_11 => l_array_source_11(Idx)
79955 , p_source_12 => l_array_source_12(Idx)
79956 , p_source_13 => l_array_source_13(Idx)
79957 , p_source_14 => l_array_source_14(Idx)
79958 , p_source_15 => l_array_source_15(Idx)
79959 , p_source_20 => l_array_source_20(Idx)
79960 , p_source_22 => l_array_source_22(Idx)
79961 , p_source_23 => l_array_source_23(Idx)
79962 , p_source_24 => l_array_source_24(Idx)
79963 , p_source_28 => l_array_source_28(Idx)
79964 , p_source_29 => l_array_source_29(Idx)
79965 , p_source_33 => l_array_source_33(Idx)
79966 , p_source_34 => l_array_source_34(Idx)
79967 , p_source_35 => l_array_source_35(Idx)
79968 , p_source_56 => l_array_source_56(Idx)
79969 , p_source_57 => l_array_source_57(Idx)
79970 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
79971 , p_source_59 => l_array_source_59(Idx)
79972 , p_source_60 => l_array_source_60(Idx)
79973 , p_source_61 => l_array_source_61(Idx)
79974 , p_source_62 => l_array_source_62(Idx)
79975 , p_source_63 => l_array_source_63(Idx)
79976 , p_source_64 => l_array_source_64(Idx)
79977 , p_source_65 => l_array_source_65(Idx)
79978 );
79979 If(l_balance_type_code = 'A') THEN
79980 l_actual_gain_loss_ref := l_gain_or_loss_ref;
79981 END IF;
79982
79983 --
79984
79985
79986 --
79987 AcctLineType_77 (
79988 p_application_id => p_application_id
79989 ,p_event_id => l_event_id
79990 ,p_calculate_acctd_flag => l_calculate_acctd_flag
79991 ,p_calculate_g_l_flag => l_calculate_g_l_flag
79992 ,p_actual_flag => l_actual_flag
79993 ,p_balance_type_code => l_balance_type_code
79994 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
79995
79996 , p_source_5 => l_array_source_5(Idx)
79997 , p_source_11 => l_array_source_11(Idx)
79998 , p_source_12 => l_array_source_12(Idx)
79999 , p_source_13 => l_array_source_13(Idx)
80000 , p_source_14 => l_array_source_14(Idx)
80001 , p_source_15 => l_array_source_15(Idx)
80002 , p_source_20 => l_array_source_20(Idx)
80003 , p_source_22 => l_array_source_22(Idx)
80004 , p_source_23 => l_array_source_23(Idx)
80005 , p_source_24 => l_array_source_24(Idx)
80006 , p_source_28 => l_array_source_28(Idx)
80007 , p_source_29 => l_array_source_29(Idx)
80008 , p_source_33 => l_array_source_33(Idx)
80009 , p_source_34 => l_array_source_34(Idx)
80010 , p_source_35 => l_array_source_35(Idx)
80011 , p_source_56 => l_array_source_56(Idx)
80012 , p_source_57 => l_array_source_57(Idx)
80013 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80014 , p_source_59 => l_array_source_59(Idx)
80015 , p_source_60 => l_array_source_60(Idx)
80016 , p_source_61 => l_array_source_61(Idx)
80017 , p_source_62 => l_array_source_62(Idx)
80018 , p_source_63 => l_array_source_63(Idx)
80019 , p_source_64 => l_array_source_64(Idx)
80020 , p_source_65 => l_array_source_65(Idx)
80021 );
80022 If(l_balance_type_code = 'A') THEN
80023 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80024 END IF;
80025
80026 --
80027
80028
80029 --
80030 AcctLineType_78 (
80031 p_application_id => p_application_id
80032 ,p_event_id => l_event_id
80033 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80034 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80035 ,p_actual_flag => l_actual_flag
80036 ,p_balance_type_code => l_balance_type_code
80037 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80038
80039 , p_source_5 => l_array_source_5(Idx)
80040 , p_source_11 => l_array_source_11(Idx)
80044 , p_source_20 => l_array_source_20(Idx)
80041 , p_source_12 => l_array_source_12(Idx)
80042 , p_source_13 => l_array_source_13(Idx)
80043 , p_source_14 => l_array_source_14(Idx)
80045 , p_source_22 => l_array_source_22(Idx)
80046 , p_source_23 => l_array_source_23(Idx)
80047 , p_source_24 => l_array_source_24(Idx)
80048 , p_source_28 => l_array_source_28(Idx)
80049 , p_source_29 => l_array_source_29(Idx)
80050 , p_source_33 => l_array_source_33(Idx)
80051 , p_source_34 => l_array_source_34(Idx)
80052 , p_source_35 => l_array_source_35(Idx)
80053 , p_source_56 => l_array_source_56(Idx)
80054 , p_source_57 => l_array_source_57(Idx)
80055 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80056 , p_source_59 => l_array_source_59(Idx)
80057 , p_source_60 => l_array_source_60(Idx)
80058 , p_source_61 => l_array_source_61(Idx)
80059 , p_source_62 => l_array_source_62(Idx)
80060 , p_source_63 => l_array_source_63(Idx)
80061 , p_source_64 => l_array_source_64(Idx)
80062 , p_source_65 => l_array_source_65(Idx)
80063 );
80064 If(l_balance_type_code = 'A') THEN
80065 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80066 END IF;
80067
80068 --
80069
80070
80071 --
80072 AcctLineType_79 (
80073 p_application_id => p_application_id
80074 ,p_event_id => l_event_id
80075 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80076 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80077 ,p_actual_flag => l_actual_flag
80078 ,p_balance_type_code => l_balance_type_code
80079 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80080
80081 , p_source_5 => l_array_source_5(Idx)
80082 , p_source_11 => l_array_source_11(Idx)
80083 , p_source_12 => l_array_source_12(Idx)
80084 , p_source_13 => l_array_source_13(Idx)
80085 , p_source_14 => l_array_source_14(Idx)
80086 , p_source_20 => l_array_source_20(Idx)
80087 , p_source_22 => l_array_source_22(Idx)
80088 , p_source_23 => l_array_source_23(Idx)
80089 , p_source_24 => l_array_source_24(Idx)
80090 , p_source_28 => l_array_source_28(Idx)
80091 , p_source_29 => l_array_source_29(Idx)
80092 , p_source_33 => l_array_source_33(Idx)
80093 , p_source_34 => l_array_source_34(Idx)
80094 , p_source_35 => l_array_source_35(Idx)
80095 , p_source_56 => l_array_source_56(Idx)
80096 , p_source_57 => l_array_source_57(Idx)
80097 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80098 , p_source_59 => l_array_source_59(Idx)
80099 , p_source_60 => l_array_source_60(Idx)
80100 , p_source_61 => l_array_source_61(Idx)
80101 , p_source_62 => l_array_source_62(Idx)
80102 , p_source_63 => l_array_source_63(Idx)
80103 , p_source_64 => l_array_source_64(Idx)
80104 , p_source_65 => l_array_source_65(Idx)
80105 );
80106 If(l_balance_type_code = 'A') THEN
80107 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80108 END IF;
80109
80110 --
80111
80112
80113 --
80114 AcctLineType_80 (
80115 p_application_id => p_application_id
80116 ,p_event_id => l_event_id
80117 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80118 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80119 ,p_actual_flag => l_actual_flag
80120 ,p_balance_type_code => l_balance_type_code
80121 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80122
80123 , p_source_5 => l_array_source_5(Idx)
80124 , p_source_10 => l_array_source_10(Idx)
80125 , p_source_11 => l_array_source_11(Idx)
80126 , p_source_20 => l_array_source_20(Idx)
80127 , p_source_22 => l_array_source_22(Idx)
80128 , p_source_23 => l_array_source_23(Idx)
80129 , p_source_24 => l_array_source_24(Idx)
80130 , p_source_26 => l_array_source_26(Idx)
80131 , p_source_27 => l_array_source_27(Idx)
80132 , p_source_28 => l_array_source_28(Idx)
80133 , p_source_29 => l_array_source_29(Idx)
80134 , p_source_33 => l_array_source_33(Idx)
80135 , p_source_34 => l_array_source_34(Idx)
80136 , p_source_35 => l_array_source_35(Idx)
80137 , p_source_56 => l_array_source_56(Idx)
80138 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80139 , p_source_59 => l_array_source_59(Idx)
80140 , p_source_60 => l_array_source_60(Idx)
80141 , p_source_61 => l_array_source_61(Idx)
80142 , p_source_63 => l_array_source_63(Idx)
80143 , p_source_64 => l_array_source_64(Idx)
80144 , p_source_65 => l_array_source_65(Idx)
80145 );
80146 If(l_balance_type_code = 'A') THEN
80147 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80148 END IF;
80149
80150 --
80151
80152
80153 --
80154 AcctLineType_81 (
80155 p_application_id => p_application_id
80156 ,p_event_id => l_event_id
80157 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80158 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80159 ,p_actual_flag => l_actual_flag
80160 ,p_balance_type_code => l_balance_type_code
80161 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80162
80163 , p_source_5 => l_array_source_5(Idx)
80164 , p_source_10 => l_array_source_10(Idx)
80165 , p_source_11 => l_array_source_11(Idx)
80166 , p_source_20 => l_array_source_20(Idx)
80167 , p_source_22 => l_array_source_22(Idx)
80168 , p_source_23 => l_array_source_23(Idx)
80169 , p_source_24 => l_array_source_24(Idx)
80170 , p_source_28 => l_array_source_28(Idx)
80171 , p_source_29 => l_array_source_29(Idx)
80172 , p_source_33 => l_array_source_33(Idx)
80173 , p_source_34 => l_array_source_34(Idx)
80174 , p_source_35 => l_array_source_35(Idx)
80175 , p_source_56 => l_array_source_56(Idx)
80176 , p_source_57 => l_array_source_57(Idx)
80177 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80178 , p_source_59 => l_array_source_59(Idx)
80179 , p_source_60 => l_array_source_60(Idx)
80180 , p_source_61 => l_array_source_61(Idx)
80181 , p_source_62 => l_array_source_62(Idx)
80182 , p_source_63 => l_array_source_63(Idx)
80183 , p_source_64 => l_array_source_64(Idx)
80184 , p_source_65 => l_array_source_65(Idx)
80185 );
80186 If(l_balance_type_code = 'A') THEN
80187 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80188 END IF;
80189
80190 --
80191
80192
80193 --
80194 AcctLineType_104 (
80195 p_application_id => p_application_id
80196 ,p_event_id => l_event_id
80197 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80198 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80199 ,p_actual_flag => l_actual_flag
80200 ,p_balance_type_code => l_balance_type_code
80201 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80202
80203 , p_source_5 => l_array_source_5(Idx)
80204 , p_source_20 => l_array_source_20(Idx)
80205 , p_source_22 => l_array_source_22(Idx)
80206 , p_source_23 => l_array_source_23(Idx)
80207 , p_source_26 => l_array_source_26(Idx)
80208 , p_source_27 => l_array_source_27(Idx)
80209 , p_source_28 => l_array_source_28(Idx)
80210 , p_source_34 => l_array_source_34(Idx)
80211 , p_source_35 => l_array_source_35(Idx)
80212 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80213 , p_source_59 => l_array_source_59(Idx)
80214 , p_source_60 => l_array_source_60(Idx)
80215 , p_source_61 => l_array_source_61(Idx)
80216 , p_source_63 => l_array_source_63(Idx)
80217 , p_source_64 => l_array_source_64(Idx)
80218 , p_source_65 => l_array_source_65(Idx)
80219 , p_source_67 => l_array_source_67(Idx)
80220 , p_source_68 => l_array_source_68(Idx)
80221 , p_source_69 => l_array_source_69(Idx)
80222 );
80223 If(l_balance_type_code = 'A') THEN
80224 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80225 END IF;
80226
80227 --
80228
80229
80230 --
80231 AcctLineType_105 (
80232 p_application_id => p_application_id
80233 ,p_event_id => l_event_id
80234 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80235 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80236 ,p_actual_flag => l_actual_flag
80237 ,p_balance_type_code => l_balance_type_code
80238 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80239
80240 , p_source_5 => l_array_source_5(Idx)
80241 , p_source_20 => l_array_source_20(Idx)
80242 , p_source_22 => l_array_source_22(Idx)
80243 , p_source_23 => l_array_source_23(Idx)
80244 , p_source_26 => l_array_source_26(Idx)
80245 , p_source_27 => l_array_source_27(Idx)
80246 , p_source_28 => l_array_source_28(Idx)
80247 , p_source_34 => l_array_source_34(Idx)
80248 , p_source_35 => l_array_source_35(Idx)
80249 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80250 , p_source_59 => l_array_source_59(Idx)
80251 , p_source_60 => l_array_source_60(Idx)
80252 , p_source_61 => l_array_source_61(Idx)
80253 , p_source_63 => l_array_source_63(Idx)
80254 , p_source_64 => l_array_source_64(Idx)
80255 , p_source_65 => l_array_source_65(Idx)
80256 , p_source_67 => l_array_source_67(Idx)
80257 , p_source_68 => l_array_source_68(Idx)
80258 , p_source_69 => l_array_source_69(Idx)
80259 );
80260 If(l_balance_type_code = 'A') THEN
80261 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80262 END IF;
80263
80264 --
80265
80266
80267 --
80268 AcctLineType_106 (
80269 p_application_id => p_application_id
80270 ,p_event_id => l_event_id
80271 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80272 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80273 ,p_actual_flag => l_actual_flag
80274 ,p_balance_type_code => l_balance_type_code
80275 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80276
80277 , p_source_5 => l_array_source_5(Idx)
80278 , p_source_20 => l_array_source_20(Idx)
80279 , p_source_22 => l_array_source_22(Idx)
80280 , p_source_23 => l_array_source_23(Idx)
80281 , p_source_26 => l_array_source_26(Idx)
80282 , p_source_27 => l_array_source_27(Idx)
80283 , p_source_28 => l_array_source_28(Idx)
80284 , p_source_34 => l_array_source_34(Idx)
80285 , p_source_35 => l_array_source_35(Idx)
80286 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80287 , p_source_59 => l_array_source_59(Idx)
80288 , p_source_60 => l_array_source_60(Idx)
80289 , p_source_61 => l_array_source_61(Idx)
80290 , p_source_63 => l_array_source_63(Idx)
80291 , p_source_64 => l_array_source_64(Idx)
80292 , p_source_65 => l_array_source_65(Idx)
80293 , p_source_67 => l_array_source_67(Idx)
80294 , p_source_68 => l_array_source_68(Idx)
80295 , p_source_69 => l_array_source_69(Idx)
80299 END IF;
80296 );
80297 If(l_balance_type_code = 'A') THEN
80298 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80300
80301 --
80302
80303
80304 --
80305 AcctLineType_107 (
80306 p_application_id => p_application_id
80307 ,p_event_id => l_event_id
80308 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80309 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80310 ,p_actual_flag => l_actual_flag
80311 ,p_balance_type_code => l_balance_type_code
80312 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80313
80314 , p_source_5 => l_array_source_5(Idx)
80315 , p_source_20 => l_array_source_20(Idx)
80316 , p_source_21 => l_array_source_21(Idx)
80317 , p_source_22 => l_array_source_22(Idx)
80318 , p_source_23 => l_array_source_23(Idx)
80319 , p_source_26 => l_array_source_26(Idx)
80320 , p_source_27 => l_array_source_27(Idx)
80321 , p_source_34 => l_array_source_34(Idx)
80322 , p_source_35 => l_array_source_35(Idx)
80323 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80324 , p_source_59 => l_array_source_59(Idx)
80325 , p_source_60 => l_array_source_60(Idx)
80326 , p_source_61 => l_array_source_61(Idx)
80327 , p_source_63 => l_array_source_63(Idx)
80328 , p_source_64 => l_array_source_64(Idx)
80329 , p_source_65 => l_array_source_65(Idx)
80330 , p_source_67 => l_array_source_67(Idx)
80331 , p_source_68 => l_array_source_68(Idx)
80332 , p_source_69 => l_array_source_69(Idx)
80333 , p_source_70 => l_array_source_70(Idx)
80334 );
80335 If(l_balance_type_code = 'A') THEN
80336 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80337 END IF;
80338
80339 --
80340
80341
80342 --
80343 AcctLineType_108 (
80344 p_application_id => p_application_id
80345 ,p_event_id => l_event_id
80346 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80347 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80348 ,p_actual_flag => l_actual_flag
80349 ,p_balance_type_code => l_balance_type_code
80350 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80351
80352 , p_source_5 => l_array_source_5(Idx)
80353 , p_source_20 => l_array_source_20(Idx)
80354 , p_source_21 => l_array_source_21(Idx)
80355 , p_source_22 => l_array_source_22(Idx)
80356 , p_source_23 => l_array_source_23(Idx)
80357 , p_source_26 => l_array_source_26(Idx)
80358 , p_source_27 => l_array_source_27(Idx)
80362 , p_source_59 => l_array_source_59(Idx)
80359 , p_source_34 => l_array_source_34(Idx)
80360 , p_source_35 => l_array_source_35(Idx)
80361 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80363 , p_source_60 => l_array_source_60(Idx)
80364 , p_source_61 => l_array_source_61(Idx)
80365 , p_source_63 => l_array_source_63(Idx)
80366 , p_source_64 => l_array_source_64(Idx)
80367 , p_source_65 => l_array_source_65(Idx)
80368 , p_source_67 => l_array_source_67(Idx)
80369 , p_source_68 => l_array_source_68(Idx)
80370 , p_source_69 => l_array_source_69(Idx)
80371 , p_source_70 => l_array_source_70(Idx)
80372 );
80373 If(l_balance_type_code = 'A') THEN
80374 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80375 END IF;
80376
80377 --
80378
80379
80380 --
80381 AcctLineType_109 (
80382 p_application_id => p_application_id
80383 ,p_event_id => l_event_id
80384 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80385 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80386 ,p_actual_flag => l_actual_flag
80387 ,p_balance_type_code => l_balance_type_code
80388 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80389
80390 , p_source_5 => l_array_source_5(Idx)
80391 , p_source_20 => l_array_source_20(Idx)
80392 , p_source_21 => l_array_source_21(Idx)
80393 , p_source_22 => l_array_source_22(Idx)
80394 , p_source_23 => l_array_source_23(Idx)
80395 , p_source_26 => l_array_source_26(Idx)
80396 , p_source_27 => l_array_source_27(Idx)
80397 , p_source_34 => l_array_source_34(Idx)
80398 , p_source_35 => l_array_source_35(Idx)
80399 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80400 , p_source_59 => l_array_source_59(Idx)
80401 , p_source_60 => l_array_source_60(Idx)
80402 , p_source_61 => l_array_source_61(Idx)
80403 , p_source_63 => l_array_source_63(Idx)
80404 , p_source_64 => l_array_source_64(Idx)
80405 , p_source_65 => l_array_source_65(Idx)
80406 , p_source_67 => l_array_source_67(Idx)
80407 , p_source_68 => l_array_source_68(Idx)
80408 , p_source_69 => l_array_source_69(Idx)
80409 , p_source_70 => l_array_source_70(Idx)
80410 );
80411 If(l_balance_type_code = 'A') THEN
80412 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80413 END IF;
80414
80415 --
80416
80417
80418 --
80419 AcctLineType_110 (
80420 p_application_id => p_application_id
80421 ,p_event_id => l_event_id
80422 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80423 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80424 ,p_actual_flag => l_actual_flag
80425 ,p_balance_type_code => l_balance_type_code
80426 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80427
80428 , p_source_5 => l_array_source_5(Idx)
80429 , p_source_20 => l_array_source_20(Idx)
80430 , p_source_22 => l_array_source_22(Idx)
80431 , p_source_23 => l_array_source_23(Idx)
80432 , p_source_26 => l_array_source_26(Idx)
80433 , p_source_27 => l_array_source_27(Idx)
80434 , p_source_28 => l_array_source_28(Idx)
80435 , p_source_34 => l_array_source_34(Idx)
80436 , p_source_35 => l_array_source_35(Idx)
80437 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80438 , p_source_59 => l_array_source_59(Idx)
80439 , p_source_60 => l_array_source_60(Idx)
80440 , p_source_61 => l_array_source_61(Idx)
80441 , p_source_63 => l_array_source_63(Idx)
80442 , p_source_64 => l_array_source_64(Idx)
80443 , p_source_65 => l_array_source_65(Idx)
80444 , p_source_67 => l_array_source_67(Idx)
80445 , p_source_68 => l_array_source_68(Idx)
80446 , p_source_69 => l_array_source_69(Idx)
80447 );
80448 If(l_balance_type_code = 'A') THEN
80449 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80450 END IF;
80451
80452 --
80453
80454
80455 --
80456 AcctLineType_111 (
80457 p_application_id => p_application_id
80458 ,p_event_id => l_event_id
80459 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80460 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80461 ,p_actual_flag => l_actual_flag
80462 ,p_balance_type_code => l_balance_type_code
80463 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80464
80465 , p_source_5 => l_array_source_5(Idx)
80466 , p_source_20 => l_array_source_20(Idx)
80467 , p_source_22 => l_array_source_22(Idx)
80468 , p_source_23 => l_array_source_23(Idx)
80469 , p_source_26 => l_array_source_26(Idx)
80470 , p_source_27 => l_array_source_27(Idx)
80471 , p_source_28 => l_array_source_28(Idx)
80472 , p_source_34 => l_array_source_34(Idx)
80473 , p_source_35 => l_array_source_35(Idx)
80474 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80475 , p_source_59 => l_array_source_59(Idx)
80476 , p_source_60 => l_array_source_60(Idx)
80477 , p_source_61 => l_array_source_61(Idx)
80478 , p_source_63 => l_array_source_63(Idx)
80479 , p_source_64 => l_array_source_64(Idx)
80480 , p_source_65 => l_array_source_65(Idx)
80481 , p_source_67 => l_array_source_67(Idx)
80482 , p_source_68 => l_array_source_68(Idx)
80483 , p_source_69 => l_array_source_69(Idx)
80484 );
80485 If(l_balance_type_code = 'A') THEN
80486 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80487 END IF;
80488
80489 --
80490
80491
80492 --
80493 AcctLineType_112 (
80494 p_application_id => p_application_id
80495 ,p_event_id => l_event_id
80496 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80497 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80498 ,p_actual_flag => l_actual_flag
80499 ,p_balance_type_code => l_balance_type_code
80500 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80501
80502 , p_source_5 => l_array_source_5(Idx)
80503 , p_source_20 => l_array_source_20(Idx)
80504 , p_source_22 => l_array_source_22(Idx)
80505 , p_source_23 => l_array_source_23(Idx)
80506 , p_source_26 => l_array_source_26(Idx)
80507 , p_source_27 => l_array_source_27(Idx)
80508 , p_source_28 => l_array_source_28(Idx)
80509 , p_source_34 => l_array_source_34(Idx)
80510 , p_source_35 => l_array_source_35(Idx)
80511 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80512 , p_source_59 => l_array_source_59(Idx)
80513 , p_source_60 => l_array_source_60(Idx)
80514 , p_source_61 => l_array_source_61(Idx)
80515 , p_source_63 => l_array_source_63(Idx)
80516 , p_source_64 => l_array_source_64(Idx)
80517 , p_source_65 => l_array_source_65(Idx)
80518 , p_source_67 => l_array_source_67(Idx)
80519 , p_source_68 => l_array_source_68(Idx)
80520 , p_source_69 => l_array_source_69(Idx)
80521 );
80522 If(l_balance_type_code = 'A') THEN
80523 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80524 END IF;
80525
80526 --
80527
80528
80529 --
80530 AcctLineType_113 (
80531 p_application_id => p_application_id
80532 ,p_event_id => l_event_id
80533 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80534 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80535 ,p_actual_flag => l_actual_flag
80536 ,p_balance_type_code => l_balance_type_code
80537 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80538
80539 , p_source_1 => l_array_source_1(Idx)
80540 , p_source_2 => l_array_source_2(Idx)
80541 , p_source_3 => l_array_source_3(Idx)
80542 , p_source_5 => l_array_source_5(Idx)
80543 , p_source_20 => l_array_source_20(Idx)
80544 , p_source_22 => l_array_source_22(Idx)
80545 , p_source_23 => l_array_source_23(Idx)
80546 , p_source_24 => l_array_source_24(Idx)
80547 , p_source_25 => l_array_source_25(Idx)
80548 , p_source_29 => l_array_source_29(Idx)
80549 , p_source_34 => l_array_source_34(Idx)
80550 , p_source_35 => l_array_source_35(Idx)
80551 , p_source_57 => l_array_source_57(Idx)
80552 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80553 , p_source_59 => l_array_source_59(Idx)
80554 , p_source_60 => l_array_source_60(Idx)
80555 , p_source_62 => l_array_source_62(Idx)
80556 , p_source_63 => l_array_source_63(Idx)
80557 , p_source_64 => l_array_source_64(Idx)
80558 , p_source_65 => l_array_source_65(Idx)
80559 , p_source_67 => l_array_source_67(Idx)
80560 , p_source_70 => l_array_source_70(Idx)
80561 );
80562 If(l_balance_type_code = 'A') THEN
80563 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80564 END IF;
80565
80566 --
80567
80568
80569 --
80570 AcctLineType_114 (
80571 p_application_id => p_application_id
80572 ,p_event_id => l_event_id
80573 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80574 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80575 ,p_actual_flag => l_actual_flag
80576 ,p_balance_type_code => l_balance_type_code
80577 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80578
80579 , p_source_5 => l_array_source_5(Idx)
80580 , p_source_20 => l_array_source_20(Idx)
80581 , p_source_22 => l_array_source_22(Idx)
80582 , p_source_23 => l_array_source_23(Idx)
80583 , p_source_24 => l_array_source_24(Idx)
80584 , p_source_25 => l_array_source_25(Idx)
80585 , p_source_29 => l_array_source_29(Idx)
80586 , p_source_34 => l_array_source_34(Idx)
80587 , p_source_35 => l_array_source_35(Idx)
80588 , p_source_57 => l_array_source_57(Idx)
80589 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80590 , p_source_59 => l_array_source_59(Idx)
80591 , p_source_60 => l_array_source_60(Idx)
80592 , p_source_62 => l_array_source_62(Idx)
80593 , p_source_63 => l_array_source_63(Idx)
80594 , p_source_64 => l_array_source_64(Idx)
80595 , p_source_65 => l_array_source_65(Idx)
80596 , p_source_67 => l_array_source_67(Idx)
80597 , p_source_70 => l_array_source_70(Idx)
80598 );
80599 If(l_balance_type_code = 'A') THEN
80600 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80601 END IF;
80602
80603 --
80604
80605
80606 --
80607 AcctLineType_115 (
80608 p_application_id => p_application_id
80609 ,p_event_id => l_event_id
80610 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80611 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80612 ,p_actual_flag => l_actual_flag
80613 ,p_balance_type_code => l_balance_type_code
80614 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80615
80616 , p_source_5 => l_array_source_5(Idx)
80617 , p_source_20 => l_array_source_20(Idx)
80618 , p_source_22 => l_array_source_22(Idx)
80619 , p_source_23 => l_array_source_23(Idx)
80620 , p_source_24 => l_array_source_24(Idx)
80621 , p_source_25 => l_array_source_25(Idx)
80622 , p_source_29 => l_array_source_29(Idx)
80623 , p_source_34 => l_array_source_34(Idx)
80624 , p_source_35 => l_array_source_35(Idx)
80625 , p_source_57 => l_array_source_57(Idx)
80626 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80627 , p_source_59 => l_array_source_59(Idx)
80628 , p_source_60 => l_array_source_60(Idx)
80629 , p_source_62 => l_array_source_62(Idx)
80630 , p_source_63 => l_array_source_63(Idx)
80631 , p_source_64 => l_array_source_64(Idx)
80632 , p_source_65 => l_array_source_65(Idx)
80633 , p_source_67 => l_array_source_67(Idx)
80634 , p_source_70 => l_array_source_70(Idx)
80635 );
80636 If(l_balance_type_code = 'A') THEN
80637 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80638 END IF;
80639
80640 --
80641
80642
80643 --
80644 AcctLineType_116 (
80645 p_application_id => p_application_id
80646 ,p_event_id => l_event_id
80647 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80648 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80649 ,p_actual_flag => l_actual_flag
80650 ,p_balance_type_code => l_balance_type_code
80651 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80652
80653 , p_source_5 => l_array_source_5(Idx)
80654 , p_source_20 => l_array_source_20(Idx)
80655 , p_source_22 => l_array_source_22(Idx)
80656 , p_source_23 => l_array_source_23(Idx)
80657 , p_source_24 => l_array_source_24(Idx)
80658 , p_source_25 => l_array_source_25(Idx)
80659 , p_source_29 => l_array_source_29(Idx)
80660 , p_source_34 => l_array_source_34(Idx)
80661 , p_source_35 => l_array_source_35(Idx)
80662 , p_source_57 => l_array_source_57(Idx)
80663 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80664 , p_source_59 => l_array_source_59(Idx)
80665 , p_source_60 => l_array_source_60(Idx)
80666 , p_source_62 => l_array_source_62(Idx)
80667 , p_source_63 => l_array_source_63(Idx)
80668 , p_source_64 => l_array_source_64(Idx)
80669 , p_source_65 => l_array_source_65(Idx)
80670 , p_source_67 => l_array_source_67(Idx)
80671 , p_source_70 => l_array_source_70(Idx)
80672 );
80673 If(l_balance_type_code = 'A') THEN
80674 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80675 END IF;
80676
80677 --
80678
80679
80680 --
80681 AcctLineType_117 (
80682 p_application_id => p_application_id
80683 ,p_event_id => l_event_id
80684 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80685 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80686 ,p_actual_flag => l_actual_flag
80687 ,p_balance_type_code => l_balance_type_code
80688 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80689
80690 , p_source_6 => l_array_source_6(Idx)
80691 , p_source_7 => g_array_event(l_event_id).array_value_num('source_7')
80692 , p_source_8 => g_array_event(l_event_id).array_value_num('source_8')
80693 , p_source_22 => l_array_source_22(Idx)
80694 , p_source_23 => l_array_source_23(Idx)
80695 , p_source_63 => l_array_source_63(Idx)
80696 , p_source_64 => l_array_source_64(Idx)
80697 , p_source_65 => l_array_source_65(Idx)
80698 , p_source_69 => l_array_source_69(Idx)
80699 );
80700 If(l_balance_type_code = 'A') THEN
80701 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80702 END IF;
80703
80704 --
80705
80706
80707 --
80708 AcctLineType_118 (
80709 p_application_id => p_application_id
80710 ,p_event_id => l_event_id
80711 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80712 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80713 ,p_actual_flag => l_actual_flag
80714 ,p_balance_type_code => l_balance_type_code
80715 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80716
80717 , p_source_5 => l_array_source_5(Idx)
80718 , p_source_20 => l_array_source_20(Idx)
80719 , p_source_22 => l_array_source_22(Idx)
80720 , p_source_23 => l_array_source_23(Idx)
80721 , p_source_26 => l_array_source_26(Idx)
80722 , p_source_27 => l_array_source_27(Idx)
80723 , p_source_28 => l_array_source_28(Idx)
80724 , p_source_34 => l_array_source_34(Idx)
80725 , p_source_35 => l_array_source_35(Idx)
80726 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80727 , p_source_59 => l_array_source_59(Idx)
80728 , p_source_60 => l_array_source_60(Idx)
80729 , p_source_61 => l_array_source_61(Idx)
80730 , p_source_63 => l_array_source_63(Idx)
80731 , p_source_64 => l_array_source_64(Idx)
80732 , p_source_65 => l_array_source_65(Idx)
80733 , p_source_67 => l_array_source_67(Idx)
80734 , p_source_68 => l_array_source_68(Idx)
80735 , p_source_69 => l_array_source_69(Idx)
80736 , p_source_71 => l_array_source_71(Idx)
80737 );
80738 If(l_balance_type_code = 'A') THEN
80739 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80740 END IF;
80741
80742 --
80743
80744
80745 --
80746 AcctLineType_119 (
80747 p_application_id => p_application_id
80748 ,p_event_id => l_event_id
80749 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80750 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80751 ,p_actual_flag => l_actual_flag
80752 ,p_balance_type_code => l_balance_type_code
80753 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80754
80755 , p_source_5 => l_array_source_5(Idx)
80756 , p_source_20 => l_array_source_20(Idx)
80757 , p_source_22 => l_array_source_22(Idx)
80758 , p_source_23 => l_array_source_23(Idx)
80759 , p_source_26 => l_array_source_26(Idx)
80760 , p_source_27 => l_array_source_27(Idx)
80761 , p_source_28 => l_array_source_28(Idx)
80762 , p_source_34 => l_array_source_34(Idx)
80763 , p_source_35 => l_array_source_35(Idx)
80764 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80765 , p_source_59 => l_array_source_59(Idx)
80766 , p_source_60 => l_array_source_60(Idx)
80767 , p_source_61 => l_array_source_61(Idx)
80768 , p_source_63 => l_array_source_63(Idx)
80769 , p_source_64 => l_array_source_64(Idx)
80770 , p_source_65 => l_array_source_65(Idx)
80771 , p_source_67 => l_array_source_67(Idx)
80772 , p_source_68 => l_array_source_68(Idx)
80773 , p_source_69 => l_array_source_69(Idx)
80774 , p_source_71 => l_array_source_71(Idx)
80775 );
80776 If(l_balance_type_code = 'A') THEN
80777 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80778 END IF;
80779
80780 --
80781
80782
80783 --
80784 AcctLineType_120 (
80785 p_application_id => p_application_id
80786 ,p_event_id => l_event_id
80787 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80788 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80789 ,p_actual_flag => l_actual_flag
80790 ,p_balance_type_code => l_balance_type_code
80791 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80792
80793 , p_source_5 => l_array_source_5(Idx)
80794 , p_source_20 => l_array_source_20(Idx)
80795 , p_source_21 => l_array_source_21(Idx)
80796 , p_source_22 => l_array_source_22(Idx)
80797 , p_source_23 => l_array_source_23(Idx)
80798 , p_source_26 => l_array_source_26(Idx)
80799 , p_source_27 => l_array_source_27(Idx)
80800 , p_source_28 => l_array_source_28(Idx)
80801 , p_source_29 => l_array_source_29(Idx)
80802 , p_source_34 => l_array_source_34(Idx)
80803 , p_source_35 => l_array_source_35(Idx)
80804 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80805 , p_source_59 => l_array_source_59(Idx)
80806 , p_source_60 => l_array_source_60(Idx)
80807 , p_source_61 => l_array_source_61(Idx)
80808 , p_source_63 => l_array_source_63(Idx)
80809 , p_source_64 => l_array_source_64(Idx)
80810 , p_source_65 => l_array_source_65(Idx)
80811 , p_source_67 => l_array_source_67(Idx)
80812 , p_source_68 => l_array_source_68(Idx)
80813 );
80814 If(l_balance_type_code = 'A') THEN
80815 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80816 END IF;
80817
80818 --
80819
80820
80821 --
80822 AcctLineType_121 (
80823 p_application_id => p_application_id
80824 ,p_event_id => l_event_id
80825 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80826 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80827 ,p_actual_flag => l_actual_flag
80828 ,p_balance_type_code => l_balance_type_code
80829 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80830
80831 , p_source_5 => l_array_source_5(Idx)
80832 , p_source_20 => l_array_source_20(Idx)
80833 , p_source_21 => l_array_source_21(Idx)
80834 , p_source_22 => l_array_source_22(Idx)
80835 , p_source_23 => l_array_source_23(Idx)
80836 , p_source_26 => l_array_source_26(Idx)
80837 , p_source_27 => l_array_source_27(Idx)
80838 , p_source_28 => l_array_source_28(Idx)
80839 , p_source_34 => l_array_source_34(Idx)
80840 , p_source_35 => l_array_source_35(Idx)
80841 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80842 , p_source_59 => l_array_source_59(Idx)
80843 , p_source_60 => l_array_source_60(Idx)
80844 , p_source_61 => l_array_source_61(Idx)
80845 , p_source_63 => l_array_source_63(Idx)
80846 , p_source_64 => l_array_source_64(Idx)
80847 , p_source_65 => l_array_source_65(Idx)
80848 , p_source_67 => l_array_source_67(Idx)
80849 , p_source_68 => l_array_source_68(Idx)
80850 , p_source_69 => l_array_source_69(Idx)
80851 );
80852 If(l_balance_type_code = 'A') THEN
80853 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80854 END IF;
80855
80856 --
80857
80858
80859 --
80860 AcctLineType_122 (
80861 p_application_id => p_application_id
80862 ,p_event_id => l_event_id
80863 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80864 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80865 ,p_actual_flag => l_actual_flag
80866 ,p_balance_type_code => l_balance_type_code
80867 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80868
80869 , p_source_5 => l_array_source_5(Idx)
80870 , p_source_20 => l_array_source_20(Idx)
80871 , p_source_21 => l_array_source_21(Idx)
80872 , p_source_22 => l_array_source_22(Idx)
80873 , p_source_23 => l_array_source_23(Idx)
80874 , p_source_26 => l_array_source_26(Idx)
80875 , p_source_27 => l_array_source_27(Idx)
80876 , p_source_28 => l_array_source_28(Idx)
80877 , p_source_34 => l_array_source_34(Idx)
80878 , p_source_35 => l_array_source_35(Idx)
80879 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80880 , p_source_59 => l_array_source_59(Idx)
80881 , p_source_60 => l_array_source_60(Idx)
80882 , p_source_61 => l_array_source_61(Idx)
80883 , p_source_63 => l_array_source_63(Idx)
80884 , p_source_64 => l_array_source_64(Idx)
80885 , p_source_65 => l_array_source_65(Idx)
80886 , p_source_67 => l_array_source_67(Idx)
80887 , p_source_68 => l_array_source_68(Idx)
80888 , p_source_69 => l_array_source_69(Idx)
80889 );
80890 If(l_balance_type_code = 'A') THEN
80891 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80892 END IF;
80893
80894 --
80895
80896
80897 --
80898 AcctLineType_123 (
80899 p_application_id => p_application_id
80900 ,p_event_id => l_event_id
80901 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80902 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80903 ,p_actual_flag => l_actual_flag
80904 ,p_balance_type_code => l_balance_type_code
80905 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80906
80907 , p_source_5 => l_array_source_5(Idx)
80908 , p_source_20 => l_array_source_20(Idx)
80909 , p_source_22 => l_array_source_22(Idx)
80910 , p_source_23 => l_array_source_23(Idx)
80911 , p_source_26 => l_array_source_26(Idx)
80912 , p_source_27 => l_array_source_27(Idx)
80913 , p_source_28 => l_array_source_28(Idx)
80914 , p_source_34 => l_array_source_34(Idx)
80915 , p_source_35 => l_array_source_35(Idx)
80916 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80917 , p_source_59 => l_array_source_59(Idx)
80918 , p_source_60 => l_array_source_60(Idx)
80919 , p_source_61 => l_array_source_61(Idx)
80920 , p_source_63 => l_array_source_63(Idx)
80921 , p_source_64 => l_array_source_64(Idx)
80922 , p_source_65 => l_array_source_65(Idx)
80923 , p_source_67 => l_array_source_67(Idx)
80924 , p_source_68 => l_array_source_68(Idx)
80925 , p_source_69 => l_array_source_69(Idx)
80926 , p_source_71 => l_array_source_71(Idx)
80927 );
80928 If(l_balance_type_code = 'A') THEN
80929 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80930 END IF;
80931
80932 --
80933
80934
80935 --
80936 AcctLineType_124 (
80937 p_application_id => p_application_id
80938 ,p_event_id => l_event_id
80939 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80940 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80941 ,p_actual_flag => l_actual_flag
80942 ,p_balance_type_code => l_balance_type_code
80943 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80944
80945 , p_source_5 => l_array_source_5(Idx)
80946 , p_source_20 => l_array_source_20(Idx)
80947 , p_source_22 => l_array_source_22(Idx)
80948 , p_source_23 => l_array_source_23(Idx)
80949 , p_source_26 => l_array_source_26(Idx)
80950 , p_source_27 => l_array_source_27(Idx)
80951 , p_source_28 => l_array_source_28(Idx)
80952 , p_source_34 => l_array_source_34(Idx)
80953 , p_source_35 => l_array_source_35(Idx)
80954 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80955 , p_source_59 => l_array_source_59(Idx)
80956 , p_source_60 => l_array_source_60(Idx)
80957 , p_source_61 => l_array_source_61(Idx)
80958 , p_source_63 => l_array_source_63(Idx)
80959 , p_source_64 => l_array_source_64(Idx)
80960 , p_source_65 => l_array_source_65(Idx)
80961 , p_source_67 => l_array_source_67(Idx)
80962 , p_source_68 => l_array_source_68(Idx)
80963 , p_source_69 => l_array_source_69(Idx)
80964 , p_source_71 => l_array_source_71(Idx)
80965 );
80966 If(l_balance_type_code = 'A') THEN
80967 l_actual_gain_loss_ref := l_gain_or_loss_ref;
80968 END IF;
80969
80970 --
80971
80972
80973 --
80974 AcctLineType_125 (
80975 p_application_id => p_application_id
80976 ,p_event_id => l_event_id
80977 ,p_calculate_acctd_flag => l_calculate_acctd_flag
80978 ,p_calculate_g_l_flag => l_calculate_g_l_flag
80979 ,p_actual_flag => l_actual_flag
80980 ,p_balance_type_code => l_balance_type_code
80981 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
80982
80983 , p_source_5 => l_array_source_5(Idx)
80984 , p_source_20 => l_array_source_20(Idx)
80985 , p_source_22 => l_array_source_22(Idx)
80986 , p_source_23 => l_array_source_23(Idx)
80987 , p_source_24 => l_array_source_24(Idx)
80988 , p_source_25 => l_array_source_25(Idx)
80989 , p_source_29 => l_array_source_29(Idx)
80990 , p_source_34 => l_array_source_34(Idx)
80991 , p_source_35 => l_array_source_35(Idx)
80992 , p_source_57 => l_array_source_57(Idx)
80993 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
80994 , p_source_59 => l_array_source_59(Idx)
80995 , p_source_60 => l_array_source_60(Idx)
80996 , p_source_62 => l_array_source_62(Idx)
80997 , p_source_63 => l_array_source_63(Idx)
80998 , p_source_64 => l_array_source_64(Idx)
80999 , p_source_65 => l_array_source_65(Idx)
81000 , p_source_67 => l_array_source_67(Idx)
81001 , p_source_70 => l_array_source_70(Idx)
81002 );
81003 If(l_balance_type_code = 'A') THEN
81004 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81005 END IF;
81006
81007 --
81008
81009
81010 --
81011 AcctLineType_126 (
81012 p_application_id => p_application_id
81013 ,p_event_id => l_event_id
81014 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81015 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81016 ,p_actual_flag => l_actual_flag
81017 ,p_balance_type_code => l_balance_type_code
81018 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81019
81020 , p_source_17 => g_array_event(l_event_id).array_value_num('source_17')
81021 , p_source_20 => l_array_source_20(Idx)
81022 , p_source_21 => l_array_source_21(Idx)
81023 , p_source_22 => l_array_source_22(Idx)
81024 , p_source_23 => l_array_source_23(Idx)
81025 , p_source_26 => l_array_source_26(Idx)
81026 , p_source_27 => l_array_source_27(Idx)
81027 , p_source_28 => l_array_source_28(Idx)
81028 , p_source_34 => l_array_source_34(Idx)
81029 , p_source_35 => l_array_source_35(Idx)
81030 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
81031 , p_source_59 => l_array_source_59(Idx)
81032 , p_source_60 => l_array_source_60(Idx)
81033 , p_source_61 => l_array_source_61(Idx)
81034 , p_source_65 => l_array_source_65(Idx)
81035 , p_source_67 => l_array_source_67(Idx)
81036 , p_source_68 => l_array_source_68(Idx)
81037 , p_source_69 => l_array_source_69(Idx)
81038 , p_source_71 => l_array_source_71(Idx)
81039 , p_source_72 => g_array_event(l_event_id).array_value_num('source_72')
81040 , p_source_73 => g_array_event(l_event_id).array_value_num('source_73')
81041 );
81042 If(l_balance_type_code = 'A') THEN
81043 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81044 END IF;
81045
81046 --
81047
81048
81049 --
81050 AcctLineType_127 (
81051 p_application_id => p_application_id
81052 ,p_event_id => l_event_id
81053 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81054 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81055 ,p_actual_flag => l_actual_flag
81056 ,p_balance_type_code => l_balance_type_code
81057 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81058
81059 , p_source_17 => g_array_event(l_event_id).array_value_num('source_17')
81060 , p_source_20 => l_array_source_20(Idx)
81061 , p_source_22 => l_array_source_22(Idx)
81062 , p_source_23 => l_array_source_23(Idx)
81063 , p_source_26 => l_array_source_26(Idx)
81064 , p_source_27 => l_array_source_27(Idx)
81065 , p_source_28 => l_array_source_28(Idx)
81066 , p_source_34 => l_array_source_34(Idx)
81067 , p_source_35 => l_array_source_35(Idx)
81068 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
81069 , p_source_59 => l_array_source_59(Idx)
81070 , p_source_60 => l_array_source_60(Idx)
81071 , p_source_61 => l_array_source_61(Idx)
81072 , p_source_65 => l_array_source_65(Idx)
81073 , p_source_67 => l_array_source_67(Idx)
81074 , p_source_68 => l_array_source_68(Idx)
81075 , p_source_69 => l_array_source_69(Idx)
81076 , p_source_71 => l_array_source_71(Idx)
81077 , p_source_72 => g_array_event(l_event_id).array_value_num('source_72')
81078 , p_source_73 => g_array_event(l_event_id).array_value_num('source_73')
81079 , p_source_74 => g_array_event(l_event_id).array_value_char('source_74')
81080 );
81081 If(l_balance_type_code = 'A') THEN
81082 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81083 END IF;
81084
81085 --
81086
81087
81088 --
81089 AcctLineType_128 (
81090 p_application_id => p_application_id
81091 ,p_event_id => l_event_id
81092 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81093 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81094 ,p_actual_flag => l_actual_flag
81095 ,p_balance_type_code => l_balance_type_code
81096 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81097
81098 , p_source_17 => g_array_event(l_event_id).array_value_num('source_17')
81099 , p_source_20 => l_array_source_20(Idx)
81100 , p_source_22 => l_array_source_22(Idx)
81101 , p_source_23 => l_array_source_23(Idx)
81105 , p_source_27 => l_array_source_27(Idx)
81102 , p_source_24 => l_array_source_24(Idx)
81103 , p_source_25 => l_array_source_25(Idx)
81104 , p_source_26 => l_array_source_26(Idx)
81106 , p_source_28 => l_array_source_28(Idx)
81107 , p_source_34 => l_array_source_34(Idx)
81108 , p_source_35 => l_array_source_35(Idx)
81109 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
81110 , p_source_59 => l_array_source_59(Idx)
81111 , p_source_60 => l_array_source_60(Idx)
81112 , p_source_65 => l_array_source_65(Idx)
81113 , p_source_67 => l_array_source_67(Idx)
81114 , p_source_69 => l_array_source_69(Idx)
81115 , p_source_71 => l_array_source_71(Idx)
81116 , p_source_74 => g_array_event(l_event_id).array_value_char('source_74')
81117 , p_source_75 => g_array_event(l_event_id).array_value_num('source_75')
81118 , p_source_76 => g_array_event(l_event_id).array_value_num('source_76')
81119 );
81120 If(l_balance_type_code = 'A') THEN
81121 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81122 END IF;
81123
81124 --
81125
81126
81127 --
81128 AcctLineType_129 (
81129 p_application_id => p_application_id
81130 ,p_event_id => l_event_id
81131 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81132 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81133 ,p_actual_flag => l_actual_flag
81134 ,p_balance_type_code => l_balance_type_code
81135 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81136
81137 , p_source_5 => l_array_source_5(Idx)
81138 , p_source_20 => l_array_source_20(Idx)
81139 , p_source_22 => l_array_source_22(Idx)
81140 , p_source_23 => l_array_source_23(Idx)
81141 , p_source_24 => l_array_source_24(Idx)
81142 , p_source_25 => l_array_source_25(Idx)
81143 , p_source_29 => l_array_source_29(Idx)
81144 , p_source_34 => l_array_source_34(Idx)
81145 , p_source_35 => l_array_source_35(Idx)
81146 , p_source_57 => l_array_source_57(Idx)
81147 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
81148 , p_source_59 => l_array_source_59(Idx)
81149 , p_source_60 => l_array_source_60(Idx)
81150 , p_source_62 => l_array_source_62(Idx)
81151 , p_source_63 => l_array_source_63(Idx)
81152 , p_source_64 => l_array_source_64(Idx)
81153 , p_source_65 => l_array_source_65(Idx)
81154 , p_source_67 => l_array_source_67(Idx)
81155 , p_source_70 => l_array_source_70(Idx)
81156 );
81157 If(l_balance_type_code = 'A') THEN
81158 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81159 END IF;
81160
81161 --
81162
81163
81164 --
81165 AcctLineType_130 (
81166 p_application_id => p_application_id
81167 ,p_event_id => l_event_id
81168 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81169 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81170 ,p_actual_flag => l_actual_flag
81171 ,p_balance_type_code => l_balance_type_code
81172 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81173
81174 , p_source_5 => l_array_source_5(Idx)
81175 , p_source_20 => l_array_source_20(Idx)
81176 , p_source_22 => l_array_source_22(Idx)
81177 , p_source_23 => l_array_source_23(Idx)
81178 , p_source_24 => l_array_source_24(Idx)
81179 , p_source_25 => l_array_source_25(Idx)
81180 , p_source_29 => l_array_source_29(Idx)
81181 , p_source_34 => l_array_source_34(Idx)
81182 , p_source_35 => l_array_source_35(Idx)
81183 , p_source_57 => l_array_source_57(Idx)
81184 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
81185 , p_source_59 => l_array_source_59(Idx)
81186 , p_source_60 => l_array_source_60(Idx)
81187 , p_source_62 => l_array_source_62(Idx)
81188 , p_source_63 => l_array_source_63(Idx)
81189 , p_source_64 => l_array_source_64(Idx)
81190 , p_source_65 => l_array_source_65(Idx)
81191 , p_source_67 => l_array_source_67(Idx)
81192 , p_source_70 => l_array_source_70(Idx)
81193 );
81194 If(l_balance_type_code = 'A') THEN
81195 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81196 END IF;
81197
81198 --
81199
81200
81201 --
81202 AcctLineType_131 (
81203 p_application_id => p_application_id
81204 ,p_event_id => l_event_id
81205 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81206 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81207 ,p_actual_flag => l_actual_flag
81208 ,p_balance_type_code => l_balance_type_code
81209 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81210
81211 , p_source_5 => l_array_source_5(Idx)
81212 , p_source_20 => l_array_source_20(Idx)
81213 , p_source_22 => l_array_source_22(Idx)
81214 , p_source_23 => l_array_source_23(Idx)
81215 , p_source_26 => l_array_source_26(Idx)
81216 , p_source_27 => l_array_source_27(Idx)
81217 , p_source_28 => l_array_source_28(Idx)
81218 , p_source_34 => l_array_source_34(Idx)
81219 , p_source_35 => l_array_source_35(Idx)
81220 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
81221 , p_source_59 => l_array_source_59(Idx)
81222 , p_source_60 => l_array_source_60(Idx)
81223 , p_source_61 => l_array_source_61(Idx)
81224 , p_source_63 => l_array_source_63(Idx)
81225 , p_source_64 => l_array_source_64(Idx)
81226 , p_source_65 => l_array_source_65(Idx)
81227 , p_source_67 => l_array_source_67(Idx)
81228 , p_source_68 => l_array_source_68(Idx)
81229 , p_source_69 => l_array_source_69(Idx)
81230 );
81231 If(l_balance_type_code = 'A') THEN
81232 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81233 END IF;
81234
81235 --
81236
81237
81238 --
81239 AcctLineType_132 (
81240 p_application_id => p_application_id
81241 ,p_event_id => l_event_id
81242 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81243 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81247
81244 ,p_actual_flag => l_actual_flag
81245 ,p_balance_type_code => l_balance_type_code
81246 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81248 , p_source_18 => g_array_event(l_event_id).array_value_num('source_18')
81249 , p_source_20 => l_array_source_20(Idx)
81250 , p_source_22 => l_array_source_22(Idx)
81251 , p_source_23 => l_array_source_23(Idx)
81252 , p_source_24 => l_array_source_24(Idx)
81253 , p_source_25 => l_array_source_25(Idx)
81254 , p_source_26 => l_array_source_26(Idx)
81255 , p_source_27 => l_array_source_27(Idx)
81256 , p_source_28 => l_array_source_28(Idx)
81257 , p_source_34 => l_array_source_34(Idx)
81258 , p_source_35 => l_array_source_35(Idx)
81259 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
81260 , p_source_59 => l_array_source_59(Idx)
81261 , p_source_60 => l_array_source_60(Idx)
81262 , p_source_63 => l_array_source_63(Idx)
81263 , p_source_64 => l_array_source_64(Idx)
81264 , p_source_65 => l_array_source_65(Idx)
81265 , p_source_67 => l_array_source_67(Idx)
81266 , p_source_69 => l_array_source_69(Idx)
81267 , p_source_71 => l_array_source_71(Idx)
81268 , p_source_74 => g_array_event(l_event_id).array_value_char('source_74')
81269 , p_source_75 => g_array_event(l_event_id).array_value_num('source_75')
81270 , p_source_76 => g_array_event(l_event_id).array_value_num('source_76')
81271 );
81272 If(l_balance_type_code = 'A') THEN
81273 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81274 END IF;
81275
81276 --
81277
81278
81279 --
81280 AcctLineType_133 (
81281 p_application_id => p_application_id
81282 ,p_event_id => l_event_id
81283 ,p_calculate_acctd_flag => l_calculate_acctd_flag
81284 ,p_calculate_g_l_flag => l_calculate_g_l_flag
81285 ,p_actual_flag => l_actual_flag
81286 ,p_balance_type_code => l_balance_type_code
81287 ,p_gain_or_loss_ref=> l_gain_or_loss_ref
81288
81289 , p_source_5 => l_array_source_5(Idx)
81290 , p_source_20 => l_array_source_20(Idx)
81291 , p_source_21 => l_array_source_21(Idx)
81292 , p_source_22 => l_array_source_22(Idx)
81293 , p_source_23 => l_array_source_23(Idx)
81294 , p_source_26 => l_array_source_26(Idx)
81295 , p_source_27 => l_array_source_27(Idx)
81296 , p_source_28 => l_array_source_28(Idx)
81297 , p_source_34 => l_array_source_34(Idx)
81298 , p_source_35 => l_array_source_35(Idx)
81299 , p_source_58 => g_array_event(l_event_id).array_value_num('source_58')
81300 , p_source_59 => l_array_source_59(Idx)
81301 , p_source_60 => l_array_source_60(Idx)
81302 , p_source_61 => l_array_source_61(Idx)
81303 , p_source_63 => l_array_source_63(Idx)
81304 , p_source_64 => l_array_source_64(Idx)
81305 , p_source_65 => l_array_source_65(Idx)
81306 , p_source_67 => l_array_source_67(Idx)
81307 , p_source_68 => l_array_source_68(Idx)
81308 , p_source_69 => l_array_source_69(Idx)
81309 );
81310 If(l_balance_type_code = 'A') THEN
81311 l_actual_gain_loss_ref := l_gain_or_loss_ref;
81312 END IF;
81313
81314 --
81315
81316 -- only execute it if calculate g/l flag is yes, and primary or secondary ledger
81317 -- or secondary ledger that has different currency with primary
81318 -- or alc that is calculated by sla
81319 IF (((l_calculate_g_l_flag = 'Y' AND XLA_AE_JOURNAL_ENTRY_PKG.g_cache_ledgers_info.ledger_category_code <> 'ALC') or
81320 (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'))
81321
81322 -- IF((l_calculate_g_l_flag='Y' or XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.target_ledger_id <>
81323 -- XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.ledger_id)
81324 AND (l_actual_flag = 'A')) THEN
81325 XLA_AE_LINES_PKG.CreateGainOrLossLines(
81326 p_event_id => xla_ae_journal_entry_pkg.g_cache_event.event_id
81327 ,p_application_id => p_application_id
81328 ,p_amb_context_code => 'DEFAULT'
81329 ,p_entity_code => xla_ae_journal_entry_pkg.g_cache_event.entity_code
81330 ,p_event_class_code => C_EVENT_CLASS_CODE
81331 ,p_event_type_code => C_EVENT_TYPE_CODE
81332
81333 ,p_gain_ccid => TO_NUMBER(g_array_event(l_event_id).array_value_num('source_7'))
81334 ,p_loss_ccid => TO_NUMBER(g_array_event(l_event_id).array_value_num('source_8'))
81335
81336 ,p_actual_flag => l_actual_flag
81337 ,p_enc_flag => null
81338 ,p_actual_g_l_ref => l_actual_gain_loss_ref
81339 ,p_enc_g_l_ref => null
81340 );
81341 END IF;
81342 END IF;
81343 END IF;
81344
81345 ELSE
81346 --
81347 -- Bug 4872078 - Do nothing if the event is meant for transaction reversal
81348 --
81349 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81350 trace
81351 (p_msg => 'Trancaction revesal option is Y'
81352 ,p_level => C_LEVEL_STATEMENT
81353 ,p_module => l_log_module);
81354 END IF;
81355 END IF;
81356
81357 END LOOP;
81358 l_result := XLA_AE_LINES_PKG.InsertLines ;
81359 end loop;
81360 close line_cur;
81361
81362
81363 --
81364 -- insert headers into xla_ae_headers_gt table
81365 --
81366 l_result := XLA_AE_HEADER_PKG.InsertHeaders ;
81367
81368 -- insert into errors table here.
81369
81370 END LOOP;
81371
81372 --
81373 -- 4865292
81374 --
81375 -- Compare g_hdr_extract_count with event count in
81376 -- CreateHeadersAndLines.
81377 --
81378 g_hdr_extract_count := g_hdr_extract_count + header_cur%ROWCOUNT;
81379
81380 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81384 ,p_level => C_LEVEL_STATEMENT
81381 trace (p_msg => '# rows extracted from header extract objects '
81382 || ' (running total): '
81383 || g_hdr_extract_count
81385 ,p_module => l_log_module);
81386 END IF;
81387
81388 CLOSE header_cur;
81389 --
81390
81391 --
81392 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
81393 trace
81394 (p_msg => 'END of EventClass_142'
81395 ,p_level => C_LEVEL_PROCEDURE
81396 ,p_module => l_log_module);
81397 END IF;
81398 --
81399 RETURN l_result;
81400 EXCEPTION
81401 WHEN xla_exceptions_pkg.application_exception THEN
81402
81403 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
81404
81405
81406 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
81407
81408 RAISE;
81409
81410 WHEN NO_DATA_FOUND THEN
81411
81412 IF header_cur%ISOPEN THEN CLOSE header_cur; END IF;
81413 IF line_cur%ISOPEN THEN CLOSE line_cur; END IF;
81414
81415 FOR header_record IN header_cur
81416 LOOP
81417 l_array_header_events(header_record.event_id) := header_record.event_id;
81418 END LOOP;
81419
81420 l_first_event_id := l_array_header_events(l_array_header_events.FIRST);
81421 l_last_event_id := l_array_header_events(l_array_header_events.LAST);
81422
81423 fnd_file.put_line(fnd_file.LOG, ' ');
81424 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
81425 fnd_file.put_line(fnd_file.LOG, 'EVENT CLASS CODE = ' || C_EVENT_CLASS_CODE );
81426 fnd_file.put_line(fnd_file.LOG, 'The following events are present in the line extract but MISSING in the header extract: ');
81427
81428 FOR line_record IN line_cur(l_first_event_id, l_last_event_id)
81429 LOOP
81430 IF (NOT l_array_header_events.EXISTS(line_record.event_id)) AND (NOT l_array_duplicate_checker.EXISTS(line_record.event_id)) THEN
81431 fnd_file.put_line(fnd_file.log, 'Event_id = ' || line_record.event_id);
81432 l_array_duplicate_checker(line_record.event_id) := line_record.event_id;
81433 END IF;
81434 END LOOP;
81435
81436 fnd_file.put_line(fnd_file.LOG, '***************************************************************************');
81437 fnd_file.put_line(fnd_file.LOG, ' ');
81438
81439
81440 xla_exceptions_pkg.raise_message
81441 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_142');
81442
81443
81444 WHEN OTHERS THEN
81445 xla_exceptions_pkg.raise_message
81446 (p_location => 'XLA_00222_AAD_S_000005_PKG.EventClass_142');
81447 END EventClass_142;
81448 --
81449
81450 --
81451 --+============================================+
81452 --| |
81453 --| PRIVATE FUNCTION |
81454 --| |
81455 --+============================================+
81456 --
81457 FUNCTION CreateHeadersAndLines
81458 (p_application_id IN NUMBER
81459 ,p_base_ledger_id IN NUMBER
81460 ,p_target_ledger_id IN NUMBER
81461 ,p_pad_start_date IN DATE
81462 ,p_pad_end_date IN DATE
81463 ,p_primary_ledger_id IN NUMBER)
81464 RETURN BOOLEAN IS
81465 l_created BOOLEAN:=FALSE;
81466 l_event_id NUMBER;
81467 l_event_date DATE;
81468 l_language VARCHAR2(30);
81469 l_currency_code VARCHAR2(30);
81470 l_sla_ledger_id NUMBER;
81471 l_log_module VARCHAR2(240);
81472
81473 BEGIN
81474 --
81475 IF g_log_enabled THEN
81476 l_log_module := C_DEFAULT_MODULE||'.CreateHeadersAndLines';
81477 END IF;
81478 --
81479 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
81480 trace
81481 (p_msg => 'BEGIN of CreateHeadersAndLines'
81482 ,p_level => C_LEVEL_PROCEDURE
81483 ,p_module => l_log_module);
81484 END IF;
81485
81486 l_language := xla_ae_journal_entry_pkg.g_cache_ledgers_info.description_language;
81487 l_currency_code := xla_ae_journal_entry_pkg.g_cache_ledgers_info.currency_code;
81488 l_sla_ledger_id := xla_ae_journal_entry_pkg.g_cache_ledgers_info.sla_ledger_id;
81489
81490 --
81491 -- initialize array of lines with NULL
81492 --
81493 xla_ae_lines_pkg.SetNullLine;
81494
81495 --
81496 -- initialize header extract count -- Bug 4865292
81497 --
81498 g_hdr_extract_count:= 0;
81499
81500
81501 l_created := EventClass_134(
81502 p_application_id => p_application_id
81503 , p_base_ledger_id => p_base_ledger_id
81504 , p_target_ledger_id => p_target_ledger_id
81505 , p_language => l_language
81506 , p_currency_code => l_currency_code
81507 , p_sla_ledger_id => l_sla_ledger_id
81508 , p_pad_start_date => p_pad_start_date
81509 , p_pad_end_date => p_pad_end_date
81510 , p_primary_ledger_id => p_primary_ledger_id
81511 );
81512
81513
81514
81515 IF ( g_diagnostics_mode ='Y' ) THEN
81516
81517 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81518 trace
81519 (p_msg => 'CALL Transaction Objects Diagnostics'
81520 ,p_level => C_LEVEL_STATEMENT
81521 ,p_module => l_log_module);
81522
81523 END IF;
81524
81525 insert_sources_134(
81526 p_target_ledger_id => p_target_ledger_id
81527 , p_language => l_language
81531 );
81528 , p_sla_ledger_id => l_sla_ledger_id
81529 , p_pad_start_date => p_pad_start_date
81530 , p_pad_end_date => p_pad_end_date
81532
81533 END IF;
81534
81535 l_created := EventClass_135(
81536 p_application_id => p_application_id
81537 , p_base_ledger_id => p_base_ledger_id
81538 , p_target_ledger_id => p_target_ledger_id
81539 , p_language => l_language
81540 , p_currency_code => l_currency_code
81541 , p_sla_ledger_id => l_sla_ledger_id
81542 , p_pad_start_date => p_pad_start_date
81543 , p_pad_end_date => p_pad_end_date
81544 , p_primary_ledger_id => p_primary_ledger_id
81545 );
81546
81547
81548
81549 IF ( g_diagnostics_mode ='Y' ) THEN
81550
81551 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81552 trace
81553 (p_msg => 'CALL Transaction Objects Diagnostics'
81554 ,p_level => C_LEVEL_STATEMENT
81555 ,p_module => l_log_module);
81556
81557 END IF;
81558
81559 insert_sources_135(
81560 p_target_ledger_id => p_target_ledger_id
81561 , p_language => l_language
81562 , p_sla_ledger_id => l_sla_ledger_id
81563 , p_pad_start_date => p_pad_start_date
81564 , p_pad_end_date => p_pad_end_date
81565 );
81566
81567 END IF;
81568
81569 l_created := EventClass_136(
81570 p_application_id => p_application_id
81571 , p_base_ledger_id => p_base_ledger_id
81572 , p_target_ledger_id => p_target_ledger_id
81573 , p_language => l_language
81574 , p_currency_code => l_currency_code
81575 , p_sla_ledger_id => l_sla_ledger_id
81576 , p_pad_start_date => p_pad_start_date
81577 , p_pad_end_date => p_pad_end_date
81578 , p_primary_ledger_id => p_primary_ledger_id
81579 );
81580
81581
81582
81583 IF ( g_diagnostics_mode ='Y' ) THEN
81584
81585 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81586 trace
81587 (p_msg => 'CALL Transaction Objects Diagnostics'
81588 ,p_level => C_LEVEL_STATEMENT
81589 ,p_module => l_log_module);
81590
81591 END IF;
81592
81593 insert_sources_136(
81594 p_target_ledger_id => p_target_ledger_id
81595 , p_language => l_language
81596 , p_sla_ledger_id => l_sla_ledger_id
81597 , p_pad_start_date => p_pad_start_date
81598 , p_pad_end_date => p_pad_end_date
81599 );
81600
81601 END IF;
81602
81603 l_created := EventClass_137(
81604 p_application_id => p_application_id
81605 , p_base_ledger_id => p_base_ledger_id
81606 , p_target_ledger_id => p_target_ledger_id
81607 , p_language => l_language
81608 , p_currency_code => l_currency_code
81609 , p_sla_ledger_id => l_sla_ledger_id
81610 , p_pad_start_date => p_pad_start_date
81611 , p_pad_end_date => p_pad_end_date
81612 , p_primary_ledger_id => p_primary_ledger_id
81613 );
81614
81615
81616
81617 IF ( g_diagnostics_mode ='Y' ) THEN
81618
81619 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81620 trace
81621 (p_msg => 'CALL Transaction Objects Diagnostics'
81622 ,p_level => C_LEVEL_STATEMENT
81623 ,p_module => l_log_module);
81624
81625 END IF;
81626
81627 insert_sources_137(
81628 p_target_ledger_id => p_target_ledger_id
81629 , p_language => l_language
81630 , p_sla_ledger_id => l_sla_ledger_id
81631 , p_pad_start_date => p_pad_start_date
81632 , p_pad_end_date => p_pad_end_date
81633 );
81634
81635 END IF;
81636
81637 l_created := EventClass_138(
81638 p_application_id => p_application_id
81639 , p_base_ledger_id => p_base_ledger_id
81640 , p_target_ledger_id => p_target_ledger_id
81641 , p_language => l_language
81642 , p_currency_code => l_currency_code
81643 , p_sla_ledger_id => l_sla_ledger_id
81644 , p_pad_start_date => p_pad_start_date
81645 , p_pad_end_date => p_pad_end_date
81646 , p_primary_ledger_id => p_primary_ledger_id
81647 );
81648
81649
81650
81651 IF ( g_diagnostics_mode ='Y' ) THEN
81652
81653 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81654 trace
81655 (p_msg => 'CALL Transaction Objects Diagnostics'
81656 ,p_level => C_LEVEL_STATEMENT
81657 ,p_module => l_log_module);
81658
81659 END IF;
81660
81661 insert_sources_138(
81662 p_target_ledger_id => p_target_ledger_id
81663 , p_language => l_language
81664 , p_sla_ledger_id => l_sla_ledger_id
81665 , p_pad_start_date => p_pad_start_date
81666 , p_pad_end_date => p_pad_end_date
81670
81667 );
81668
81669 END IF;
81671 l_created := EventClass_139(
81672 p_application_id => p_application_id
81673 , p_base_ledger_id => p_base_ledger_id
81674 , p_target_ledger_id => p_target_ledger_id
81675 , p_language => l_language
81676 , p_currency_code => l_currency_code
81677 , p_sla_ledger_id => l_sla_ledger_id
81678 , p_pad_start_date => p_pad_start_date
81679 , p_pad_end_date => p_pad_end_date
81680 , p_primary_ledger_id => p_primary_ledger_id
81681 );
81682
81683
81684
81685 IF ( g_diagnostics_mode ='Y' ) THEN
81686
81687 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81688 trace
81689 (p_msg => 'CALL Transaction Objects Diagnostics'
81690 ,p_level => C_LEVEL_STATEMENT
81691 ,p_module => l_log_module);
81692
81693 END IF;
81694
81695 insert_sources_139(
81696 p_target_ledger_id => p_target_ledger_id
81697 , p_language => l_language
81698 , p_sla_ledger_id => l_sla_ledger_id
81699 , p_pad_start_date => p_pad_start_date
81700 , p_pad_end_date => p_pad_end_date
81701 );
81702
81703 END IF;
81704
81705 l_created := EventClass_140(
81706 p_application_id => p_application_id
81707 , p_base_ledger_id => p_base_ledger_id
81708 , p_target_ledger_id => p_target_ledger_id
81709 , p_language => l_language
81710 , p_currency_code => l_currency_code
81711 , p_sla_ledger_id => l_sla_ledger_id
81712 , p_pad_start_date => p_pad_start_date
81713 , p_pad_end_date => p_pad_end_date
81714 , p_primary_ledger_id => p_primary_ledger_id
81715 );
81716
81717
81718
81719 IF ( g_diagnostics_mode ='Y' ) THEN
81720
81721 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81722 trace
81723 (p_msg => 'CALL Transaction Objects Diagnostics'
81724 ,p_level => C_LEVEL_STATEMENT
81725 ,p_module => l_log_module);
81726
81727 END IF;
81728
81729 insert_sources_140(
81730 p_target_ledger_id => p_target_ledger_id
81731 , p_language => l_language
81732 , p_sla_ledger_id => l_sla_ledger_id
81733 , p_pad_start_date => p_pad_start_date
81734 , p_pad_end_date => p_pad_end_date
81735 );
81736
81737 END IF;
81738
81739 l_created := EventClass_141(
81740 p_application_id => p_application_id
81741 , p_base_ledger_id => p_base_ledger_id
81742 , p_target_ledger_id => p_target_ledger_id
81743 , p_language => l_language
81744 , p_currency_code => l_currency_code
81745 , p_sla_ledger_id => l_sla_ledger_id
81746 , p_pad_start_date => p_pad_start_date
81747 , p_pad_end_date => p_pad_end_date
81748 , p_primary_ledger_id => p_primary_ledger_id
81749 );
81750
81751
81752
81753 IF ( g_diagnostics_mode ='Y' ) THEN
81754
81755 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81756 trace
81757 (p_msg => 'CALL Transaction Objects Diagnostics'
81758 ,p_level => C_LEVEL_STATEMENT
81759 ,p_module => l_log_module);
81760
81761 END IF;
81762
81763 insert_sources_141(
81764 p_target_ledger_id => p_target_ledger_id
81765 , p_language => l_language
81766 , p_sla_ledger_id => l_sla_ledger_id
81767 , p_pad_start_date => p_pad_start_date
81768 , p_pad_end_date => p_pad_end_date
81769 );
81770
81771 END IF;
81772
81773 l_created := EventClass_142(
81774 p_application_id => p_application_id
81775 , p_base_ledger_id => p_base_ledger_id
81776 , p_target_ledger_id => p_target_ledger_id
81777 , p_language => l_language
81778 , p_currency_code => l_currency_code
81779 , p_sla_ledger_id => l_sla_ledger_id
81780 , p_pad_start_date => p_pad_start_date
81781 , p_pad_end_date => p_pad_end_date
81782 , p_primary_ledger_id => p_primary_ledger_id
81783 );
81784
81785
81786
81787 IF ( g_diagnostics_mode ='Y' ) THEN
81788
81789 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81790 trace
81791 (p_msg => 'CALL Transaction Objects Diagnostics'
81792 ,p_level => C_LEVEL_STATEMENT
81793 ,p_module => l_log_module);
81794
81795 END IF;
81796
81797 insert_sources_142(
81798 p_target_ledger_id => p_target_ledger_id
81799 , p_language => l_language
81800 , p_sla_ledger_id => l_sla_ledger_id
81801 , p_pad_start_date => p_pad_start_date
81802 , p_pad_end_date => p_pad_end_date
81803 );
81804
81805 END IF;
81806
81807
81808 --
81809 -- Bug 4865292
81810 -- When the number of events and that of header extract do not match,
81811 -- set the no header extract flag to indicate there are some issues
81812 -- in header extract.
81816 -- to report it as a general error.
81813 --
81814 -- Event count context is set in xla_accounting_pkg.unit_processor.
81815 -- Build_Message for this error is called in xla_accounting_pkg.post_accounting
81817 --
81818 IF xla_context_pkg.get_event_count_context <> g_hdr_extract_count
81819 AND xla_context_pkg.get_event_nohdr_context <> 'Y' THEN
81820
81821 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81822 trace
81823 (p_msg => '# of extracted headers and events does not match'
81824 ,p_level => C_LEVEL_STATEMENT
81825 ,p_module => l_log_module);
81826
81827 trace
81828 (p_msg => '# of extracted headers: '
81829 ||g_hdr_extract_count
81830 ,p_level => C_LEVEL_STATEMENT
81831 ,p_module => l_log_module);
81832
81833 trace
81834 (p_msg => '# of events in xla_events_gt: '
81835 ||xla_context_pkg.get_event_count_context
81836 ,p_level => C_LEVEL_STATEMENT
81837 ,p_module => l_log_module);
81838
81839 trace
81840 (p_msg => 'Event No Header Extract Context: '
81841 ||xla_context_pkg.get_event_nohdr_context
81842 ,p_level => C_LEVEL_STATEMENT
81843 ,p_module => l_log_module);
81844
81845 END IF;
81846
81847
81848 xla_context_pkg.set_event_nohdr_context
81849 (p_nohdr_extract_flag => 'Y'
81850 ,p_client_id => sys_context('USERENV','CLIENT_IDENTIFIER'));
81851
81852 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81853 trace
81854 (p_msg => 'No Header Extract Flag is set to Y'
81855 ,p_level => C_LEVEL_STATEMENT
81856 ,p_module => l_log_module);
81857 END IF;
81858
81859 END IF;
81860
81861 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
81862 trace
81863 (p_msg => 'END of CreateHeadersAndLines'
81864 ,p_level => C_LEVEL_PROCEDURE
81865 ,p_module => l_log_module);
81866 END IF;
81867
81868 RETURN l_created;
81869 EXCEPTION
81870 WHEN xla_exceptions_pkg.application_exception THEN
81871 RAISE;
81872 WHEN OTHERS THEN
81873 xla_exceptions_pkg.raise_message
81874 (p_location => 'XLA_00222_AAD_S_000005_PKG.CreateHeadersAndLines');
81875 END CreateHeadersAndLines;
81876 --
81877 --
81878
81879 --
81880 --+============================================+
81881 --| |
81882 --| PUBLIC FUNCTION |
81883 --| |
81884 --+============================================+
81885 --
81886 FUNCTION CreateJournalEntries
81887 (p_application_id IN NUMBER
81888 ,p_base_ledger_id IN NUMBER
81889 ,p_pad_start_date IN DATE
81890 ,p_pad_end_date IN DATE
81891 ,p_primary_ledger_id IN NUMBER)
81892 RETURN NUMBER IS
81893 l_log_module VARCHAR2(240);
81894 l_array_ledgers xla_accounting_cache_pkg.t_array_ledger_id;
81895 l_temp_result BOOLEAN;
81896 l_result NUMBER;
81897 BEGIN
81898 --
81899 IF g_log_enabled THEN
81900 l_log_module := C_DEFAULT_MODULE||'.CreateJournalEntries';
81901 END IF;
81902 --
81903 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
81904 trace
81905 (p_msg => 'BEGIN of CreateJournalEntries'||
81906 ' - p_base_ledger_id = '||TO_CHAR(p_base_ledger_id)
81907 ,p_level => C_LEVEL_PROCEDURE
81908 ,p_module => l_log_module);
81909
81910 END IF;
81911
81912 --
81913 g_diagnostics_mode:= xla_accounting_engine_pkg.g_diagnostics_mode;
81914
81915 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
81916 trace
81917 (p_msg => 'g_diagnostics_mode = '||g_diagnostics_mode
81918 ,p_level => C_LEVEL_STATEMENT
81919 ,p_module => l_log_module);
81920 END IF;
81921 --
81922 xla_ae_journal_entry_pkg.SetProductAcctDefinition
81923 (p_product_rule_code => 'FEDERAL_AR_ACCRUAL'
81924 ,p_product_rule_type_code => 'S'
81925 ,p_product_rule_version => ''
81926 ,p_product_rule_name => 'Federal Receivables Accrual'
81927 ,p_amb_context_code => 'DEFAULT'
81928 );
81929
81930 l_array_ledgers :=
81931 xla_ae_journal_entry_pkg.GetAlternateCurrencyLedger
81932 (p_base_ledger_id => p_base_ledger_id);
81933
81934 FOR Idx IN 1 .. l_array_ledgers.COUNT LOOP
81935 l_temp_result :=
81936 XLA_AE_JOURNAL_ENTRY_PKG.GetLedgersInfo
81937 (p_application_id => p_application_id
81938 ,p_base_ledger_id => p_base_ledger_id
81939 ,p_target_ledger_id => l_array_ledgers(Idx)
81940 ,p_primary_ledger_id => p_primary_ledger_id
81941 ,p_pad_start_date => p_pad_start_date
81942 ,p_pad_end_date => p_pad_end_date);
81943
81944 l_temp_result :=
81945 l_temp_result AND
81946 CreateHeadersAndLines
81947 (p_application_id => p_application_id
81948 ,p_base_ledger_id => p_base_ledger_id
81949 ,p_target_ledger_id => l_array_ledgers(Idx)
81950 ,p_pad_start_date => p_pad_start_date
81951 ,p_pad_end_date => p_pad_end_date
81952 ,p_primary_ledger_id => p_primary_ledger_id
81953 );
81954 END LOOP;
81955
81956
81957 IF (g_diagnostics_mode = 'Y' AND
81958 C_LEVEL_UNEXPECTED >= g_log_level AND
81959 xla_environment_pkg.g_Req_Id IS NOT NULL ) THEN
81960
81961 xla_accounting_dump_pkg.acctg_event_extract_log(
81962 p_application_id => p_application_id
81963 ,p_request_id => xla_environment_pkg.g_Req_Id
81964 );
81965
81966 END IF;
81967
81968 CASE l_temp_result
81969 WHEN TRUE THEN l_result := 0;
81970 ELSE l_result := 2;
81971 END CASE;
81972
81973 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
81974 trace
81975 (p_msg => 'return value. = '||TO_CHAR(l_result)
81976 ,p_level => C_LEVEL_PROCEDURE
81977 ,p_module => l_log_module);
81978 trace
81979 (p_msg => 'END of CreateJournalEntries '
81980 ,p_level => C_LEVEL_PROCEDURE
81981 ,p_module => l_log_module);
81982 END IF;
81983
81984 RETURN l_result;
81985 EXCEPTION
81986 WHEN xla_exceptions_pkg.application_exception THEN
81987 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
81988 trace
81989 (p_msg => 'ERROR. = '||sqlerrm
81990 ,p_level => C_LEVEL_PROCEDURE
81991 ,p_module => l_log_module);
81992 END IF;
81993 RAISE;
81994 WHEN OTHERS THEN
81995 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
81996 trace
81997 (p_msg => 'ERROR. = '||sqlerrm
81998 ,p_level => C_LEVEL_PROCEDURE
81999 ,p_module => l_log_module);
82000 END IF;
82001 xla_exceptions_pkg.raise_message
82002 (p_location => 'XLA_00222_AAD_S_000005_PKG.CreateJournalEntries');
82003 END CreateJournalEntries;
82004 --
82005 --=============================================================================
82006 --
82007 --
82008 --
82009 --
82010 --
82011 --
82012 --
82013 --
82014 --
82015 --
82016 --
82017 --
82018 --
82019 --
82020 --
82021 --
82022 --
82023 --
82024 --
82025 --
82026 --
82027 --
82028 --=============================================================================
82029 --=============================================================================
82030 -- *********** Initialization routine **********
82031 --=============================================================================
82032
82033 BEGIN
82034 g_log_level := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
82035 g_log_enabled := fnd_log.test
82036 (log_level => g_log_level
82037 ,module => C_DEFAULT_MODULE);
82038
82039 IF NOT g_log_enabled THEN
82040 g_log_level := C_LEVEL_LOG_DISABLED;
82041 END IF;
82042 --
82043 END XLA_00222_AAD_S_000005_PKG;
82044 --